fix(editor): read-only undo, upload session check, restore and submit guards

This commit is contained in:
bchanot committed 2026-11-04 18:06:40 +01:00
1 parent 5979cd59ec
commit 05c9b3e10b
20 files changed
+102 -33

No files matched your search

+12
View File
@@ -334,6 +334,8 @@ describe('discard and submit', () => {
sb.submitSheetReview.mockResolvedValue('review-1' as never)
expect(await store.getState().submit()).toEqual({ ok: true, reviewId: 'review-1' })
expect(sb.submitSheetReview).toHaveBeenCalledWith(expect.anything(), { version_id: VERSION, expected_revision: 3 })
// The accepted submission froze the store; a fresh session meets the conflict.
await openReady({ revision: 3 })
sb.submitSheetReview.mockRejectedValue(new SheetFailure('draft_conflict'))
sb.getOfficialSheetAdmin.mockRejectedValue(new SheetFailure('network'))
expect(await store.getState().submit()).toMatchObject({ kind: 'draft_conflict' })
@@ -342,6 +344,16 @@ describe('discard and submit', () => {
})
})
describe('after the server accepted the submission', () => {
it('takes no further change before the sheet reload turns the draft frozen', async () => {
await openReady({ revision: 3 })
sb.submitSheetReview.mockResolvedValue('review-1' as never)
expect(await store.getState().submit()).toMatchObject({ ok: true })
expect(commitMove(40)).toMatchObject({ ok: false, reason: 'blocked', kind: 'read_only' })
expect(store.getState().unsaved).toBe(false)
})
})
describe('guards', () => {
it('refuses a submit while the document differs from the saved text', async () => {
await openReady()