forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnavigable-toolbar.spec.js
More file actions
48 lines (42 loc) · 1.34 KB
/
navigable-toolbar.spec.js
File metadata and controls
48 lines (42 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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 );
} );
} );
} );