Skip to content

test: Make Progress and TitleBar findable in UI tests - #3383

Merged
huacnlee merged 2 commits into
longbridge:mainfrom
AncientPixel:kit-observe-progress-title-bar
Oct 7, 2026
Merged

huacnlee merged 2 commits into
longbridge:mainfrom
AncientPixel:kit-observe-progress-title-bar

Conversation

@AncientPixel

Copy link
Copy Markdown
Contributor

Description

An app's UI tests could not find a Progress bar or the TitleBar with TestWindowExt::find. They asserted neighbouring text instead, or the tests were #[ignore]d. Neither control registered its element for the test harness, although both already have stable IDs. Progress also already sets its accessibility role and label.

On main:

  • Base Progress holds a plain gpui::Stateful<Div> built with div().id(id) (crates/base/src/progress.rs:13, :24). It sets Role::ProgressIndicator, the label and the numeric value, but nothing registers it. Component Progress (crates/component/src/progress/progress.rs:120) and ProgressCircle (crates/component/src/progress/progress_circle.rs:160) build on it, so neither could be found.
  • TitleBar gives title-bar, window-controls and the caption buttons (minimize, maximize/restore, close) element IDs, but does not call .test_support() on them (crates/component/src/title_bar.rs:209, :255, :269, :278, :330 on main).

This PR adds the existing .test_support() registration to these elements, as Base Button and other controls already do:

  • crates/base/src/progress.rs:13,24: the root becomes crate::ObservedElement<gpui::Stateful<Div>>, built with div().id(id).test_support(). This is the same pattern as crates/base/src/button.rs:22,41. Without the test-support feature, ObservedElement<E> is E, so normal builds keep the exact type they had before.
  • crates/component/src/title_bar.rs: .test_support() on the caption buttons (:211), on all three window-controls returns (:257, :271, :281) and on title-bar (:354). On title-bar, the call comes after the two on_double_click calls, because InteractiveElementExt is implemented only for Stateful<E> (crates/base/src/event.rs:60). A short comment there says why.

This is a change to gpui-base, but only to register an element that already exists. It follows how Base Button, Select, Accordion and others are registered. Nothing else changes: no roles, labels or locale keys are added. The TitleBar elements still have no accessibility role or name.

The table of observable controls in website/docs/test.md and website/zh-CN/docs/test.md gets rows for Progress / ProgressCircle and TitleBar.

Where caption buttons appear: on macOS and the web, WindowControls renders an empty window-controls and no buttons. On Linux it draws them only under client-side decorations. GPUI's test window uses server-side decorations (the PlatformWindow::window_decorations default), so in tests the buttons are found only on Windows.

This change was written with AI assistance (Claude Code).

How to Test

Two new tests in crates/kit/tests/components.rs:

  • progress_and_progress_circle_are_observable renders a Progress and a loading ProgressCircle. It checks that find(id) gives Role::ProgressIndicator, the accessibility label, and a visible element.
  • title_bar_and_window_controls_are_observable renders a TitleBar. It checks that title-bar is found and visible and that window-controls is found. On Windows it also checks that minimize, maximize and close are visible inside window-controls. On other platforms it checks that close is absent, because the title bar does not draw caption buttons there.

Both tests failed before the fix (missing ElementId Name("download") and missing ElementId Name("title-bar"), with no registered paths) and pass after it.

Commands run on macOS (aarch64):

cargo test -p gpui-kit --features test-support,component --test components   # 6 passed
cargo test -p gpui-base --lib progress                                        # base Progress a11y tests
cargo test -p gpui-component --lib progress                                   # component Progress builder tests
cargo test -p gpui-component --lib title_bar
cargo fmt --all --check
cargo clippy -p gpui-base -p gpui-component -- -D warnings -A clippy::nonminimal_bool
cargo clippy -p gpui-kit --features test-support,component --tests -- -D warnings -A clippy::nonminimal_bool

I ran clippy with -A clippy::nonminimal_bool because my local clippy (Rust 1.95) reports two nonminimal_bool errors at crates/base/src/calendar.rs:132. This PR does not touch that file. There are no other clippy findings.

I did not run the Windows branch of the TitleBar test (the caption-button assertions). It compiles only on Windows, so CI is the first run of it.

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate.
  • Passed cargo run for story tests related to the changes. Not applicable: the change only registers existing elements for the test harness. It does not change layout or rendering.
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific) Not applicable: no platform-specific code changes. The test's caption-button assertions run only on Windows.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PRpJSFk3zTwdgAJHehdZFm

An application's UI tests could not find a Progress bar or the
TitleBar's window controls with `TestWindowExt::find`, so they
asserted neighbouring text instead or were ignored. Both controls
already have stable element IDs, and Progress already sets its
progress indicator role and label, but neither called
`.test_support()`.

Base Progress now keeps its root as an `ObservedElement`, as Base
Button does, so Progress and ProgressCircle register with the harness.
TitleBar registers `title-bar`, `window-controls` and the caption
buttons. Without the `test-support` feature `ObservedElement<E>` is
`E`, so normal builds are unchanged. The harness docs list both
controls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PRpJSFk3zTwdgAJHehdZFm
@AncientPixel

Copy link
Copy Markdown
Contributor Author

The failing GPUI Fast (windows-latest) check isn't from this change. It fails at link time with LNK1123: failure during conversion to COFF, the same way it fails on main at c0bebdc, the commit this branch is based on. #3380 looks like the fix. Once it lands I'll rebase onto main so CI runs again.

@huacnlee huacnlee changed the title kit: Make Progress and TitleBar findable in UI tests test: Make Progress and TitleBar findable in UI tests Oct 7, 2026
@huacnlee
huacnlee enabled auto-merge (squash) October 7, 2026 05:51
@huacnlee
huacnlee merged commit 4921e5b into longbridge:main Oct 7, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants