Fix up merged PRs: a background open that fails says why on the start screen

Main (#346) shows why a file couldn't be opened as a notice over the start
screen; #488's background open put the error in the status bar instead, which
broke a_file_that_cant_be_opened_says_why. The background open now reports
through the same notice, and the test waits for the background read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-14 15:50:07 -04:00
co-authored by Claude Opus 5.5
parent a7d47dbc1b
commit 76978b1634
2 changed files with 16 additions and 6 deletions
+9
View File
@@ -444,6 +444,15 @@ fn a_file_that_cant_be_opened_says_why() {
h.run_steps(2);
h.get_by_label("Browse").click();
h.run_steps(3);
// The file is read in the background (#350): wait for it.
for _ in 0..500 {
if h.state().opening.is_none() {
break;
}
std::thread::sleep(std::time::Duration::from_millis(10));
h.run_steps(1);
}
h.run_steps(2);
assert!(h.state().session.documents().is_empty());
assert!(h.query_by_label_contains("not a presentation DeckCraft can read").is_some(), "the error is on screen");
let _ = std::fs::remove_dir_all(&dir);
+7 -6
View File
@@ -32,7 +32,7 @@ impl SlideApp {
#[cfg(target_arch = "wasm32")]
{
if let Err(e) = self.open_path(path) {
self.set_status(e);
self.notify(e);
}
}
#[cfg(not(target_arch = "wasm32"))]
@@ -47,7 +47,7 @@ impl SlideApp {
Ok(_) => self.opening = Some(Opening { path: path.to_string(), started_ms: crate::now_ms(), rx }),
Err(_) => {
if let Err(e) = self.open_path(path) {
self.set_status(e);
self.notify(e);
}
}
}
@@ -76,10 +76,11 @@ impl SlideApp {
let token = self.session.stage_loaded(f);
match self.session.execute("file.adopt", &serde_json::json!({"path": o.path, "token": token})) {
Ok(_) => self.note_recent(&o.path),
Err(e) => self.set_status(e.to_string()),
Err(e) => self.notify(e.to_string()),
}
}
Err(e) => self.set_status(e),
// Over the start screen too, like a failed file.open (#346).
Err(e) => self.notify(e),
}
}
@@ -167,14 +168,14 @@ mod tests {
}
#[test]
fn errors_show_in_the_status_bar_and_a_second_open_waits() {
fn errors_are_shown_and_a_second_open_waits() {
let mut app = SlideApp::new(Session::new(), crate::Services::default());
app.open_path_in_background("/nonexistent/deckcraft/missing.pptx");
app.open_path_in_background("/nonexistent/deckcraft/other.pptx");
assert!(app.status.as_ref().is_some_and(|(m, _)| m.starts_with("Still opening missing.pptx")));
wait(&mut app);
assert!(app.session.documents().is_empty());
assert!(app.status.as_ref().is_some_and(|(m, _)| m.contains("missing.pptx")), "{:?}", app.status);
assert!(app.toast.as_ref().is_some_and(|t| t.text.contains("missing.pptx")), "the reason is shown");
}
#[test]