test(pdf): apply owner-approved revised S01 baseline metric
This commit is contained in:
@@ -1,6 +1,50 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { measureNative, verifyBytes, assertPass, requireProtectedEntry } from './verify.mjs';
|
||||
import * as verifier from './verify.mjs';
|
||||
|
||||
function s01Fixture() {
|
||||
const hash = 'a'.repeat(64);
|
||||
return [{ total: 1, tolerances: { positionMm: 2, fontPt: .5, pageDimensionMm: .5, rgbComponent: 1 / 255 }, fixtures: [{ fixture: 'short-en-modern', pass: false, failures: ['S01: position delta x=0.00mm y=2.92mm'], comparisons: [{ token: 'S01', previewPage: 1, pdfPage: 1, deltaXmm: 0, deltaYmm: 2.92, fontDeltaPt: 0, colorDelta: 0 }] }] },
|
||||
{ rows: [{ fixture: 'short-en-modern', pdfSha256: hash, domBaselinePx: 92, pdfBaselinePx: 92 }] },
|
||||
{ fixtures: [{ fixture: 'short-en-modern', pdfSha256: hash, settings: { designVersion: 2 } }] }];
|
||||
}
|
||||
|
||||
test('approved S01 changes only the vertical coordinate metric and retains historical results', () => {
|
||||
const inputs = s01Fixture();
|
||||
assert.equal(verifier.qualifyRevisedS01(...inputs).passed, 1);
|
||||
assert.equal(inputs[0].fixtures[0].pass, false);
|
||||
assert.equal(inputs[0].fixtures[0].failures.length, 1);
|
||||
});
|
||||
test('approved S01 still rejects horizontal and actual vertical shifts above2mm', () => {
|
||||
for (const horizontal of [true, false]) {
|
||||
const inputs = s01Fixture();
|
||||
if (horizontal) inputs[0].fixtures[0].comparisons[0].deltaXmm = 2.01;
|
||||
else inputs[1].rows[0].pdfBaselinePx += 2.01 * 96 / 25.4;
|
||||
assert.equal(verifier.qualifyRevisedS01(...inputs).passed, 0);
|
||||
}
|
||||
});
|
||||
test('approved S01 retains font color and page checks', () => {
|
||||
for (const patch of [{ fontDeltaPt: .51 }, { colorDelta: .01 }, { pdfPage: 2 }]) {
|
||||
const inputs = s01Fixture(); Object.assign(inputs[0].fixtures[0].comparisons[0], patch);
|
||||
assert.equal(verifier.qualifyRevisedS01(...inputs).passed, 0);
|
||||
}
|
||||
});
|
||||
test('approved S01 retains every unrelated original failure', () => {
|
||||
const inputs = s01Fixture(); inputs[0].fixtures[0].failures.push('page 1: hidden section leaked');
|
||||
assert.equal(verifier.qualifyRevisedS01(...inputs).passed, 0);
|
||||
});
|
||||
test('approved S01 rejects missing duplicate foreign PDFs and version1 input', () => {
|
||||
for (const mutate of [x => x[1].rows.pop(), x => x[1].rows.push(x[1].rows[0]), x => x[1].rows[0].pdfSha256 = 'b'.repeat(64), x => x[2].fixtures[0].settings.designVersion = 1]) {
|
||||
const inputs = s01Fixture(); mutate(inputs); assert.throws(() => verifier.qualifyRevisedS01(...inputs));
|
||||
}
|
||||
});
|
||||
test('approved S01 rejects nonfinite coordinates and recomputes claimed deltas', () => {
|
||||
const inputs = s01Fixture(); inputs[1].rows[0].pdfBaselinePx = NaN;
|
||||
assert.throws(() => verifier.qualifyRevisedS01(...inputs));
|
||||
inputs[1].rows[0].pdfBaselinePx = 112; inputs[1].rows[0].baselineDeltaMm = 0;
|
||||
assert.equal(verifier.qualifyRevisedS01(...inputs).passed, 0);
|
||||
});
|
||||
|
||||
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' }] }] }));
|
||||
|
||||
Reference in New Issue
Block a user