Files
story/web/test/privacy-detail.test.mjs
T
Codex Local bf1233d5df
ci / verify (push) Canceled after 0s
feat: expand companion platform, device controls, and memoir workflows
Add customer and operator login, BLE provisioning, device fleet controls, call memory, memoir generation, and refreshed family and maintenance portals. Include API contracts, migrations, firmware sources, tests, assets, and deployment documentation.
2026-10-08 10:06:44 +08:00

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);
});