Skip to content

Commit 5e26a31

Browse files
committed
Fix flaky e2e tests
This commit simplifies the searchAndInsertBlock function
1 parent 42c29fd commit 5e26a31

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tests/e2e/tools/lib/editor.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ const closeBlockInserter = async ({page}) => {
4646
const searchAndInsertBlock = async ({page}, blockName, namespace = '') => {
4747
const openSidebar = await page.getByRole('button', {name: 'Block Inserter', exact: true});
4848
const searchInput = page.getByPlaceholder('Search');
49+
4950
if (await openSidebar.getAttribute('aria-expanded') === 'false') {
50-
await openSidebar.dispatchEvent('click');
51+
await openSidebar.click();
5152
await expect(searchInput).toBeVisible();
5253
}
5354

@@ -57,14 +58,12 @@ const searchAndInsertBlock = async ({page}, blockName, namespace = '') => {
5758
const blocksList = page.getByRole('listbox', {name: 'Blocks'});
5859
await expect(blocksList).toBeVisible();
5960

60-
let blockOption;
61+
let blockOption = blocksList.getByRole('option', {name: blockName});
6162

6263
if (namespace) {
6364
blockOption = blocksList.locator(
6465
`button.editor-block-list-item-${namespace.toLowerCase()}[role="option"]`
6566
);
66-
} else {
67-
blockOption = blocksList.getByRole('option', {name: blockName});
6867
}
6968

7069
await expect(blockOption).toBeVisible();

0 commit comments

Comments
 (0)