fix(app): editor store keeps an unanswered copy across mode changes, refuses unsaved submit
This commit is contained in:
1 parent
7f1d44065b
commit
b14509f221
7 files changed
+102
-4
No files matched your search
@@ -263,3 +263,35 @@ describe('cap, quota and other accounts', () => {
|
||||
expect(storedCopy()).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('becoming editable with a stored copy', () => {
|
||||
it('offers a different copy and keeps its bytes, commit refused', async () => {
|
||||
seed(movedText(10), 3)
|
||||
const raw = sessionStorage.getItem(copyKeyOf())
|
||||
await openReady({ canEdit: false })
|
||||
store.getState().setCanEdit(true)
|
||||
expect(store.getState()).toMatchObject({ recovery: 'pending', unusableCopy: false })
|
||||
expect(commitMove(40)).toMatchObject({ kind: 'recovery.pending' })
|
||||
expect(sessionStorage.getItem(copyKeyOf())).toBe(raw)
|
||||
})
|
||||
|
||||
it('refuses an unreadable copy and never overwrites it', async () => {
|
||||
sessionStorage.setItem(copyKeyOf(), 'not json{')
|
||||
await openReady({ canEdit: false })
|
||||
store.getState().setCanEdit(true)
|
||||
expect(store.getState()).toMatchObject({ recovery: 'refused', refusedKind: 'unreadable' })
|
||||
expect(commitMove(40)).toMatchObject({ kind: 'recovery.pending' })
|
||||
expect(sessionStorage.getItem(copyKeyOf())).toBe('not json{')
|
||||
})
|
||||
|
||||
it('does not write over a copy flagged unusable', async () => {
|
||||
seed(movedText(10), 3)
|
||||
const raw = sessionStorage.getItem(copyKeyOf())
|
||||
await openReady()
|
||||
store.getState().ignoreCopy({ confirmed: true })
|
||||
seed(movedText(10), 3)
|
||||
store.setState({ unusableCopy: true })
|
||||
commitMove(40)
|
||||
expect(sessionStorage.getItem(copyKeyOf())).toBe(raw)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user