Files
faunosteo/apps/app/e2e/shell/editor-signout.spec.ts
T
bchanot 79a09f8b25 test(editor): keep-alive paths, neutral place visibility
Place visibility context moves to lib/placeVisibility.ts so the catalogue
no longer imports from components/editor. Adds tests: selection survival,
unmeasured hint round trip, keyboard tab move and « Aller à » with a field
focused, replace-tracing kept, announcements. Parse-sharing test uses
object identity. Early exits are two statements; shortcut comment on the
parse cache.

R-24:
- editor-equine.spec.ts:118, editor-geometry.spec.ts:376,
  editor-recovery.spec.ts:39, editor-signout.spec.ts:26: page.getByLabel
  ('Nom (FR)') -> place(page, 'general').getByLabel(...)
- editor-shell.spec.ts: toHaveCount(0) on the visible query -> count 1
  on the raw selector and toBeHidden()
- editor-keep-alive.test.tsx: JSON.parse stack-trace count -> same
  object reference across places
2026-11-06 20:57:08 +01:00

85 lines
2.9 KiB
TypeScript

import { fr } from '@/i18n/fr'
import type { Locator, Page, TestInfo } from '@playwright/test'
import { expect, test } from '../support/browser'
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
import {
place,
copyKeyOf,
editorActor,
openDraft,
openEditor,
seedDraft,
selectTab,
standardShape,
storedCopy,
} from '../support/editor'
import { stepUpAdmin } from '../support/admin'
import { signIn } from '../support/shell'
// V1-2.6 Lot N2 (contract C43, ruling R24): a voluntary sign-out with unsaved work asks,
// purges this account's local copies on confirmation, and the next sign-in offers nothing.
const dict = fr
const isPhone = (info: TestInfo) => info.project.name === 'chromium-375'
const nameFr = (page: Page) =>
place(page, 'general').getByLabel(dict['editor.general.name_fr'], {
exact: true,
})
const button = (scope: Page | Locator, name: string) =>
scope.getByRole('button', { name, exact: true })
test.describe('sign-out with unsaved editor work', () => {
test.use({ locale: 'fr-FR', actionTimeout: 15_000 })
test.beforeEach(async ({ context }, info) => {
test.skip(isPhone(info), 'editing needs 1 024 px') // floor-guard: allow C16 editing needs >= 1024 px; phone read-only covered in editor-access
await routeToSandbox(context)
})
test.afterEach(async ({ context }) => {
await dropLateReplays(context)
})
test('confirming drops the copy, and signing in again offers no recovery', async ({
page,
requests,
}) => {
const actor = await editorActor('fr')
requests.forbid(actor.account.email, actor.account.password)
const seed = await seedDraft(actor, { shape: standardShape })
const key = copyKeyOf(actor.account.id, seed.draftId)
await openEditor(page, dict, actor, seed.sheetId)
await selectTab(page, dict, 'general')
await nameFr(page).fill('Travail non enregistré')
await nameFr(page).press('Enter')
expect(await storedCopy(page, key)).not.toBeNull()
const signOut = button(page, dict['shell.sign_out'])
await signOut.click()
const dialog = page.getByRole('dialog', {
name: dict['shell.sign_out_loss_title'],
})
await expect(dialog).toBeVisible()
await button(dialog, dict['shell.sign_out_loss_cancel']).click()
await expect(dialog).toBeHidden()
expect(await storedCopy(page, key)).not.toBeNull()
await expect(nameFr(page)).toHaveValue('Travail non enregistré')
await signOut.click()
await button(dialog, dict['shell.sign_out_loss_confirm']).click()
await expect(page).toHaveURL(/\/(login)?$/)
expect(await storedCopy(page, key)).toBeNull()
await signIn(page, actor.account, dict)
await page.goto('/app/admin')
await stepUpAdmin(page, dict, actor.secret)
await openDraft(page, dict, seed.sheetId)
await selectTab(page, dict, 'general')
await expect(nameFr(page)).toBeEditable()
await expect(
button(page, dict['editor.draft.recovery.restore']),
).toHaveCount(0)
})
})