fix(editor): Task 1 review round 1, section back pops, scroll proof

This commit is contained in:
bchanot committed 2026-11-13 18:12:19 +01:00
1 parent 792394d3b2
commit 8e4f02620a
7 files changed
+251 -64

No files matched your search

@@ -68,6 +68,14 @@ describe('readEntry and ownership', () => {
expect(ownedEntry(stateOf(entry()), { ...mine, userId: 'V' })).toBeNull()
})
it('refuses an owner without a sheet or an account', () => {
const blank = entry({ sheetId: '', userId: '' })
expect(ownedEntry(stateOf(blank), { sheetId: '', userId: '' })).toBeNull()
expect(
ownedEntry(stateOf(entry()), { sheetId: 'S', userId: '' }),
).toBeNull()
})
it('keeps only navigation: nothing typed survives the read', () => {
const raw = { ...entry(), draft: 'typed text', term: 'search' }
expect(JSON.stringify(readEntry(stateOf(raw)))).not.toContain('typed')
@@ -92,6 +100,21 @@ describe('planWrite', () => {
expect(planWrite(onAnnotations, views, false)).toBe('push')
})
it('goes back for a section left for its drawing, else replaces', () => {
const drawing = view('annotations')
const inSection = entry({
view: view('annotations', { section: 'views' }),
below: drawing,
})
expect(planWrite(inSection, drawing, false)).toBe('back')
const reloaded = entry({ view: inSection.view, below: null })
expect(planWrite(reloaded, drawing, false)).toBe('replace')
// another section, or another tab, is a step forward
const regions = view('annotations', { section: 'regions' })
expect(planWrite(inSection, regions, false)).toBe('push')
expect(planWrite(inSection, view('general'), false)).toBe('push')
})
it('goes back for a layer removed when the entry holds the view below', () => {
const layer = view('findings', { reference: { create: true } })
const opened = entry({ view: layer, below: view('findings') })