Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 3m1s
CI / OCR Service Tests (pull_request) Successful in 30s
CI / Backend Unit Tests (pull_request) Failing after 3m0s
CI / Unit & Component Tests (push) Failing after 2m59s
CI / OCR Service Tests (push) Successful in 37s
CI / Backend Unit Tests (push) Failing after 2m54s
- DocumentServiceTest.applyBulkEditToDocument_propagatesDomainException_whenSenderIdUnresolvable (Sara C1) - DocumentServiceTest.findIdsForFilter_passesTagOperatorOR_throughBuildSearchSpec (Sara C3) - bulkSelection.svelte.spec.ts: setAll([]) no-op + previous-IDs-absent + ids getter (Sara C4 + S4) - /documents/bulk-edit/+page.server.ts now defensively handles a UserGroup with NULL `permissions` (treats it as not-WRITE_ALL instead of throwing on .includes()) + matching test (Sara C7) 233 backend tests + frontend bulk-edit specs all green. Refs #225, PR #331 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
77 lines
2.3 KiB
TypeScript
77 lines
2.3 KiB
TypeScript
import { afterEach, describe, expect, it } from 'vitest';
|
|
import { bulkSelectionStore } from './bulkSelection.svelte';
|
|
|
|
describe('bulkSelectionStore', () => {
|
|
afterEach(() => bulkSelectionStore.clear());
|
|
|
|
it('starts empty', () => {
|
|
expect(bulkSelectionStore.size).toBe(0);
|
|
});
|
|
|
|
it('toggle adds an id when absent', () => {
|
|
bulkSelectionStore.toggle('a');
|
|
expect(bulkSelectionStore.has('a')).toBe(true);
|
|
expect(bulkSelectionStore.size).toBe(1);
|
|
});
|
|
|
|
it('toggle removes an id when present', () => {
|
|
bulkSelectionStore.add('a');
|
|
bulkSelectionStore.toggle('a');
|
|
expect(bulkSelectionStore.has('a')).toBe(false);
|
|
});
|
|
|
|
it('add and remove update size', () => {
|
|
bulkSelectionStore.add('a');
|
|
bulkSelectionStore.add('b');
|
|
expect(bulkSelectionStore.size).toBe(2);
|
|
bulkSelectionStore.remove('a');
|
|
expect(bulkSelectionStore.size).toBe(1);
|
|
expect(bulkSelectionStore.has('b')).toBe(true);
|
|
});
|
|
|
|
it('add is idempotent', () => {
|
|
bulkSelectionStore.add('a');
|
|
bulkSelectionStore.add('a');
|
|
expect(bulkSelectionStore.size).toBe(1);
|
|
});
|
|
|
|
it('setAll replaces the selection', () => {
|
|
bulkSelectionStore.add('a');
|
|
bulkSelectionStore.add('b');
|
|
bulkSelectionStore.setAll(['c', 'd', 'e']);
|
|
expect(bulkSelectionStore.size).toBe(3);
|
|
expect(bulkSelectionStore.has('a')).toBe(false);
|
|
expect(bulkSelectionStore.has('c')).toBe(true);
|
|
});
|
|
|
|
it('clear empties the selection', () => {
|
|
bulkSelectionStore.add('a');
|
|
bulkSelectionStore.add('b');
|
|
bulkSelectionStore.clear();
|
|
expect(bulkSelectionStore.size).toBe(0);
|
|
});
|
|
|
|
it('setAll([]) leaves the store empty (no-op when filter returned zero matches)', () => {
|
|
bulkSelectionStore.add('a');
|
|
bulkSelectionStore.setAll([]);
|
|
expect(bulkSelectionStore.size).toBe(0);
|
|
});
|
|
|
|
it('setAll drops all previously selected ids, not just some', () => {
|
|
bulkSelectionStore.add('a');
|
|
bulkSelectionStore.add('b');
|
|
bulkSelectionStore.setAll(['c', 'd']);
|
|
expect(bulkSelectionStore.has('a')).toBe(false);
|
|
expect(bulkSelectionStore.has('b')).toBe(false);
|
|
expect(bulkSelectionStore.has('c')).toBe(true);
|
|
expect(bulkSelectionStore.has('d')).toBe(true);
|
|
});
|
|
|
|
it('ids getter exposes the current SvelteSet', () => {
|
|
bulkSelectionStore.add('a');
|
|
bulkSelectionStore.add('b');
|
|
const ids = Array.from(bulkSelectionStore.ids);
|
|
expect(ids.sort()).toEqual(['a', 'b']);
|
|
});
|
|
});
|