test(import): pin where an absent coordinate draws and how a saved file view projects (improvise-8jk6.2, improvise-lpzu)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze
This commit is contained in:
Claude (agent-lpzu)
2026-09-24 20:51:40 -07:00
committed by Edward Langley
parent bb505f8faf
commit 736e9e5e18
2 changed files with 112 additions and 0 deletions
+55
View File
@@ -2208,6 +2208,61 @@ mod tests {
.collect()
}
/// improvise-8jk6.2: where a record with no `Date` shows up, axis by axis.
/// Evidence: `context/test-evidence/formula-and-io.md`.
#[test]
fn a_record_with_no_coordinate_is_drawn_only_where_that_category_is_off_the_grid() {
use crate::model::cell::CellKey;
use crate::persistence::{format_md, parse_md};
use crate::view::{GridLayout, drill_snapshot};
let mut p = ImportPipeline::new(json!([
{"Payee": "Acme", "Date": "d1", "Amount": 10.0},
{"Payee": "Bolt", "Amount": 20.0},
]));
force_category(&mut p, "Date");
let (mut wb, _) = p.build_model_with_warnings().unwrap();
let mut seat = |date: Axis, payee: Axis| {
let view = wb.active_view_mut();
view.set_axis("_Measure", Axis::None);
view.set_axis("Payee", payee);
view.set_axis("Date", date);
(drawn(&wb, "Default"), wb.clone())
};
assert_eq!(
seat(Axis::Column, Axis::Row).0,
[10.0],
"no column holds Bolt"
);
assert_eq!(seat(Axis::Page, Axis::Row).0, [10.0], "no page holds Bolt");
assert_eq!(
seat(Axis::None, Axis::Row).0,
[10.0, 20.0],
"None counts it"
);
let (_, mut records) = seat(Axis::None, Axis::None);
records.active_view_mut().set_axis("_Index", Axis::Row);
records.active_view_mut().set_axis("_Dim", Axis::Column);
let layout = GridLayout::with_frozen_records(&records.model, records.active_view(), None);
let row: Vec<String> = (0..layout.col_count())
.map(|c| layout.records_display(1, c).unwrap_or_default())
.collect();
assert_eq!(row, ["", "Bolt", "", "20", ""], "a blank Date cell");
let text = format_md(&records);
assert!(
text.contains("\nPayee=Bolt, _Measure=Amount = 20\n"),
"{text}"
);
assert_eq!(format_md(&parse_md(&text).unwrap()), text);
let drill = |cat: &str, item: &str| {
let key = CellKey::new(vec![(cat.to_string(), item.to_string())]);
drill_snapshot(&records.model, &key).len()
};
assert_eq!((drill("Payee", "Bolt"), drill("Date", "d1")), (1, 1));
}
/// improvise-lpzu: each merged file gets a view of its own records and
/// columns. Evidence: `context/test-evidence/formula-and-io.md`.
#[test]