import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { test } from 'node:test';

const webConfig = readFileSync(new URL('../public/web.config', import.meta.url), 'utf8');
const deployScript = readFileSync(new URL('../../tools/deploy-web-apps.ps1', import.meta.url), 'utf8');
const angularConfig = readFileSync(new URL('../angular.json', import.meta.url), 'utf8');

test('website web.config routes IIS requests through the Angular SSR server', () => {
  assert.match(webConfig, /iisnode/i);
  assert.match(webConfig, /server\.mjs/);
  assert.match(webConfig, /node_env/i);
  assert.match(webConfig, /api\/releases/i);
});

test('IIS deployment publishes the full SSR output instead of only browser assets', () => {
  assert.match(deployScript, /website\\dist\\toju-website(?!\\browser)/);
});

test('web.config is kept at the SSR release root, not copied as a browser asset', () => {
  assert.match(angularConfig, /"ignore":\s*\[\s*"web\.config"\s*\]/);
});