fix(editor): a sign-out with a dirty dialog is said at the next sign-in

This commit is contained in:
bchanot committed 2026-11-14 18:50:42 +01:00
1 parent 7ecaf1998e
commit 28e298ac56
4 files changed
+178 -53

No files matched your search

+3 -1
View File
@@ -105,6 +105,8 @@ export interface MountOptions {
entries?: InitialEntry[]
/** Called on every render with the router's navigate and location: Back, Forward, state. */
probe?: (navigate: NavigateFunction, location: Location) => void
/** The signed-in account's id (default: USER). */
user?: string
}
/** Hands the router to a test: MemoryRouter listens to no popstate, a test calls navigate(-1). */
@@ -119,7 +121,7 @@ export function mountDraft(options: MountOptions = {}) {
useLocaleStore.setState({ locale: 'fr' })
useLeaveGuardStore.setState({ armed: false })
useAuthStore.setState({
user: { id: USER } as never,
user: { id: options.user ?? USER } as never,
catalogGrants: options.grants ?? [grant('sheet_editor')],
catalogGrantsStatus: options.grantsStatus ?? 'ready',
roles: options.roles ?? ['admin'],
@@ -621,7 +621,7 @@ describe('final review: leaving the editor with a dirty dialog (criterion 17)',
expect(screen.queryByText(notice)).toBeNull()
})
it('a sign-out leaves no flag under the tag it rotated', async () => {
it('a sign-out with a dirty dialog is said once to the same account, never to another', async () => {
const user = await mount()
await openFinding(user, /Node A/)
await modify(user)
@@ -631,10 +631,23 @@ describe('final review: leaving the editor with a dirty dialog (criterion 17)',
useAuthStore.setState({ user: null })
})
await waitFor(() => expect(findingDialog()).toBeNull())
const flags = Object.keys(sessionStorage).filter((k) =>
k.startsWith('faunosteo:editor:left-draft:'),
)
expect(flags).toEqual([])
const values = Object.keys(sessionStorage).map((k) => k + sessionStorage[k])
expect(values.join()).not.toContain('bis')
expect(values.join()).not.toContain(USER)
cleanup()
serverHas(sheetText(), 3)
mountDraft({ width: 1280, probe, user: 'user-2' })
await screen.findByRole('heading', {
level: 1,
name: 'Brouillon, version 4',
})
expect(screen.queryByText(notice)).toBeNull()
cleanup()
await mount()
expect(screen.getByText(notice)).toBeVisible()
cleanup()
await mount()
expect(screen.queryByText(notice)).toBeNull()
})
it('a clean dialog leaves no flag', async () => {