Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

AF.3: the read-only Save test follows the asynchronous file dialog

callmeBalloch92207eb7c254
diff --git a/crates/ui-egui/src/file_open/tests.rs b/crates/ui-egui/src/file_open/tests.rs
index 7856f0545..c43f1e20a 100644
--- a/crates/ui-egui/src/file_open/tests.rs
+++ b/crates/ui-egui/src/file_open/tests.rs
@@ -84,7 +84,7 @@ fn open_file_sets_name_path_and_recent() {
fn affinity_preview_does_not_acquire_the_source_path_even_when_renamed() {
for automation in [false, true] {
for path in ["/pics/source.af", "/pics/renamed.psd"] {
- let (mut app, written) = app_with(Vec::new());
+ let (mut app, written) = app_with(vec![None]);
// The fake importer supplies the preview; its source signature controls path policy.
if automation {
app.open_automation_bytes(&display_name(path), b"\x00\xffKA").unwrap();
@@ -95,7 +95,9 @@ fn affinity_preview_does_not_acquire_the_source_path_even_when_renamed() {
assert!(app.session.active().unwrap().source_read_only);
assert!(app.session.active().unwrap().path.is_none());
assert_eq!(app.ui.recent_files.first().map(String::as_str), Some(path));
- assert_eq!(menus::invoke(&mut app, &egui::Context::default(), "file.save", json!({})).unwrap_err(), "cancelled");
+ // Save asks for a new file (cancelled here) instead of writing over the source.
+ assert_eq!(menus::invoke(&mut app, &egui::Context::default(), "file.save", json!({})).unwrap(), json!({"fileDialog": "save"}));
+ answer(&mut app);
assert!(written.borrow().is_empty());
}
}