Repository navigation
docs(changeset): shared announcer regions can match an app's getByRole('status') queries - #8354
Conversation
…e('status') queries
EmptyState now announces through the page's shared announcer regions
(spec:AST-086 FR2), a visually hidden role="status" / role="alert" pair on
document.body, so a test's getByRole('status') or getByRole('alert') can
match one of them. The changeset tells callers to scope such queries or
skip elements carrying data-astryx-live-region.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
|
There was a problem hiding this comment.
The release note matches what ships: on this head, an EmptyState that appears after load creates the shared, visually hidden role="status" / role="alert" regions on document.body, and within(container) scopes getByRole back to the app's own elements. Approval waits on one decision, because the note also tells consumers to skip elements carrying data-astryx-live-region, an internal attribute that no current spec names as a supported surface (spec:AST-086 keeps the announcement channel's internals replaceable, and spec:AST-017 FR3 leaves undocumented markup outside compatibility). An engineering owner needs to settle whether consumer tests may rely on that attribute, identifying or adding the governing spec claim, and record the decision by commenting /approve-spec <full head SHA> on this pull request; the author can do this if they are an engineering owner.
[Automated review]
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [docs] EmptyState now announces through the page's shared announcer regions, a visually hidden `role="status"` (polite) and `role="alert"` (assertive) pair that Astryx mounts once on `document.body`. In tests, a query such as `getByRole('status')` or `getByRole('alert')` can therefore match one of these regions rather than your component. Scope the query to your component (`within(container)`), or skip elements carrying `data-astryx-live-region`. |
There was a problem hiding this comment.
This recommends filtering on data-astryx-live-region, a module-private constant in packages/core/src/hooks/useAnnounce.ts that no current spec or consumer doc names as something consumer tests may rely on, so an engineering owner needs to decide whether it is a supported surface. On this head, within(container) alone already returns the app's own status and alert.
…eries data-astryx-live-region is an internal attribute of the shared announcer (spec:AST-086 keeps the channel's internals replaceable), so the note no longer suggests consumer tests skip elements by it.
There was a problem hiding this comment.
This release note is accurate and needs no changes: on this revision, an EmptyState that appears after load creates the shared, visually hidden role="status" / role="alert" regions on document.body, unscoped getByRole queries also find them, and within(container) returns the app's own elements. Dropping the data-astryx-live-region suggestion settles the earlier open point, since the note no longer asks consumer tests to rely on internal markup. Two optional wording tweaks would help readers who arrive from a failing test:
- With the app's own element present, Testing Library reports
Found multiple elements with the role "status"(or"alert"), and the error persists into later tests in the same file because the regions stay ondocument.body. - Text queries meet the same regions: with a title-only EmptyState,
screen.getByText('<title>')also matches the polite region's copy of the title, andwithin(container)fixes that too.
[Automated review]
User impact
A product engineer whose tests find their own status or alert with
getByRole('status')/getByRole('alert')may see those queries start matching a different element after #8294: EmptyState now announces through the page's shared announcer regions, a visually hiddenrole="status"/role="alert"pair Astryx mounts once ondocument.body(spec:AST-086FR2). This changeset tells them why and how to scope the query, so the upgrade note is in the CHANGELOG.Change
One
[docs]patch changeset for@astryxdesign/core. No code, record, or behavior change.Testing
node scripts/check-changesets.mjspasses.