Files
lage-chat-control/tests/e2e/prefs.spec.ts
T
Aurealibe 8ebc1da9e4 Rebuild du site sur Astro : i18n multilingue, faits verifies, Docker, CI, tests
- Astro statique, EN par defaut + /fr/ + /nl/, detection langue navigateur
- i18n par fichiers JSON, ajouter une langue = ajouter des traductions
- Contenu original porte a l'identique (diff d'inventaire par langue)
- Chronologie legislative corrigee sur sources primaires (PE, Conseil, votes)
- Timeline 23 precedents + observatoire 35 items + annuaire 66 outils FOSS,
  chaque affirmation verifiee et sourcee
- Zero requete tierce (teste), lisible JS coupe, axe WCAG AA x2 themes
- Version offline monofichier par langue a chaque build
- Docker multi-stage vers nginx + CSP stricte auto-generee
- CI GitHub Actions (SHA-pinnees) + verification hebdo des liens
- CONTRIBUTING : divulgation d'affiliation obligatoire, allowlist de
  domaines testee en CI
2026-07-10 03:52:49 +01:00

42 lines
1.8 KiB
TypeScript

import { expect, test } from '@playwright/test'
test.skip(({ javaScriptEnabled }) => javaScriptEnabled === false, 'prefs need JS')
test('theme toggle persists across reloads', async ({ page }) => {
await page.goto('/')
const before = await page.evaluate(() => document.documentElement.dataset.theme || '')
await page.locator('[data-theme-toggle]').click()
const after = await page.evaluate(() => document.documentElement.dataset.theme)
expect(after).toMatch(/^(light|dark)$/)
expect(after).not.toBe(before)
await page.reload()
await expect(page.locator('html')).toHaveAttribute('data-theme', after!)
})
test('explicit language choice is remembered on the root', async ({ page }) => {
await page.goto('/')
// pick French from the dropdown: stores ecc-lang and navigates
await page.locator('[data-lang-menu] summary').click()
await page.locator('[data-lang-choice="fr"]').click()
await page.waitForURL('**/fr/')
// back to the root: the boot script honors the stored choice
await page.goto('/')
await page.waitForURL('**/fr/')
await expect(page.locator('html')).toHaveAttribute('lang', 'fr')
// switching back to English sticks too (no redirect loop)
await page.locator('[data-lang-menu] summary').click()
await page.locator('[data-lang-choice="en"]').click()
await page.waitForURL((url) => url.pathname === '/')
await page.goto('/')
await expect(page.locator('html')).toHaveAttribute('lang', 'en')
})
test('checklist state survives a reload (when present)', async ({ page }) => {
await page.goto('/')
const box = page.locator('[data-checklist] input[type="checkbox"]').first()
test.skip((await box.count()) === 0, 'checklist not yet wired')
await box.check()
await page.reload()
await expect(page.locator('[data-checklist] input[type="checkbox"]').first()).toBeChecked()
})