(page: Page, locale: Locale | string)
| 34 | }; |
| 35 | |
| 36 | const verifyTranslation = async (page: Page, locale: Locale | string) => { |
| 37 | // Load locale data if string code provided (e.g., 'es', 'fr') |
| 38 | const localeData: Locale = |
| 39 | typeof locale === 'string' |
| 40 | ? ( |
| 41 | await import(`@node-core/website-i18n/locales/${locale}.json`, { |
| 42 | with: { type: 'json' }, |
| 43 | }) |
| 44 | ).default |
| 45 | : locale; |
| 46 | |
| 47 | // Get navigation links and expected translations |
| 48 | const links = await page |
| 49 | .locator(locators.navLinksLocator) |
| 50 | .locator('a > span') |
| 51 | .all(); |
| 52 | const expectedTexts = Object.values( |
| 53 | localeData.components.containers.navBar.links |
| 54 | ); |
| 55 | |
| 56 | // Verify each navigation link text matches an expected translation |
| 57 | for (const link of links) { |
| 58 | const linkText = await link.textContent(); |
| 59 | expect(expectedTexts).toContain(linkText!.trim()); |
| 60 | } |
| 61 | }; |
| 62 | |
| 63 | test.describe('Node.js Website', () => { |
| 64 | // Start each test from the English homepage |
no outgoing calls
no test coverage detected