82 lines
2.9 KiB
TypeScript
82 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 {
|
|
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) =>
|
|
page.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)
|
|
})
|
|
})
|