Assessor_2.0/tests/features/work-timeslot-state.test.ts

27 lines
1.6 KiB
TypeScript

import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
const provider = readFileSync(new URL('../../src/app/AppProvider.tsx', import.meta.url), 'utf8');
const snapshots = readFileSync(new URL('../../src/features/view-bookmarks/ViewBookmarks.tsx', import.meta.url), 'utf8');
describe('Work timeslot state', () => {
it('loads workspace marks and snapshots from the active timeslot scope', () => {
expect(provider).toContain('const scopeId = createWorkScopeId(projectId, scanRunIds)');
expect(provider).toContain('setActiveScanRunIds(scanRunIds?.length ? [...new Set(scanRunIds)] : undefined)');
expect(provider).toContain('const reviews = await reviewRepository.load(scopeId)');
expect(provider).toContain('reviewRepository.save(workScopeId, state.reviews)');
expect(snapshots).toContain('const scopeId = app.workScopeId');
expect(snapshots).toContain('loadProjectViewBookmarks(storage, scopeId)');
expect(snapshots).toContain('saveProjectViewBookmarks(storage, scopeId, next)');
expect(snapshots).toContain("mode === 'path' ? 'Path Snapshot' : 'Snapshot'");
expect(snapshots).toContain("bookmark.kind === 'path' ? ' is-path' : ''");
expect(snapshots).toContain('bookmarks.length >= VIEW_BOOKMARK_LIMIT');
});
it('restores the active tool profile defaults on timeslot and sheet changes', () => {
expect(provider.match(/statusFilter:\s*defaults\.statusFilter/g)?.length).toBeGreaterThanOrEqual(3);
expect(provider).toContain('setActiveSheet: activeSheetId => setState');
expect(provider).toContain('facetFilters: {}');
});
});