Skip to content

Commit

Permalink
Use list role instead of listbox for patterns (#54884)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 authored and mikachan committed Sep 29, 2023
1 parent 7b19836 commit 458a73d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/page-patterns/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Grid( { categoryId, items, ...props } ) {
}

return (
<ul role="listbox" className="edit-site-patterns__grid" { ...props }>
<ul className="edit-site-patterns__grid" { ...props }>
{ items.map( ( item ) => (
<GridItem
key={ item.name }
Expand Down
17 changes: 9 additions & 8 deletions test/e2e/specs/site-editor/patterns.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,28 @@ test.describe( 'Patterns', () => {

await expect(
navigation.getByRole( 'button', { name: 'All patterns' } )
).toBeVisible();
).toContainText( '1' );
await expect(
navigation.getByRole( 'button', { name: 'My patterns' } )
).toBeVisible();
).toContainText( '1' );
await expect(
navigation.getByRole( 'button', { name: 'Uncategorized' } )
).toBeVisible();
).toContainText( '1' );

await expect(
patternsContent.getByRole( 'heading', {
name: 'All patterns',
level: 2,
} )
).toBeVisible();
const patternsList = patternsContent.getByRole( 'list', {
name: 'All patterns',
} );
await expect( patternsList.getByRole( 'listitem' ) ).toHaveCount( 1 );
await expect(
patternsContent
.getByRole( 'listbox', { name: 'All patterns' } )
// TODO: should be `getByRole( 'option', { name: 'My pattern' } )`
patternsList
.getByRole( 'heading', { name: 'My pattern' } )
.getByRole( 'button', { name: 'My pattern', exact: true } )
// TODO: Shouldn't need this.
.nth( 0 )
).toBeVisible();
} );
} );

0 comments on commit 458a73d

Please sign in to comment.