QA Request: Stable hooks for end-to-end tests (data-testid and state attributes) #68
Labels
No labels
android
bug
duplicate
feature request
linux
macos
needsinfo
severity: high
severity: low
severity: medium
telegram_gw
ui/ux
windows
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
another-im/anotherim-js#68
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stable hooks for end-to-end tests (data-testid and state attributes)
Context
We run Playwright end-to-end tests against the browser client (mock backend, plus a real-Prosody tier), mapped to the QA test cases. About 90% of the locators use roles and accessible names (
getByRole('button', { name: 'Block…' })).The remaining ~10% have no role or name to find them by.
For those we currently depend on internal CSS classes, tags and
titleattributes, and those break silently on refactors. We'd like to ask for a small set of stable hooks there.Buttons, menus, switches and dialogs stay as they are.
Stable hooks for end-to-end tests (data-testid and state attributes)
1. Test ids where an element has no role
aim-message-rowdata-testid="message"on the rowui/src/views/message-row.ts.bubbledata-testid="message-bubble"message-row.ts:1521aim-sheet.members-sheetdata-testid="room-members"muc-details.ts:657aim-call-viewdata-testid="call"call-view.ts(root element ofrender(), line 1278)aim-sheet)aim-sheet+ dialog titledata-sheet="<kind>", e.g.contact-info,encryption-info,room-detailssheet.ts/ callersPlaywright's
getByTestIdpierces open shadow roots, so a plain attribute on the element inside the component is enough. No changes to lit or to the build.2. State as attributes, ideally as ARIA
Today some states are visible only as an icon, so a test (and a screen reader) can't read them:
.tick--sent,.tick--delivered,.tick--readwith atitle(message-row.ts:2888-2893).Proposal:
data-status="sending|sent|delivered|read|failed"anddata-direction="out|in"on the message row. Even better, also anaria-labelon the tick ("Delivered", "Read"), so screen readers get it too.chat-list.ts:1051,<li data-jid=…>, which already hasdata-jid, thanks):data-pinnedwhen pinned. Today it is only<span title="Pinned">(chat-list.ts:1127).data-mutedwhen muted. Today it is only visible asbadge--muted, and only when there are unread messages (chat-list.ts:1130), so a muted chat with nothing unread can't be told apart at all.data-unread="<n>".3. A note on visible texts
The tests find most controls by their English labels. That's intended (it also checks accessibility), but a renamed label breaks a test while the feature still works. No code change is asked for here: just mention renamed buttons and menu items in the CHANGELOG, and the tests are updated in one place.
Why this matters
Thanks for the detailed request. Sections 1 and 2 are on develop and will be in the next app release. Nothing visible changed, and every attribute follows the state live.
data-testid="message"on a message row,data-testid="message-bubble"on its bubble (a pending upload's row too).data-testid="room-members"on the room members pane.data-testid="call"on the call view's root.data-sheet="<kind>"on every sheet, e.g.contact-info,encryption-info,room-details,room-members,preferences,calls,join-room,media-viewer,verify-keys,add-contact,find-people,xml-console,disco. The chat picker's isnew-chat,forward,share-toormuc-invitedepending on its mode.data-direction="out|in"on every row, anddata-status="sending|sent|delivered|read|failed"on outgoing rows.role="img"and anaria-label("Sending", "Sent", "Delivered", "Read", "Not sent"), translated in every language the app ships.data-pinnedanddata-muted(also on a muted chat with nothing unread), anddata-unread="<n>", including0.