Document Actions integration controls

This commit is contained in:
yoriswind committed 2026-11-01 15:26:19 -08:00
1 parent dcf68b5b86
commit ca11c144d9
6 files changed
+18

No files matched your search

@@ -2,6 +2,7 @@
use photocraft_engine::{Session, actions_cmds::Action};
use serde_json::json;
/// Clearing requires consent and idle playback/recording, and preserves document history.
#[test]
fn confirmed_clear_is_atomic_for_definitions_shortcuts_and_recording() {
let mut s = Session::new();
@@ -9,6 +9,7 @@ fn session() -> Session {
s
}
/// Copies retain metadata and call targets without taking the original function key.
#[test]
fn action_copies_follow_the_source_without_retargeting_calls_or_function_keys() {
let mut s = session();
@@ -62,6 +63,7 @@ fn action_copies_follow_the_source_without_retargeting_calls_or_function_keys()
assert_eq!(s.actions.list[1].steps[0].1["action"], 3);
}
/// Step copies own their settings and retain both flag columns after insertion.
#[test]
fn step_copies_preserve_payloads_and_shift_both_flag_columns() {
let mut s = session();
@@ -87,6 +89,7 @@ fn step_copies_preserve_payloads_and_shift_both_flag_columns() {
assert_eq!(s.active().unwrap().revision, revision);
}
/// Refusals preserve pending recording; valid step copies keep recording usable.
#[test]
fn invalid_copies_do_not_flush_recording_and_valid_step_copies_keep_recording() {
let mut s = session();
+3
View File
@@ -6,6 +6,7 @@ use photocraft_psd::{
};
use serde_json::json;
/// Build a single-step ATN input independently of the engine's exporter.
fn file(item: AtnItem) -> Vec<u8> {
atn::write(&AtnFile {
name: UnicodeString::new_nul("Menu"),
@@ -16,6 +17,7 @@ fn file(item: AtnItem) -> Vec<u8> {
.unwrap()
}
/// Absent settings retain menu intent and event kind, and refuse headless edits.
#[test]
fn absent_image_size_settings_round_trip_and_require_interaction_without_edits() {
for (event, kind) in [(AtnEvent::Code(*b"ImgS"), "code"), (AtnEvent::name("imageSize"), "name")] {
@@ -44,6 +46,7 @@ fn absent_image_size_settings_round_trip_and_require_interaction_without_edits()
}
}
/// Empty and target descriptors, other events and recorded settings keep their meaning.
#[test]
fn empty_target_and_other_event_forms_keep_their_existing_meaning() {
let empty = Descriptor::new("null");
@@ -39,6 +39,7 @@ fn open(h: &mut Harness<'static, PhotocraftApp>) -> u64 {
h.state().ui.dialogs.last().unwrap().id
}
/// Cancel preserves the library and selection; OK clears only the intended state.
#[test]
fn cancel_preserves_the_library_and_ok_clears_it_and_panel_selection() {
let mut h = harness();
@@ -67,10 +68,12 @@ fn cancel_preserves_the_library_and_ok_clears_it_and_panel_selection() {
assert_eq!(h.state().session.active().unwrap().revision, revision);
}
/// Deny the concrete destructive command at either authorization boundary.
fn deny_clear(id: &str, _: &Value) -> photocraft_engine::Result<()> {
if id == "actions.clearAll" { Err(EngineError::Other("clear denied".into())) } else { Ok(()) }
}
/// Stale state, denied authority and a changed command cannot redirect confirmation.
#[test]
fn stale_denied_or_retargeted_confirmations_never_clear_the_library() {
for mode in ["stale", "denied", "retargeted"] {
@@ -4,6 +4,7 @@ use photocraft_engine::{Session, actions_cmds::Action, atn_cmds};
use photocraft_ui_egui::{PhotocraftApp, actions, dialogs};
use serde_json::json;
/// Real panel clicks select each new action or step and preserve its flag columns.
#[test]
fn duplicate_menu_selects_the_new_action_and_then_the_new_step() {
let mut app = PhotocraftApp::new(Session::new(), Default::default());
@@ -34,6 +35,7 @@ fn duplicate_menu_selects_the_new_action_and_then_the_new_step() {
assert_eq!(copied.dialogs.iter().copied().collect::<Vec<_>>(), [0, 1]);
}
/// Duplication cannot shift a recording owner held by a paused action dialog.
#[test]
fn duplicate_cannot_shift_the_owner_of_a_suspended_recording() {
let mut app = PhotocraftApp::new(Session::new(), Default::default());
+6
View File
@@ -4,6 +4,7 @@ use photocraft_engine::{EngineError, Session, actions_cmds::Action, atn_cmds};
use photocraft_ui_egui::{PhotocraftApp, dialogs};
use serde_json::{Value, json};
/// Import a menu step and append a selection step to expose continuation ordering.
fn app() -> PhotocraftApp {
let mut app = PhotocraftApp::new(Session::new(), Default::default());
app.run("file.new", json!({"width": 8, "height": 6})).unwrap();
@@ -14,6 +15,7 @@ fn app() -> PhotocraftApp {
app
}
/// The real sizing dialog cancels without edits and resumes only after confirmation.
#[test]
fn image_size_menu_item_opens_real_dialog_cancel_stops_and_confirm_resumes() {
let mut h = Harness::builder().with_size(egui::vec2(1000.0, 760.0)).build_ui_state(|ui, app: &mut PhotocraftApp| dialogs::show(app, ui.ctx()), app());
@@ -50,10 +52,12 @@ fn image_size_menu_item_opens_real_dialog_cancel_stops_and_confirm_resumes() {
assert_eq!(h.state().session.actions.list[0].steps, definition, "menu playback does not record the entered settings into the definition");
}
/// Permit the wrapper while denying the concrete resize command it would open.
fn deny_resize(id: &str, _: &Value) -> photocraft_engine::Result<()> {
if id == "image.imageSize" { Err(EngineError::Other("resize denied".into())) } else { Ok(()) }
}
/// Authorization of the actual menu command precedes any dialog or mutation.
#[test]
fn menu_item_gates_its_actual_command_before_opening_a_dialog() {
let mut app = app();
@@ -68,10 +72,12 @@ fn menu_item_gates_its_actual_command_before_opening_a_dialog() {
assert!(app.session.active().unwrap().doc.selection.is_none());
}
/// Allow opening without settings, but deny the settings entered at confirmation.
fn deny_changed_width(id: &str, p: &Value) -> photocraft_engine::Result<()> {
if id == "image.imageSize" && p.get("width").is_some() { Err(EngineError::Other("entered resize denied".into())) } else { Ok(()) }
}
/// Final dialog settings remain subject to the gate that began playback.
#[test]
fn menu_item_confirmation_keeps_the_playback_gate_after_the_request_ends() {
let mut app = app();