@wordpress/e2e-tests 7.5.0 → 7.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/config/setup-test-framework.js +9 -0
- package/mu-plugins/nocache-headers.php +21 -0
- package/package.json +7 -7
- package/plugins/block-context.php +1 -1
- package/plugins/iframed-block/block.json +1 -1
- package/plugins/iframed-block.php +2 -2
- package/plugins/iframed-enqueue-block-assets.php +1 -1
- package/plugins/iframed-inline-styles/block.json +1 -1
- package/plugins/iframed-inline-styles/editor.js +1 -1
- package/plugins/iframed-inline-styles.php +3 -3
- package/plugins/iframed-masonry-block/block.json +1 -1
- package/plugins/iframed-masonry-block/editor.js +1 -1
- package/plugins/iframed-masonry-block.php +2 -2
- package/plugins/iframed-multiple-stylesheets/block.json +1 -1
- package/plugins/iframed-multiple-stylesheets/editor.js +1 -1
- package/plugins/iframed-multiple-stylesheets.php +2 -2
- package/plugins/inner-blocks-allowed-blocks/index.js +17 -58
- package/plugins/inner-blocks-allowed-blocks.php +2 -3
- package/plugins/marquee-function-widget.php +2 -2
- package/specs/editor/blocks/post-title.test.js +5 -4
- package/specs/editor/blocks/site-title.test.js +3 -2
- package/specs/editor/plugins/annotations.test.js +17 -9
- package/specs/editor/plugins/block-variations.test.js +6 -5
- package/specs/editor/plugins/cpt-locking.test.js +15 -12
- package/specs/editor/plugins/iframed-inline-styles.test.js +6 -2
- package/specs/editor/plugins/iframed-masonry-block.test.js +1 -1
- package/specs/editor/plugins/iframed-multiple-block-stylesheets.test.js +1 -1
- package/specs/editor/plugins/inner-blocks-prioritized-inserter-blocks.test.js +2 -1
- package/specs/editor/various/__snapshots__/links.test.js.snap +0 -24
- package/specs/editor/various/adding-inline-tokens.test.js +0 -1
- package/specs/editor/various/autosave.test.js +2 -1
- package/specs/editor/various/block-editor-keyboard-shortcuts.test.js +4 -3
- package/specs/editor/various/block-grouping.test.js +5 -4
- package/specs/editor/various/change-detection.test.js +20 -19
- package/specs/editor/various/editor-modes.test.js +7 -6
- package/specs/editor/various/embedding.test.js +21 -15
- package/specs/editor/various/inserting-blocks.test.js +19 -14
- package/specs/editor/various/invalid-block.test.js +4 -6
- package/specs/editor/various/keyboard-navigable-blocks.test.js +16 -17
- package/specs/editor/various/links.test.js +26 -152
- package/specs/editor/various/nux.test.js +6 -2
- package/specs/editor/various/publish-button.test.js +3 -2
- package/specs/editor/various/publish-panel.test.js +4 -3
- package/specs/editor/various/publishing.test.js +9 -5
- package/specs/editor/various/reusable-blocks.test.js +39 -25
- package/specs/editor/various/rich-text.test.js +9 -8
- package/specs/editor/various/sidebar-permalink.test.js +4 -3
- package/specs/editor/various/taxonomies.test.js +4 -3
- package/specs/editor/various/typewriter.test.js +68 -50
- package/specs/performance/front-end-block-theme.test.js +1 -2
- package/specs/performance/front-end-classic-theme.test.js +1 -1
- package/specs/performance/post-editor.test.js +6 -0
- package/specs/performance/site-editor.test.js +11 -7
- package/specs/site-editor/settings-sidebar.test.js +2 -2
- package/specs/editor/plugins/inner-blocks-allowed-blocks.test.js +0 -96
- package/specs/editor/various/__snapshots__/block-hierarchy-navigation.test.js.snap +0 -63
- package/specs/editor/various/block-hierarchy-navigation.test.js +0 -227
- package/specs/editor/various/navigable-toolbar.test.js +0 -104
@@ -1,96 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
createNewPost,
|
7
|
-
deactivatePlugin,
|
8
|
-
getAllBlockInserterItemTitles,
|
9
|
-
insertBlock,
|
10
|
-
openGlobalBlockInserter,
|
11
|
-
closeGlobalBlockInserter,
|
12
|
-
clickBlockToolbarButton,
|
13
|
-
} from '@wordpress/e2e-test-utils';
|
14
|
-
|
15
|
-
describe( 'Allowed Blocks Setting on InnerBlocks', () => {
|
16
|
-
const paragraphSelector =
|
17
|
-
'.block-editor-rich-text__editable[data-type="core/paragraph"]';
|
18
|
-
beforeAll( async () => {
|
19
|
-
await activatePlugin( 'gutenberg-test-innerblocks-allowed-blocks' );
|
20
|
-
} );
|
21
|
-
|
22
|
-
beforeEach( async () => {
|
23
|
-
await createNewPost();
|
24
|
-
} );
|
25
|
-
|
26
|
-
afterAll( async () => {
|
27
|
-
await deactivatePlugin( 'gutenberg-test-innerblocks-allowed-blocks' );
|
28
|
-
} );
|
29
|
-
|
30
|
-
it( 'allows all blocks if the allowed blocks setting was not set', async () => {
|
31
|
-
const parentBlockSelector = '[data-type="test/allowed-blocks-unset"]';
|
32
|
-
const childParagraphSelector = `${ parentBlockSelector } ${ paragraphSelector }`;
|
33
|
-
await insertBlock( 'Allowed Blocks Unset' );
|
34
|
-
await closeGlobalBlockInserter();
|
35
|
-
await page.waitForSelector( childParagraphSelector );
|
36
|
-
await page.click( childParagraphSelector );
|
37
|
-
await openGlobalBlockInserter();
|
38
|
-
await expect(
|
39
|
-
(
|
40
|
-
await getAllBlockInserterItemTitles()
|
41
|
-
).length
|
42
|
-
).toBeGreaterThan( 20 );
|
43
|
-
} );
|
44
|
-
|
45
|
-
it( 'allows the blocks if the allowed blocks setting was set', async () => {
|
46
|
-
const parentBlockSelector = '[data-type="test/allowed-blocks-set"]';
|
47
|
-
const childParagraphSelector = `${ parentBlockSelector } ${ paragraphSelector }`;
|
48
|
-
await insertBlock( 'Allowed Blocks Set' );
|
49
|
-
await closeGlobalBlockInserter();
|
50
|
-
await page.waitForSelector( childParagraphSelector );
|
51
|
-
await page.click( childParagraphSelector );
|
52
|
-
await openGlobalBlockInserter();
|
53
|
-
const allowedBlocks = await getAllBlockInserterItemTitles();
|
54
|
-
expect( allowedBlocks.sort() ).toEqual( [
|
55
|
-
'Button',
|
56
|
-
'Gallery',
|
57
|
-
'List',
|
58
|
-
'Media & Text',
|
59
|
-
'Quote',
|
60
|
-
] );
|
61
|
-
} );
|
62
|
-
|
63
|
-
it( 'correctly applies dynamic allowed blocks restrictions', async () => {
|
64
|
-
await insertBlock( 'Allowed Blocks Dynamic' );
|
65
|
-
await closeGlobalBlockInserter();
|
66
|
-
const parentBlockSelector = '[data-type="test/allowed-blocks-dynamic"]';
|
67
|
-
const blockAppender = '.block-list-appender button';
|
68
|
-
const appenderSelector = `${ parentBlockSelector } ${ blockAppender }`;
|
69
|
-
await page.waitForSelector( appenderSelector );
|
70
|
-
await page.click( appenderSelector );
|
71
|
-
expect( await getAllBlockInserterItemTitles() ).toEqual( [
|
72
|
-
'Image',
|
73
|
-
'List',
|
74
|
-
] );
|
75
|
-
const insertButton = (
|
76
|
-
await page.$x( `//button//span[contains(text(), 'List')]` )
|
77
|
-
)[ 0 ];
|
78
|
-
await insertButton.click();
|
79
|
-
// Select the list wrapper so the image is insertable.
|
80
|
-
await page.keyboard.press( 'ArrowUp' );
|
81
|
-
await insertBlock( 'Image' );
|
82
|
-
await closeGlobalBlockInserter();
|
83
|
-
await page.waitForSelector( '.product[data-number-of-children="2"]' );
|
84
|
-
await clickBlockToolbarButton( 'Select Allowed Blocks Dynamic' );
|
85
|
-
// This focus shouldn't be neessary but there's a bug in trunk right now
|
86
|
-
// Where if you open the inserter, don't do anything and click the "appender" on the canvas
|
87
|
-
// the appender is not opened right away.
|
88
|
-
// It needs to be investigated on its own.
|
89
|
-
await page.focus( appenderSelector );
|
90
|
-
await page.click( appenderSelector );
|
91
|
-
expect( await getAllBlockInserterItemTitles() ).toEqual( [
|
92
|
-
'Gallery',
|
93
|
-
'Video',
|
94
|
-
] );
|
95
|
-
} );
|
96
|
-
} );
|
@@ -1,63 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`Navigating the block hierarchy should appear and function even without nested blocks 1`] = `
|
4
|
-
"<!-- wp:paragraph -->
|
5
|
-
<p>and I say hello</p>
|
6
|
-
<!-- /wp:paragraph -->
|
7
|
-
|
8
|
-
<!-- wp:image -->
|
9
|
-
<figure class="wp-block-image"><img alt=""/></figure>
|
10
|
-
<!-- /wp:image -->"
|
11
|
-
`;
|
12
|
-
|
13
|
-
exports[`Navigating the block hierarchy should navigate block hierarchy using only the keyboard 1`] = `
|
14
|
-
"<!-- wp:columns -->
|
15
|
-
<div class="wp-block-columns"><!-- wp:column -->
|
16
|
-
<div class="wp-block-column"><!-- wp:paragraph -->
|
17
|
-
<p>First column</p>
|
18
|
-
<!-- /wp:paragraph --></div>
|
19
|
-
<!-- /wp:column -->
|
20
|
-
|
21
|
-
<!-- wp:column -->
|
22
|
-
<div class="wp-block-column"></div>
|
23
|
-
<!-- /wp:column -->
|
24
|
-
|
25
|
-
<!-- wp:column -->
|
26
|
-
<div class="wp-block-column"><!-- wp:paragraph -->
|
27
|
-
<p>Third column</p>
|
28
|
-
<!-- /wp:paragraph --></div>
|
29
|
-
<!-- /wp:column --></div>
|
30
|
-
<!-- /wp:columns -->"
|
31
|
-
`;
|
32
|
-
|
33
|
-
exports[`Navigating the block hierarchy should navigate using the list view sidebar 1`] = `
|
34
|
-
"<!-- wp:columns -->
|
35
|
-
<div class="wp-block-columns"><!-- wp:column -->
|
36
|
-
<div class="wp-block-column"><!-- wp:paragraph -->
|
37
|
-
<p>First column</p>
|
38
|
-
<!-- /wp:paragraph --></div>
|
39
|
-
<!-- /wp:column -->
|
40
|
-
|
41
|
-
<!-- wp:column -->
|
42
|
-
<div class="wp-block-column"></div>
|
43
|
-
<!-- /wp:column -->
|
44
|
-
|
45
|
-
<!-- wp:column -->
|
46
|
-
<div class="wp-block-column"><!-- wp:paragraph -->
|
47
|
-
<p>Third column</p>
|
48
|
-
<!-- /wp:paragraph --></div>
|
49
|
-
<!-- /wp:column --></div>
|
50
|
-
<!-- /wp:columns -->"
|
51
|
-
`;
|
52
|
-
|
53
|
-
exports[`Navigating the block hierarchy should select the wrapper div for a group 1`] = `
|
54
|
-
"<!-- wp:group {"layout":{"type":"constrained"}} -->
|
55
|
-
<div class="wp-block-group"><!-- wp:paragraph -->
|
56
|
-
<p>just a paragraph</p>
|
57
|
-
<!-- /wp:paragraph -->
|
58
|
-
|
59
|
-
<!-- wp:separator -->
|
60
|
-
<hr class="wp-block-separator has-alpha-channel-opacity"/>
|
61
|
-
<!-- /wp:separator --></div>
|
62
|
-
<!-- /wp:group -->"
|
63
|
-
`;
|
@@ -1,227 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
createNewPost,
|
6
|
-
insertBlock,
|
7
|
-
getEditedPostContent,
|
8
|
-
pressKeyTimes,
|
9
|
-
pressKeyWithModifier,
|
10
|
-
openDocumentSettingsSidebar,
|
11
|
-
getListViewBlocks,
|
12
|
-
switchBlockInspectorTab,
|
13
|
-
} from '@wordpress/e2e-test-utils';
|
14
|
-
|
15
|
-
async function openListViewSidebar() {
|
16
|
-
await pressKeyWithModifier( 'access', 'o' );
|
17
|
-
await page.waitForSelector( '.block-editor-list-view-leaf.is-selected' );
|
18
|
-
}
|
19
|
-
|
20
|
-
async function tabToColumnsControl() {
|
21
|
-
let isColumnsControl = false;
|
22
|
-
do {
|
23
|
-
await page.keyboard.press( 'Tab' );
|
24
|
-
|
25
|
-
const isBlockInspectorTab = await page.evaluate( () => {
|
26
|
-
const activeElement = document.activeElement;
|
27
|
-
return (
|
28
|
-
activeElement.getAttribute( 'role' ) === 'tab' &&
|
29
|
-
activeElement.attributes.getNamedItem( 'aria-label' ).value ===
|
30
|
-
'Styles'
|
31
|
-
);
|
32
|
-
} );
|
33
|
-
|
34
|
-
if ( isBlockInspectorTab ) {
|
35
|
-
await page.keyboard.press( 'ArrowRight' );
|
36
|
-
}
|
37
|
-
|
38
|
-
isColumnsControl = await page.evaluate( () => {
|
39
|
-
const activeElement = document.activeElement;
|
40
|
-
return (
|
41
|
-
activeElement.tagName === 'INPUT' &&
|
42
|
-
activeElement.attributes.getNamedItem( 'aria-label' ).value ===
|
43
|
-
'Columns'
|
44
|
-
);
|
45
|
-
} );
|
46
|
-
} while ( ! isColumnsControl );
|
47
|
-
}
|
48
|
-
|
49
|
-
describe( 'Navigating the block hierarchy', () => {
|
50
|
-
beforeEach( async () => {
|
51
|
-
await createNewPost();
|
52
|
-
} );
|
53
|
-
|
54
|
-
it( 'should navigate using the list view sidebar', async () => {
|
55
|
-
await insertBlock( 'Columns' );
|
56
|
-
await page.click( '[aria-label="Two columns; equal split"]' );
|
57
|
-
|
58
|
-
// Add a paragraph in the first column.
|
59
|
-
await page.keyboard.press( 'ArrowDown' ); // Navigate to inserter.
|
60
|
-
await page.keyboard.press( 'Enter' ); // Activate inserter.
|
61
|
-
// Wait for inserter results to appear and then insert a paragraph.
|
62
|
-
await page.waitForSelector(
|
63
|
-
'.block-editor-inserter__quick-inserter-results .editor-block-list-item-paragraph'
|
64
|
-
);
|
65
|
-
await page.click( '.editor-block-list-item-paragraph' );
|
66
|
-
await page.keyboard.type( 'First column' );
|
67
|
-
|
68
|
-
// Navigate to the columns blocks.
|
69
|
-
await page.click(
|
70
|
-
'.edit-post-header-toolbar__document-overview-toggle'
|
71
|
-
);
|
72
|
-
|
73
|
-
const firstColumnsBlockMenuItem = (
|
74
|
-
await getListViewBlocks( 'Columns' )
|
75
|
-
)[ 0 ];
|
76
|
-
await firstColumnsBlockMenuItem.click();
|
77
|
-
|
78
|
-
// Tweak the columns count.
|
79
|
-
await openDocumentSettingsSidebar();
|
80
|
-
await switchBlockInspectorTab( 'Settings' );
|
81
|
-
await page.focus(
|
82
|
-
'.block-editor-block-inspector [aria-label="Columns"][type="number"]'
|
83
|
-
);
|
84
|
-
await page.keyboard.down( 'Shift' );
|
85
|
-
await page.keyboard.press( 'ArrowLeft' );
|
86
|
-
await page.keyboard.up( 'Shift' );
|
87
|
-
await page.keyboard.type( '3' );
|
88
|
-
|
89
|
-
// Wait for the new column block to appear in the list view
|
90
|
-
// 5 = Columns, Column, Paragraph, Column, *Column*
|
91
|
-
await page.waitForSelector(
|
92
|
-
'tr.block-editor-list-view-leaf:nth-of-type(5)'
|
93
|
-
);
|
94
|
-
|
95
|
-
// Navigate to the last column block.
|
96
|
-
const lastColumnBlockMenuItem = (
|
97
|
-
await getListViewBlocks( 'Column' )
|
98
|
-
)[ 2 ];
|
99
|
-
await lastColumnBlockMenuItem.click();
|
100
|
-
|
101
|
-
// Insert text in the last column block.
|
102
|
-
await page.keyboard.press( 'ArrowDown' ); // Navigate to inserter.
|
103
|
-
await page.keyboard.press( 'Enter' ); // Activate inserter.
|
104
|
-
// Wait for inserter results to appear and then insert a paragraph.
|
105
|
-
await page.waitForSelector(
|
106
|
-
'.block-editor-inserter__quick-inserter-results .editor-block-list-item-paragraph'
|
107
|
-
);
|
108
|
-
await page.click( '.editor-block-list-item-paragraph' );
|
109
|
-
await page.keyboard.type( 'Third column' );
|
110
|
-
|
111
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
112
|
-
} );
|
113
|
-
|
114
|
-
it( 'should navigate block hierarchy using only the keyboard', async () => {
|
115
|
-
await insertBlock( 'Columns' );
|
116
|
-
await openDocumentSettingsSidebar();
|
117
|
-
await page.click( '[aria-label="Two columns; equal split"]' );
|
118
|
-
|
119
|
-
// Add a paragraph in the first column.
|
120
|
-
await page.keyboard.press( 'ArrowDown' ); // Navigate to inserter.
|
121
|
-
await page.keyboard.press( 'Enter' ); // Activate inserter.
|
122
|
-
// Wait for inserter results to appear and then insert a paragraph.
|
123
|
-
await page.waitForSelector(
|
124
|
-
'.block-editor-inserter__quick-inserter-results .editor-block-list-item-paragraph'
|
125
|
-
);
|
126
|
-
await page.click( '.editor-block-list-item-paragraph' );
|
127
|
-
await page.keyboard.type( 'First column' );
|
128
|
-
|
129
|
-
// Navigate to the columns blocks using the keyboard.
|
130
|
-
await openListViewSidebar();
|
131
|
-
await pressKeyTimes( 'ArrowUp', 2 );
|
132
|
-
await page.keyboard.press( 'Enter' );
|
133
|
-
|
134
|
-
// Move focus to the sidebar area.
|
135
|
-
await pressKeyWithModifier( 'ctrl', '`' );
|
136
|
-
await tabToColumnsControl();
|
137
|
-
|
138
|
-
// Tweak the columns count by increasing it by one.
|
139
|
-
await page.keyboard.press( 'ArrowRight' );
|
140
|
-
|
141
|
-
// Navigate to the third column in the columns block.
|
142
|
-
await pressKeyWithModifier( 'ctrlShift', '`' );
|
143
|
-
await pressKeyWithModifier( 'ctrlShift', '`' );
|
144
|
-
await pressKeyTimes( 'Tab', 4 );
|
145
|
-
await pressKeyTimes( 'ArrowDown', 4 );
|
146
|
-
await page.waitForSelector(
|
147
|
-
'.is-highlighted[aria-label="Block: Column (3 of 3)"]'
|
148
|
-
);
|
149
|
-
await page.keyboard.press( 'Enter' );
|
150
|
-
await page.waitForSelector( '.is-selected[data-type="core/column"]' );
|
151
|
-
|
152
|
-
// Insert text in the last column block.
|
153
|
-
await page.keyboard.press( 'ArrowDown' ); // Navigate to inserter.
|
154
|
-
await page.keyboard.press( 'Enter' ); // Activate inserter.
|
155
|
-
// Wait for inserter results to appear and then insert a paragraph.
|
156
|
-
await page.waitForSelector(
|
157
|
-
'.block-editor-inserter__quick-inserter-results .editor-block-list-item-paragraph'
|
158
|
-
);
|
159
|
-
await page.click( '.editor-block-list-item-paragraph' );
|
160
|
-
await page.keyboard.type( 'Third column' );
|
161
|
-
|
162
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
163
|
-
} );
|
164
|
-
|
165
|
-
it( 'should appear and function even without nested blocks', async () => {
|
166
|
-
const textString = 'You say goodbye';
|
167
|
-
|
168
|
-
await insertBlock( 'Paragraph' );
|
169
|
-
|
170
|
-
// Add content so there is a block in the hierarchy.
|
171
|
-
await page.keyboard.type( textString );
|
172
|
-
|
173
|
-
// Create an image block too.
|
174
|
-
await page.keyboard.press( 'Enter' );
|
175
|
-
await insertBlock( 'Image' );
|
176
|
-
|
177
|
-
// Return to first block.
|
178
|
-
await openListViewSidebar();
|
179
|
-
await page.keyboard.press( 'ArrowUp' );
|
180
|
-
await page.keyboard.press( 'Space' );
|
181
|
-
|
182
|
-
// Replace its content.
|
183
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
184
|
-
await page.keyboard.type( 'and I say hello' );
|
185
|
-
|
186
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
187
|
-
} );
|
188
|
-
|
189
|
-
it( 'should select the wrapper div for a group', async () => {
|
190
|
-
// Insert a group block.
|
191
|
-
await insertBlock( 'Group' );
|
192
|
-
// Select the default, selected Group layout from the variation picker.
|
193
|
-
await page.click(
|
194
|
-
'button[aria-label="Group: Gather blocks in a container."]'
|
195
|
-
);
|
196
|
-
// Insert some random blocks.
|
197
|
-
// The last block shouldn't be a textual block.
|
198
|
-
await page.click( '.block-list-appender .block-editor-inserter' );
|
199
|
-
const paragraphMenuItem = (
|
200
|
-
await page.$x( `//button//span[contains(text(), 'Paragraph')]` )
|
201
|
-
)[ 0 ];
|
202
|
-
await paragraphMenuItem.click();
|
203
|
-
await page.keyboard.type( 'just a paragraph' );
|
204
|
-
await insertBlock( 'Separator' );
|
205
|
-
|
206
|
-
// Check the Group block content.
|
207
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
208
|
-
|
209
|
-
// Unselect the blocks.
|
210
|
-
await page.click( '.editor-post-title' );
|
211
|
-
|
212
|
-
// Try selecting the group block using the Outline.
|
213
|
-
await page.click(
|
214
|
-
'.edit-post-header-toolbar__document-overview-toggle'
|
215
|
-
);
|
216
|
-
const groupMenuItem = ( await getListViewBlocks( 'Group' ) )[ 0 ];
|
217
|
-
await groupMenuItem.click();
|
218
|
-
|
219
|
-
// The group block's wrapper should be selected.
|
220
|
-
const isGroupBlockSelected = await page.evaluate(
|
221
|
-
() =>
|
222
|
-
document.activeElement.getAttribute( 'data-type' ) ===
|
223
|
-
'core/group'
|
224
|
-
);
|
225
|
-
expect( isGroupBlockSelected ).toBe( true );
|
226
|
-
} );
|
227
|
-
} );
|
@@ -1,104 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import { createNewPost, pressKeyWithModifier } from '@wordpress/e2e-test-utils';
|
5
|
-
|
6
|
-
async function isInBlockToolbar() {
|
7
|
-
return await page.evaluate( () => {
|
8
|
-
return !! document.activeElement.closest(
|
9
|
-
'.block-editor-block-toolbar'
|
10
|
-
);
|
11
|
-
} );
|
12
|
-
}
|
13
|
-
|
14
|
-
describe( 'Block Toolbar', () => {
|
15
|
-
beforeEach( async () => {
|
16
|
-
await createNewPost();
|
17
|
-
} );
|
18
|
-
|
19
|
-
describe( 'Contextual Toolbar', () => {
|
20
|
-
it( 'should not scroll page', async () => {
|
21
|
-
while (
|
22
|
-
await page.evaluate( () => {
|
23
|
-
const scrollable = wp.dom.getScrollContainer(
|
24
|
-
document.activeElement
|
25
|
-
);
|
26
|
-
return ! scrollable || scrollable.scrollTop === 0;
|
27
|
-
} )
|
28
|
-
) {
|
29
|
-
await page.keyboard.press( 'Enter' );
|
30
|
-
}
|
31
|
-
|
32
|
-
await page.keyboard.type( 'a' );
|
33
|
-
|
34
|
-
const scrollTopBefore = await page.evaluate(
|
35
|
-
() =>
|
36
|
-
wp.dom.getScrollContainer( document.activeElement )
|
37
|
-
.scrollTop
|
38
|
-
);
|
39
|
-
|
40
|
-
await pressKeyWithModifier( 'alt', 'F10' );
|
41
|
-
expect( await isInBlockToolbar() ).toBe( true );
|
42
|
-
|
43
|
-
const scrollTopAfter = await page.evaluate(
|
44
|
-
() =>
|
45
|
-
wp.dom.getScrollContainer( document.activeElement )
|
46
|
-
.scrollTop
|
47
|
-
);
|
48
|
-
|
49
|
-
expect( scrollTopBefore ).toBe( scrollTopAfter );
|
50
|
-
} );
|
51
|
-
|
52
|
-
it( 'navigates into the toolbar by keyboard (Alt+F10)', async () => {
|
53
|
-
// Assumes new post focus starts in title. Create first new
|
54
|
-
// block by Enter.
|
55
|
-
await page.keyboard.press( 'Enter' );
|
56
|
-
|
57
|
-
// [TEMPORARY]: A new paragraph is not technically a block yet
|
58
|
-
// until starting to type within it.
|
59
|
-
await page.keyboard.type( 'Example' );
|
60
|
-
|
61
|
-
// Upward.
|
62
|
-
await pressKeyWithModifier( 'alt', 'F10' );
|
63
|
-
|
64
|
-
expect( await isInBlockToolbar() ).toBe( true );
|
65
|
-
} );
|
66
|
-
} );
|
67
|
-
|
68
|
-
describe( 'Unified Toolbar', () => {
|
69
|
-
beforeEach( async () => {
|
70
|
-
// Enable unified toolbar
|
71
|
-
await page.evaluate( () => {
|
72
|
-
const { select, dispatch } = wp.data;
|
73
|
-
const isCurrentlyUnified =
|
74
|
-
select( 'core/edit-post' ).isFeatureActive(
|
75
|
-
'fixedToolbar'
|
76
|
-
);
|
77
|
-
if ( ! isCurrentlyUnified ) {
|
78
|
-
dispatch( 'core/edit-post' ).toggleFeature(
|
79
|
-
'fixedToolbar'
|
80
|
-
);
|
81
|
-
}
|
82
|
-
} );
|
83
|
-
} );
|
84
|
-
|
85
|
-
it( 'navigates into the toolbar by keyboard (Alt+F10)', async () => {
|
86
|
-
// Assumes new post focus starts in title. Create first new
|
87
|
-
// block by Enter.
|
88
|
-
await page.keyboard.press( 'Enter' );
|
89
|
-
|
90
|
-
// [TEMPORARY]: A new paragraph is not technically a block yet
|
91
|
-
// until starting to type within it.
|
92
|
-
await page.keyboard.type( 'Example' );
|
93
|
-
|
94
|
-
// Upward.
|
95
|
-
await pressKeyWithModifier( 'alt', 'F10' );
|
96
|
-
|
97
|
-
expect(
|
98
|
-
await page.evaluate( () => {
|
99
|
-
return document.activeElement.getAttribute( 'aria-label' );
|
100
|
-
} )
|
101
|
-
).toBe( 'Show document tools' );
|
102
|
-
} );
|
103
|
-
} );
|
104
|
-
} );
|