@wordpress/e2e-tests 7.2.0 → 7.4.0
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 +4 -0
- package/package.json +7 -7
- package/plugins/iframed-enqueue-block-assets/style.css +9 -0
- package/plugins/iframed-enqueue-block-assets.php +21 -0
- package/plugins/plugins-api/annotations-sidebar.js +2 -2
- package/plugins/plugins-api/sidebar.js +2 -2
- package/specs/editor/plugins/__snapshots__/plugins-api.test.js.snap +2 -2
- package/specs/editor/plugins/annotations.test.js +4 -4
- package/specs/editor/plugins/iframed-equeue-block-assets.test.js +44 -0
- package/specs/editor/plugins/iframed-inline-styles.test.js +1 -1
- package/specs/editor/plugins/plugins-api.test.js +6 -6
- package/specs/editor/various/navigable-toolbar.test.js +55 -29
- package/specs/editor/various/preferences.test.js +1 -1
- package/specs/site-editor/multi-entity-saving.test.js +1 -1
- package/specs/editor/blocks/pullquote.test.js +0 -47
- package/specs/editor/plugins/custom-post-types.test.js +0 -81
- package/specs/editor/various/__snapshots__/adding-patterns.test.js.snap +0 -11
- package/specs/editor/various/__snapshots__/keep-styles-on-block-transforms.test.js.snap +0 -29
- package/specs/editor/various/__snapshots__/undo.test.js.snap +0 -31
- package/specs/editor/various/adding-patterns.test.js +0 -22
- package/specs/editor/various/keep-styles-on-block-transforms.test.js +0 -64
- package/specs/editor/various/undo.test.js +0 -444
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/e2e-tests",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.4.0",
|
4
4
|
"description": "End-To-End (E2E) tests for WordPress.",
|
5
5
|
"author": "The WordPress Contributors",
|
6
6
|
"license": "GPL-2.0-or-later",
|
@@ -23,11 +23,11 @@
|
|
23
23
|
"node": ">=14"
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
|
-
"@wordpress/e2e-test-utils": "^10.
|
27
|
-
"@wordpress/jest-console": "^7.
|
28
|
-
"@wordpress/jest-puppeteer-axe": "^6.
|
29
|
-
"@wordpress/scripts": "^26.
|
30
|
-
"@wordpress/url": "^3.
|
26
|
+
"@wordpress/e2e-test-utils": "^10.4.0",
|
27
|
+
"@wordpress/jest-console": "^7.4.0",
|
28
|
+
"@wordpress/jest-puppeteer-axe": "^6.4.0",
|
29
|
+
"@wordpress/scripts": "^26.4.0",
|
30
|
+
"@wordpress/url": "^3.34.0",
|
31
31
|
"chalk": "^4.0.0",
|
32
32
|
"expect-puppeteer": "^4.4.0",
|
33
33
|
"filenamify": "^4.2.0",
|
@@ -45,5 +45,5 @@
|
|
45
45
|
"publishConfig": {
|
46
46
|
"access": "public"
|
47
47
|
},
|
48
|
-
"gitHead": "
|
48
|
+
"gitHead": "e936127e1e13881f1a940b7bd1593a9e500147f3"
|
49
49
|
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* Plugin Name: Gutenberg Test Iframed enqueue_block_assets
|
4
|
+
* Plugin URI: https://github.com/WordPress/gutenberg
|
5
|
+
* Author: Gutenberg Team
|
6
|
+
*
|
7
|
+
* @package gutenberg-test-iframed-iframed-enqueue-block-assets
|
8
|
+
*/
|
9
|
+
|
10
|
+
add_action(
|
11
|
+
'enqueue_block_assets',
|
12
|
+
function() {
|
13
|
+
wp_enqueue_style(
|
14
|
+
'iframed-enqueue-block-assets',
|
15
|
+
plugin_dir_url( __FILE__ ) . 'iframed-enqueue-block-assets/style.css',
|
16
|
+
array(),
|
17
|
+
filemtime( plugin_dir_path( __FILE__ ) . 'iframed-enqueue-block-assets/style.css' )
|
18
|
+
);
|
19
|
+
wp_add_inline_style( 'iframed-enqueue-block-assets', 'body{padding:20px!important}' );
|
20
|
+
}
|
21
|
+
);
|
@@ -94,7 +94,7 @@
|
|
94
94
|
PluginSidebar,
|
95
95
|
{
|
96
96
|
name: 'annotations-sidebar',
|
97
|
-
title: __( 'Annotations
|
97
|
+
title: __( 'Annotations' ),
|
98
98
|
},
|
99
99
|
el( SidebarContents, {} )
|
100
100
|
),
|
@@ -103,7 +103,7 @@
|
|
103
103
|
{
|
104
104
|
target: 'annotations-sidebar',
|
105
105
|
},
|
106
|
-
__( 'Annotations
|
106
|
+
__( 'Annotations' )
|
107
107
|
)
|
108
108
|
);
|
109
109
|
}
|
@@ -70,7 +70,7 @@
|
|
70
70
|
PluginSidebar,
|
71
71
|
{
|
72
72
|
name: 'title-sidebar',
|
73
|
-
title: __( 'Plugin
|
73
|
+
title: __( 'Plugin title' ),
|
74
74
|
},
|
75
75
|
el( SidebarContents, {} )
|
76
76
|
),
|
@@ -79,7 +79,7 @@
|
|
79
79
|
{
|
80
80
|
target: 'title-sidebar',
|
81
81
|
},
|
82
|
-
__( 'Plugin
|
82
|
+
__( 'Plugin more menu title' )
|
83
83
|
)
|
84
84
|
);
|
85
85
|
}
|
@@ -2,6 +2,6 @@
|
|
2
2
|
|
3
3
|
exports[`Using Plugins API Document Setting Custom Panel Should render a custom panel inside Document Setting sidebar 1`] = `"My Custom Panel"`;
|
4
4
|
|
5
|
-
exports[`Using Plugins API Sidebar Medium screen Should open plugins sidebar using More Menu item and render content 1`] = `"<div class="components-panel__header interface-complementary-area-header__small"><span class="interface-complementary-area-header__small-title">(no title)</span><button type="button" class="components-button has-icon" aria-label="Close plugin"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"></path></svg></button></div><div class="components-panel__header interface-complementary-area-header" tabindex="-1"><strong>Plugin
|
5
|
+
exports[`Using Plugins API Sidebar Medium screen Should open plugins sidebar using More Menu item and render content 1`] = `"<div class="components-panel__header interface-complementary-area-header__small"><span class="interface-complementary-area-header__small-title">(no title)</span><button type="button" class="components-button has-icon" aria-label="Close plugin"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"></path></svg></button></div><div class="components-panel__header interface-complementary-area-header" tabindex="-1"><strong>Plugin title</strong><button type="button" aria-pressed="true" aria-expanded="true" class="components-button interface-complementary-area__pin-unpin-item is-pressed has-icon" aria-label="Unpin from toolbar"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"></path></svg></button><button type="button" class="components-button has-icon" aria-label="Close plugin"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"></path></svg></button></div><div class="components-panel"><div class="components-panel__body sidebar-title-plugin-panel is-opened"><div class="components-panel__row"><label for="title-plain-text">Title:</label><textarea class="block-editor-plain-text" id="title-plain-text" placeholder="(no title)" rows="1" style="overflow: hidden; overflow-wrap: break-word; resize: none; height: 18px;"></textarea></div><div class="components-panel__row"><button type="button" class="components-button is-primary">Reset</button></div></div></div>"`;
|
6
6
|
|
7
|
-
exports[`Using Plugins API Sidebar Should open plugins sidebar using More Menu item and render content 1`] = `"<div class="components-panel__header interface-complementary-area-header__small"><span class="interface-complementary-area-header__small-title">(no title)</span><button type="button" class="components-button has-icon" aria-label="Close plugin"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"></path></svg></button></div><div class="components-panel__header interface-complementary-area-header" tabindex="-1"><strong>Plugin
|
7
|
+
exports[`Using Plugins API Sidebar Should open plugins sidebar using More Menu item and render content 1`] = `"<div class="components-panel__header interface-complementary-area-header__small"><span class="interface-complementary-area-header__small-title">(no title)</span><button type="button" class="components-button has-icon" aria-label="Close plugin"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"></path></svg></button></div><div class="components-panel__header interface-complementary-area-header" tabindex="-1"><strong>Plugin title</strong><button type="button" aria-pressed="true" aria-expanded="true" class="components-button interface-complementary-area__pin-unpin-item is-pressed has-icon" aria-label="Unpin from toolbar"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"></path></svg></button><button type="button" class="components-button has-icon" aria-label="Close plugin"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"></path></svg></button></div><div class="components-panel"><div class="components-panel__body sidebar-title-plugin-panel is-opened"><div class="components-panel__row"><label for="title-plain-text">Title:</label><textarea class="block-editor-plain-text" id="title-plain-text" placeholder="(no title)" rows="1" style="overflow: hidden; overflow-wrap: break-word; resize: none; height: 18px;"></textarea></div><div class="components-panel__row"><button type="button" class="components-button is-primary">Reset</button></div></div></div>"`;
|
@@ -100,7 +100,7 @@ describe( 'Annotations', () => {
|
|
100
100
|
it( 'allows a block to be annotated', async () => {
|
101
101
|
await page.keyboard.type( 'Title' + '\n' + 'Paragraph to annotate' );
|
102
102
|
|
103
|
-
await clickOnMoreMenuItem( 'Annotations
|
103
|
+
await clickOnMoreMenuItem( 'Annotations' );
|
104
104
|
|
105
105
|
let annotations = await page.$$( ANNOTATIONS_SELECTOR );
|
106
106
|
expect( annotations ).toHaveLength( 0 );
|
@@ -128,7 +128,7 @@ describe( 'Annotations', () => {
|
|
128
128
|
|
129
129
|
it( 'keeps the cursor in the same location when applying annotation', async () => {
|
130
130
|
await page.keyboard.type( 'Title' + '\n' + 'ABC' );
|
131
|
-
await clickOnMoreMenuItem( 'Annotations
|
131
|
+
await clickOnMoreMenuItem( 'Annotations' );
|
132
132
|
|
133
133
|
await annotateFirstBlock( 1, 2 );
|
134
134
|
|
@@ -146,7 +146,7 @@ describe( 'Annotations', () => {
|
|
146
146
|
|
147
147
|
it( 'moves when typing before it', async () => {
|
148
148
|
await page.keyboard.type( 'Title' + '\n' + 'ABC' );
|
149
|
-
await clickOnMoreMenuItem( 'Annotations
|
149
|
+
await clickOnMoreMenuItem( 'Annotations' );
|
150
150
|
|
151
151
|
await annotateFirstBlock( 1, 2 );
|
152
152
|
|
@@ -168,7 +168,7 @@ describe( 'Annotations', () => {
|
|
168
168
|
|
169
169
|
it( 'grows when typing inside it', async () => {
|
170
170
|
await page.keyboard.type( 'Title' + '\n' + 'ABC' );
|
171
|
-
await clickOnMoreMenuItem( 'Annotations
|
171
|
+
await clickOnMoreMenuItem( 'Annotations' );
|
172
172
|
|
173
173
|
await annotateFirstBlock( 1, 2 );
|
174
174
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/**
|
2
|
+
* WordPress dependencies
|
3
|
+
*/
|
4
|
+
import {
|
5
|
+
activatePlugin,
|
6
|
+
createNewPost,
|
7
|
+
deactivatePlugin,
|
8
|
+
canvas,
|
9
|
+
activateTheme,
|
10
|
+
} from '@wordpress/e2e-test-utils';
|
11
|
+
|
12
|
+
async function getComputedStyle( context, selector, property ) {
|
13
|
+
return await context.evaluate(
|
14
|
+
( sel, prop ) =>
|
15
|
+
window.getComputedStyle( document.querySelector( sel ) )[ prop ],
|
16
|
+
selector,
|
17
|
+
property
|
18
|
+
);
|
19
|
+
}
|
20
|
+
|
21
|
+
describe( 'iframed inline styles', () => {
|
22
|
+
beforeEach( async () => {
|
23
|
+
// Activate the empty theme (block based theme), which is iframed.
|
24
|
+
await activateTheme( 'emptytheme' );
|
25
|
+
await activatePlugin( 'gutenberg-test-iframed-enqueue_block_assets' );
|
26
|
+
await createNewPost();
|
27
|
+
} );
|
28
|
+
|
29
|
+
afterEach( async () => {
|
30
|
+
await deactivatePlugin( 'gutenberg-test-iframed-enqueue_block_assets' );
|
31
|
+
await activateTheme( 'twentytwentyone' );
|
32
|
+
} );
|
33
|
+
|
34
|
+
it( 'should load styles added through enqueue_block_assets', async () => {
|
35
|
+
// Check stylesheet.
|
36
|
+
expect(
|
37
|
+
await getComputedStyle( canvas(), 'body', 'background-color' )
|
38
|
+
).toBe( 'rgb(33, 117, 155)' );
|
39
|
+
// Check inline style.
|
40
|
+
expect( await getComputedStyle( canvas(), 'body', 'padding' ) ).toBe(
|
41
|
+
'20px'
|
42
|
+
);
|
43
|
+
} );
|
44
|
+
} );
|
@@ -32,7 +32,7 @@ describe( 'iframed inline styles', () => {
|
|
32
32
|
} );
|
33
33
|
|
34
34
|
// Skip flaky test. See https://github.com/WordPress/gutenberg/issues/35172
|
35
|
-
it( 'should load inline styles in iframe', async () => {
|
35
|
+
it.skip( 'should load inline styles in iframe', async () => {
|
36
36
|
await insertBlock( 'Iframed Inline Styles' );
|
37
37
|
|
38
38
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
@@ -69,10 +69,10 @@ describe( 'Using Plugins API', () => {
|
|
69
69
|
|
70
70
|
describe( 'Sidebar', () => {
|
71
71
|
const SIDEBAR_PINNED_ITEM_BUTTON =
|
72
|
-
'.interface-pinned-items button[aria-label="Plugin
|
72
|
+
'.interface-pinned-items button[aria-label="Plugin title"]';
|
73
73
|
const SIDEBAR_PANEL_SELECTOR = '.sidebar-title-plugin-panel';
|
74
74
|
it( 'Should open plugins sidebar using More Menu item and render content', async () => {
|
75
|
-
await clickOnMoreMenuItem( 'Plugin
|
75
|
+
await clickOnMoreMenuItem( 'Plugin more menu title' );
|
76
76
|
|
77
77
|
const pluginSidebarContent = await page.$eval(
|
78
78
|
'.edit-post-sidebar',
|
@@ -105,7 +105,7 @@ describe( 'Using Plugins API', () => {
|
|
105
105
|
await page.reload();
|
106
106
|
await page.waitForSelector( '.edit-post-layout' );
|
107
107
|
expect( await page.$( SIDEBAR_PINNED_ITEM_BUTTON ) ).toBeNull();
|
108
|
-
await clickOnMoreMenuItem( 'Plugin
|
108
|
+
await clickOnMoreMenuItem( 'Plugin more menu title' );
|
109
109
|
await page.click( 'button[aria-label="Pin to toolbar"]' );
|
110
110
|
expect( await page.$( SIDEBAR_PINNED_ITEM_BUTTON ) ).not.toBeNull();
|
111
111
|
await page.reload();
|
@@ -114,12 +114,12 @@ describe( 'Using Plugins API', () => {
|
|
114
114
|
} );
|
115
115
|
|
116
116
|
it( 'Should close plugins sidebar using More Menu item', async () => {
|
117
|
-
await clickOnMoreMenuItem( 'Plugin
|
117
|
+
await clickOnMoreMenuItem( 'Plugin more menu title' );
|
118
118
|
|
119
119
|
const pluginSidebarOpened = await page.$( '.edit-post-sidebar' );
|
120
120
|
expect( pluginSidebarOpened ).not.toBeNull();
|
121
121
|
|
122
|
-
await clickOnMoreMenuItem( 'Plugin
|
122
|
+
await clickOnMoreMenuItem( 'Plugin more menu title' );
|
123
123
|
|
124
124
|
const pluginSidebarClosed = await page.$( '.edit-post-sidebar' );
|
125
125
|
expect( pluginSidebarClosed ).toBeNull();
|
@@ -135,7 +135,7 @@ describe( 'Using Plugins API', () => {
|
|
135
135
|
} );
|
136
136
|
|
137
137
|
it( 'Should open plugins sidebar using More Menu item and render content', async () => {
|
138
|
-
await clickOnMoreMenuItem( 'Plugin
|
138
|
+
await clickOnMoreMenuItem( 'Plugin more menu title' );
|
139
139
|
|
140
140
|
const pluginSidebarContent = await page.$eval(
|
141
141
|
'.edit-post-sidebar',
|
@@ -11,38 +11,12 @@ async function isInBlockToolbar() {
|
|
11
11
|
} );
|
12
12
|
}
|
13
13
|
|
14
|
-
describe
|
15
|
-
[ 'unified', true ],
|
16
|
-
[ 'contextual', false ],
|
17
|
-
] )( 'block toolbar (%s: %p)', ( label, isUnifiedToolbar ) => {
|
14
|
+
describe( 'Block Toolbar', () => {
|
18
15
|
beforeEach( async () => {
|
19
16
|
await createNewPost();
|
20
|
-
|
21
|
-
await page.evaluate( ( _isUnifiedToolbar ) => {
|
22
|
-
const { select, dispatch } = wp.data;
|
23
|
-
const isCurrentlyUnified =
|
24
|
-
select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' );
|
25
|
-
if ( isCurrentlyUnified !== _isUnifiedToolbar ) {
|
26
|
-
dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' );
|
27
|
-
}
|
28
|
-
}, isUnifiedToolbar );
|
29
17
|
} );
|
30
18
|
|
31
|
-
|
32
|
-
// Assumes new post focus starts in title. Create first new
|
33
|
-
// block by Enter.
|
34
|
-
await page.keyboard.press( 'Enter' );
|
35
|
-
|
36
|
-
// [TEMPORARY]: A new paragraph is not technically a block yet
|
37
|
-
// until starting to type within it.
|
38
|
-
await page.keyboard.type( 'Example' );
|
39
|
-
|
40
|
-
// Upward.
|
41
|
-
await pressKeyWithModifier( 'alt', 'F10' );
|
42
|
-
expect( await isInBlockToolbar() ).toBe( true );
|
43
|
-
} );
|
44
|
-
|
45
|
-
if ( ! isUnifiedToolbar ) {
|
19
|
+
describe( 'Contextual Toolbar', () => {
|
46
20
|
it( 'should not scroll page', async () => {
|
47
21
|
while (
|
48
22
|
await page.evaluate( () => {
|
@@ -74,5 +48,57 @@ describe.each( [
|
|
74
48
|
|
75
49
|
expect( scrollTopBefore ).toBe( scrollTopAfter );
|
76
50
|
} );
|
77
|
-
|
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
|
+
} );
|
78
104
|
} );
|
@@ -46,7 +46,7 @@ describe( 'preferences', () => {
|
|
46
46
|
|
47
47
|
// Dismiss.
|
48
48
|
await page.click(
|
49
|
-
'.edit-post-sidebar__panel-tabs [aria-label="Close
|
49
|
+
'.edit-post-sidebar__panel-tabs [aria-label="Close Settings"]'
|
50
50
|
);
|
51
51
|
expect( await getActiveSidebarTabText() ).toBe( null );
|
52
52
|
|
@@ -275,7 +275,7 @@ describe( 'Multi-entity save flow', () => {
|
|
275
275
|
'//a[contains(@class, "block-editor-list-view-block-select-button")][contains(., "header")]'
|
276
276
|
);
|
277
277
|
headerTemplatePartListViewButton.click();
|
278
|
-
await page.click( 'button[aria-label="Close
|
278
|
+
await page.click( 'button[aria-label="Close"]' );
|
279
279
|
|
280
280
|
// Insert something to dirty the editor.
|
281
281
|
await insertBlock( 'Paragraph' );
|
@@ -1,47 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
clickBlockAppender,
|
6
|
-
getEditedPostContent,
|
7
|
-
createNewPost,
|
8
|
-
transformBlockTo,
|
9
|
-
} from '@wordpress/e2e-test-utils';
|
10
|
-
|
11
|
-
describe( 'Quote', () => {
|
12
|
-
beforeEach( async () => {
|
13
|
-
await createNewPost();
|
14
|
-
} );
|
15
|
-
|
16
|
-
it( 'can be created by converting a quote and converted back to quote', async () => {
|
17
|
-
await clickBlockAppender();
|
18
|
-
await page.keyboard.type( 'test' );
|
19
|
-
await transformBlockTo( 'Quote' );
|
20
|
-
|
21
|
-
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
22
|
-
"<!-- wp:quote -->
|
23
|
-
<blockquote class="wp-block-quote"><!-- wp:paragraph -->
|
24
|
-
<p>test</p>
|
25
|
-
<!-- /wp:paragraph --></blockquote>
|
26
|
-
<!-- /wp:quote -->"
|
27
|
-
` );
|
28
|
-
|
29
|
-
await transformBlockTo( 'Pullquote' );
|
30
|
-
|
31
|
-
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
32
|
-
"<!-- wp:pullquote -->
|
33
|
-
<figure class="wp-block-pullquote"><blockquote><p>test</p></blockquote></figure>
|
34
|
-
<!-- /wp:pullquote -->"
|
35
|
-
` );
|
36
|
-
|
37
|
-
await transformBlockTo( 'Quote' );
|
38
|
-
|
39
|
-
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
40
|
-
"<!-- wp:quote -->
|
41
|
-
<blockquote class="wp-block-quote"><!-- wp:paragraph -->
|
42
|
-
<p>test</p>
|
43
|
-
<!-- /wp:paragraph --></blockquote>
|
44
|
-
<!-- /wp:quote -->"
|
45
|
-
` );
|
46
|
-
} );
|
47
|
-
} );
|
@@ -1,81 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
createNewPost,
|
7
|
-
deactivatePlugin,
|
8
|
-
publishPost,
|
9
|
-
findSidebarPanelWithTitle,
|
10
|
-
clickBlockAppender,
|
11
|
-
} from '@wordpress/e2e-test-utils';
|
12
|
-
|
13
|
-
const openPageAttributesPanel = async () => {
|
14
|
-
const openButton = await findSidebarPanelWithTitle( 'Page Attributes' );
|
15
|
-
|
16
|
-
// Get the classes from the panel.
|
17
|
-
const buttonClassName = await (
|
18
|
-
await openButton.getProperty( 'className' )
|
19
|
-
).jsonValue();
|
20
|
-
|
21
|
-
// Open the panel if needed.
|
22
|
-
if ( -1 === buttonClassName.indexOf( 'is-opened' ) ) {
|
23
|
-
await openButton.click();
|
24
|
-
}
|
25
|
-
};
|
26
|
-
|
27
|
-
describe( 'Test Custom Post Types', () => {
|
28
|
-
beforeAll( async () => {
|
29
|
-
await activatePlugin( 'gutenberg-test-custom-post-types' );
|
30
|
-
} );
|
31
|
-
|
32
|
-
afterAll( async () => {
|
33
|
-
await deactivatePlugin( 'gutenberg-test-custom-post-types' );
|
34
|
-
} );
|
35
|
-
|
36
|
-
it( 'should be able to create an hierarchical post without title support', async () => {
|
37
|
-
const PARENT_PAGE_INPUT =
|
38
|
-
'.editor-page-attributes__parent input:not([disabled])';
|
39
|
-
const SUGGESTION =
|
40
|
-
'.editor-page-attributes__parent .components-form-token-field__suggestion:first-child';
|
41
|
-
|
42
|
-
// Create a parent post.
|
43
|
-
await createNewPost( { postType: 'hierar-no-title' } );
|
44
|
-
await clickBlockAppender();
|
45
|
-
await page.keyboard.type( 'Parent Post' );
|
46
|
-
await publishPost();
|
47
|
-
// Create a post that is a child of the previously created post.
|
48
|
-
await createNewPost( { postType: 'hierar-no-title' } );
|
49
|
-
await openPageAttributesPanel();
|
50
|
-
await page.waitForSelector( PARENT_PAGE_INPUT );
|
51
|
-
await page.click( PARENT_PAGE_INPUT );
|
52
|
-
await page.waitForSelector( SUGGESTION );
|
53
|
-
const optionToSelect = await page.$( SUGGESTION );
|
54
|
-
const valueToSelect = await page.$eval(
|
55
|
-
SUGGESTION,
|
56
|
-
( element ) => element.textContent
|
57
|
-
);
|
58
|
-
await optionToSelect.click();
|
59
|
-
await clickBlockAppender();
|
60
|
-
await page.keyboard.type( 'Child Post' );
|
61
|
-
await publishPost();
|
62
|
-
// Reload the child post and verify it is still correctly selected as a child post.
|
63
|
-
await page.reload();
|
64
|
-
await page.waitForSelector( PARENT_PAGE_INPUT );
|
65
|
-
// Wait for the list of suggestions to fetch
|
66
|
-
// There should be a better way to do that.
|
67
|
-
await page.waitForFunction(
|
68
|
-
( [ value, inputSelector ] ) =>
|
69
|
-
document.querySelector( inputSelector ).value === value,
|
70
|
-
{},
|
71
|
-
[ valueToSelect, PARENT_PAGE_INPUT ]
|
72
|
-
);
|
73
|
-
} );
|
74
|
-
it( 'should create a cpt with a legacy block in its template without WSOD', async () => {
|
75
|
-
await createNewPost( { postType: 'leg_block_in_tpl' } );
|
76
|
-
await clickBlockAppender();
|
77
|
-
await page.keyboard.type( 'Hello there' );
|
78
|
-
await page.waitForSelector( '[data-type="core/embed"]' );
|
79
|
-
await publishPost();
|
80
|
-
} );
|
81
|
-
} );
|
@@ -1,11 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`adding patterns should insert a block pattern 1`] = `
|
4
|
-
"<!-- wp:social-links {"customIconColor":"#ffffff","iconColorValue":"#ffffff","customIconBackgroundColor":"#3962e3","iconBackgroundColorValue":"#3962e3","className":"has-icon-color"} -->
|
5
|
-
<ul class="wp-block-social-links has-icon-color has-icon-background-color"><!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->
|
6
|
-
|
7
|
-
<!-- wp:social-link {"url":"#","service":"chain"} /-->
|
8
|
-
|
9
|
-
<!-- wp:social-link {"url":"#","service":"mail"} /--></ul>
|
10
|
-
<!-- /wp:social-links -->"
|
11
|
-
`;
|
@@ -1,29 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`Keep styles on block transforms Should keep colors during a transform 1`] = `
|
4
|
-
"<!-- wp:paragraph {"textColor":"luminous-vivid-orange"} -->
|
5
|
-
<p class="has-luminous-vivid-orange-color has-text-color">Heading</p>
|
6
|
-
<!-- /wp:paragraph -->"
|
7
|
-
`;
|
8
|
-
|
9
|
-
exports[`Keep styles on block transforms Should keep the font size during a transform from multiple blocks into multiple blocks 1`] = `
|
10
|
-
"<!-- wp:heading {"fontSize":"large"} -->
|
11
|
-
<h2 class="wp-block-heading has-large-font-size">Line 1 to be made large</h2>
|
12
|
-
<!-- /wp:heading -->
|
13
|
-
|
14
|
-
<!-- wp:heading {"fontSize":"large"} -->
|
15
|
-
<h2 class="wp-block-heading has-large-font-size">Line 2 to be made large</h2>
|
16
|
-
<!-- /wp:heading -->
|
17
|
-
|
18
|
-
<!-- wp:heading {"fontSize":"large"} -->
|
19
|
-
<h2 class="wp-block-heading has-large-font-size">Line 3 to be made large</h2>
|
20
|
-
<!-- /wp:heading -->"
|
21
|
-
`;
|
22
|
-
|
23
|
-
exports[`Keep styles on block transforms Should not include styles in the group block when grouping a block 1`] = `
|
24
|
-
"<!-- wp:group {"layout":{"type":"constrained"}} -->
|
25
|
-
<div class="wp-block-group"><!-- wp:paragraph {"fontSize":"large"} -->
|
26
|
-
<p class="has-large-font-size">Line 1 to be made large</p>
|
27
|
-
<!-- /wp:paragraph --></div>
|
28
|
-
<!-- /wp:group -->"
|
29
|
-
`;
|
@@ -1,31 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`undo should immediately create an undo level on typing 1`] = `
|
4
|
-
"<!-- wp:paragraph -->
|
5
|
-
<p>1</p>
|
6
|
-
<!-- /wp:paragraph -->"
|
7
|
-
`;
|
8
|
-
|
9
|
-
exports[`undo should undo typing after a pause 1`] = `
|
10
|
-
"<!-- wp:paragraph -->
|
11
|
-
<p>before pause after pause</p>
|
12
|
-
<!-- /wp:paragraph -->"
|
13
|
-
`;
|
14
|
-
|
15
|
-
exports[`undo should undo typing after a pause 2`] = `
|
16
|
-
"<!-- wp:paragraph -->
|
17
|
-
<p>before pause</p>
|
18
|
-
<!-- /wp:paragraph -->"
|
19
|
-
`;
|
20
|
-
|
21
|
-
exports[`undo should undo typing after non input change 1`] = `
|
22
|
-
"<!-- wp:paragraph -->
|
23
|
-
<p>before keyboard <strong>after keyboard</strong></p>
|
24
|
-
<!-- /wp:paragraph -->"
|
25
|
-
`;
|
26
|
-
|
27
|
-
exports[`undo should undo typing after non input change 2`] = `
|
28
|
-
"<!-- wp:paragraph -->
|
29
|
-
<p>before keyboard </p>
|
30
|
-
<!-- /wp:paragraph -->"
|
31
|
-
`;
|
@@ -1,22 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
createNewPost,
|
6
|
-
insertPattern,
|
7
|
-
getEditedPostContent,
|
8
|
-
} from '@wordpress/e2e-test-utils';
|
9
|
-
|
10
|
-
/** @typedef {import('puppeteer-core').ElementHandle} ElementHandle */
|
11
|
-
|
12
|
-
describe( 'adding patterns', () => {
|
13
|
-
beforeEach( async () => {
|
14
|
-
await createNewPost();
|
15
|
-
} );
|
16
|
-
|
17
|
-
it( 'should insert a block pattern', async () => {
|
18
|
-
await insertPattern( 'Social links with a shared background color' );
|
19
|
-
|
20
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
21
|
-
} );
|
22
|
-
} );
|
@@ -1,64 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
clickBlockAppender,
|
6
|
-
createNewPost,
|
7
|
-
getEditedPostContent,
|
8
|
-
pressKeyWithModifier,
|
9
|
-
transformBlockTo,
|
10
|
-
} from '@wordpress/e2e-test-utils';
|
11
|
-
|
12
|
-
describe( 'Keep styles on block transforms', () => {
|
13
|
-
beforeEach( async () => {
|
14
|
-
await createNewPost();
|
15
|
-
} );
|
16
|
-
|
17
|
-
it( 'Should keep colors during a transform', async () => {
|
18
|
-
await clickBlockAppender();
|
19
|
-
await page.keyboard.type( '## Heading' );
|
20
|
-
|
21
|
-
const textColorButton = await page.waitForSelector(
|
22
|
-
'.block-editor-panel-color-gradient-settings__dropdown'
|
23
|
-
);
|
24
|
-
await textColorButton.click();
|
25
|
-
|
26
|
-
const colorButtonSelector = `//button[@aria-label='Color: Luminous vivid orange']`;
|
27
|
-
const [ colorButton ] = await page.$x( colorButtonSelector );
|
28
|
-
await colorButton.click();
|
29
|
-
await page.waitForXPath(
|
30
|
-
`${ colorButtonSelector }[@aria-pressed='true']`
|
31
|
-
);
|
32
|
-
await page.click( 'h2[data-type="core/heading"]' );
|
33
|
-
await transformBlockTo( 'Paragraph' );
|
34
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
35
|
-
} );
|
36
|
-
|
37
|
-
it( 'Should keep the font size during a transform from multiple blocks into multiple blocks', async () => {
|
38
|
-
// Create a paragraph block with some content.
|
39
|
-
await clickBlockAppender();
|
40
|
-
await page.keyboard.type( 'Line 1 to be made large' );
|
41
|
-
await page.keyboard.press( 'Enter' );
|
42
|
-
await page.keyboard.type( 'Line 2 to be made large' );
|
43
|
-
await page.keyboard.press( 'Enter' );
|
44
|
-
await page.keyboard.type( 'Line 3 to be made large' );
|
45
|
-
await pressKeyWithModifier( 'shift', 'ArrowUp' );
|
46
|
-
await pressKeyWithModifier( 'shift', 'ArrowUp' );
|
47
|
-
await page.click(
|
48
|
-
'[role="radiogroup"][aria-label="Font size"] [aria-label="Large"]'
|
49
|
-
);
|
50
|
-
await transformBlockTo( 'Heading' );
|
51
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
52
|
-
} );
|
53
|
-
|
54
|
-
it( 'Should not include styles in the group block when grouping a block', async () => {
|
55
|
-
// Create a paragraph block with some content.
|
56
|
-
await clickBlockAppender();
|
57
|
-
await page.keyboard.type( 'Line 1 to be made large' );
|
58
|
-
await page.click(
|
59
|
-
'[role="radiogroup"][aria-label="Font size"] [aria-label="Large"]'
|
60
|
-
);
|
61
|
-
await transformBlockTo( 'Group' );
|
62
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
63
|
-
} );
|
64
|
-
} );
|
@@ -1,444 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
clickBlockAppender,
|
6
|
-
getEditedPostContent,
|
7
|
-
createNewPost,
|
8
|
-
pressKeyWithModifier,
|
9
|
-
selectBlockByClientId,
|
10
|
-
getAllBlocks,
|
11
|
-
saveDraft,
|
12
|
-
publishPost,
|
13
|
-
} from '@wordpress/e2e-test-utils';
|
14
|
-
|
15
|
-
const getSelection = async () => {
|
16
|
-
return await page.evaluate( () => {
|
17
|
-
const selectedBlock = document.activeElement.closest( '.wp-block' );
|
18
|
-
const blocks = Array.from( document.querySelectorAll( '.wp-block' ) );
|
19
|
-
const blockIndex = blocks.indexOf( selectedBlock );
|
20
|
-
|
21
|
-
if ( blockIndex === -1 ) {
|
22
|
-
return {};
|
23
|
-
}
|
24
|
-
|
25
|
-
let editables;
|
26
|
-
|
27
|
-
if ( selectedBlock.getAttribute( 'contenteditable' ) ) {
|
28
|
-
editables = [ selectedBlock ];
|
29
|
-
} else {
|
30
|
-
editables = Array.from(
|
31
|
-
selectedBlock.querySelectorAll( '[contenteditable]' )
|
32
|
-
);
|
33
|
-
}
|
34
|
-
|
35
|
-
const editableIndex = editables.indexOf( document.activeElement );
|
36
|
-
const selection = window.getSelection();
|
37
|
-
|
38
|
-
if ( editableIndex === -1 || ! selection.rangeCount ) {
|
39
|
-
return { blockIndex };
|
40
|
-
}
|
41
|
-
|
42
|
-
const range = selection.getRangeAt( 0 );
|
43
|
-
const cloneStart = range.cloneRange();
|
44
|
-
const cloneEnd = range.cloneRange();
|
45
|
-
|
46
|
-
cloneStart.setStart( document.activeElement, 0 );
|
47
|
-
cloneEnd.setStart( document.activeElement, 0 );
|
48
|
-
|
49
|
-
/**
|
50
|
-
* Zero width non-breaking space, used as padding in the editable DOM
|
51
|
-
* tree when it is empty otherwise.
|
52
|
-
*/
|
53
|
-
const ZWNBSP = '\ufeff';
|
54
|
-
|
55
|
-
return {
|
56
|
-
blockIndex,
|
57
|
-
editableIndex,
|
58
|
-
startOffset: cloneStart.toString().replace( ZWNBSP, '' ).length,
|
59
|
-
endOffset: cloneEnd.toString().replace( ZWNBSP, '' ).length,
|
60
|
-
};
|
61
|
-
} );
|
62
|
-
};
|
63
|
-
|
64
|
-
describe( 'undo', () => {
|
65
|
-
beforeEach( async () => {
|
66
|
-
await createNewPost();
|
67
|
-
} );
|
68
|
-
|
69
|
-
it( 'should undo typing after a pause', async () => {
|
70
|
-
await clickBlockAppender();
|
71
|
-
|
72
|
-
await page.keyboard.type( 'before pause' );
|
73
|
-
await new Promise( ( resolve ) => setTimeout( resolve, 1000 ) );
|
74
|
-
await page.keyboard.type( ' after pause' );
|
75
|
-
|
76
|
-
const after = await getEditedPostContent();
|
77
|
-
|
78
|
-
expect( after ).toMatchSnapshot();
|
79
|
-
|
80
|
-
await pressKeyWithModifier( 'primary', 'z' );
|
81
|
-
|
82
|
-
const before = await getEditedPostContent();
|
83
|
-
|
84
|
-
expect( before ).toMatchSnapshot();
|
85
|
-
expect( await getSelection() ).toEqual( {
|
86
|
-
blockIndex: 1,
|
87
|
-
editableIndex: 0,
|
88
|
-
startOffset: 'before pause'.length,
|
89
|
-
endOffset: 'before pause'.length,
|
90
|
-
} );
|
91
|
-
|
92
|
-
await pressKeyWithModifier( 'primary', 'z' );
|
93
|
-
|
94
|
-
expect( await getEditedPostContent() ).toBe( '' );
|
95
|
-
expect( await getSelection() ).toEqual( {
|
96
|
-
blockIndex: 1,
|
97
|
-
editableIndex: 0,
|
98
|
-
startOffset: 0,
|
99
|
-
endOffset: 0,
|
100
|
-
} );
|
101
|
-
|
102
|
-
await pressKeyWithModifier( 'primaryShift', 'z' );
|
103
|
-
|
104
|
-
expect( await getEditedPostContent() ).toBe( before );
|
105
|
-
expect( await getSelection() ).toEqual( {
|
106
|
-
blockIndex: 1,
|
107
|
-
editableIndex: 0,
|
108
|
-
startOffset: 'before pause'.length,
|
109
|
-
endOffset: 'before pause'.length,
|
110
|
-
} );
|
111
|
-
|
112
|
-
await pressKeyWithModifier( 'primaryShift', 'z' );
|
113
|
-
|
114
|
-
expect( await getEditedPostContent() ).toBe( after );
|
115
|
-
expect( await getSelection() ).toEqual( {
|
116
|
-
blockIndex: 1,
|
117
|
-
editableIndex: 0,
|
118
|
-
startOffset: 'before pause after pause'.length,
|
119
|
-
endOffset: 'before pause after pause'.length,
|
120
|
-
} );
|
121
|
-
} );
|
122
|
-
|
123
|
-
it( 'should undo typing after non input change', async () => {
|
124
|
-
await clickBlockAppender();
|
125
|
-
|
126
|
-
await page.keyboard.type( 'before keyboard ' );
|
127
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
128
|
-
await page.keyboard.type( 'after keyboard' );
|
129
|
-
|
130
|
-
const after = await getEditedPostContent();
|
131
|
-
|
132
|
-
expect( after ).toMatchSnapshot();
|
133
|
-
|
134
|
-
await pressKeyWithModifier( 'primary', 'z' );
|
135
|
-
|
136
|
-
const before = await getEditedPostContent();
|
137
|
-
|
138
|
-
expect( before ).toMatchSnapshot();
|
139
|
-
expect( await getSelection() ).toEqual( {
|
140
|
-
blockIndex: 1,
|
141
|
-
editableIndex: 0,
|
142
|
-
startOffset: 'before keyboard '.length,
|
143
|
-
endOffset: 'before keyboard '.length,
|
144
|
-
} );
|
145
|
-
|
146
|
-
await pressKeyWithModifier( 'primary', 'z' );
|
147
|
-
|
148
|
-
expect( await getEditedPostContent() ).toBe( '' );
|
149
|
-
expect( await getSelection() ).toEqual( {
|
150
|
-
blockIndex: 1,
|
151
|
-
editableIndex: 0,
|
152
|
-
startOffset: 0,
|
153
|
-
endOffset: 0,
|
154
|
-
} );
|
155
|
-
|
156
|
-
await pressKeyWithModifier( 'primaryShift', 'z' );
|
157
|
-
|
158
|
-
expect( await getEditedPostContent() ).toBe( before );
|
159
|
-
expect( await getSelection() ).toEqual( {
|
160
|
-
blockIndex: 1,
|
161
|
-
editableIndex: 0,
|
162
|
-
startOffset: 'before keyboard '.length,
|
163
|
-
endOffset: 'before keyboard '.length,
|
164
|
-
} );
|
165
|
-
|
166
|
-
await pressKeyWithModifier( 'primaryShift', 'z' );
|
167
|
-
|
168
|
-
expect( await getEditedPostContent() ).toBe( after );
|
169
|
-
expect( await getSelection() ).toEqual( {
|
170
|
-
blockIndex: 1,
|
171
|
-
editableIndex: 0,
|
172
|
-
startOffset: 'before keyboard after keyboard'.length,
|
173
|
-
endOffset: 'before keyboard after keyboard'.length,
|
174
|
-
} );
|
175
|
-
} );
|
176
|
-
|
177
|
-
it( 'should undo bold', async () => {
|
178
|
-
await clickBlockAppender();
|
179
|
-
await page.keyboard.type( 'test' );
|
180
|
-
await saveDraft();
|
181
|
-
await page.reload();
|
182
|
-
await page.waitForSelector( '.edit-post-layout' );
|
183
|
-
await page.click( '[data-type="core/paragraph"]' );
|
184
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
185
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
186
|
-
await pressKeyWithModifier( 'primary', 'z' );
|
187
|
-
|
188
|
-
const visibleResult = await page.evaluate(
|
189
|
-
() => document.activeElement.innerHTML
|
190
|
-
);
|
191
|
-
expect( visibleResult ).toBe( 'test' );
|
192
|
-
} );
|
193
|
-
|
194
|
-
it( 'Should undo/redo to expected level intervals', async () => {
|
195
|
-
await clickBlockAppender();
|
196
|
-
|
197
|
-
const firstBlock = await getEditedPostContent();
|
198
|
-
|
199
|
-
await page.keyboard.type( 'This' );
|
200
|
-
|
201
|
-
const firstText = await getEditedPostContent();
|
202
|
-
|
203
|
-
await page.keyboard.press( 'Enter' );
|
204
|
-
|
205
|
-
const secondBlock = await getEditedPostContent();
|
206
|
-
|
207
|
-
await page.keyboard.type( 'is' );
|
208
|
-
|
209
|
-
const secondText = await getEditedPostContent();
|
210
|
-
|
211
|
-
await page.keyboard.press( 'Enter' );
|
212
|
-
|
213
|
-
const thirdBlock = await getEditedPostContent();
|
214
|
-
|
215
|
-
await page.keyboard.type( 'test' );
|
216
|
-
|
217
|
-
const thirdText = await getEditedPostContent();
|
218
|
-
|
219
|
-
await pressKeyWithModifier( 'primary', 'z' ); // Undo 3rd paragraph text.
|
220
|
-
|
221
|
-
expect( await getEditedPostContent() ).toBe( thirdBlock );
|
222
|
-
expect( await getSelection() ).toEqual( {
|
223
|
-
blockIndex: 3,
|
224
|
-
editableIndex: 0,
|
225
|
-
startOffset: 0,
|
226
|
-
endOffset: 0,
|
227
|
-
} );
|
228
|
-
|
229
|
-
await pressKeyWithModifier( 'primary', 'z' ); // Undo 3rd block.
|
230
|
-
|
231
|
-
expect( await getEditedPostContent() ).toBe( secondText );
|
232
|
-
expect( await getSelection() ).toEqual( {
|
233
|
-
blockIndex: 2,
|
234
|
-
editableIndex: 0,
|
235
|
-
startOffset: 'is'.length,
|
236
|
-
endOffset: 'is'.length,
|
237
|
-
} );
|
238
|
-
|
239
|
-
await pressKeyWithModifier( 'primary', 'z' ); // Undo 2nd paragraph text.
|
240
|
-
|
241
|
-
expect( await getEditedPostContent() ).toBe( secondBlock );
|
242
|
-
expect( await getSelection() ).toEqual( {
|
243
|
-
blockIndex: 2,
|
244
|
-
editableIndex: 0,
|
245
|
-
startOffset: 0,
|
246
|
-
endOffset: 0,
|
247
|
-
} );
|
248
|
-
|
249
|
-
await pressKeyWithModifier( 'primary', 'z' ); // Undo 2nd block.
|
250
|
-
|
251
|
-
expect( await getEditedPostContent() ).toBe( firstText );
|
252
|
-
expect( await getSelection() ).toEqual( {
|
253
|
-
blockIndex: 1,
|
254
|
-
editableIndex: 0,
|
255
|
-
startOffset: 'This'.length,
|
256
|
-
endOffset: 'This'.length,
|
257
|
-
} );
|
258
|
-
|
259
|
-
await pressKeyWithModifier( 'primary', 'z' ); // Undo 1st paragraph text.
|
260
|
-
|
261
|
-
expect( await getEditedPostContent() ).toBe( firstBlock );
|
262
|
-
expect( await getSelection() ).toEqual( {
|
263
|
-
blockIndex: 1,
|
264
|
-
editableIndex: 0,
|
265
|
-
startOffset: 0,
|
266
|
-
endOffset: 0,
|
267
|
-
} );
|
268
|
-
|
269
|
-
await pressKeyWithModifier( 'primary', 'z' ); // Undo 1st block.
|
270
|
-
|
271
|
-
expect( await getEditedPostContent() ).toBe( '' );
|
272
|
-
expect( await getSelection() ).toEqual( {} );
|
273
|
-
// After undoing every action, there should be no more undo history.
|
274
|
-
expect(
|
275
|
-
await page.$( '.editor-history__undo[aria-disabled="true"]' )
|
276
|
-
).not.toBeNull();
|
277
|
-
|
278
|
-
await pressKeyWithModifier( 'primaryShift', 'z' ); // Redo 1st block.
|
279
|
-
|
280
|
-
expect( await getEditedPostContent() ).toBe( firstBlock );
|
281
|
-
expect( await getSelection() ).toEqual( {
|
282
|
-
blockIndex: 1,
|
283
|
-
editableIndex: 0,
|
284
|
-
startOffset: 0,
|
285
|
-
endOffset: 0,
|
286
|
-
} );
|
287
|
-
// After redoing one change, the undo button should be enabled again.
|
288
|
-
expect(
|
289
|
-
await page.$( '.editor-history__undo[aria-disabled="true"]' )
|
290
|
-
).toBeNull();
|
291
|
-
|
292
|
-
await pressKeyWithModifier( 'primaryShift', 'z' ); // Redo 1st paragraph text.
|
293
|
-
|
294
|
-
expect( await getEditedPostContent() ).toBe( firstText );
|
295
|
-
expect( await getSelection() ).toEqual( {
|
296
|
-
blockIndex: 1,
|
297
|
-
editableIndex: 0,
|
298
|
-
startOffset: 'This'.length,
|
299
|
-
endOffset: 'This'.length,
|
300
|
-
} );
|
301
|
-
|
302
|
-
await pressKeyWithModifier( 'primaryShift', 'z' ); // Redo 2nd block.
|
303
|
-
|
304
|
-
expect( await getEditedPostContent() ).toBe( secondBlock );
|
305
|
-
expect( await getSelection() ).toEqual( {
|
306
|
-
blockIndex: 2,
|
307
|
-
editableIndex: 0,
|
308
|
-
startOffset: 0,
|
309
|
-
endOffset: 0,
|
310
|
-
} );
|
311
|
-
|
312
|
-
await pressKeyWithModifier( 'primaryShift', 'z' ); // Redo 2nd paragraph text.
|
313
|
-
|
314
|
-
expect( await getEditedPostContent() ).toBe( secondText );
|
315
|
-
expect( await getSelection() ).toEqual( {
|
316
|
-
blockIndex: 2,
|
317
|
-
editableIndex: 0,
|
318
|
-
startOffset: 'is'.length,
|
319
|
-
endOffset: 'is'.length,
|
320
|
-
} );
|
321
|
-
|
322
|
-
await pressKeyWithModifier( 'primaryShift', 'z' ); // Redo 3rd block.
|
323
|
-
|
324
|
-
expect( await getEditedPostContent() ).toBe( thirdBlock );
|
325
|
-
expect( await getSelection() ).toEqual( {
|
326
|
-
blockIndex: 3,
|
327
|
-
editableIndex: 0,
|
328
|
-
startOffset: 0,
|
329
|
-
endOffset: 0,
|
330
|
-
} );
|
331
|
-
|
332
|
-
await pressKeyWithModifier( 'primaryShift', 'z' ); // Redo 3rd paragraph text.
|
333
|
-
|
334
|
-
expect( await getEditedPostContent() ).toBe( thirdText );
|
335
|
-
expect( await getSelection() ).toEqual( {
|
336
|
-
blockIndex: 3,
|
337
|
-
editableIndex: 0,
|
338
|
-
startOffset: 'test'.length,
|
339
|
-
endOffset: 'test'.length,
|
340
|
-
} );
|
341
|
-
} );
|
342
|
-
|
343
|
-
it( 'should undo for explicit persistence editing post', async () => {
|
344
|
-
// Regression test: An issue had occurred where the creation of an
|
345
|
-
// explicit undo level would interfere with blocks values being synced
|
346
|
-
// correctly to the block editor.
|
347
|
-
//
|
348
|
-
// See: https://github.com/WordPress/gutenberg/issues/14950
|
349
|
-
|
350
|
-
// Issue is demonstrated from an edited post: create, save, and reload.
|
351
|
-
await clickBlockAppender();
|
352
|
-
await page.keyboard.type( 'original' );
|
353
|
-
await saveDraft();
|
354
|
-
await page.reload();
|
355
|
-
await page.waitForSelector( '.edit-post-layout' );
|
356
|
-
|
357
|
-
// Issue is demonstrated by forcing state merges (multiple inputs) on
|
358
|
-
// an existing text after a fresh reload.
|
359
|
-
await selectBlockByClientId( ( await getAllBlocks() )[ 0 ].clientId );
|
360
|
-
await page.keyboard.type( 'modified' );
|
361
|
-
|
362
|
-
// The issue is demonstrated after the one second delay to trigger the
|
363
|
-
// creation of an explicit undo persistence level.
|
364
|
-
await new Promise( ( resolve ) => setTimeout( resolve, 1000 ) );
|
365
|
-
|
366
|
-
await pressKeyWithModifier( 'primary', 'z' );
|
367
|
-
|
368
|
-
// Assert against the _visible_ content. Since editor state with the
|
369
|
-
// regression present was accurate, it would produce the correct
|
370
|
-
// content. The issue had manifested in the form of what was shown to
|
371
|
-
// the user since the blocks state failed to sync to block editor.
|
372
|
-
const visibleContent = await page.evaluate(
|
373
|
-
() => document.activeElement.textContent
|
374
|
-
);
|
375
|
-
expect( visibleContent ).toBe( 'original' );
|
376
|
-
} );
|
377
|
-
|
378
|
-
it( 'should not create undo levels when saving', async () => {
|
379
|
-
await clickBlockAppender();
|
380
|
-
await page.keyboard.type( '1' );
|
381
|
-
await saveDraft();
|
382
|
-
await pressKeyWithModifier( 'primary', 'z' );
|
383
|
-
|
384
|
-
expect( await getEditedPostContent() ).toBe( '' );
|
385
|
-
} );
|
386
|
-
|
387
|
-
it( 'should not create undo levels when publishing', async () => {
|
388
|
-
await clickBlockAppender();
|
389
|
-
await page.keyboard.type( '1' );
|
390
|
-
await publishPost();
|
391
|
-
await pressKeyWithModifier( 'primary', 'z' );
|
392
|
-
|
393
|
-
expect( await getEditedPostContent() ).toBe( '' );
|
394
|
-
} );
|
395
|
-
|
396
|
-
it( 'should immediately create an undo level on typing', async () => {
|
397
|
-
await clickBlockAppender();
|
398
|
-
|
399
|
-
await page.keyboard.type( '1' );
|
400
|
-
await saveDraft();
|
401
|
-
await page.reload();
|
402
|
-
await page.waitForSelector( '.edit-post-layout' );
|
403
|
-
|
404
|
-
// Expect undo button to be disabled.
|
405
|
-
expect(
|
406
|
-
await page.$( '.editor-history__undo[aria-disabled="true"]' )
|
407
|
-
).not.toBeNull();
|
408
|
-
|
409
|
-
await page.click( '[data-type="core/paragraph"]' );
|
410
|
-
|
411
|
-
await page.keyboard.type( '2' );
|
412
|
-
|
413
|
-
// Expect undo button to be enabled.
|
414
|
-
expect(
|
415
|
-
await page.$( '.editor-history__undo[aria-disabled="true"]' )
|
416
|
-
).toBeNull();
|
417
|
-
|
418
|
-
await pressKeyWithModifier( 'primary', 'z' );
|
419
|
-
|
420
|
-
// Expect "1".
|
421
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
422
|
-
} );
|
423
|
-
|
424
|
-
it( 'should be able to undo and redo when transient changes have been made and we update/publish', async () => {
|
425
|
-
// Typing consecutive characters in a `Paragraph` block updates the same
|
426
|
-
// block attribute as in the previous action and results in transient edits
|
427
|
-
// and skipping `undo` history steps.
|
428
|
-
const text = 'tonis';
|
429
|
-
await clickBlockAppender();
|
430
|
-
await page.keyboard.type( text );
|
431
|
-
await publishPost();
|
432
|
-
await pressKeyWithModifier( 'primary', 'z' );
|
433
|
-
expect( await getEditedPostContent() ).toBe( '' );
|
434
|
-
await page.waitForSelector(
|
435
|
-
'.editor-history__redo[aria-disabled="false"]'
|
436
|
-
);
|
437
|
-
await page.click( '.editor-history__redo[aria-disabled="false"]' );
|
438
|
-
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
439
|
-
"<!-- wp:paragraph -->
|
440
|
-
<p>tonis</p>
|
441
|
-
<!-- /wp:paragraph -->"
|
442
|
-
` );
|
443
|
-
} );
|
444
|
-
} );
|