import assert from 'node:assert/strict';
import { access, readFile } from 'node:fs/promises';
import { join, resolve } from 'node:path';
const output=resolve('out');
const routes=['/','/aboutus/','/blog/','/contactus/','/ourservices/','/portfolios/'];
const titles=new Set(); const descriptions=new Set();
for(const route of routes){
const html=await readFile(join(output,route,'index.html'),'utf8');
const title=html.match(/
([^<]+)<\/title>/)?.[1];
const description=html.match(/)/g)||[]).length,1,`Expected one H1: ${route}`);
assert.match(html,/page.path),['/','/aboutus','/blog','/contactus','/ourservices','/portfolios']);
for(const forbidden of ['sitemap.xml','robots.txt']){try{await access(join(output,forbidden));assert.fail(`${forbidden} must be proxied, not shipped`)}catch(error){if(error.code!=='ENOENT')throw error}}
console.log(`PASS: SEO metadata, one H1, canonical URLs and image alt text on ${routes.length} crawlable static pages; sitemap config contains ${sitemap.staticPages.length} routes.`);