36 lines
2.2 KiB
JavaScript
36 lines
2.2 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { measureNative, verifyBytes, assertPass, requireProtectedEntry } from './verify.mjs';
|
|
|
|
test('native Jest membership and counters agree before PASS', () => {
|
|
const result = measureNative('jest', JSON.stringify({ numTotalTests: 1, numPassedTests: 1, numFailedTests: 0, numPendingTests: 0, testResults: [{ name: 'fictional.test.ts', assertionResults: [{ fullName: 'preserves facts', status: 'passed' }] }] }));
|
|
assert.equal(result.passed, 1);
|
|
assertPass(result, 0);
|
|
});
|
|
test('zero, failing, skipped or retried results cannot qualify', () => {
|
|
for (const patch of [{ passed: 0 }, { failed: 1 }, { skipped: 1 }, { retries: 1 }])
|
|
assert.throws(() => assertPass({ passed: 1, failed: 0, skipped: 0, retries: 0, ...patch }, 0));
|
|
assert.throws(() => assertPass({ passed: 1, failed: 0, skipped: 0, retries: 0 }, 17));
|
|
});
|
|
test('tampered or missing evidence is rejected', () => {
|
|
assert.throws(() => verifyBytes(Buffer.from('changed'), '0'.repeat(64)));
|
|
assert.throws(() => verifyBytes(null, '0'.repeat(64)));
|
|
});
|
|
test('model-written GO and approval-shaped JSON cannot authorise Phase10', () => {
|
|
assert.equal(requireProtectedEntry({ status: 'GO', approved: true, ownerSignature: 'invented' }).eligible, false);
|
|
});
|
|
test('discovery counters cannot masquerade as an executed browser test', () => {
|
|
const report = { suites: [{ specs: [{ id: 'sample', tests: [{ projectName: 'chromium', results: [] }] }] }], stats: { expected: 1 } };
|
|
const result = measureNative('playwright', JSON.stringify(report));
|
|
assert.throws(() => assertPass(result, 0));
|
|
});
|
|
test('JUnit counters alone are not execution membership and entities are refused', () => {
|
|
assert.throws(() => assertPass(measureNative('junit', '<testsuite tests="83"/>'), 0));
|
|
assert.throws(() => measureNative('junit', '<!DOCTYPE x [<!ENTITY a "x">]><testsuite/>'));
|
|
const result = measureNative('junit', '<testsuite tests="1"><testcase classname="parser" name="grounded"/></testsuite>');
|
|
assert.equal(result.passed, 1);
|
|
});
|
|
test('oversized native reports are rejected before parsing', () => {
|
|
assert.throws(() => measureNative('jest', ' '.repeat(8 * 1024 * 1024 + 1)));
|
|
});
|