import { test, expect } from '@playwright/test'; import { signUp } from '../support/app.js'; // Through the navbar, not page.goto('/profile'): a cold load of that URL bounces // to /subscriptions (the Authenticated wrapper decides before Meteor has resumed // the login token). Worth its own fix, but it is not what this spec is about. const openProfile = async (page) => { await page.click('#profile'); await page.waitForURL('**/profile', { timeout: 30000 }); }; const chooseLanguage = async (page, name) => { await page.locator('.lang-selector').first().click(); await page.getByRole('button', { name }).click(); }; // The site is bilingual (es/en) and the language belongs to the account, not to // the browser session: notifications and emails go out in it too. test.describe('cambio de idioma', () => { test('the interface follows the language chosen in the profile', async ({ page }) => { await signUp(page); await expect(page.locator('#moniZones')).toHaveText('Zonas vigiladas'); await openProfile(page); await chooseLanguage(page, 'English'); await expect(page.locator('#moniZones')).toHaveText('Monitored areas', { timeout: 30000 }); }); test('going back to Spanish works too', async ({ page }) => { await signUp(page); await openProfile(page); await chooseLanguage(page, 'English'); await expect(page.locator('#moniZones')).toHaveText('Monitored areas', { timeout: 30000 }); await chooseLanguage(page, 'Español'); await expect(page.locator('#moniZones')).toHaveText('Zonas vigiladas', { timeout: 30000 }); }); // KNOWN BUG, kept as a failing-by-design test instead of being quietly dropped: // users.setLang does store the choice on the account, and Login.js applies it // when you log in — but a plain reload of an already-logged-in session falls // back to the browser's locale. Someone who picked English sees Spanish again // on the next page load. test.fixme('the chosen language survives a reload', async ({ page }) => { await signUp(page); await openProfile(page); await chooseLanguage(page, 'English'); await expect(page.locator('#moniZones')).toHaveText('Monitored areas', { timeout: 30000 }); await page.reload(); await expect(page.locator('#moniZones')).toHaveText('Monitored areas', { timeout: 30000 }); }); });