diff --git a/scripts/test-website.py b/scripts/test-website.py index 23f1668371..55342c80dc 100644 --- a/scripts/test-website.py +++ b/scripts/test-website.py @@ -21,7 +21,7 @@ from urllib.request import build_opener, ProxyHandler, urlopen import xml.etree.ElementTree as ET import polib -from website_i18n import Document, build_translations, checked_catalog, extract_catalogs, languages, prose_units, reading_pages, read_runtime +from website_i18n import FALLBACK_NOTICE, Document, build_translations, checked_catalog, extract_catalogs, languages, prose_units, reading_pages, read_runtime ROOT = Path(__file__).resolve().parent.parent @@ -391,6 +391,13 @@ class WebsiteSearchChecks(unittest.TestCase): class WebsiteMaintenanceChecks(unittest.TestCase): """Exercise contributor edits and the static preview through real consumers.""" + def test_home_navigation_starts_closed(self): + document = Document((ROOT / "website/public/index.html").read_text(encoding="utf-8")) + menus = [node for node in document.nodes if "home-page-nav" in node.attrs.get("class", "").split()] + self.assertEqual([node.tag for node in menus], ["details"]) + self.assertNotIn("open", menus[0].attrs) + self.assertIn("data-home-nav", menus[0].attrs) + def test_electron_guide_renderer_matches_download(self): public = ROOT / "website/public" source = (public / "guides/javascript/index.html").read_text(encoding="utf-8") @@ -883,6 +890,27 @@ class WebsiteTranslationChecks(unittest.TestCase): self.assertIn('hreflang="zh-CN"', (site / "faq/index.html").read_text()) self.assertIn("https://rea.tools/zh-CN/faq/", (site / "sitemap.xml").read_text()) + def test_fallback_notice_direction_follows_its_own_language(self): + with self.translated_project() as root: + page = root / "website/public/faq/index.html" + page.write_text(page.read_text().replace("How do I install REA?", "How do I install REA today?")) + extract_catalogs(root) + path = root / "website/locales/ar/messages.po" + catalog = polib.pofile(path) + notice = catalog.find(FALLBACK_NOTICE, msgctxt="runtime") + translated_notice = notice.msgstr + self.assertNotEqual(translated_notice, "") + site = root / "website/_site" + for msgstr, attributes in ( + ("", 'lang="en" dir="ltr"'), + (translated_notice, 'lang="ar" dir="rtl"'), + ): + notice.msgstr = msgstr + catalog.save(path) + build_translations(root, site) + result = (site / "ar/faq/index.html").read_text() + self.assertIn(f'