tts-voice-creator-clone-and.../tests/i18n.spec.js

28 lines
1.7 KiB
JavaScript

// @ts-check
// Verifies the language picker + German translation of the UI chrome.
const { test, expect } = require('@playwright/test');
test('defaults to English and shows the language picker in Settings', async ({ page }) => {
await page.goto('/', { waitUntil: 'domcontentloaded' });
await page.waitForFunction(() => typeof window.navTo === 'function', null, { timeout: 15_000 });
await page.evaluate(() => window.navSettingsCat('general'));
await expect(page.locator('#s-lang-select')).toHaveCount(1);
await page.evaluate(() => window.navSettingsCat('general'));
await expect(page.locator('[data-nav-section="s-clone"]')).toContainText('Clone a Voice');
});
test('German translates the navigation and section titles', async ({ page }) => {
await page.addInitScript(() => { try { localStorage.setItem('app-lang', 'de'); } catch (e) {} });
await page.goto('/', { waitUntil: 'domcontentloaded' });
await page.waitForFunction(() => typeof window.applyI18n === 'function', null, { timeout: 15_000 });
await page.waitForFunction(() => typeof window.navTo === 'function', null, { timeout: 15_000 });
await page.evaluate(() => window.navSettingsCat('general'));
await expect(page.locator('#s-lang-select')).toHaveCount(1);
await page.evaluate(() => window.navSettingsCat('general'));
await expect(page.locator('#s-lang-select')).toHaveValue('de');
await expect(page.locator('[data-nav-section="s-clone"]')).toContainText('Stimme klonen');
await expect(page.getByText('Meine Stimmen').first()).toHaveCount(1);
// English source text should no longer be present in the nav
await expect(page.locator('.nav-item', { hasText: 'Get Voices Online' })).toHaveCount(0);
});