From 5cc9032ae44affdd24549da9262e2fa5c775a2e5 Mon Sep 17 00:00:00 2001 From: Simon Klee Date: Wed, 18 Nov 2026 21:08:26 +0100 Subject: [PATCH] test(cli-rs): check plugin row actions in the actual manager The private toggle-row examples duplicate the observable manager: a_failed_built_in_shows_and_a_plugin_is_found_by_its_target checks the failed active row, plugin_manager_toggles_checks_and_updates exercises enabling and disabling, a_configured_typescript_plugin_is_listed_as_skipped_with_its_reason opens the skipped row's error, and the_manager_asks_before_a_project_plugin_runs opens the pending row's approval question. Move the version abbreviation assertion to the_server_rows_follow_typescript on both carriers. locale_compare_matches_bun already checks the exact three sort inputs. Keep the independent slow-report cases. --- .../cli-rs/crates/tui/src/plugins/manager.rs | 37 ------------------- .../crates/tui/tests/all/plugin_manager.rs | 10 ++++- 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/packages/cli-rs/crates/tui/src/plugins/manager.rs b/packages/cli-rs/crates/tui/src/plugins/manager.rs index 82cfece80ee..2cb13e51623 100644 --- a/packages/cli-rs/crates/tui/src/plugins/manager.rs +++ b/packages/cli-rs/crates/tui/src/plugins/manager.rs @@ -536,43 +536,6 @@ fn display_version(version: &str) -> String { mod tests { use super::*; - #[test] - fn versions_and_labels_order_as_in_typescript() { - assert_eq!(display_version(&"a".repeat(40)), "aaaaaaa"); - assert_eq!(display_version("1.2.3"), "1.2.3"); - let mut labels = vec!["beta", "Alpha", "alpha"]; - labels.sort_by(|a, b| locale_compare(a, b)); - assert_eq!(labels, ["alpha", "Alpha", "beta"]); - } - - // Expected (TS `focusedTui`): a plugin with a definition is a toggle row, a failed active one included, and so is a - // project's build waiting for approval; a configured target that never loaded is not, and opens its reason. - #[test] - fn a_row_toggles_what_has_a_definition_or_waits_for_approval() { - let row = |origin: PluginOrigin, status: PluginStatus| { - Row::Tui(PluginEntry { - key: "k".to_owned(), - id: "sample".to_owned(), - target: Some("/plugins/sample".to_owned()), - origin, - status, - active: status == PluginStatus::Active, - slow: None, - }) - }; - let failed = row(PluginOrigin::External, PluginStatus::Failed); - assert_eq!((failed.toggle().as_deref(), failed.has_error()), (Some("k"), true)); - assert_eq!(failed.footer().as_deref(), Some("failed, local")); - assert_eq!(row(PluginOrigin::Builtin, PluginStatus::Inactive).toggle().as_deref(), Some("k")); - let skipped = row(PluginOrigin::Configured, PluginStatus::Skipped); - assert_eq!((skipped.toggle(), skipped.label().as_str(), skipped.has_error()), (None, "sample", true)); - let pending = row(PluginOrigin::Configured, PluginStatus::Pending); - assert_eq!((pending.toggle().as_deref(), pending.label().as_str()), (Some("k"), "sample")); - assert!(!pending.has_error()); - } - - // Expected (PL-5): a slow plugin's footer names the kind of call that cost the most, by its worst time, and its - // details hold the whole report; a backlog says so, and a healthy row has no details. #[test] fn a_slow_row_says_what_costs_and_shows_the_report() { let report = "slow (p50/p99/worst): view 0.0/0.0/0.1 ms, run-command 0.0/0.0/0.0 ms, draw 1.9/2.0/2.4 ms, \ diff --git a/packages/cli-rs/crates/tui/tests/all/plugin_manager.rs b/packages/cli-rs/crates/tui/tests/all/plugin_manager.rs index 43621f172bd..b51edd955ff 100644 --- a/packages/cli-rs/crates/tui/tests/all/plugin_manager.rs +++ b/packages/cli-rs/crates/tui/tests/all/plugin_manager.rs @@ -1054,11 +1054,16 @@ fn the_server_rows_follow_typescript() { } fn the_server_rows_follow_typescript_on() { - let failed = serde_json::json!({ "state": { "status": "failed", "error": "boom" } }); + let hash = "0123456789abcdef".repeat(4); + let failed = serde_json::json!({ + "source": { "type": "package", "target": "pkg", "version": hash, "outdated": true }, + "state": { "status": "failed", "error": "boom" }, + }); let opened: Gate = Arc::new((std::sync::Mutex::new(true), std::sync::Condvar::new())); let (harness, _) = open_on(package_server(failed, 500, opened.clone())); harness.dispatch("plugins.list"); let shown = harness.wait_for("update ctrl+u"); + assert!(shown.contains("0123456") && !shown.contains("01234567"), "{shown}"); let footer = shown.lines().find(|line| line.contains("update ctrl+u")).unwrap(); assert!(footer.find("update ctrl+u") < footer.find("view error enter"), "{footer}"); let updating = serde_json::json!({ @@ -1076,7 +1081,8 @@ fn the_server_rows_follow_typescript_on() { open_on(package_server(serde_json::json!({ "state": { "status": "active" } }), 500, gate.clone())); harness.dispatch("plugins.list"); harness.wait_for("check for updates"); - harness.wait_for("update available"); + let shown = harness.wait_for("update available"); + assert!(shown.contains("1.0.0"), "{shown}"); let checks = || log.lock().unwrap().iter().filter(|seen| seen.path == "/api/plugin/check").count(); harness.app.press("ctrl+r"); harness.wait_for("checking for updates");