Skip to content

Commit

Permalink
Change how to test editor mobile overlay colors
Browse files Browse the repository at this point in the history
The tests were a little flaky when tryingn to click the button to open the mobile view since the animation from desktop to mobile in the editor took some time, and the test was trying to click the open menu button before it was able to be clicked.

This updates the test to use the navigation settings itself, which doesn't have an animation, so it should be more reliable.
  • Loading branch information
jeryj committed Jul 12, 2023
1 parent e7c72ed commit 8f27fd3
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions test/e2e/specs/editor/blocks/navigation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1647,16 +1647,6 @@ class ColorControl {
this.transparent = 'rgba(0, 0, 0, 0)';
}

async openEditorOverlay() {
await this.page
.getByRole( 'button', { name: 'View', exact: true } )
.click();
await this.page.getByRole( 'menuitem', { name: 'Mobile' } ).click();
await this.editor.canvas
.getByRole( 'button', { name: 'Open menu' } )
.click();
}

async testEditorColors( {
textColor,
backgroundColor,
Expand Down Expand Up @@ -1701,7 +1691,19 @@ class ColorControl {
submenuBackgroundColor
);

await this.openEditorOverlay();
// Switch to mobile view for the rest of the editor color tests
// Focus the navigation block
await this.editor.canvas
.getByRole( 'document', { name: 'Block: Navigation' } )
.click();
await this.editor.openDocumentSettingsSidebar();
// Switch to settings tab
await this.page.getByRole( 'tab', { name: 'Settings' } ).click();
// Set it to always be the mobile view, but don't save this setting so we can still check all the frontend colors
await this.page.getByRole( 'radio', { name: 'Always' } ).click();
await this.editor.canvas
.getByRole( 'button', { name: 'Open menu' } )
.click();

const overlay = this.editor.canvas
.locator( '.wp-block-navigation__responsive-container' )
Expand Down

0 comments on commit 8f27fd3

Please sign in to comment.