feat(app): sign-out warns before losing editor work, local copies purged
This commit is contained in:
1 parent
8b6adcb7df
commit
bd4ba338af
12 files changed
+417
-16
No files matched your search
@@ -0,0 +1,44 @@
|
||||
/** Lot N2: the purge of local recovery copies by account (contract C43, ruling R24). */
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import {
|
||||
copyKey,
|
||||
hasUserCopies,
|
||||
removeOtherUsersCopies,
|
||||
removeUserCopies,
|
||||
} from '@/editor/state/recovery'
|
||||
|
||||
const A = 'aaaaaaaa-0000-0000-0000-000000000001'
|
||||
const B = 'bbbbbbbb-0000-0000-0000-000000000002'
|
||||
|
||||
function seed() {
|
||||
sessionStorage.setItem(copyKey(A, 'v1'), '{}')
|
||||
sessionStorage.setItem(copyKey(A, 'v2'), '{}')
|
||||
sessionStorage.setItem(copyKey(B, 'v1'), '{}')
|
||||
sessionStorage.setItem('osteo:draft', '{}')
|
||||
}
|
||||
const keys = () => Object.keys(sessionStorage).sort()
|
||||
|
||||
afterEach(() => sessionStorage.clear())
|
||||
|
||||
describe('copy purge', () => {
|
||||
it('sees whether an account holds a copy', () => {
|
||||
expect(hasUserCopies(A)).toBe(false)
|
||||
seed()
|
||||
expect(hasUserCopies(A)).toBe(true)
|
||||
expect(hasUserCopies('cccccccc')).toBe(false)
|
||||
})
|
||||
|
||||
it('removes every copy of one account and nothing else', () => {
|
||||
seed()
|
||||
removeUserCopies(A)
|
||||
expect(keys()).toEqual([copyKey(B, 'v1'), 'osteo:draft'].sort())
|
||||
})
|
||||
|
||||
it('keeps the signed-in account copies and removes the others', () => {
|
||||
seed()
|
||||
removeOtherUsersCopies(A)
|
||||
expect(keys()).toEqual(
|
||||
[copyKey(A, 'v1'), copyKey(A, 'v2'), 'osteo:draft'].sort(),
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user