From d738263ca18ff2d1098d4d4d2243680ecc956277 Mon Sep 17 00:00:00 2001 From: Amirhossein Khalili Date: Tue, 8 Sep 2026 19:22:07 +0330 Subject: [PATCH] test: cover bilingual static exports --- tests/footer-scene.test.mjs | 2 +- tests/static-export.test.mjs | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/footer-scene.test.mjs b/tests/footer-scene.test.mjs index a377753..33cdffd 100644 --- a/tests/footer-scene.test.mjs +++ b/tests/footer-scene.test.mjs @@ -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 loader = await readFile('src/components/SiteLoader.tsx', 'utf8'); - assert.match(footerSection, //); + assert.match(footerSection, //); assert.doesNotMatch(footerSection, /next\/image/); assert.doesNotMatch(footerSection, /footer-background.*\.png/); assert.doesNotMatch(loader, /footer-background.*\.png/); diff --git a/tests/static-export.test.mjs b/tests/static-export.test.mjs index 9bb0d0d..5174884 100644 --- a/tests/static-export.test.mjs +++ b/tests/static-export.test.mjs @@ -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, /]*lang="en"[^>]*dir="ltr"/i); + assert.match(englishHtml, /href="\/fa"[^>]*hreflang="fa"/i); + assert.match(englishHtml, />Software EngineerQueraمهندس نرم‌افزارکوئرا]*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'); +});