test(tests): R2 freeze — archive envelopes of the three golden reports and the frozen N-1 reader
Envelopes exported by the TypeScript domain before the Rust switch (FR, no
logos, fixed export time) are the semantic oracle of the switch (D-R11:
key order may change, values may not). The shipped Zod schemas are copied
verbatim under packages/core-wasm/tests/n-1 (develop 1a7ee7d) so a rollback
reader stays testable after packages/domain is deleted at R5.
This commit is contained in:
1 parent
1a7ee7d9ac
commit
3114d67959
29 files changed
+8581
-46
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import {
|
||||
readReportDocument,
|
||||
ReportSchema,
|
||||
type Report,
|
||||
} from '@faunosteo/domain'
|
||||
import type { SheetIndex } from '@/services/sheetIndex'
|
||||
import { FIXTURES_DIR } from './goldens'
|
||||
import {
|
||||
leavesAsV2Report,
|
||||
legacyLeaves,
|
||||
loadLegacyBaseline,
|
||||
} from './legacyLeaves'
|
||||
|
||||
/**
|
||||
* The three reports the Step 6 goldens and the R2 envelope freeze are drawn
|
||||
* from: the Step 5 v2 archive fixture migrated, the v3 demo report, and a v2
|
||||
* report whose sphenoid and ssb findings the migration cannot place.
|
||||
*/
|
||||
|
||||
export const GOLDEN_REPORTS = ['v2full', 'demo', 'v2unresolved'] as const
|
||||
export type GoldenReportName = (typeof GOLDEN_REPORTS)[number]
|
||||
|
||||
export interface GoldenReports {
|
||||
reports: Record<GoldenReportName, Report>
|
||||
/** Findings the migration flagged in `v2unresolved`. */
|
||||
unresolvedOfV2Unresolved: number
|
||||
}
|
||||
|
||||
const readJson = (name: string): unknown =>
|
||||
JSON.parse(readFileSync(resolve(FIXTURES_DIR, name), 'utf8'))
|
||||
|
||||
/** sphenoid + ssb (the families the migration cannot place) plus one leaf that resolves. */
|
||||
function buildV2Unresolved(sheet: SheetIndex) {
|
||||
const leaves = legacyLeaves(loadLegacyBaseline())
|
||||
const unresolvedFamilies = leaves.filter(
|
||||
(l) => l.zoneId === 'sphenoid' || l.zoneId === 'ssb',
|
||||
)
|
||||
const resolved = leaves.find((l) => l.zoneId === 'frontal')!
|
||||
return readReportDocument(
|
||||
leavesAsV2Report([...unresolvedFamilies, resolved]),
|
||||
sheet.sheet.migrationMap,
|
||||
)
|
||||
}
|
||||
|
||||
export function buildGoldenReports(sheet: SheetIndex): GoldenReports {
|
||||
const v2unresolved = buildV2Unresolved(sheet)
|
||||
return {
|
||||
reports: {
|
||||
v2full: readReportDocument(
|
||||
readJson('report-v2.full.json'),
|
||||
sheet.sheet.migrationMap,
|
||||
).report,
|
||||
demo: ReportSchema.parse(readJson('report-v3.demo.json')),
|
||||
v2unresolved: v2unresolved.report,
|
||||
},
|
||||
unresolvedOfV2Unresolved: v2unresolved.unresolvedFindings,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user