test(ui-automation): cover SwiftUI tab identifier surfacing (#442)#456
Open
vsolano9 wants to merge 1 commit into
Open
test(ui-automation): cover SwiftUI tab identifier surfacing (#442)#456vsolano9 wants to merge 1 commit into
vsolano9 wants to merge 1 commit into
Conversation
…y#442) A `.accessibilityIdentifier(...)` applied to a SwiftUI `Tab` is not forwarded to the native tab bar item's accessibility element, so describe-ui reports no AXUniqueId/AXIdentifier for the tab. Reproduced on a simulator: the identifier string is absent from the entire AX tree, while an identifier applied to the tab's content still propagates. Add regression coverage for the snapshot behavior: the tab is still exposed for automation by role + label without inventing an identifier or leaking the tab's SF Symbol image identifier, and a tab identifier is surfaced when the platform does provide one. No production behavior changes; parsing already reads AXUniqueId/AXIdentifier when present. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Adds regression coverage for the
SwiftUI.Tabaccessibility-identifier behavior described in #442, and documents (via the tests and this PR) whatsnapshot-uican and cannot surface for native tabs.No production behavior changes.
normalizeNodealready readsAXUniqueId/AXIdentifierwhen present; the tests lock in that a tab is still exposed for automation by role + label when the platform provides no identifier, and that an identifier is surfaced when it is present.Background
#442 reports that an
.accessibilityIdentifier(...)set on aSwiftUI.Tabdoes not appear on the native tab target emitted bysnapshot-ui, and asks whether the identifier can be surfaced or whether this is expected SwiftUI/UIKit behavior.I reproduced it on an iPhone 17 Pro simulator with a minimal app:
Running
axe describe-uiagainst it, the tab node is:{ "role": "AXRadioButton", "role_description": "tab", "subrole": "AXTabButton", "AXLabel": "Wheels", "AXValue": 0, "AXUniqueId": null, // <- no identifier "children": [ { "role": "AXImage", "AXUniqueId": "arrow.trianglehead.2.clockwise" } ] }The
tab_wheelsstring is absent from the entire accessibility tree. In contrast,screen_wheels/screen_dashboardapplied to the tab's content does propagate normally. So this is a SwiftUI/UIKit limitation: the identifier applied to aTabis not forwarded to the underlying tab bar item's accessibility element. There is no identifier in the tree forsnapshot-uito surface.Solution
Two focused unit tests in
runtime-snapshot.test.ts:SwiftUI.Tab-shaped node with noAXUniqueId(matching the reproduced AX shape, including the SF Symbol child image) is still exposed as atabwith its label and atapaction, and does not gain an invented identifier or leak the child image's symbol identifier.AXUniqueIdsurfaces it as the elementidentifier, confirming the parser already forwards identifiers when the platform provides them.The practical guidance for tab automation stays: target tabs by
role=tabplus visible label, which already works.Testing
npm run typecheck(afternpm run generate:version) - passnpm run lint- passnpm run format:check- passnpm run build- passnpm test(vitest run) - 213 files, 2665 tests pass (includes the 2 new tests)describe-ui, as shown aboveNotes
Tabidentifier to the tab bar item") would help, I am happy to follow up.CHANGELOG.mdentry was added.