Skip to content

Commit 0ab5bbf

Browse files
zberryclaude
andcommitted
The column-insertion test also checks the journal entry and that each insertion is one undo step
The test went through Session::execute but only read the table afterwards; it now checks the last journal entry is the call as made and that three undos bring back the three 280 pt columns, their text and the frame width. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent d405745 commit 0ab5bbf

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎crates/engine/src/tests.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4113,6 +4113,23 @@ fn table_insert_column_keeps_the_table_width_and_copies_the_neighbour_format() {
41134113
let t = table_of(&s, id);
41144114
assert_eq!(t.n_cols(), 6);
41154115
assert!((t.width() - 840.0 - 168.0).abs() < 1e-6, "width {}", t.width());
4116+
// The insertion is journaled as called, and each one is a single undo step back to the table
4117+
// as it was: the columns, their widths and the frame.
4118+
let (jid, jp) = s.journal.last().cloned().unwrap();
4119+
assert_eq!(jid, "table.insertColumnRight");
4120+
assert_eq!(jp["keepWidth"], json!(false), "{jp}");
4121+
s.execute("edit.undo", &json!({})).unwrap();
4122+
let t = table_of(&s, id);
4123+
assert_eq!(t.n_cols(), 5);
4124+
assert!((t.width() - 840.0).abs() < 1e-6, "width {}", t.width());
4125+
s.execute("edit.undo", &json!({})).unwrap();
4126+
s.execute("edit.undo", &json!({})).unwrap();
4127+
let t = table_of(&s, id);
4128+
assert_eq!(t.n_cols(), 3);
4129+
assert!(t.cols.iter().all(|w| (w - 280.0).abs() < 1e-6), "{:?}", t.cols);
4130+
assert_eq!(t.cell(0, 2).unwrap().text.text(), "c");
4131+
let x = s.doc().unwrap().shape(id).unwrap().xfrm.unwrap();
4132+
assert!((x.w - 840.0).abs() < 1e-6, "frame {}", x.w);
41164133
}
41174134

41184135
/// A `keepWidth` that is not a bool is refused, naming it, and the table is left alone; it used

0 commit comments

Comments
 (0)