migrateReportV2ToV3 / readReportDocument (version read on the raw value, JS truthiness kept, a malformed mapped path still fails the read), rebaseReportOnSheet (??= labels, archived names first-match), buildSheetSnapshot / assertSnapshot (raw depth, shape, caps in UTF-16 and UTF-8, integrity), readArchiveDocument (layered: report first, wrapper, snapshot gate, sheet invariant, unsupported_envelope origin quirk). Checked against 84 cases frozen from the TypeScript and 765 Zod verdicts (one declared difference: L1, a lone surrogate reads as U+FFFD), the ported report and archive suites and the 612 legacy leaves. Facade: draft.restore (content kinds invalid / unsupported_version, rebase_failed never a content kind), archive.import (incompatible_version with found, no_attachment), archive.snapshot.
552 lines
20 KiB
Rust
552 lines
20 KiB
Rust
//! `packages/domain/tests/report.{schema,migrate,rebase}.test.ts` ported with their exact
|
|
//! expectations, plus the 612 legacy leaves migrated through the draft map.
|
|
#![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)]
|
|
|
|
mod archive_support;
|
|
mod common;
|
|
|
|
use archive_support::*;
|
|
use faunosteo_core::domain::archive::{SheetSnapshot, build_sheet_snapshot};
|
|
use faunosteo_core::domain::report::v2::ReportV2;
|
|
use faunosteo_core::domain::report::{
|
|
Animal, Finding, LateralSide, Observation, Practitioner, ReadFailure, Report,
|
|
ReportMigrationMap, ReportZone, Severity, Vertebra, migrate_report_v2_to_v3,
|
|
read_report_document, rebase_report_on_sheet,
|
|
};
|
|
use faunosteo_core::domain::sheet::LoadedSheet;
|
|
use serde::de::DeserializeOwned;
|
|
use serde_json::{Value, json};
|
|
|
|
const SHA: &str = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
|
|
|
fn accepts<T: DeserializeOwned>(value: Value) -> bool {
|
|
serde_json::from_value::<T>(value).is_ok()
|
|
}
|
|
|
|
fn finding() -> Value {
|
|
json!({ "findingZoneId": "z", "path": ["a"], "labelFrSnapshot": "a", "labelEnSnapshot": "a" })
|
|
}
|
|
|
|
fn observation() -> Value {
|
|
json!({ "id": "o1", "zones": [], "findings": [], "freeTextFindings": [], "comment": "" })
|
|
}
|
|
|
|
fn report() -> Value {
|
|
json!({
|
|
"version": 3, "id": "r1", "createdAt": "2026-10-01T00:00:00Z", "date": "2026-10-01",
|
|
"practitioner": { "name": "P" }, "animal": { "speciesId": "equine", "name": "A" },
|
|
"owner": { "name": "O" },
|
|
"sheet": { "sheetId": "s", "versionId": null, "documentSha256": SHA },
|
|
"observations": [], "conclusion": "", "recommendations": ""
|
|
})
|
|
}
|
|
|
|
fn with(mut base: Value, key: &str, value: Value) -> Value {
|
|
base[key] = value;
|
|
base
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// report.schema.test.ts
|
|
|
|
#[test]
|
|
fn report_v3_leaf_schemas() {
|
|
assert!(accepts::<Finding>(finding()));
|
|
assert!(!accepts::<Finding>(with(finding(), "path", json!([]))));
|
|
assert!(!accepts::<Finding>(with(
|
|
finding(),
|
|
"findingZoneId",
|
|
json!("")
|
|
)));
|
|
assert!(accepts::<LateralSide>(json!("left")));
|
|
assert!(!accepts::<LateralSide>(json!("both")) && !accepts::<LateralSide>(json!("")));
|
|
assert!(accepts::<Vertebra>(json!({ "region": "C", "index": 1 })));
|
|
assert!(!accepts::<Vertebra>(json!({ "region": "C", "index": 0 })));
|
|
assert!(!accepts::<Vertebra>(json!({ "region": "C", "index": 1.5 })));
|
|
assert!(accepts::<Observation>(observation()));
|
|
assert!(!accepts::<Observation>(with(
|
|
observation(),
|
|
"id",
|
|
json!("")
|
|
)));
|
|
for code in ["mild", "moderate", "severe"] {
|
|
assert!(accepts::<Severity>(json!(code)));
|
|
}
|
|
assert!(!accepts::<Severity>(json!("légère")) && !accepts::<Severity>(json!("unknown")));
|
|
let zone = json!({ "annotationId": "a", "viewId": "main" });
|
|
assert!(accepts::<ReportZone>(zone.clone()));
|
|
assert!(!accepts::<ReportZone>(with(
|
|
zone,
|
|
"annotationId",
|
|
json!("")
|
|
)));
|
|
}
|
|
|
|
#[test]
|
|
fn report_v3_document_and_identity() {
|
|
let date = json!({ "kind": "date", "date": "2026-11-01" });
|
|
let period = json!({ "kind": "period", "text": "dans 3 semaines" });
|
|
assert!(accepts::<Report>(with(report(), "nextAppointment", date)));
|
|
assert!(accepts::<Report>(with(report(), "nextAppointment", period)));
|
|
assert!(!accepts::<Report>(with(
|
|
report(),
|
|
"nextAppointment",
|
|
json!({ "kind": "other" })
|
|
)));
|
|
assert!(!accepts::<Practitioner>(json!({ "name": "" })));
|
|
assert!(!accepts::<Animal>(json!({ "speciesId": "", "name": "A" })));
|
|
}
|
|
|
|
#[test]
|
|
fn report_v3_permissive_boundaries() {
|
|
let out: Report = from(with(report(), "foo", json!(1)));
|
|
assert!(to_value(&out).get("foo").is_none());
|
|
assert!(accepts::<Vertebra>(json!({ "region": "C", "index": 99 })));
|
|
let animal = json!({ "speciesId": "dragon", "name": "A" });
|
|
assert!(accepts::<Report>(with(report(), "animal", animal)));
|
|
let orphan = with(observation(), "findings", json!([finding()]));
|
|
assert!(accepts::<Report>(with(
|
|
report(),
|
|
"observations",
|
|
json!([orphan])
|
|
)));
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// report.migrate.test.ts
|
|
|
|
fn test_map() -> ReportMigrationMap {
|
|
from(json!({
|
|
"schema_version": 1,
|
|
"sheet": { "sheetId": "sheet-1", "versionId": null, "documentSha256": SHA },
|
|
"main_view_id": "main",
|
|
"views": { "head": "head" },
|
|
"annotations": {
|
|
"point-mpbwyyc9": { "id": "c7-t1", "name": {
|
|
"fr": "Charnière C7-T1 (cervico-thoracique)", "en": "C7-T1 (Cervicothoracic)" } },
|
|
"point-mpbwtst0": { "id": "hip", "name": { "fr": "Hanche (coxo-fémorale)", "en": "Hip joint" } },
|
|
"zone-mpbx5hx2": { "id": "cervical", "name": { "fr": "Vertèbres cervicales", "en": "Cervical Vertebrae" } },
|
|
"point-mpbyo7zq": { "id": "atm", "name": {
|
|
"fr": "Articulation Temporo-Mandibulaire (ATM)", "en": "Temporomandibular Joint (TMJ)" } }
|
|
},
|
|
"finding_paths": {
|
|
"c7-t1/c7-t1-dysfunctions/segmental/fixation": "c7-t1/c7-t1-dysfunctions/segmental/fixation",
|
|
"hip/hip-dysfunctions/articular/restriction-flexion": "hip/hip-dysfunctions/articular/restriction-flexion",
|
|
"cervical/cervical-observations/stumbling-proprioceptive": "cervical/cervical-consultation-reasons/stumbling-proprioceptive",
|
|
"atm/atm-observations/headshaking": null
|
|
}
|
|
}))
|
|
}
|
|
|
|
fn fixture(name: &str) -> Value {
|
|
json_file(&format!("packages/domain/tests/fixtures/{name}"))
|
|
}
|
|
|
|
fn migrated(
|
|
v2: &Value,
|
|
map: &ReportMigrationMap,
|
|
) -> faunosteo_core::domain::report::MigrationOutcome {
|
|
migrate_report_v2_to_v3(&from::<ReportV2>(v2.clone()), map).unwrap()
|
|
}
|
|
|
|
#[test]
|
|
fn report_v3_schema_defaults_and_refusals() {
|
|
let parsed: Report = from(report());
|
|
assert!(parsed.local_annotations.is_empty());
|
|
let base = to_value(&migrated(&fixture("report-v2.minimal.json"), &test_map()).report);
|
|
let severity = json!([{ "id": "o", "zones": [], "findings": [], "freeTextFindings": [],
|
|
"comment": "", "severity": "légère" }]);
|
|
let hash = json!({ "sheetId": "s", "versionId": null, "documentSha256": "xyz" });
|
|
for (key, value) in [
|
|
("version", json!(2)),
|
|
("localAnnotations", json!([{ "x": 1 }])),
|
|
("observations", severity),
|
|
("sheet", hash),
|
|
] {
|
|
assert!(!accepts::<Report>(with(base.clone(), key, value)), "{key}");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn migrate_keeps_identity_dates_conclusion_and_appointment() {
|
|
let v2 = fixture("report-v2.full.json");
|
|
let report = migrated(&v2, &test_map()).report;
|
|
let out = to_value(&report);
|
|
assert_eq!(out["version"], 3);
|
|
for key in [
|
|
"id",
|
|
"practitioner",
|
|
"animal",
|
|
"owner",
|
|
"conclusion",
|
|
"nextAppointment",
|
|
] {
|
|
assert_eq!(out[key], v2[key], "{key}");
|
|
}
|
|
assert_eq!(to_value(&report.sheet), to_value(&test_map().sheet));
|
|
let ids: Vec<&Value> = v2["observations"]
|
|
.as_array()
|
|
.unwrap()
|
|
.iter()
|
|
.map(|o| &o["id"])
|
|
.collect();
|
|
let migrated_ids: Vec<Value> = report.observations.iter().map(|o| json!(o.id)).collect();
|
|
assert_eq!(migrated_ids.iter().collect::<Vec<_>>(), ids);
|
|
}
|
|
|
|
#[test]
|
|
fn migrate_maps_legacy_ids_views_and_snapshots_the_legacy_names() {
|
|
let v2 = fixture("report-v2.full.json");
|
|
let outcome = migrated(&v2, &test_map());
|
|
let zones: Vec<&ReportZone> = outcome
|
|
.report
|
|
.observations
|
|
.iter()
|
|
.flat_map(|o| &o.zones)
|
|
.collect();
|
|
let hip: Vec<&&ReportZone> = zones.iter().filter(|z| z.annotation_id == "hip").collect();
|
|
let mut sides: Vec<Value> = hip.iter().map(|z| to_value(&z.side)).collect();
|
|
sides.sort_by_key(|v| v.to_string());
|
|
assert_eq!(sides, vec![json!("left"), json!("right")]);
|
|
assert_eq!(hip[0].view_id, "main");
|
|
assert_eq!(
|
|
hip[0].label_fr_snapshot.as_deref(),
|
|
Some("Hanche (coxo-fémorale)")
|
|
);
|
|
let atm = zones.iter().find(|z| z.annotation_id == "atm").unwrap();
|
|
assert_eq!(atm.view_id, "head");
|
|
let cervical = zones
|
|
.iter()
|
|
.find(|z| z.annotation_id == "cervical")
|
|
.unwrap();
|
|
let legacy = v2["observations"]
|
|
.as_array()
|
|
.unwrap()
|
|
.iter()
|
|
.flat_map(|o| o["zones"].as_array().unwrap())
|
|
.find(|z| z["boneId"] == "zone-mpbx5hx2")
|
|
.unwrap();
|
|
assert_eq!(to_value(&cervical.vertebrae), legacy["vertebrae"]);
|
|
assert!(zones.iter().all(|z| z.unresolved.is_none()));
|
|
assert_eq!(outcome.unresolved_zones, 0);
|
|
}
|
|
|
|
#[test]
|
|
fn migrate_remaps_moved_paths_and_flags_removed_ones() {
|
|
let outcome = migrated(&fixture("report-v2.full.json"), &test_map());
|
|
let findings: Vec<&Finding> = outcome
|
|
.report
|
|
.observations
|
|
.iter()
|
|
.flat_map(|o| &o.findings)
|
|
.collect();
|
|
let moved = findings
|
|
.iter()
|
|
.find(|f| f.path.iter().any(|s| s == "stumbling-proprioceptive"))
|
|
.unwrap();
|
|
assert_eq!(
|
|
moved.path,
|
|
["cervical-consultation-reasons", "stumbling-proprioceptive"]
|
|
);
|
|
assert_eq!(moved.finding_zone_id, "cervical");
|
|
assert!(moved.unresolved.is_none());
|
|
let removed = findings
|
|
.iter()
|
|
.find(|f| f.path.iter().any(|s| s == "headshaking"))
|
|
.unwrap();
|
|
assert!(removed.unresolved.is_some());
|
|
assert_eq!(removed.path, ["atm-observations", "headshaking"]);
|
|
assert_eq!(
|
|
removed.label_fr_snapshot,
|
|
"Headshaking (secouement de tête)"
|
|
);
|
|
assert_eq!(removed.requires_vet_referral, Some(true));
|
|
assert_eq!(outcome.unresolved_findings, 1);
|
|
}
|
|
|
|
#[test]
|
|
fn migrate_converts_severities_to_stable_codes() {
|
|
let outcome = migrated(&fixture("report-v2.full.json"), &test_map());
|
|
let codes: Vec<Option<Severity>> = outcome
|
|
.report
|
|
.observations
|
|
.iter()
|
|
.map(|o| o.severity)
|
|
.collect();
|
|
assert!(codes.contains(&Some(Severity::Moderate)) && codes.contains(&Some(Severity::Severe)));
|
|
}
|
|
|
|
#[test]
|
|
fn migrate_flags_an_unknown_zone_and_an_unknown_path_instead_of_dropping_them() {
|
|
let odd = with(
|
|
fixture("report-v2.full.json"),
|
|
"observations",
|
|
json!([{
|
|
"id": "o", "zones": [{ "boneId": "point-unknown" }],
|
|
"findings": [{ "zoneId": "nowhere", "path": ["x"], "labelFrSnapshot": "X", "labelEnSnapshot": "X" }],
|
|
"freeTextFindings": [], "comment": ""
|
|
}]),
|
|
);
|
|
let out = migrated(&odd, &test_map());
|
|
let obs = to_value(&out.report.observations[0]);
|
|
assert_eq!(
|
|
obs["zones"][0],
|
|
json!({ "annotationId": "point-unknown", "viewId": "main", "unresolved": true })
|
|
);
|
|
assert_eq!(
|
|
obs["findings"][0],
|
|
json!({ "findingZoneId": "nowhere", "path": ["x"],
|
|
"labelFrSnapshot": "X", "labelEnSnapshot": "X", "unresolved": true })
|
|
);
|
|
assert_eq!((out.unresolved_zones, out.unresolved_findings), (1, 1));
|
|
}
|
|
|
|
#[test]
|
|
fn read_report_document_returns_v3_as_is_and_migrates_v2() {
|
|
let minimal = fixture("report-v2.minimal.json");
|
|
let v3 = migrated(&minimal, &test_map()).report;
|
|
assert_eq!(
|
|
read_report_document(&to_value(&v3), &test_map())
|
|
.unwrap()
|
|
.report,
|
|
v3
|
|
);
|
|
let read = read_report_document(&minimal, &test_map()).unwrap();
|
|
assert_eq!(to_value(&read.report)["version"], 3);
|
|
}
|
|
|
|
#[test]
|
|
fn read_report_document_refuses_unknown_versions_with_the_found_version() {
|
|
let minimal = fixture("report-v2.minimal.json");
|
|
let map = test_map();
|
|
assert_eq!(
|
|
read_report_document(&with(minimal.clone(), "version", json!(1)), &map).err(),
|
|
Some(ReadFailure::UnsupportedVersion(Some(1.0)))
|
|
);
|
|
assert_eq!(
|
|
read_report_document(&json!({ "hello": "world" }), &map).err(),
|
|
Some(ReadFailure::UnsupportedVersion(None))
|
|
);
|
|
assert_eq!(
|
|
read_report_document(&with(minimal, "version", json!(7)), &map).err(),
|
|
Some(ReadFailure::UnsupportedVersion(Some(7.0)))
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn hostile_identifiers_are_unknown_ids() {
|
|
let odd = with(
|
|
fixture("report-v2.minimal.json"),
|
|
"observations",
|
|
json!([{
|
|
"id": "o",
|
|
"zones": [{ "boneId": "__proto__" }, { "boneId": "constructor", "detailSourceId": "__proto__" }],
|
|
"findings": [{ "zoneId": "constructor", "path": ["__proto__"], "labelFrSnapshot": "X", "labelEnSnapshot": "X" }],
|
|
"freeTextFindings": [], "comment": ""
|
|
}]),
|
|
);
|
|
let out = migrated(&odd, &test_map());
|
|
assert_eq!((out.unresolved_zones, out.unresolved_findings), (2, 1));
|
|
assert_eq!(out.report.observations[0].zones[1].view_id, "__proto__");
|
|
}
|
|
|
|
#[test]
|
|
fn the_612_legacy_leaves_migrate_through_the_draft_map() {
|
|
let leaves = legacy_leaves();
|
|
assert_eq!(leaves.len(), 612);
|
|
assert_eq!(leaves.iter().filter(|l| l.vet).count(), 41);
|
|
let v2 = leaves_as_v2_report(&leaves);
|
|
let outcome = read_report_document(&v2, &draft_map()).unwrap();
|
|
let findings: Vec<&Finding> = outcome
|
|
.report
|
|
.observations
|
|
.iter()
|
|
.flat_map(|o| &o.findings)
|
|
.collect();
|
|
assert_eq!(findings.len(), 612);
|
|
let unresolved = findings.iter().filter(|f| f.unresolved.is_some()).count();
|
|
assert_eq!(unresolved, outcome.unresolved_findings as usize);
|
|
assert!(unresolved > 0 && unresolved < 612);
|
|
// Every resolved path exists in the draft; every unresolved one is gone or never was.
|
|
let draft = draft_sheet();
|
|
for f in &findings {
|
|
let found = draft
|
|
.indexed()
|
|
.node_at(&f.finding_zone_id, &f.path)
|
|
.is_some();
|
|
assert_eq!(
|
|
found,
|
|
f.unresolved.is_none(),
|
|
"{}/{}",
|
|
f.finding_zone_id,
|
|
f.path.join("/")
|
|
);
|
|
}
|
|
assert_eq!(
|
|
findings
|
|
.iter()
|
|
.filter(|f| f.requires_vet_referral == Some(true))
|
|
.count(),
|
|
41
|
|
);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// report.rebase.test.ts
|
|
|
|
const SHA_B: &str = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
|
|
|
|
fn revision_b() -> Value {
|
|
let mut doc = horse_slice();
|
|
let annotations: Vec<Value> = doc["annotations"]
|
|
.as_array()
|
|
.unwrap()
|
|
.iter()
|
|
.filter(|a| a["id"] != "atm" && a["id"] != "head-trigger")
|
|
.cloned()
|
|
.collect();
|
|
doc["annotations"] = json!(annotations);
|
|
let zones = doc["finding_zones"].as_array_mut().unwrap();
|
|
let hip = zones.iter_mut().find(|z| z["id"] == "hip").unwrap();
|
|
let kept: Vec<Value> = hip["categories"][0]["children"]
|
|
.as_array()
|
|
.unwrap()
|
|
.iter()
|
|
.filter(|n| n["id"] != "articular")
|
|
.cloned()
|
|
.collect();
|
|
hip["categories"][0]["children"] = json!(kept);
|
|
doc
|
|
}
|
|
|
|
fn sheet_a() -> LoadedSheet {
|
|
slice_sheet(
|
|
snake_ref("sheet-1", None, SHA),
|
|
horse_slice(),
|
|
"<svg/>",
|
|
None,
|
|
)
|
|
}
|
|
|
|
fn sheet_b() -> LoadedSheet {
|
|
slice_sheet(
|
|
snake_ref("sheet-1", Some("v2"), SHA_B),
|
|
revision_b(),
|
|
"<svg/>",
|
|
None,
|
|
)
|
|
}
|
|
|
|
fn report_on_a() -> Report {
|
|
from(json!({
|
|
"version": 3, "id": "r1", "createdAt": "2026-10-10T10:00:00Z", "date": "2026-10-10",
|
|
"practitioner": { "name": "Dr. Dupont" }, "animal": { "speciesId": "equine", "name": "Mistral" },
|
|
"owner": { "name": "Jean Martin" },
|
|
"sheet": { "sheetId": "sheet-1", "versionId": null, "documentSha256": SHA },
|
|
"observations": [{
|
|
"id": "obs-1",
|
|
"zones": [
|
|
{ "annotationId": "hip", "viewId": "view-main", "side": "left",
|
|
"labelFrSnapshot": "Hanche (coxo-fémorale)", "labelEnSnapshot": "Hip joint" },
|
|
{ "annotationId": "atm", "viewId": "view-head" },
|
|
{ "annotationId": "head-trigger", "viewId": "view-main" },
|
|
{ "annotationId": "hip", "viewId": "ghost-view", "labelFrSnapshot": "Gardé" },
|
|
{ "annotationId": "gone-long-ago", "viewId": "view-main", "labelFrSnapshot": "Ancien", "unresolved": true }
|
|
],
|
|
"findings": [
|
|
{ "findingZoneId": "hip", "path": ["hip-dysfunctions", "articular", "restriction-flexion"],
|
|
"labelFrSnapshot": "Restriction en flexion", "labelEnSnapshot": "Flexion restriction" },
|
|
{ "findingZoneId": "cervical", "path": ["cervical-observations", "stumbling-proprioceptive"],
|
|
"labelFrSnapshot": "Trébuchements", "labelEnSnapshot": "Stumbling", "requiresVetReferral": true },
|
|
{ "findingZoneId": "atm", "path": ["atm-observations", "headshaking"],
|
|
"labelFrSnapshot": "Headshaking", "labelEnSnapshot": "Headshaking", "unresolved": true }
|
|
],
|
|
"freeTextFindings": ["note"], "severity": "moderate", "comment": ""
|
|
}],
|
|
"conclusion": "c", "recommendations": "r", "localAnnotations": []
|
|
}))
|
|
}
|
|
|
|
#[test]
|
|
fn rebase_returns_the_report_untouched_on_the_loaded_sheet() {
|
|
let report = report_on_a();
|
|
let outcome = rebase_report_on_sheet(&report, &sheet_a(), None).unwrap();
|
|
assert_eq!(outcome.report, report);
|
|
assert_eq!(
|
|
(
|
|
outcome.unresolved_zones,
|
|
outcome.unresolved_findings,
|
|
outcome.rebased
|
|
),
|
|
(0, 0, false)
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn rebase_flags_what_the_new_sheet_lost_labels_it_from_the_archive_keeps_the_rest() {
|
|
let report = report_on_a();
|
|
let archived: SheetSnapshot = build_sheet_snapshot(&sheet_a(), &report);
|
|
let outcome = rebase_report_on_sheet(&report, &sheet_b(), Some(&archived)).unwrap();
|
|
assert!(outcome.rebased);
|
|
assert_eq!(
|
|
(outcome.unresolved_zones, outcome.unresolved_findings),
|
|
(3, 1)
|
|
);
|
|
assert_eq!(
|
|
to_value(&outcome.report.sheet),
|
|
json!({ "sheetId": "sheet-1", "versionId": "v2", "documentSha256": SHA_B })
|
|
);
|
|
let zones = to_value(&outcome.report.observations[0].zones);
|
|
let before = to_value(&report.observations[0].zones);
|
|
assert_eq!(zones[0], before[0]);
|
|
assert_eq!(
|
|
zones[1],
|
|
json!({ "annotationId": "atm", "viewId": "view-head", "unresolved": true,
|
|
"labelFrSnapshot": "Articulation Temporo-Mandibulaire (ATM)",
|
|
"labelEnSnapshot": "Temporomandibular Joint (TMJ)" })
|
|
);
|
|
assert_eq!(
|
|
zones[2],
|
|
json!({ "annotationId": "head-trigger", "viewId": "view-main",
|
|
"unresolved": true, "labelFrSnapshot": "Tête", "labelEnSnapshot": "Head" })
|
|
);
|
|
assert_eq!(
|
|
zones[3],
|
|
json!({ "annotationId": "hip", "viewId": "ghost-view", "unresolved": true,
|
|
"labelFrSnapshot": "Gardé", "labelEnSnapshot": "Hip joint" })
|
|
);
|
|
assert_eq!(zones[4], before[4]);
|
|
let findings = to_value(&outcome.report.observations[0].findings);
|
|
let original = to_value(&report.observations[0].findings);
|
|
let mut flexion = original[0].clone();
|
|
flexion["unresolved"] = json!(true);
|
|
assert_eq!(findings[0], flexion);
|
|
assert_eq!(findings[1], original[1]);
|
|
assert_eq!(findings[2], original[2]);
|
|
assert_eq!(outcome.report.observations[0].free_text_findings, ["note"]);
|
|
assert_eq!(report, report_on_a());
|
|
}
|
|
|
|
#[test]
|
|
fn rebase_fills_no_label_without_an_archived_snapshot() {
|
|
let outcome = rebase_report_on_sheet(&report_on_a(), &sheet_b(), None).unwrap();
|
|
assert_eq!(
|
|
to_value(&outcome.report.observations[0].zones[1]),
|
|
json!({ "annotationId": "atm", "viewId": "view-head", "unresolved": true })
|
|
);
|
|
assert_eq!(outcome.unresolved_zones, 3);
|
|
}
|
|
|
|
#[test]
|
|
fn rebase_counts_nothing_twice() {
|
|
let first = rebase_report_on_sheet(&report_on_a(), &sheet_b(), None).unwrap();
|
|
let mut back = first.report.clone();
|
|
back.sheet = report_on_a().sheet;
|
|
let second = rebase_report_on_sheet(&back, &sheet_b(), None).unwrap();
|
|
assert_eq!(
|
|
(second.unresolved_zones, second.unresolved_findings),
|
|
(0, 0)
|
|
);
|
|
assert_eq!(second.report, first.report);
|
|
}
|