Compare commits

...
2 changed files with 41 additions and 0 deletions
@@ -0,0 +1,16 @@
name: Unsaved workbook prompt validation
on:
push:
branches: [fredapps/5079-unsaved-dialog-validation]
permissions:
contents: read
jobs:
unsaved-prompt:
uses: storytold/craft-common-actions/.github/workflows/gate.yml@main
with:
os: '["ubuntu-24.04"]'
craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83
packages: >-
pkg-config libxkbcommon-dev libwayland-dev libx11-dev libxcursor-dev libxrandr-dev libxi-dev
libgtk-3-dev libfontconfig1-dev libfreetype-dev mesa-vulkan-drivers
command: cargo test --locked -p gridcraft-ui-egui --test doc_windows
+25
View File
@@ -449,6 +449,31 @@ fn replacing_an_unsaved_question_keeps_the_new_answer() {
assert!(desk.app.session.documents().is_empty(), "the new answer closes the workbook");
}
#[test]
fn an_unsaved_question_remains_answerable_after_switching_windows() {
let mut desk = Desk::new(false);
let original = desk.window_of(0);
desk.app.run("cell.set", json!({"cell": "A1", "input": "2"})).unwrap();
desk.app.run("file.new", json!({})).unwrap();
desk.frames(3);
let other = desk.window_of(1);
desk.app.enter_window(original);
desk.app.open_dialog("saveChanges", json!({}));
desk.frames(3);
desk.app.run("view.switchWindows", json!({"window": other})).unwrap();
desk.frames(3);
assert_eq!(desk.app.session.active_window(), Some(other));
assert!(desk.app.unsaved_prompt.as_ref().is_some_and(|prompt| prompt.window == Some(original)));
// Send Escape to the original viewport while the other workbook is active.
desk.answer(SaveAnswer::Cancel);
assert!(desk.app.unsaved_prompt.is_none());
assert_eq!(desk.app.session.active_window(), Some(other));
assert_eq!(desk.app.session.documents().len(), 2);
assert!(desk.app.session.documents()[0].is_dirty());
}
#[test]
fn a_dialog_stays_with_its_window_across_a_switch() {
let mut desk = Desk::new(true);