test(domain): characterise the N-1 core on a sheet carrying cat-access
This commit is contained in:
1 parent
7433df279a
commit
2860f4535f
2 files changed
+919
No files matched your search
+723
@@ -0,0 +1,723 @@
|
||||
{
|
||||
"schema_version": 2,
|
||||
"species_id": "equine",
|
||||
"name": {
|
||||
"fr": "Cheval (extrait)",
|
||||
"en": "Horse (slice)"
|
||||
},
|
||||
"description": {
|
||||
"fr": "Extrait de la fiche équine pour les tests du modèle",
|
||||
"en": "Equine sheet slice for model tests"
|
||||
},
|
||||
"scope_disclaimer": {
|
||||
"fr": "Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."
|
||||
},
|
||||
"attribution": {
|
||||
"authors": [
|
||||
"Faunosteo"
|
||||
],
|
||||
"license": "MIT",
|
||||
"notes": null
|
||||
},
|
||||
"vertebral_config": {
|
||||
"regions": [
|
||||
{
|
||||
"code": "C",
|
||||
"name": {
|
||||
"fr": "Cervicales",
|
||||
"en": "Cervical"
|
||||
},
|
||||
"count": 7
|
||||
},
|
||||
{
|
||||
"code": "T",
|
||||
"name": {
|
||||
"fr": "Thoraciques",
|
||||
"en": "Thoracic"
|
||||
},
|
||||
"count": 18
|
||||
},
|
||||
{
|
||||
"code": "L",
|
||||
"name": {
|
||||
"fr": "Lombaires",
|
||||
"en": "Lumbar"
|
||||
},
|
||||
"count": 6
|
||||
},
|
||||
{
|
||||
"code": "S",
|
||||
"name": {
|
||||
"fr": "Sacrées",
|
||||
"en": "Sacral"
|
||||
},
|
||||
"count": 5
|
||||
},
|
||||
{
|
||||
"code": "Cd",
|
||||
"name": {
|
||||
"fr": "Caudales",
|
||||
"en": "Caudal"
|
||||
},
|
||||
"count": 18,
|
||||
"count_range": {
|
||||
"min": 15,
|
||||
"max": 21
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"id": "legacy-catalog",
|
||||
"type": "manual",
|
||||
"citation": "Legacy equine catalog (pathologies.json, schema 2.0)"
|
||||
}
|
||||
],
|
||||
"categories": [
|
||||
{
|
||||
"id": "articulations",
|
||||
"name": {
|
||||
"fr": "Articulations",
|
||||
"en": "Joints"
|
||||
},
|
||||
"color": "#ff9500"
|
||||
},
|
||||
{
|
||||
"id": "zone-colonne",
|
||||
"name": {
|
||||
"fr": "Zone colonne",
|
||||
"en": "Spine zone"
|
||||
},
|
||||
"color": "#e100ff"
|
||||
},
|
||||
{
|
||||
"id": "charnieres-vertebrales",
|
||||
"name": {
|
||||
"fr": "Charnières vertébrales",
|
||||
"en": "Vertebral junctions"
|
||||
},
|
||||
"color": "#ff0000"
|
||||
},
|
||||
{
|
||||
"id": "cadrans-du-crane",
|
||||
"name": {
|
||||
"fr": "Cadrans du crâne",
|
||||
"en": "Skull quadrants"
|
||||
},
|
||||
"color": "#1baa08"
|
||||
},
|
||||
{
|
||||
"id": "cat-access",
|
||||
"name": {
|
||||
"fr": "Accès aux vues détaillées",
|
||||
"en": "Detail view access"
|
||||
},
|
||||
"color": null
|
||||
}
|
||||
],
|
||||
"views": [
|
||||
{
|
||||
"id": "view-main",
|
||||
"kind": "main",
|
||||
"name": {
|
||||
"fr": "Cheval entier",
|
||||
"en": "Whole horse"
|
||||
},
|
||||
"svg_asset_id": "3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8",
|
||||
"view_box": null
|
||||
},
|
||||
{
|
||||
"id": "view-head",
|
||||
"kind": "detail",
|
||||
"name": {
|
||||
"fr": "Tête",
|
||||
"en": "Head"
|
||||
},
|
||||
"parent_view_id": "view-main",
|
||||
"svg_asset_id": null,
|
||||
"view_box": {
|
||||
"min_x": 60,
|
||||
"min_y": 100,
|
||||
"width": 500,
|
||||
"height": 380
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "view-forelimbaa",
|
||||
"kind": "detail",
|
||||
"name": {
|
||||
"fr": "Membre antérieur",
|
||||
"en": "Forelimb"
|
||||
},
|
||||
"parent_view_id": "view-main",
|
||||
"svg_asset_id": null,
|
||||
"view_box": {
|
||||
"min_x": 625,
|
||||
"min_y": 969,
|
||||
"width": 220,
|
||||
"height": 660
|
||||
}
|
||||
}
|
||||
],
|
||||
"annotations": [
|
||||
{
|
||||
"id": "hip",
|
||||
"kind": "point",
|
||||
"view_id": "view-main",
|
||||
"category_id": "articulations",
|
||||
"laterality": "bilateral",
|
||||
"geometry": {
|
||||
"type": "circle",
|
||||
"cx": 1516,
|
||||
"cy": 695,
|
||||
"r": 34
|
||||
},
|
||||
"name": {
|
||||
"fr": "Hanche (coxo-fémorale)",
|
||||
"en": "Hip joint"
|
||||
},
|
||||
"finding_zone_id": "hip",
|
||||
"vertebral_region_code": null
|
||||
},
|
||||
{
|
||||
"id": "cervical-vertebrae",
|
||||
"kind": "zone",
|
||||
"view_id": "view-main",
|
||||
"category_id": "zone-colonne",
|
||||
"laterality": "unpaired",
|
||||
"geometry": {
|
||||
"type": "polygon",
|
||||
"points": [
|
||||
[
|
||||
468,
|
||||
276
|
||||
],
|
||||
[
|
||||
489,
|
||||
216
|
||||
],
|
||||
[
|
||||
558,
|
||||
248
|
||||
],
|
||||
[
|
||||
586,
|
||||
339
|
||||
],
|
||||
[
|
||||
552,
|
||||
461
|
||||
],
|
||||
[
|
||||
524,
|
||||
370
|
||||
]
|
||||
]
|
||||
},
|
||||
"name": {
|
||||
"fr": "Vertèbres cervicales",
|
||||
"en": "Cervical Vertebrae"
|
||||
},
|
||||
"finding_zone_id": "cervical",
|
||||
"vertebral_region_code": "C"
|
||||
},
|
||||
{
|
||||
"id": "hinge-c7-t1",
|
||||
"kind": "point",
|
||||
"view_id": "view-main",
|
||||
"category_id": "charnieres-vertebrales",
|
||||
"laterality": "unpaired",
|
||||
"geometry": {
|
||||
"type": "circle",
|
||||
"cx": 840.17,
|
||||
"cy": 399.08,
|
||||
"r": 30
|
||||
},
|
||||
"name": {
|
||||
"fr": "Charnière C7-T1 (cervico-thoracique)",
|
||||
"en": "C7-T1 (Cervicothoracic)"
|
||||
},
|
||||
"finding_zone_id": "c7-t1",
|
||||
"vertebral_region_code": null
|
||||
},
|
||||
{
|
||||
"id": "head-trigger",
|
||||
"kind": "detail_trigger",
|
||||
"view_id": "view-main",
|
||||
"category_id": "cadrans-du-crane",
|
||||
"laterality": "unpaired",
|
||||
"geometry": {
|
||||
"type": "polygon",
|
||||
"points": [
|
||||
[
|
||||
454,
|
||||
332
|
||||
],
|
||||
[
|
||||
429,
|
||||
202
|
||||
],
|
||||
[
|
||||
349,
|
||||
154
|
||||
],
|
||||
[
|
||||
234,
|
||||
279
|
||||
],
|
||||
[
|
||||
164,
|
||||
384
|
||||
],
|
||||
[
|
||||
234,
|
||||
468
|
||||
]
|
||||
]
|
||||
},
|
||||
"name": null,
|
||||
"opens_view_id": "view-head"
|
||||
},
|
||||
{
|
||||
"id": "atm",
|
||||
"kind": "point",
|
||||
"view_id": "view-head",
|
||||
"category_id": "articulations",
|
||||
"laterality": "bilateral",
|
||||
"geometry": {
|
||||
"type": "circle",
|
||||
"cx": 384.94,
|
||||
"cy": 314.02,
|
||||
"r": 27
|
||||
},
|
||||
"name": {
|
||||
"fr": "Articulation Temporo-Mandibulaire (ATM)",
|
||||
"en": "Temporomandibular Joint (TMJ)"
|
||||
},
|
||||
"finding_zone_id": "atm",
|
||||
"vertebral_region_code": null
|
||||
},
|
||||
{
|
||||
"id": "sphenoid",
|
||||
"kind": "point",
|
||||
"view_id": "view-head",
|
||||
"category_id": "cadrans-du-crane",
|
||||
"laterality": "unpaired",
|
||||
"geometry": {
|
||||
"type": "circle",
|
||||
"cx": 299,
|
||||
"cy": 298,
|
||||
"r": 27
|
||||
},
|
||||
"name": {
|
||||
"fr": "Sphénoïde",
|
||||
"en": "Sphenoid"
|
||||
},
|
||||
"finding_zone_id": "sphenoid",
|
||||
"vertebral_region_code": null
|
||||
},
|
||||
{
|
||||
"id": "anno-forelimbaa",
|
||||
"kind": "detail_trigger",
|
||||
"view_id": "view-main",
|
||||
"category_id": "cat-access",
|
||||
"laterality": "left",
|
||||
"geometry": {
|
||||
"type": "polygon",
|
||||
"points": [
|
||||
[
|
||||
625,
|
||||
969
|
||||
],
|
||||
[
|
||||
845,
|
||||
969
|
||||
],
|
||||
[
|
||||
845,
|
||||
1629
|
||||
],
|
||||
[
|
||||
625,
|
||||
1629
|
||||
]
|
||||
]
|
||||
},
|
||||
"review_status": "to_confirm",
|
||||
"color": null,
|
||||
"name": null,
|
||||
"opens_view_id": "view-forelimbaa"
|
||||
}
|
||||
],
|
||||
"finding_zones": [
|
||||
{
|
||||
"id": "hip",
|
||||
"name": {
|
||||
"fr": "Hanche (coxo-fémorale)",
|
||||
"en": "Hip joint"
|
||||
},
|
||||
"categories": [
|
||||
{
|
||||
"id": "hip-dysfunctions",
|
||||
"kind": "dysfunction",
|
||||
"name": {
|
||||
"fr": "Dysfonctions ostéopathiques",
|
||||
"en": "Osteopathic dysfunctions"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "articular",
|
||||
"name": {
|
||||
"fr": "Restrictions de mobilité articulaire",
|
||||
"en": "Articular mobility restrictions"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "restriction-flexion",
|
||||
"name": {
|
||||
"fr": "Restriction en flexion",
|
||||
"en": "Flexion restriction"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "restriction-extension",
|
||||
"name": {
|
||||
"fr": "Restriction en extension",
|
||||
"en": "Extension restriction"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "hip-observations",
|
||||
"kind": "consultation_reason",
|
||||
"name": {
|
||||
"fr": "Observations / motifs de consultation",
|
||||
"en": "Observations / consultation reasons"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "limb-lameness",
|
||||
"name": {
|
||||
"fr": "Boiterie rapportée (membre concerné)",
|
||||
"en": "Reported lameness (affected limb)"
|
||||
},
|
||||
"requires_vet_referral": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "anamnesis",
|
||||
"kind": "anamnesis",
|
||||
"name": {
|
||||
"fr": "Anamnèse / facteurs rapportés",
|
||||
"en": "Anamnesis / reported factors"
|
||||
},
|
||||
"description": {
|
||||
"fr": "Facteurs rapportés par le propriétaire lors de l'anamnèse"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "trauma-direct",
|
||||
"name": {
|
||||
"fr": "Traumatisme rapporté (choc, chute)",
|
||||
"en": "Reported trauma (blow, fall)"
|
||||
},
|
||||
"reference_ids": [
|
||||
"legacy-catalog"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "cervical",
|
||||
"name": {
|
||||
"fr": "Vertèbres cervicales",
|
||||
"en": "Cervical Vertebrae"
|
||||
},
|
||||
"categories": [
|
||||
{
|
||||
"id": "cervical-dysfunctions",
|
||||
"kind": "dysfunction",
|
||||
"name": {
|
||||
"fr": "Dysfonctions ostéopathiques",
|
||||
"en": "Osteopathic dysfunctions"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "muscular",
|
||||
"name": {
|
||||
"fr": "Tensions musculaires paravertébrales",
|
||||
"en": "Paravertebral muscle tensions"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "splenius-tension",
|
||||
"name": {
|
||||
"fr": "Tension du splénius",
|
||||
"en": "Splenius tension"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "cervical-observations",
|
||||
"kind": "consultation_reason",
|
||||
"name": {
|
||||
"fr": "Observations / motifs de consultation",
|
||||
"en": "Observations / consultation reasons"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "stumbling-proprioceptive",
|
||||
"name": {
|
||||
"fr": "Trébuchements / déficit proprioceptif rapporté",
|
||||
"en": "Reported stumbling / proprioceptive deficit"
|
||||
},
|
||||
"requires_vet_referral": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "anamnesis",
|
||||
"kind": "anamnesis",
|
||||
"name": {
|
||||
"fr": "Anamnèse / facteurs rapportés",
|
||||
"en": "Anamnesis / reported factors"
|
||||
},
|
||||
"description": {
|
||||
"fr": "Facteurs rapportés par le propriétaire lors de l'anamnèse"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "trauma-direct",
|
||||
"name": {
|
||||
"fr": "Traumatisme rapporté (choc, chute)",
|
||||
"en": "Reported trauma (blow, fall)"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "c7-t1",
|
||||
"name": {
|
||||
"fr": "Charnière C7-T1 (cervico-thoracique)",
|
||||
"en": "C7-T1 (Cervicothoracic)"
|
||||
},
|
||||
"categories": [
|
||||
{
|
||||
"id": "c7-t1-dysfunctions",
|
||||
"kind": "dysfunction",
|
||||
"name": {
|
||||
"fr": "Dysfonctions ostéopathiques",
|
||||
"en": "Osteopathic dysfunctions"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "restriction-rotation",
|
||||
"name": {
|
||||
"fr": "Restriction en rotation",
|
||||
"en": "Rotation restriction"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "c7-t1-observations",
|
||||
"kind": "consultation_reason",
|
||||
"name": {
|
||||
"fr": "Observations / motifs de consultation",
|
||||
"en": "Observations / consultation reasons"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "base-neck-stiffness",
|
||||
"name": {
|
||||
"fr": "Raideur de la base de l'encolure",
|
||||
"en": "Base-of-neck stiffness"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "anamnesis",
|
||||
"kind": "anamnesis",
|
||||
"name": {
|
||||
"fr": "Anamnèse / facteurs rapportés",
|
||||
"en": "Anamnesis / reported factors"
|
||||
},
|
||||
"description": {
|
||||
"fr": "Facteurs rapportés par le propriétaire lors de l'anamnèse"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "stress-context",
|
||||
"name": {
|
||||
"fr": "Contexte de stress / changement",
|
||||
"en": "Stress / change context"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "atm",
|
||||
"name": {
|
||||
"fr": "Articulation Temporo-Mandibulaire (ATM)",
|
||||
"en": "Temporomandibular Joint (TMJ)"
|
||||
},
|
||||
"categories": [
|
||||
{
|
||||
"id": "atm-dysfunctions",
|
||||
"kind": "dysfunction",
|
||||
"name": {
|
||||
"fr": "Dysfonctions ostéopathiques de l'ATM",
|
||||
"en": "Osteopathic TMJ dysfunctions"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "masseter-tension",
|
||||
"name": {
|
||||
"fr": "Tension du masséter",
|
||||
"en": "Masseter tension"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "atm-observations",
|
||||
"kind": "consultation_reason",
|
||||
"name": {
|
||||
"fr": "Observations / motifs de consultation",
|
||||
"en": "Observations / consultation reasons"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "bit-defense",
|
||||
"name": {
|
||||
"fr": "Réactions de défense au mors",
|
||||
"en": "Defense reactions to bit"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "anamnesis",
|
||||
"kind": "anamnesis",
|
||||
"name": {
|
||||
"fr": "Anamnèse / facteurs rapportés",
|
||||
"en": "Anamnesis / reported factors"
|
||||
},
|
||||
"description": {
|
||||
"fr": "Facteurs rapportés par le propriétaire lors de l'anamnèse"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "dental-context",
|
||||
"name": {
|
||||
"fr": "Suite de soin dentaire récent",
|
||||
"en": "Post recent dental care"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "sphenoid",
|
||||
"name": {
|
||||
"fr": "Sphénoïde",
|
||||
"en": "Sphenoid"
|
||||
},
|
||||
"categories": [
|
||||
{
|
||||
"id": "ssb-dysfunctions",
|
||||
"kind": "dysfunction",
|
||||
"name": {
|
||||
"fr": "Dysfonctions ostéopathiques",
|
||||
"en": "Osteopathic dysfunctions"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "physiological",
|
||||
"name": {
|
||||
"fr": "Lésions physiologiques (SSB)",
|
||||
"en": "Physiological lesions (SBS)"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "torsion-right",
|
||||
"name": {
|
||||
"fr": "Torsion droite",
|
||||
"en": "Right torsion"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "torsion-left",
|
||||
"name": {
|
||||
"fr": "Torsion gauche",
|
||||
"en": "Left torsion"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "sphenoid-observations",
|
||||
"kind": "consultation_reason",
|
||||
"name": {
|
||||
"fr": "Observations / motifs de consultation",
|
||||
"en": "Observations / consultation reasons"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "post-trauma-head",
|
||||
"name": {
|
||||
"fr": "Suite de traumatisme crânien",
|
||||
"en": "Post head trauma"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "anamnesis",
|
||||
"kind": "anamnesis",
|
||||
"name": {
|
||||
"fr": "Anamnèse / facteurs rapportés",
|
||||
"en": "Anamnesis / reported factors"
|
||||
},
|
||||
"description": {
|
||||
"fr": "Facteurs rapportés par le propriétaire lors de l'anamnèse"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "trauma-direct",
|
||||
"name": {
|
||||
"fr": "Traumatisme rapporté (choc, chute)",
|
||||
"en": "Reported trauma (blow, fall)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "stress-context",
|
||||
"name": {
|
||||
"fr": "Contexte de stress / changement",
|
||||
"en": "Stress / change context"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
//! N-1 characterisation of the internal access category (owner 2026-11-22, board
|
||||
//! `docs/design/v1-2-6-u2-detail-views/README.md`, « Conséquences » 1). Written and green on the
|
||||
//! core BEFORE the change: what that core does with a sheet carrying `cat-access` is what every
|
||||
//! N-1 application does. `permanent` stays green for ever. `baseline_edits` records the N-1
|
||||
//! edits; at Task 2 they flip to refusals, and Task 5 replays this file at the baseline commit
|
||||
//! on the current fixture (read by path: the replay copies that one file).
|
||||
#![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)]
|
||||
|
||||
mod common;
|
||||
|
||||
use faunosteo_core::domain::js::parse_json;
|
||||
use faunosteo_core::domain::sheet::edit::{EditCommand, EditError, apply_edit};
|
||||
use faunosteo_core::domain::sheet::{
|
||||
AnatomicalSheetDocument, is_publishable, validate_sheet_document,
|
||||
};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
const FIXTURE: &str = "crates/core/tests/fixtures/n1/access-category.json";
|
||||
const SLICE: &str = "crates/core/tests/fixtures/horse-slice.json";
|
||||
|
||||
fn value_of(path: &str) -> Value {
|
||||
parse_json(&common::repo_file(path)).unwrap()
|
||||
}
|
||||
|
||||
fn fixture() -> AnatomicalSheetDocument {
|
||||
serde_json::from_value(value_of(FIXTURE)).unwrap()
|
||||
}
|
||||
|
||||
fn slice() -> AnatomicalSheetDocument {
|
||||
serde_json::from_value(value_of(SLICE)["input"].clone()).unwrap()
|
||||
}
|
||||
|
||||
fn command(value: Value) -> EditCommand {
|
||||
serde_json::from_value(value).unwrap()
|
||||
}
|
||||
|
||||
fn insert(kind: &str, value: Value) -> EditCommand {
|
||||
command(json!({ "op": "insert", "element": { "kind": kind, "value": value } }))
|
||||
}
|
||||
|
||||
fn apply_all(
|
||||
doc: &AnatomicalSheetDocument,
|
||||
commands: Vec<EditCommand>,
|
||||
) -> Result<AnatomicalSheetDocument, EditError> {
|
||||
commands
|
||||
.into_iter()
|
||||
.try_fold(doc.clone(), |next, c| apply_edit(&next, c))
|
||||
}
|
||||
|
||||
fn issues(doc: &AnatomicalSheetDocument) -> Vec<(String, String)> {
|
||||
let mut list: Vec<(String, String)> = validate_sheet_document(doc)
|
||||
.into_iter()
|
||||
.map(|issue| (issue.code, issue.path))
|
||||
.collect();
|
||||
list.sort();
|
||||
list
|
||||
}
|
||||
|
||||
fn access_category() -> Value {
|
||||
json!({ "id": "cat-access",
|
||||
"name": { "fr": "Accès aux vues détaillées", "en": "Detail view access" }, "color": null })
|
||||
}
|
||||
|
||||
fn forelimb_view() -> Value {
|
||||
json!({ "id": "view-forelimbaa", "kind": "detail",
|
||||
"name": { "fr": "Membre antérieur", "en": "Forelimb" }, "parent_view_id": "view-main",
|
||||
"svg_asset_id": null,
|
||||
"view_box": { "min_x": 625, "min_y": 969, "width": 220, "height": 660 } })
|
||||
}
|
||||
|
||||
fn forelimb_access() -> Value {
|
||||
json!({ "id": "anno-forelimbaa", "kind": "detail_trigger", "view_id": "view-main",
|
||||
"category_id": "cat-access", "laterality": "left",
|
||||
"geometry": { "type": "polygon",
|
||||
"points": [[625, 969], [845, 969], [845, 1629], [625, 1629]] },
|
||||
"review_status": "to_confirm", "color": null, "name": null,
|
||||
"opens_view_id": "view-forelimbaa" })
|
||||
}
|
||||
|
||||
fn a_point_in_the_access_category() -> Value {
|
||||
json!({ "id": "anno-n1pointaa", "kind": "point", "view_id": "view-main",
|
||||
"category_id": "cat-access", "laterality": "unpaired",
|
||||
"geometry": { "type": "circle", "cx": 700, "cy": 1000, "r": 14 },
|
||||
"review_status": "to_confirm", "color": null, "name": { "fr": "P", "en": "P" },
|
||||
"finding_zone_id": null, "vertebral_region_code": null })
|
||||
}
|
||||
|
||||
mod permanent {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_fixture_reads_strictly_and_rewrites_to_itself() {
|
||||
let written = serde_json::to_value(fixture()).unwrap();
|
||||
let reread: AnatomicalSheetDocument = serde_json::from_value(written.clone()).unwrap();
|
||||
assert_eq!(serde_json::to_value(reread).unwrap(), written);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_fixture_raises_no_issue_the_slice_does_not() {
|
||||
assert_eq!(issues(&fixture()), issues(&slice()));
|
||||
}
|
||||
|
||||
/// Owner R1: a detail view without its access saves, but keeps the error that blocks
|
||||
/// submission and publication.
|
||||
#[test]
|
||||
fn a_view_without_its_access_saves_and_blocks_submission() {
|
||||
let doc = apply_all(&slice(), vec![insert("view", forelimb_view())]).unwrap();
|
||||
let unreachable = validate_sheet_document(&doc)
|
||||
.into_iter()
|
||||
.find(|issue| issue.code == "view.unreachable")
|
||||
.expect("view.unreachable");
|
||||
assert_eq!(unreachable.path, "views[2]");
|
||||
assert!(!is_publishable(&validate_sheet_document(&doc)));
|
||||
}
|
||||
}
|
||||
|
||||
mod baseline_edits {
|
||||
use super::*;
|
||||
|
||||
/// At the N-1 baseline, the page could write the category itself: the fixture is the slice
|
||||
/// plus three plain inserts.
|
||||
#[test]
|
||||
fn the_fixture_is_the_slice_plus_three_inserts() {
|
||||
let built = apply_all(
|
||||
&slice(),
|
||||
vec![
|
||||
insert("category", access_category()),
|
||||
insert("view", forelimb_view()),
|
||||
insert("annotation", forelimb_access()),
|
||||
],
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
serde_json::to_value(&built).unwrap(),
|
||||
serde_json::to_value(fixture()).unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_n1_application_renames_and_recolours_it() {
|
||||
let renamed = json!({ "id": "cat-access", "name": { "fr": "Navigation", "en": "Navigation" },
|
||||
"color": "#123456" });
|
||||
let done = apply_edit(
|
||||
&fixture(),
|
||||
command(json!({ "op": "update",
|
||||
"key": { "kind": "category", "id": "cat-access" },
|
||||
"element": { "kind": "category", "value": renamed } })),
|
||||
);
|
||||
let doc = done.unwrap();
|
||||
let reread: AnatomicalSheetDocument =
|
||||
serde_json::from_value(serde_json::to_value(&doc).unwrap()).unwrap();
|
||||
assert_eq!(issues(&reread), issues(&slice()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_n1_application_puts_a_point_in_it() {
|
||||
let doc = apply_edit(
|
||||
&fixture(),
|
||||
insert("annotation", a_point_in_the_access_category()),
|
||||
);
|
||||
assert!(doc.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_n1_application_cannot_remove_it_while_an_access_uses_it() {
|
||||
let done = apply_edit(
|
||||
&fixture(),
|
||||
command(json!({ "op": "remove",
|
||||
"key": { "kind": "category", "id": "cat-access" } })),
|
||||
);
|
||||
assert_eq!(done.unwrap_err(), EditError::HasDependents);
|
||||
}
|
||||
|
||||
/// Uniqueness at N-1 too: a second category of that id is a duplicate key.
|
||||
#[test]
|
||||
fn an_n1_application_cannot_insert_a_second_one() {
|
||||
let done = apply_edit(&fixture(), insert("category", access_category()));
|
||||
assert_eq!(done.unwrap_err(), EditError::DuplicateKey);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_n1_application_removes_it_once_empty() {
|
||||
let done = apply_all(
|
||||
&fixture(),
|
||||
vec![
|
||||
command(
|
||||
json!({ "op": "remove", "key": { "kind": "annotation", "id": "anno-forelimbaa" } }),
|
||||
),
|
||||
command(
|
||||
json!({ "op": "remove", "key": { "kind": "category", "id": "cat-access" } }),
|
||||
),
|
||||
],
|
||||
);
|
||||
assert!(done.is_ok());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user