Skip to content

Commit

Permalink
Migrate Navigable toolbar test to Playwright (WordPress#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 and sethrubenstein committed Jul 13, 2023
1 parent 2c444d6 commit 145902a
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 );
} );
} );
} );

0 comments on commit 145902a

Please sign in to comment.