fix(editor): submission note sent as typed, copies purged again after sign-out
This commit is contained in:
1 parent
6471b25812
commit
5e0aa625a8
4 files changed
+22
-3
No files matched your search
@@ -36,7 +36,7 @@ export function useSubmission(reloadSheet: () => void) {
|
|||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
setMessage(null)
|
setMessage(null)
|
||||||
const outcome = await useEditorStore.getState().submit(note.trim())
|
const outcome = await useEditorStore.getState().submit(note)
|
||||||
// The round froze the draft: the route refreshes even if this tab is gone.
|
// The round froze the draft: the route refreshes even if this tab is gone.
|
||||||
if (outcome.ok) reloadSheet()
|
if (outcome.ok) reloadSheet()
|
||||||
if (!mounted.current) return
|
if (!mounted.current) return
|
||||||
|
|||||||
@@ -36,12 +36,15 @@ export default function SignOutButton({
|
|||||||
|
|
||||||
async function leave() {
|
async function leave() {
|
||||||
setBusy(true)
|
setBusy(true)
|
||||||
|
const leavingUser = userId
|
||||||
try {
|
try {
|
||||||
await signOut()
|
await signOut()
|
||||||
} catch {
|
} catch {
|
||||||
// The local session is cleared either way; the server may not have revoked the others.
|
// The local session is cleared either way; the server may not have revoked the others.
|
||||||
window.alert(t('shell.sign_out_failed'))
|
window.alert(t('shell.sign_out_failed'))
|
||||||
} finally {
|
} finally {
|
||||||
|
// An upload still in flight may have rewritten a copy before SIGNED_OUT landed.
|
||||||
|
if (leavingUser) removeUserCopies(leavingUser)
|
||||||
// The guard would redirect anyway; going home keeps the local tool one step away.
|
// The guard would redirect anyway; going home keeps the local tool one step away.
|
||||||
navigate('/', { replace: true })
|
navigate('/', { replace: true })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,22 @@ describe('SignOutButton', () => {
|
|||||||
expect(sessionStorage.getItem(copyKey(OTHER, 'v1'))).toBe('{}')
|
expect(sessionStorage.getItem(copyKey(OTHER, 'v1'))).toBe('{}')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('purges again when a copy is written while the sign-out is in flight', async () => {
|
||||||
|
sessionStorage.setItem(copyKey(user.id, 'v1'), '{}')
|
||||||
|
signOut.mockImplementationOnce(async () => {
|
||||||
|
sessionStorage.setItem(copyKey(user.id, 'v2'), '{}')
|
||||||
|
})
|
||||||
|
mount()
|
||||||
|
await click()
|
||||||
|
await userEvent.click(
|
||||||
|
screen.getByRole('button', { name: fr['shell.sign_out_loss_confirm'] }),
|
||||||
|
)
|
||||||
|
await waitFor(() => expect(signOut).toHaveBeenCalledTimes(1))
|
||||||
|
await waitFor(() =>
|
||||||
|
expect(sessionStorage.getItem(copyKey(user.id, 'v2'))).toBeNull(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
it('ignores the copies of another account', async () => {
|
it('ignores the copies of another account', async () => {
|
||||||
sessionStorage.setItem(copyKey(OTHER, 'v1'), '{}')
|
sessionStorage.setItem(copyKey(OTHER, 'v1'), '{}')
|
||||||
mount()
|
mount()
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ describe('Submission', () => {
|
|||||||
).toBeTruthy()
|
).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('submits the trimmed note on the saved revision and reloads the sheet', async () => {
|
it('submits the note as typed on the saved revision and reloads the sheet', async () => {
|
||||||
await openReady()
|
await openReady()
|
||||||
sb.submitSheetReview.mockResolvedValue('review-1' as never)
|
sb.submitSheetReview.mockResolvedValue('review-1' as never)
|
||||||
const user = userEvent.setup()
|
const user = userEvent.setup()
|
||||||
@@ -159,7 +159,7 @@ describe('Submission', () => {
|
|||||||
expect(sb.submitSheetReview).toHaveBeenCalledWith(expect.anything(), {
|
expect(sb.submitSheetReview).toHaveBeenCalledWith(expect.anything(), {
|
||||||
version_id: 'ver-1',
|
version_id: 'ver-1',
|
||||||
expected_revision: 3,
|
expected_revision: 3,
|
||||||
note: 'Prête',
|
note: ' Prête ',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user