test: cover bilingual static exports

This commit is contained in:
2026-09-08 19:22:07 +03:30
parent 273f92a3c3
commit d738263ca1
2 changed files with 36 additions and 1 deletions

View File

@@ -16,7 +16,7 @@ test('the footer renders the IsometricFooter scene instead of preloading PNG art
const footerSection = await readFile('src/components/FooterSection.tsx', 'utf8'); const footerSection = await readFile('src/components/FooterSection.tsx', 'utf8');
const loader = await readFile('src/components/SiteLoader.tsx', 'utf8'); const loader = await readFile('src/components/SiteLoader.tsx', 'utf8');
assert.match(footerSection, /<IsometricFooter\s*\/>/); assert.match(footerSection, /<IsometricFooter locale=\{locale\}\s*\/>/);
assert.doesNotMatch(footerSection, /next\/image/); assert.doesNotMatch(footerSection, /next\/image/);
assert.doesNotMatch(footerSection, /footer-background.*\.png/); assert.doesNotMatch(footerSection, /footer-background.*\.png/);
assert.doesNotMatch(loader, /footer-background.*\.png/); assert.doesNotMatch(loader, /footer-background.*\.png/);

View File

@@ -24,3 +24,38 @@ test('the production build exports a usable home page', async () => {
), ),
); );
}); });
test('the production build exports reciprocal English and Persian pages', async () => {
const englishHtml = await readFile(path.join(exportRoot, 'index.html'), 'utf8');
const persianHtml = await readFile(path.join(exportRoot, 'fa.html'), 'utf8');
assert.match(englishHtml, /<html[^>]*lang="en"[^>]*dir="ltr"/i);
assert.match(englishHtml, /href="\/fa"[^>]*hreflang="fa"/i);
assert.match(englishHtml, />Software Engineer</);
assert.match(englishHtml, />Quera</);
assert.doesNotMatch(englishHtml, />مهندس نرم‌افزار</);
assert.doesNotMatch(englishHtml, />کوئرا</);
assert.match(persianHtml, /<html[^>]*lang="fa"[^>]*dir="rtl"/i);
assert.match(persianHtml, /href="\/"[^>]*hreflang="en"/i);
assert.match(persianHtml, /سلام، من امیرحسین خلیلی هستم/);
assert.match(persianHtml, /از پیکسل تا محصول/);
assert.match(persianHtml, /بهمن ۱۴۰۴ تا امروز/);
assert.match(persianHtml, /آبان ۱۴۰۳ تا امروز/);
});
test('Persian source copy uses standard characters and punctuation', async () => {
const localizedFiles = [
'src/i18n/content.ts',
'src/data/projects.ts',
'src/data/experience.ts',
'src/data/education.ts',
'src/data/milestones.ts',
];
const source = (
await Promise.all(localizedFiles.map((file) => readFile(file, 'utf8')))
).join('\n');
assert.doesNotMatch(source, /[يك]/, 'use Persian ی and ک instead of Arabic forms');
assert.doesNotMatch(source, /[—–]/, 'use Persian punctuation instead of em/en dashes');
});