Skip to content

Commit

Permalink
Migrate Navigable toolbar test to Playwright (#51514)
Browse files Browse the repository at this point in the history
Removed tests related to the alt + 10 shortcut as they are covered elsewhere.
  • Loading branch information
pooja-muchandikar authored Jun 16, 2023
1 parent a96091b commit 1d9c4fa
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 104 deletions.
104 changes: 0 additions & 104 deletions packages/e2e-tests/specs/editor/various/navigable-toolbar.test.js

This file was deleted.

48 changes: 48 additions & 0 deletions test/e2e/specs/editor/various/navigable-toolbar.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Block Toolbar', () => {
test.beforeEach( async ( { admin } ) => {
await admin.createNewPost();
} );

test.describe( 'Contextual Toolbar', () => {
test( 'should not scroll page', async ( { page, pageUtils } ) => {
while (
await page.evaluate( () => {
const { activeElement } =
document.activeElement?.contentDocument ?? document;
const scrollable =
window.wp.dom.getScrollContainer( activeElement );
return ! scrollable || scrollable.scrollTop === 0;
} )
) {
await page.keyboard.press( 'Enter' );
}

await page.keyboard.type( 'a' );

const scrollTopBefore = await page.evaluate( () => {
const { activeElement } =
document.activeElement?.contentDocument ?? document;
window.scrollContainer =
window.wp.dom.getScrollContainer( activeElement );
return window.scrollContainer.scrollTop;
} );

await pageUtils.pressKeys( 'alt+F10' );
await expect(
page
.getByRole( 'toolbar', { name: 'Block Tools' } )
.getByRole( 'button', { name: 'Paragraph' } )
).toBeFocused();

const scrollTopAfter = await page.evaluate( () => {
return window.scrollContainer.scrollTop;
} );
expect( scrollTopBefore ).toBe( scrollTopAfter );
} );
} );
} );

1 comment on commit 1d9c4fa

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 1d9c4fa.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5291878028
📝 Reported issues:

Please sign in to comment.