| 1 | import { beforeEach, describe, expect, it } from 'vitest' |
| 2 | import { useSessionDetailUiStore } from '../../../src/renderer/src/store/sessionDetailStore' |
| 3 | |
| 4 | describe('session detail editor guides store', () => { |
| 5 | beforeEach(() => { |
| 6 | useSessionDetailUiStore.getState().resetForSessionChange() |
| 7 | }) |
| 8 | |
| 9 | it('keeps guides isolated by page and allows repositioning them', () => { |
| 10 | const store = useSessionDetailUiStore.getState() |
| 11 | |
| 12 | store.addEditorGuide('page-1', 'vertical', 320.04) |
| 13 | store.addEditorGuide('page-1', 'horizontal', 180) |
| 14 | store.addEditorGuide('page-2', 'vertical', 640) |
| 15 | store.moveEditorGuide('page-1', 'vertical', 0, 400.06) |
| 16 | store.removeEditorGuide('page-1', 'horizontal', 0) |
| 17 | |
| 18 | expect(useSessionDetailUiStore.getState().editorGuidesByPage).toEqual({ |
| 19 | 'page-1': { vertical: [400.1], horizontal: [] }, |
| 20 | 'page-2': { vertical: [640], horizontal: [] } |
| 21 | }) |
| 22 | }) |
| 23 | |
| 24 | it('resets transient ruler and grid state when leaving the session', () => { |
| 25 | const store = useSessionDetailUiStore.getState() |
| 26 | store.setEditorSnapEnabled(false) |
| 27 | store.setEditorGridVisible(true) |
| 28 | store.setEditorGridSize(32) |
| 29 | store.addEditorGuide('page-1', 'vertical', 320) |
| 30 | |
| 31 | useSessionDetailUiStore.getState().resetForSessionChange() |
| 32 | |
| 33 | expect(useSessionDetailUiStore.getState()).toMatchObject({ |
| 34 | editorSnapEnabled: true, |
| 35 | editorGridVisible: false, |
| 36 | editorGridSize: 20, |
| 37 | editorGuidesByPage: {} |
| 38 | }) |
| 39 | }) |
| 40 | }) |
| 41 |