first commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { readFile, stat } from 'node:fs/promises';
|
||||
import { resolve, join } from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
const root=resolve('out');
|
||||
const routes=['/','/aboutus/','/contactus/','/ourservices/','/portfolios/','/blog/',...['residential','beauty','commercial','landscape','facade'].map(slug=>`/portfolios/${slug}/`)];
|
||||
const assets=new Set();
|
||||
for(const route of routes){
|
||||
const html=await readFile(join(root,route,'index.html'),'utf8');
|
||||
assert.match(html,/<html[^>]*lang="fa"/);
|
||||
assert.match(html,/<html[^>]*dir="rtl"/);
|
||||
assert.ok(html.includes('گودرزی'),`Missing brand: ${route}`);
|
||||
if (route === '/') assert.ok(!html.includes('class="site-footer"'), 'Home must not render a footer');
|
||||
else assert.ok(html.includes('https://meshkee.com'),`Missing Meshkee credit: ${route}`);
|
||||
for(const match of html.matchAll(/(?:src|href)="(\/[^"?#]*)/g)){
|
||||
const url=decodeURIComponent(match[1]);
|
||||
if(url.startsWith('//'))continue;
|
||||
assets.add(url.endsWith('/')?`${url}index.html`:url);
|
||||
}
|
||||
const response=await fetch(`http://localhost:3000${route}`);
|
||||
assert.equal(response.status,200,route);
|
||||
}
|
||||
for(const asset of assets){assert.ok((await stat(join(root,asset))).isFile(),asset)}
|
||||
for(const font of ['iranyekanweblightfanum.woff','iranyekanwebboldfanum.woff']){
|
||||
assert.equal((await readFile(join(root,'fonts',font))).subarray(0,4).toString(),'wOFF');
|
||||
}
|
||||
const missing=await fetch('http://localhost:3000/this-page-does-not-exist/');
|
||||
assert.equal(missing.status,404);
|
||||
assert.ok((await missing.text()).includes('این صفحه پیدا نشد'));
|
||||
console.log(`PASS: ${routes.length} routes, ${assets.size} linked local files, both IRANYekan fonts, Persian RTL, Meshkee credit, and real HTTP 404.`);
|
||||
Reference in New Issue
Block a user