todos-contra-el-fuego-web/e2e/tests/i18n.spec.js
vjrj a3f2929ff7 test(e2e): browser suite for the flows the server tests cannot see
Playwright under e2e/, its own npm project so Meteor never sees the dependency
(.meteorignore keeps the directory out of the bundle — a config file at the app
root is otherwise eagerly loaded into the server and crashes it).

Covers what the phase asked for: sign up / log in, creating a zone from the map
and watching the union get painted on /subscriptions and /zones, removing it
again, commenting on a fire, and switching language. The zone spec is the flow
that froze staging on 2026-07-30 — it passes only if the server is still
answering DDP while the union is recomputed.

docker-compose.e2e.yml is a throwaway stack (Mongo on tmpfs, no named volume) so
the destructive seeds cannot be pointed at anything real by accident;
playwright.config.js refuses to start against the staging or production domains.

i18n.spec.js leaves a test.fixme on a real bug found while writing it: the
language chosen in the profile does not survive a page reload.
2026-08-01 18:44:09 +02:00

54 lines
2.3 KiB
JavaScript

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 });
});
});