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

33 lines
2.2 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, selectedAssessmentIds)');
expect(provider).toContain('setActiveScanRunIds(scanRunIds?.length ? [...new Set(scanRunIds)] : undefined)');
expect(provider).toContain('const localReviews = await reviewRepository.load(scopeId)');
expect(provider).toContain('hydrateWorkspaceReviews(dataset, models.flatMap(model => model.reviews), localReviews)');
expect(provider).toContain('await assessorApi.saveReview(review, current?.revision ?? 0)');
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 Deviation as the universal Work default, including GPO sheets', () => {
expect(provider).toContain("return 'deviation';");
expect(provider).not.toContain("sheet?.toolId === 'group-policy' ? 'all'");
expect(provider).toContain('statusFilter: initialSheetStatus(activeSheet, defaults.statusFilter)');
expect(provider).toContain('statusFilter: initialSheetStatus(sheet, defaults.statusFilter)');
expect(provider).toContain('const statusFilter = initialSheetStatus(activeSheet, defaults.statusFilter)');
expect(provider).toContain('setActiveSheet: activeSheetId => setState');
expect(provider).toContain('facetFilters: {}');
});
});