Skip to content

Commit

Permalink
Store style book locator in a const and reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewserong committed Feb 21, 2023
1 parent 8260102 commit d302f48
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions test/e2e/specs/site-editor/style-book.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,26 +120,31 @@ test.describe( 'Style Book', () => {
test( 'should disappear when closed via click event or Escape key', async ( {
page,
} ) => {
const styleBookRegion = page.getByRole( 'region', {
name: 'Style Book',
} );

// Close Style Book via click event.
await page.click(
'role=region[name="Style Book"i] >> role=button[name="Close Style Book"i]'
);
await styleBookRegion
.getByRole( 'button', { name: 'Close Style Book' } )
.click();

await expect(
page.locator( 'role=region[name="Style Book"i]' ),
styleBookRegion,
'should close when close button is clicked'
).not.toBeVisible();

// Open Style Book again.
await page.click( 'role=button[name="Style Book"i]' );
await page.getByRole( 'button', { name: 'Style Book' } ).click();
await expect(
page.locator( 'role=region[name="Style Book"i]' ),
styleBookRegion,
'style book should be visible'
).toBeVisible();

// Close Style Book via Escape key.
await page.keyboard.press( 'Escape' );
await expect(
page.locator( 'role=region[name="Style Book"i]' ),
styleBookRegion,
'should close when Escape key is pressed'
).not.toBeVisible();
} );
Expand Down

0 comments on commit d302f48

Please sign in to comment.