From 2d2dff101c56cfcdc48f13506ab8e0c118cd8afd Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 31 Oct 2026 11:23:07 -0700 Subject: [PATCH] test(kde): pin the JSON of Container Before the container moves into a shared crate: a test that fixes the serialised form of komorebi-for-kde's Container, field by field (id, locked, windows with elements and focused), for an empty container and for one with two windows, so the move cannot change what `komorebic state` prints. Verified: KDE cargo test -p komorebi --lib container (native, lite env): 50 passed, 0 failed. Not run: the rest. --- komorebi-for-kde/komorebi/src/container.rs | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/komorebi-for-kde/komorebi/src/container.rs b/komorebi-for-kde/komorebi/src/container.rs index a26dca35..143ab3c9 100644 --- a/komorebi-for-kde/komorebi/src/container.rs +++ b/komorebi-for-kde/komorebi/src/container.rs @@ -287,6 +287,29 @@ mod tests { assert_eq!(container.idx_for_window(4), None); } + #[test] + fn the_json_of_a_container_is_its_id_whether_it_is_locked_and_the_ring_of_windows() { + let mut container = Container { + id: "c1".to_string(), + locked: true, + windows: Default::default(), + }; + + assert_eq!( + serde_json::to_string(&container).unwrap(), + r#"{"id":"c1","locked":true,"windows":{"elements":[],"focused":0}}"# + ); + + container.add_window(Window::from(5)); + container.add_window(Window::from(9)); + container.focus_window(0); + + let json = serde_json::to_string(&container).unwrap(); + assert!(json.starts_with(r#"{"id":"c1","locked":true,"windows":{"elements":[{"id":5,"#)); + assert!(json.contains(r#"},{"id":9,"#)); + assert!(json.ends_with(r#"}],"focused":0}}"#)); + } + #[test] fn serializes_and_deserializes() { let mut container = Container::default();