diff --git a/crates/ui-egui/src/workflows/js_ui.rs b/crates/ui-egui/src/workflows/js_ui.rs index 040f6b4d31..3311b098f9 100644 --- a/crates/ui-egui/src/workflows/js_ui.rs +++ b/crates/ui-egui/src/workflows/js_ui.rs @@ -240,6 +240,8 @@ impl PdfCraftApp { pub(crate) fn script_tick(&mut self, ctx: &egui::Context) { // A message queued before the window had a context is posted on the first pass. if self.script_shown.is_none() && !self.script_messages.is_empty() { + // Requests from the same script may already have queued notices; post those first. + crate::notices::post_queued(self, ctx); self.next_script_message(ctx); } // Nothing acts on the document under a dialog or prompt (`modal_open`): page actions and diff --git a/crates/ui-egui/tests/it/javascript.rs b/crates/ui-egui/tests/it/javascript.rs index d172a31dac..6d5dd99cfe 100644 --- a/crates/ui-egui/tests/it/javascript.rs +++ b/crates/ui-egui/tests/it/javascript.rs @@ -151,10 +151,11 @@ fn texts(h: &Harness<'static, PdfCraftApp>) -> Vec { /// The user's close action on every card, then the passes that act on it. fn dismiss_all(h: &mut Harness<'static, PdfCraftApp>) { - for card in toast::cards(&h.ctx, &WindowKey::main()) { - toast::dismiss(&h.ctx, card.id); + // Programmatic removal emits no close event; use the user's dismiss control. + for button in h.query_all_by(|node| !node.is_hidden() && node.label().as_deref() == Some("Dismiss")) { + button.click(); } - h.run_steps(2); + h.run_steps(3); } /// One run's messages are all shown, in order (#4294): the first is a card with its title and tone @@ -196,6 +197,7 @@ fn every_message_a_script_shows_takes_the_toast_in_turn() { // have been shown. let many: Vec<_> = (0..105).map(|i| pdfcraft_engine::js::Message::plain(format!("Message {i}"))).collect(); h.state_mut().show_script_messages(many); + h.run_steps(2); assert_eq!(texts(&h), ["Message 0"]); for i in 1..100 { dismiss_all(&mut h);