Skip to content

Commit

Permalink
Utilise locator chaining to improve clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Jan 4, 2023
1 parent d9e7ec8 commit 0ff5dee
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions test/e2e/specs/editor/blocks/navigation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,26 @@ test.describe(
// Open the list view.
await page.click( '[aria-label="Document Overview"i]' );

// Click the Navigation block expander, we need to use force because it has aria-hidden set to true.
await page.click(
`//a[.//span[text()='Navigation']]/span[contains(@class, 'block-editor-list-view__expander')]`,
{ force: true }
const listView = await page.locator(
`//table[contains(@aria-label,'Block navigation structure')]`
);

// Click the Navigation block expander within the List View.
await listView
.locator( `//a[.//span[text()='Navigation']]` )
.locator( '.block-editor-list-view__expander' )
.click( {
force: true, // required as element has aria-hidden set to true.);
} );

// Find the Page list selector inside the navigation block.
const pageListSelector = await page.locator(
`//table[contains(@aria-label,'Block navigation structure')]//a[.//span[text()='Page List']]`
const pageListSelector = await listView.locator(
`//a[.//span[text()='Page List']]`
);

expect( pageListSelector ).toBeTruthy();
// Todo: wait on resolution state of the block
// in order to proceed with assertion using `toBeVisible()`.
await expect( pageListSelector ).toBeTruthy();

// Check the markup of the block is correct.
await editor.publishPost();
Expand Down

0 comments on commit 0ff5dee

Please sign in to comment.