From 73b0edd0859eb8e91c565d23ad8ef6fabe309e5c Mon Sep 17 00:00:00 2001 From: prxnvt <53838599+prxnvt@users.noreply.github.com> Date: Sat, 24 Oct 2026 02:13:39 -0400 Subject: [PATCH] UI: the Macros dialog offers Trust Scripts for scripts from a file The Macros dialog that replaces the scripts-only list keeps its Trust Scripts row (#2178): scripts that came with an opened file are listed as disabled until the row's button trusts them for the session, and Run works after it. A test covers the row, the trust and the run, and the macro page describes it. --- crates/ui-egui/tests/it/macros_ui.rs | 34 ++++++++++++++++++++++++++++ docs/macros.md | 2 ++ 2 files changed, 36 insertions(+) diff --git a/crates/ui-egui/tests/it/macros_ui.rs b/crates/ui-egui/tests/it/macros_ui.rs index 03417dd1c..d7635d572 100644 --- a/crates/ui-egui/tests/it/macros_ui.rs +++ b/crates/ui-egui/tests/it/macros_ui.rs @@ -249,3 +249,37 @@ fn view_macros_record_macro_toggles_recording() { assert!(h.state().dialog.is_none()); assert!(!h.state().session.is_recording()); } + +#[test] +fn the_macros_dialog_offers_trust_for_scripts_that_came_with_a_file() { + let mut s = Session::new(); + s.new_workbook(); + s.execute("automate.newScript", json!({"name": "Mark", "commands": [{"command": "cell.set", "params": {"cell": "D4", "input": "script"}}]})) + .unwrap(); + // As when the workbook was opened with its scripts (#2178). + s.active_mut().unwrap().scripts_trusted = false; + let mut app = SheetApp::new(s, Default::default()); + app.ui.ribbon_tab = "Automate".into(); + let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1280.0, 800.0)).build_ui_state( + |ui, app: &mut SheetApp| { + let ctx = ui.ctx().clone(); + app.logic(&ctx); + app.ui(ui); + }, + app, + ); + h.run_steps(3); + h.state_mut().open_dialog("macros", json!({})); + h.run_steps(2); + assert!(h.query_by_label_contains("came from a file and are disabled").is_some()); + h.get_by_label("Trust Scripts").click(); + // The dialog shrinks without the row: let it settle before the next click. + h.run_steps(4); + assert!(h.state().session.doc().unwrap().scripts_trusted); + assert!(h.query_by_label("Trust Scripts").is_none(), "the row goes once the scripts are trusted"); + h.get_by_label("Mark (script, 1 step)").click(); + h.run_steps(2); + h.get_by_label("Run").click(); + h.run_steps(3); + assert_eq!(value(&h, "D4"), Value::Text("script".into())); +} diff --git a/docs/macros.md b/docs/macros.md index d6f9abc66..e0cbb4b97 100644 --- a/docs/macros.md +++ b/docs/macros.md @@ -276,6 +276,8 @@ other macros open; a macro that was left out is not in the saved file. Macro opens the step editor on a new macro. - **Macros dialog** (Automate › Macros, View › Macros, Alt+F8). It lists the workbook's macros (with their shortcuts), then its Automate scripts, and says when the file carries a VBA project. + Scripts that came with an opened file stay disabled until Trust Scripts (`automate.trustScripts`) + trusts them for the session. Run runs the selected macro on the selection or the selected script; Step Into, Edit and Create open the step editor; Delete asks first; Options sets a macro's shortcut letter and description. The dialog keeps the result of `view.macros`, as before macros existed.