Skip to content

Commit

Permalink
e2e: Fix site editor test (#88571)
Browse files Browse the repository at this point in the history
After probably WordPress/gutenberg#59317 made the editor iframe be
considered a button labeled "Edit", a test started failing complaining
about there being two such buttons:

```
    locator.click: Error: strict mode violation: locator('body.block-editor-page').getByRole('button', { name: 'Edit', exact: true }) resolved to 2 elements:
        1) <button type="button" aria-label="Edit" class="component…>…</button> aka getByLabel('Navigation').getByLabel('Edit')
        2) <iframe tabindex="0" role="button" aria-label="Edit" nam…></iframe> aka locator('iframe[name="editor-canvas"]')
```

This fixes it by narrowing the search to the "Navigation" section of the
page.
  • Loading branch information
anomiex authored and billrobbins committed Mar 20, 2024
1 parent 2f43194 commit 06ce04f
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ export class FullSiteEditorNavSidebarComponent {
*/
async clickNavButtonByExactText( text: string ): Promise< void > {
const editorParent = await this.editor.parent();
await editorParent.getByRole( 'button', { name: text, exact: true } ).click();
await editorParent
.getByLabel( 'Navigation' )
.getByRole( 'button', { name: text, exact: true } )
.click();
}

/**
Expand Down

0 comments on commit 06ce04f

Please sign in to comment.