Files
faunosteo/crates/core/tests/sheet_contract.rs
T
bchanot ee0700887f feat(domain): R2.1 Rust contracts of the sheet, report and archive documents
Sheet document v2, report v3 / v2 / identity, migration map, sheet snapshot,
branding, PDF labels and archive envelope ported from the Zod schemas with
their exact semantics: strict objects where Zod is strict, optional fields
absent (never null), nullable fields required, integers as JavaScript
numbers, UTF-16 caps, hand-checked patterns, url crate for .url(), lone
surrogate escapes read as U+FFFD (L1, owner confirmation pending).
Fields in Zod schema order (PDF labels in the engine dictionary order):
the curated and legacy sheets, the demo report and the three frozen
archive envelopes print byte for byte as their Zod / attachment form.
ts-rs types regenerated; plan rev 2 after three plan challenges.
2026-10-14 00:04:01 +02:00

27 lines
926 B
Rust

//! The sheet document contract against the Zod oracles: the reference documents parse and
//! print byte for byte as `JSON.stringify(AnatomicalSheetDocumentSchema.parse(x), null, 2)`.
#![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)]
mod common;
use faunosteo_core::domain::js::parse_json;
use faunosteo_core::domain::sheet::AnatomicalSheetDocument;
use faunosteo_core::json::to_js_pretty;
fn assert_like_zod(oracle: &str) {
let (source, expected) = common::zod_oracle(oracle);
let document: AnatomicalSheetDocument =
serde_json::from_value(parse_json(&source).unwrap()).unwrap();
assert_eq!(to_js_pretty(&document).unwrap(), expected, "{oracle}");
}
#[test]
fn the_curated_draft_prints_as_zod_outputs_it() {
assert_like_zod("sheet.draft.json");
}
#[test]
fn the_legacy_import_baseline_prints_as_zod_outputs_it() {
assert_like_zod("sheet.legacy-import.json");
}