fix(stories): scope ResourceSelected click to URIs region (#1248) (#1255)

The ResourceSelected story passed both sampleResources and
sampleSubscriptions, each of which renders 'config.json' as text. The
play helper's canvas.findByText('config.json') matched two nodes and
rejected.

Extends clickByText to accept an optional regionName regex; ResourceSelected
now scopes the click to within the 'URIs' Accordion panel by aria-region
name, so the subscriptions panel's matching label is filtered out without
changing what the story demonstrates.

Full storybook suite now green (273/273), unblocking #1251.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cliff Hall 2026-04-29 17:24:52 -04:00 • committed by GitHub
commit 64a42e645b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -122,9 +122,16 @@ const readUserProfileState: ReadResourceState = {
isSubscribed: false,
};
async function clickByText(canvasElement: HTMLElement, label: string) {
async function clickByText(
canvasElement: HTMLElement,
label: string,
regionName?: RegExp,
) {
const canvas = within(canvasElement);
await userEvent.click(await canvas.findByText(label));
const scope = regionName
? within(await canvas.findByRole("region", { name: regionName }))
: canvas;
await userEvent.click(await scope.findByText(label));
}
// The userId value typed below must match the `{userId}` segment in
@ -153,7 +160,7 @@ export const ResourceSelected: Story = {
readState: readConfigState,
},
play: async ({ canvasElement }) => {
await clickByText(canvasElement, "config.json");
await clickByText(canvasElement, "config.json", /^URIs/);
},
};