test(ui): wait for the installed fonts before the Format text font field is opened (#9053)

The Format text font field is shut ("Loading fonts…") until the installed-font catalogue has
finished its first scan, and a list opened earlier closes when the catalogue arrives. Two
tests opened it after a fixed number of frames, so a slow or contended runner (the Windows gate
runs the whole `it` binary in one process) clicked a shut field. They now wait for
App::installed_fonts_pending to clear first.
This commit is contained in:
FredApps
2026-12-02 09:06:05 +01:00
parent 0f0aeda1e8
commit 116f5cbbaa
3 changed files with 22 additions and 0 deletions
+15
View File
@@ -676,6 +676,21 @@ impl PdfCraftApp {
self.views.iter().any(|v| v.render_pending())
}
/// `true` until the installed fonts have been found and catalogued, which the Format text
/// font field starts when it first shows. The field is shut ("Loading fonts…") while the
/// catalogue is built, and a list opened before that closes when it arrives, so a headless
/// test waits for this to be `false` before it opens the field.
pub fn installed_fonts_pending(&self) -> bool {
#[cfg(not(target_arch = "wasm32"))]
{
self.document_fonts.as_ref().is_none_or(|fonts| !fonts.catalog.is_ready())
}
#[cfg(target_arch = "wasm32")]
{
false
}
}
/// Check whether a tool group is pinned to Home.
pub fn is_tool_pinned(&self, id: &str) -> bool {
self.pinned_tools.iter().any(|t| t == id)
+4
View File
@@ -191,6 +191,10 @@ fn format_text_font_picker_applies_document_font_to_added_text() {
assert!(h.execute("edit.edit_text"));
h.state_mut().views[0].session.content.selected = Some((0, 0));
h.run_steps(4);
// The font field is shut ("Loading fonts…") while the installed fonts are catalogued on a
// worker thread, and a list opened before then closes when the catalogue arrives. A runner
// that reads many fonts (Windows) is still at it after these frames.
crate::support::wait_until(&mut h, "the installed fonts", |app| !app.installed_fonts_pending());
let font_node = h.get_by_role_and_label(Role::ComboBox, "Font family");
font_node.click();
+3
View File
@@ -10578,6 +10578,9 @@ fn format_panel_shows_selection_size_and_updates_after_font_applied() {
let size_node = h.get_by_role_and_label(Role::SpinButton, "Font size");
assert_eq!(size_node.value().as_deref(), Some("12"), "size text input value is 12");
// The font field reads "Loading fonts…" and is shut while the installed fonts are catalogued
// on a worker thread; a runner that reads many fonts (Windows) is still at it after the frames above.
crate::support::wait_until(&mut h, "the installed fonts", |app| !app.installed_fonts_pending());
let font_node = h.get_by_role_and_label(Role::ComboBox, "Font family");
assert_eq!(font_node.value().as_deref(), Some("Helvetica"), "initial font is Helvetica");