Repository navigation
test: Read accessibility descriptions and placeholders in element snapshots - #3672
Merged
huacnlee merged 1 commit intoOct 24, 2026
Merged
Conversation
…pshots ElementSnapshot read role, label, value and the state flags from an observed element's native node, but not its description or placeholder, so a UI test could not check either on a painted element. Snapshots now record both from the same node, and a frame with a semantic owner takes them from its editor, so an Input's placeholder is found through its component ID. Follows longbridge#3531, which added disabled() the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
boboshan
marked this pull request as ready for review
October 24, 2026 08:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ElementSnapshotreads role, label, value and the state flags from an observed element's native node, but not its description or placeholder, so a UI test cannot check either on a painted element. Both reach assistive technology: Base's input editor writesaria_placeholder(gpui-component'sInputpasses its placeholder there), and the questionnaire and diff controls writearia_description. Today a test can only check them by building the element and callingwrite_a11y_infoby hand, asfocus_trap.rsandlifecycle.rsdo, which reaches the outermost element and not one painted inside a view. GPUI'sWindow::debug_a11y_tree_json()includes both, but a test window never activates accessibility, so it returnsNone.This follows #3531, which added
disabled()the same way. Snapshots now recorddescriptionandplaceholderfrom the node they already readlabelfrom. A frame with a semantic owner takes both from its editor, like its other semantic facts, so anInput's placeholder is found through the component ID.We need this in an application's tests: a picker trigger with nothing chosen gives its prompt as a placeholder and no value, so a screen reader does not read the prompt as the choice, and a toggle without a visible label announces its description.
Public API
gpui-base
test_support::ElementSnapshot::description(&self) -> Option<&str>— the accessibility description, read after the label; it does not replace it.test_support::ElementSnapshot::placeholder(&self) -> Option<&str>— the accessibility placeholder, the prompt shown while the element has no value.Both are also reachable through
gpui_kit::test::ElementSnapshot.ElementSnapshot'sDebugoutput lists the two fields afterlabel.How to Test
snapshot_reads_description_and_placeholder(crates/kit/tests/integration/lifecycle.rs) paints an observeddivwith a label, description and placeholder, and reads all three with no value.placeholder_is_read_from_the_editor_and_is_not_a_value(crates/kit/tests/integration/input.rs) paints a componentInputwith a label and a placeholder, and reads the placeholder through the semantic owner with an empty value.prepaint, both tests fail; without the two fields in the semantic-owner snapshot, only theInputtest fails.cargo test -p gpui-kit --features test-support,component --locked,cargo test -p gpui-base --features test-support --lib --locked,cargo clippy -p gpui-base -p gpui-kit --features gpui-kit/test-support,gpui-kit/component --all-targets --locked -- --deny warnings,cargo fmt --all --checkandtypos1.40.0.Checklist
cargo runfor story tests related to the changes.🤖 Generated with Claude Code