42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { buildCoverageEvidence } from '../../scripts/lib/wp7-05-coverage.mjs';
|
|
import { REQUIRED_COVERAGE_UNITS } from '../../scripts/lib/wp7-05-ui-gate.mjs';
|
|
|
|
const viewports = [
|
|
{ width: 1920, height: 1080, deviceScaleFactor: 1, zoom: 100 },
|
|
{ width: 1920, height: 1080, deviceScaleFactor: 1, zoom: 200 },
|
|
];
|
|
|
|
function completeUnits() {
|
|
return REQUIRED_COVERAGE_UNITS.map((page_id) => ({
|
|
page_id,
|
|
states: [{
|
|
state: 'normal',
|
|
screenshot_100pct: `ui/${page_id}/normal/100pct.png`,
|
|
screenshot_200pct: `ui/${page_id}/normal/200pct.png`,
|
|
trace: `ui/${page_id}/normal/trace.zip`,
|
|
}],
|
|
}));
|
|
}
|
|
|
|
test('builds ordered, sanitized evidence for all 22 coverage units', () => {
|
|
const evidence = buildCoverageEvidence({
|
|
runId: 'wp7-05-red-001',
|
|
candidateSha256: 'a'.repeat(64),
|
|
coverageUnits: completeUnits(),
|
|
viewports,
|
|
});
|
|
assert.equal(evidence.coverage_units.length, 22);
|
|
assert.equal(evidence.coverage_units[0].page_id, 'support-gate');
|
|
assert.equal(evidence.candidate_sha256, 'A'.repeat(64));
|
|
});
|
|
|
|
test('rejects absolute evidence paths and incomplete page state', () => {
|
|
const units = completeUnits();
|
|
units[0].states[0].trace = 'C:\\secret\\trace.zip';
|
|
assert.throws(() => buildCoverageEvidence({
|
|
runId: 'wp7-05-red-001', candidateSha256: 'a'.repeat(64), coverageUnits: units, viewports,
|
|
}), /WP7_05_UNSAFE_TRACE/);
|
|
});
|