26 lines
1.5 KiB
JavaScript
26 lines
1.5 KiB
JavaScript
import test from 'node:test';
|
|||
|
|
import assert from 'node:assert/strict';
|
||
|
|
import { privacyRequestsWithDetail } from '../src/pages/privacy-detail.ts';
|
||
|
|
|
||
|
|
const summary = { id: 'synthetic-request', version: 2, updated_at: '2026-10-05T00:00:00Z', subtasks: [] };
|
||
|
|
const detail = { ...summary, subtasks: [{ id: 'synthetic-subtask', status: 'FAILED' }] };
|
||
|
|
test('list polling does not erase loaded subtasks for the same revision', () => {
|
||
|
|
assert.equal(privacyRequestsWithDetail([summary], detail)[0].subtasks.length, 1);
|
||
|
|
assert.equal(summary.subtasks.length, 0);
|
||
|
|
});
|
||
|
|
test('a newer list revision invalidates old detail evidence', () => {
|
||
|
|
assert.equal(privacyRequestsWithDetail([{ ...summary, version: 3 }], detail)[0].subtasks.length, 0);
|
||
|
|
assert.equal(privacyRequestsWithDetail([{ ...summary, updated_at: '2026-10-05T00:01:00Z' }], detail)[0].subtasks.length, 0);
|
||
|
|
});
|
||
|
|
test('a successfully fetched request is visible even when list loading failed', () => {
|
||
|
|
assert.deepEqual(privacyRequestsWithDetail([], detail), [detail]);
|
||
|
|
});
|
||
|
|
test('subtask failure projected without a parent revision invalidates the old status', () => {
|
||
|
|
const failed = { ...summary, status: 'PARTIAL_FAILED' };
|
||
|
|
assert.equal(privacyRequestsWithDetail([failed], { ...detail, status: 'EXECUTING' })[0], failed);
|
||
|
|
});
|
||
|
|
test('a more recent detail read can disclose a failure missing from the older list', () => {
|
||
|
|
const failed = { ...detail, status: 'PARTIAL_FAILED' };
|
||
|
|
assert.equal(privacyRequestsWithDetail([{ ...summary, status: 'EXECUTING' }], failed, true)[0], failed);
|
||
|
|
});
|