@wordpress/e2e-tests 7.22.4 → 7.24.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 +9 -9
- package/plugins/interactive-blocks/directive-bind/render.php +1 -1
- package/plugins/interactive-blocks/directive-context/render.php +18 -0
- package/plugins/interactive-blocks/directive-context/view.js +14 -1
- package/plugins/interactive-blocks/directive-each/render.php +2 -2
- package/plugins/interactive-blocks/directive-each/view.js +1 -1
- package/plugins/interactive-blocks/directive-init/render.php +1 -1
- package/plugins/interactive-blocks/directive-key/render.php +1 -1
- package/plugins/interactive-blocks/directive-key/view.js +1 -1
- package/plugins/interactive-blocks/directive-on/render.php +1 -1
- package/plugins/interactive-blocks/directive-on-document/render.php +2 -2
- package/plugins/interactive-blocks/directive-on-window/render.php +1 -1
- package/plugins/interactive-blocks/directive-priorities/render.php +2 -2
- package/plugins/interactive-blocks/directive-run/render.php +2 -2
- package/plugins/interactive-blocks/directive-run/view.js +1 -1
- package/plugins/interactive-blocks/directive-style/render.php +1 -1
- package/plugins/interactive-blocks/directive-text/render.php +1 -1
- package/plugins/interactive-blocks/directive-watch/render.php +1 -1
- package/plugins/interactive-blocks/negation-operator/render.php +1 -1
- package/plugins/interactive-blocks/store-tag/render.php +1 -1
- package/plugins/interactive-blocks/tovdom/render.php +1 -1
- package/plugins/interactive-blocks/tovdom-islands/render.php +8 -8
- package/plugins/interactive-blocks/with-scope/render.php +1 -1
- package/specs/editor/various/autosave.test.js +0 -346
- package/specs/editor/various/change-detection.test.js +0 -417
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.24.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,13 +23,13 @@
|
|
23
23
|
"node": ">=14"
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
|
-
"@wordpress/e2e-test-utils": "^10.
|
27
|
-
"@wordpress/interactivity": "^5.0
|
28
|
-
"@wordpress/interactivity-router": "^1.
|
29
|
-
"@wordpress/jest-console": "^7.
|
30
|
-
"@wordpress/jest-puppeteer-axe": "^6.
|
31
|
-
"@wordpress/scripts": "^27.
|
32
|
-
"@wordpress/url": "^3.
|
26
|
+
"@wordpress/e2e-test-utils": "^10.24.0",
|
27
|
+
"@wordpress/interactivity": "^5.2.0",
|
28
|
+
"@wordpress/interactivity-router": "^1.3.0",
|
29
|
+
"@wordpress/jest-console": "^7.24.0",
|
30
|
+
"@wordpress/jest-puppeteer-axe": "^6.24.0",
|
31
|
+
"@wordpress/scripts": "^27.4.0",
|
32
|
+
"@wordpress/url": "^3.54.0",
|
33
33
|
"chalk": "^4.0.0",
|
34
34
|
"expect-puppeteer": "^4.4.0",
|
35
35
|
"filenamify": "^4.2.0",
|
@@ -46,5 +46,5 @@
|
|
46
46
|
"publishConfig": {
|
47
47
|
"access": "public"
|
48
48
|
},
|
49
|
-
"gitHead": "
|
49
|
+
"gitHead": "ac3c3e465a083081a86a4da6ee6fb817b41e5130"
|
50
50
|
}
|
@@ -117,6 +117,24 @@ wp_enqueue_script_module( 'directive-context-view' );
|
|
117
117
|
>
|
118
118
|
obj.prop6
|
119
119
|
</button>
|
120
|
+
<button
|
121
|
+
data-testid="child copy obj"
|
122
|
+
data-wp-on--click="actions.copyObj"
|
123
|
+
>
|
124
|
+
Copy obj
|
125
|
+
</button>
|
126
|
+
<div>
|
127
|
+
Is proxy preserved? <span
|
128
|
+
data-testid="is proxy preserved"
|
129
|
+
data-wp-text="state.isProxyPreserved"
|
130
|
+
></span>
|
131
|
+
</div>
|
132
|
+
<div>
|
133
|
+
Is proxy preserved on copy? <span
|
134
|
+
data-testid="is proxy preserved on copy"
|
135
|
+
data-wp-text="state.isProxyPreservedOnCopy"
|
136
|
+
></span>
|
137
|
+
</div>
|
120
138
|
</div>
|
121
139
|
<br />
|
122
140
|
|
@@ -12,6 +12,15 @@ store( 'directive-context', {
|
|
12
12
|
get selected() {
|
13
13
|
const { list, selected } = getContext();
|
14
14
|
return list.find( ( obj ) => obj === selected )?.text;
|
15
|
+
},
|
16
|
+
get isProxyPreserved() {
|
17
|
+
const ctx = getContext();
|
18
|
+
const pointer = ctx.obj;
|
19
|
+
return pointer === ctx.obj;
|
20
|
+
},
|
21
|
+
get isProxyPreservedOnCopy() {
|
22
|
+
const { obj, obj2 } = getContext();
|
23
|
+
return obj === obj2;
|
15
24
|
}
|
16
25
|
},
|
17
26
|
actions: {
|
@@ -34,13 +43,17 @@ store( 'directive-context', {
|
|
34
43
|
replaceObj() {
|
35
44
|
const ctx = getContext();
|
36
45
|
ctx.obj = { overwritten: true };
|
46
|
+
},
|
47
|
+
copyObj() {
|
48
|
+
const ctx = getContext();
|
49
|
+
ctx.obj2 = ctx.obj;
|
37
50
|
}
|
38
51
|
},
|
39
52
|
} );
|
40
53
|
|
41
54
|
const html = `
|
42
55
|
<div
|
43
|
-
data-wp-interactive=
|
56
|
+
data-wp-interactive="directive-context-navigate"
|
44
57
|
data-wp-router-region="navigation"
|
45
58
|
data-wp-context='{ "text": "second page", "text2": "second page" }'
|
46
59
|
>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
wp_enqueue_script_module( 'directive-each-view' );
|
9
9
|
?>
|
10
10
|
|
11
|
-
<div data-wp-interactive=
|
11
|
+
<div data-wp-interactive="directive-each">
|
12
12
|
<div data-testid="letters">
|
13
13
|
<template data-wp-each="state.letters">
|
14
14
|
<p data-wp-text="context.item" data-testid="item"></p>
|
@@ -220,7 +220,7 @@ wp_enqueue_script_module( 'directive-each-view' );
|
|
220
220
|
<hr>
|
221
221
|
|
222
222
|
<div
|
223
|
-
data-wp-interactive=
|
223
|
+
data-wp-interactive="directive-each"
|
224
224
|
data-wp-router-region="navigation-updated list"
|
225
225
|
data-wp-context='{ "list": [ "beta", "gamma", "delta" ] }'
|
226
226
|
data-testid="navigation-updated list"
|
@@ -157,7 +157,7 @@ store( 'directive-each', {
|
|
157
157
|
|
158
158
|
const html = `
|
159
159
|
<div
|
160
|
-
data-wp-interactive=
|
160
|
+
data-wp-interactive="directive-each"
|
161
161
|
data-wp-router-region="navigation-updated list"
|
162
162
|
data-wp-context='{ "list": [ "alpha", "beta", "gamma", "delta" ] }'
|
163
163
|
data-testid="navigation-updated list"
|
@@ -8,8 +8,8 @@
|
|
8
8
|
wp_enqueue_script_module( 'directive-on-document-view' );
|
9
9
|
?>
|
10
10
|
|
11
|
-
<div data-wp-interactive=
|
12
|
-
<button
|
11
|
+
<div data-wp-interactive="directive-on-document">
|
12
|
+
<button
|
13
13
|
data-testid="visibility"
|
14
14
|
data-wp-on--click="actions.visibilityHandler"
|
15
15
|
>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
wp_enqueue_script_module( 'directive-on-window-view' );
|
9
9
|
?>
|
10
10
|
|
11
|
-
<div data-wp-interactive=
|
11
|
+
<div data-wp-interactive="directive-on-window">
|
12
12
|
<button
|
13
13
|
data-wp-on--click="actions.visibilityHandler"
|
14
14
|
data-testid="visibility">
|
@@ -8,7 +8,7 @@
|
|
8
8
|
wp_enqueue_script_module( 'directive-priorities-view' );
|
9
9
|
?>
|
10
10
|
|
11
|
-
<div data-wp-interactive=
|
11
|
+
<div data-wp-interactive="directive-priorities">
|
12
12
|
<pre data-testid="execution order"></pre>
|
13
13
|
|
14
14
|
<!-- Element with test directives -->
|
@@ -25,5 +25,5 @@ wp_enqueue_script_module( 'directive-priorities-view' );
|
|
25
25
|
<!-- WARNING: the `div` with `data-wp-non-existent-directive` should remain
|
26
26
|
inline (i.e., without new line or blank characters in between) to
|
27
27
|
ensure it is the only child node. Otherwise, tests could fail. -->
|
28
|
-
<div data-wp-interactive=
|
28
|
+
<div data-wp-interactive="directive-priorities"><div data-wp-non-existent-directive></div></div>
|
29
29
|
</div>
|
@@ -9,7 +9,7 @@ wp_enqueue_script_module( 'directive-run-view' );
|
|
9
9
|
?>
|
10
10
|
|
11
11
|
<div
|
12
|
-
data-wp-interactive=
|
12
|
+
data-wp-interactive="directive-run"
|
13
13
|
data-wp-router-region='test-directive-run'
|
14
14
|
>
|
15
15
|
<div data-testid="hydrated" data-wp-text="state.isHydrated"></div>
|
@@ -24,7 +24,7 @@ wp_enqueue_script_module( 'directive-run-view' );
|
|
24
24
|
></div>
|
25
25
|
</div>
|
26
26
|
|
27
|
-
<div data-wp-interactive=
|
27
|
+
<div data-wp-interactive="directive-run" >
|
28
28
|
<button data-testid="toggle" data-wp-on--click="actions.toggle">
|
29
29
|
Toggle
|
30
30
|
</button>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
wp_enqueue_script_module( 'negation-operator-view' );
|
9
9
|
?>
|
10
10
|
|
11
|
-
<div data-wp-interactive=
|
11
|
+
<div data-wp-interactive="negation-operator">
|
12
12
|
<button
|
13
13
|
data-wp-on--click="actions.toggle"
|
14
14
|
data-testid="toggle active value"
|
@@ -14,7 +14,7 @@ $test_store_tag_counter = 'ok' === $attributes['condition'] ? 3 : 0;
|
|
14
14
|
$test_store_tag_double = $test_store_tag_counter * 2;
|
15
15
|
?>
|
16
16
|
|
17
|
-
<div data-wp-interactive=
|
17
|
+
<div data-wp-interactive="store-tag">
|
18
18
|
<div>
|
19
19
|
Counter:
|
20
20
|
<span
|
@@ -12,7 +12,7 @@ $src_cdata = $plugin_url . 'tovdom/cdata.js';
|
|
12
12
|
wp_enqueue_script_module( 'tovdom-view' );
|
13
13
|
?>
|
14
14
|
|
15
|
-
<div data-wp-interactive=
|
15
|
+
<div data-wp-interactive="tovdom">
|
16
16
|
<div data-testid="it should delete comments">
|
17
17
|
<!-- ##1## -->
|
18
18
|
<div data-testid="it should keep this node between comments">
|
@@ -15,7 +15,7 @@ wp_enqueue_script_module( 'tovdom-islands-view' );
|
|
15
15
|
</span>
|
16
16
|
</div>
|
17
17
|
|
18
|
-
<div data-wp-interactive=
|
18
|
+
<div data-wp-interactive="tovdom-islands">
|
19
19
|
<div data-wp-show-mock="state.falseValue">
|
20
20
|
<span data-testid="inside an island with json object">
|
21
21
|
This should not be shown because it is inside an island.
|
@@ -31,7 +31,7 @@ wp_enqueue_script_module( 'tovdom-islands-view' );
|
|
31
31
|
</div>
|
32
32
|
</div>
|
33
33
|
|
34
|
-
<div data-wp-interactive=
|
34
|
+
<div data-wp-interactive="tovdom-islands">
|
35
35
|
<div data-wp-ignore>
|
36
36
|
<div data-wp-show-mock="state.falseValue">
|
37
37
|
<span
|
@@ -44,8 +44,8 @@ wp_enqueue_script_module( 'tovdom-islands-view' );
|
|
44
44
|
</div>
|
45
45
|
</div>
|
46
46
|
|
47
|
-
<div data-wp-interactive=
|
48
|
-
<div data-wp-interactive=
|
47
|
+
<div data-wp-interactive="tovdom-islands">
|
48
|
+
<div data-wp-interactive="tovdom-islands">
|
49
49
|
<div
|
50
50
|
data-wp-show-mock="state.falseValue"
|
51
51
|
data-testid="island inside another island"
|
@@ -58,10 +58,10 @@ wp_enqueue_script_module( 'tovdom-islands-view' );
|
|
58
58
|
</div>
|
59
59
|
</div>
|
60
60
|
|
61
|
-
<div data-wp-interactive=
|
61
|
+
<div data-wp-interactive="tovdom-islands">
|
62
62
|
<div>
|
63
63
|
<div
|
64
|
-
data-wp-interactive=
|
64
|
+
data-wp-interactive="tovdom-islands"
|
65
65
|
data-wp-ignore
|
66
66
|
>
|
67
67
|
<div data-wp-show-mock="state.falseValue">
|
@@ -77,8 +77,8 @@ wp_enqueue_script_module( 'tovdom-islands-view' );
|
|
77
77
|
</div>
|
78
78
|
</div>
|
79
79
|
|
80
|
-
<div data-wp-interactive=
|
81
|
-
<div data-wp-interactive=
|
80
|
+
<div data-wp-interactive="tovdom-islands">
|
81
|
+
<div data-wp-interactive="something-new"></div>
|
82
82
|
<div data-wp-show-mock="state.falseValue">
|
83
83
|
<span data-testid="directive after different namespace">
|
84
84
|
The directive above should keep the `tovdom-island` namespace,
|
@@ -8,7 +8,7 @@
|
|
8
8
|
wp_enqueue_script_module( 'with-scope-view' );
|
9
9
|
?>
|
10
10
|
|
11
|
-
<div data-wp-interactive=
|
11
|
+
<div data-wp-interactive="with-scope" data-wp-context='{"asyncCounter": 0, "syncCounter": 0}' data-wp-init--a='callbacks.asyncInit' data-wp-init--b='callbacks.syncInit'>
|
12
12
|
<p data-wp-text="context.asyncCounter" data-testid="asyncCounter">0</p>
|
13
13
|
<p data-wp-text="context.syncCounter" data-testid="syncCounter">0</p>
|
14
14
|
</div>
|
@@ -1,346 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
clickBlockAppender,
|
6
|
-
createNewPost,
|
7
|
-
getEditedPostContent,
|
8
|
-
pressKeyWithModifier,
|
9
|
-
publishPost,
|
10
|
-
saveDraft,
|
11
|
-
toggleOfflineMode,
|
12
|
-
canvas,
|
13
|
-
} from '@wordpress/e2e-test-utils';
|
14
|
-
|
15
|
-
// Constant to override editor preference
|
16
|
-
const AUTOSAVE_INTERVAL_SECONDS = 5;
|
17
|
-
|
18
|
-
const AUTOSAVE_NOTICE_REMOTE =
|
19
|
-
'There is an autosave of this post that is more recent than the version below.';
|
20
|
-
const AUTOSAVE_NOTICE_LOCAL =
|
21
|
-
'The backup of this post in your browser is different from the version below.';
|
22
|
-
|
23
|
-
// Save and wait for "Saved" to confirm save complete. Preserves focus in the
|
24
|
-
// editing area.
|
25
|
-
async function saveDraftWithKeyboard() {
|
26
|
-
await page.waitForSelector( '.editor-post-save-draft' );
|
27
|
-
await Promise.all( [
|
28
|
-
page.waitForSelector( '.editor-post-saved-state.is-saved' ),
|
29
|
-
pressKeyWithModifier( 'primary', 'S' ),
|
30
|
-
] );
|
31
|
-
}
|
32
|
-
|
33
|
-
async function sleep( durationInSeconds ) {
|
34
|
-
// Rule `no-restricted-syntax` recommends `waitForSelector` against
|
35
|
-
// `waitFor`, which isn't apt for the use case, when provided an integer,
|
36
|
-
// of waiting for a given amount of time.
|
37
|
-
// eslint-disable-next-line no-restricted-syntax
|
38
|
-
await page.waitForTimeout( durationInSeconds * 1000 );
|
39
|
-
}
|
40
|
-
|
41
|
-
async function clearSessionStorage() {
|
42
|
-
await page.evaluate( () => window.sessionStorage.clear() );
|
43
|
-
}
|
44
|
-
|
45
|
-
async function readSessionStorageAutosave( postId ) {
|
46
|
-
return page.evaluate(
|
47
|
-
( key ) => window.sessionStorage.getItem( key ),
|
48
|
-
`wp-autosave-block-editor-post-${ postId ? postId : 'auto-draft' }`
|
49
|
-
);
|
50
|
-
}
|
51
|
-
|
52
|
-
async function getCurrentPostId() {
|
53
|
-
return page.evaluate( () =>
|
54
|
-
window.wp.data.select( 'core/editor' ).getCurrentPostId()
|
55
|
-
);
|
56
|
-
}
|
57
|
-
|
58
|
-
async function setLocalAutosaveInterval( value ) {
|
59
|
-
return page.evaluate( ( _value ) => {
|
60
|
-
window.wp.data.dispatch( 'core/editor' ).updateEditorSettings( {
|
61
|
-
localAutosaveInterval: _value,
|
62
|
-
} );
|
63
|
-
}, value );
|
64
|
-
}
|
65
|
-
|
66
|
-
function wrapParagraph( text ) {
|
67
|
-
return `<!-- wp:paragraph -->
|
68
|
-
<p>${ text }</p>
|
69
|
-
<!-- /wp:paragraph -->`;
|
70
|
-
}
|
71
|
-
|
72
|
-
describe( 'autosave', () => {
|
73
|
-
beforeEach( async () => {
|
74
|
-
await clearSessionStorage();
|
75
|
-
await createNewPost();
|
76
|
-
await setLocalAutosaveInterval( AUTOSAVE_INTERVAL_SECONDS );
|
77
|
-
} );
|
78
|
-
|
79
|
-
it( 'should save to sessionStorage', async () => {
|
80
|
-
// Wait for the original timeout to kick in, it will schedule
|
81
|
-
// another run using the updated interval length of AUTOSAVE_INTERVAL_SECONDS.
|
82
|
-
await sleep( 15 );
|
83
|
-
|
84
|
-
await clickBlockAppender();
|
85
|
-
await page.keyboard.type( 'before save' );
|
86
|
-
await saveDraftWithKeyboard();
|
87
|
-
await sleep( 1 );
|
88
|
-
await page.keyboard.type( ' after save' );
|
89
|
-
|
90
|
-
// Wait long enough for local autosave to kick in.
|
91
|
-
await sleep( AUTOSAVE_INTERVAL_SECONDS + 1 );
|
92
|
-
|
93
|
-
const id = await getCurrentPostId();
|
94
|
-
const autosave = await readSessionStorageAutosave( id );
|
95
|
-
const { content } = JSON.parse( autosave );
|
96
|
-
expect( content ).toBe( wrapParagraph( 'before save after save' ) );
|
97
|
-
} );
|
98
|
-
|
99
|
-
it( 'should recover from sessionStorage', async () => {
|
100
|
-
await clickBlockAppender();
|
101
|
-
await page.keyboard.type( 'before save' );
|
102
|
-
await saveDraftWithKeyboard();
|
103
|
-
await page.keyboard.type( ' after save' );
|
104
|
-
|
105
|
-
// Trigger local autosave.
|
106
|
-
await page.evaluate( () =>
|
107
|
-
window.wp.data.dispatch( 'core/editor' ).autosave( { local: true } )
|
108
|
-
);
|
109
|
-
// Reload without saving on the server.
|
110
|
-
await page.reload();
|
111
|
-
await page.waitForSelector( '.edit-post-layout' );
|
112
|
-
|
113
|
-
const notice = await page.$eval(
|
114
|
-
'.components-notice__content',
|
115
|
-
( element ) => element.innerText
|
116
|
-
);
|
117
|
-
expect( notice ).toContain( AUTOSAVE_NOTICE_LOCAL );
|
118
|
-
|
119
|
-
expect( await getEditedPostContent() ).toEqual(
|
120
|
-
wrapParagraph( 'before save' )
|
121
|
-
);
|
122
|
-
await page.click( '.components-notice__action' );
|
123
|
-
expect( await getEditedPostContent() ).toEqual(
|
124
|
-
wrapParagraph( 'before save after save' )
|
125
|
-
);
|
126
|
-
} );
|
127
|
-
|
128
|
-
it( "shouldn't contaminate other posts", async () => {
|
129
|
-
await clickBlockAppender();
|
130
|
-
await page.keyboard.type( 'before save' );
|
131
|
-
await saveDraft();
|
132
|
-
|
133
|
-
// Fake local autosave.
|
134
|
-
await page.evaluate(
|
135
|
-
( postId ) =>
|
136
|
-
window.sessionStorage.setItem(
|
137
|
-
`wp-autosave-block-editor-post-${ postId }`,
|
138
|
-
JSON.stringify( {
|
139
|
-
post_title: 'A',
|
140
|
-
content: 'B',
|
141
|
-
excerpt: 'C',
|
142
|
-
} )
|
143
|
-
),
|
144
|
-
await getCurrentPostId()
|
145
|
-
);
|
146
|
-
expect(
|
147
|
-
await page.evaluate( () => window.sessionStorage.length )
|
148
|
-
).toBe( 1 );
|
149
|
-
|
150
|
-
await page.reload();
|
151
|
-
await page.waitForSelector( '.edit-post-layout' );
|
152
|
-
const notice = await page.$eval(
|
153
|
-
'.components-notice__content',
|
154
|
-
( element ) => element.innerText
|
155
|
-
);
|
156
|
-
expect( notice ).toContain(
|
157
|
-
'The backup of this post in your browser is different from the version below.'
|
158
|
-
);
|
159
|
-
|
160
|
-
await createNewPost();
|
161
|
-
expect( await page.$( '.components-notice__content' ) ).toBe( null );
|
162
|
-
} );
|
163
|
-
|
164
|
-
it( 'should clear local autosave after successful remote autosave', async () => {
|
165
|
-
// Edit, save draft, edit again.
|
166
|
-
await clickBlockAppender();
|
167
|
-
await page.keyboard.type( 'before save' );
|
168
|
-
await saveDraftWithKeyboard();
|
169
|
-
await page.keyboard.type( ' after save' );
|
170
|
-
|
171
|
-
// Trigger local autosave.
|
172
|
-
await page.evaluate( () =>
|
173
|
-
window.wp.data.dispatch( 'core/editor' ).autosave( { local: true } )
|
174
|
-
);
|
175
|
-
expect(
|
176
|
-
await page.evaluate( () => window.sessionStorage.length )
|
177
|
-
).toBeGreaterThanOrEqual( 1 );
|
178
|
-
|
179
|
-
// Trigger remote autosave.
|
180
|
-
await page.evaluate( () =>
|
181
|
-
window.wp.data.dispatch( 'core/editor' ).autosave()
|
182
|
-
);
|
183
|
-
expect(
|
184
|
-
await page.evaluate( () => window.sessionStorage.length )
|
185
|
-
).toBe( 0 );
|
186
|
-
} );
|
187
|
-
|
188
|
-
it( "shouldn't clear local autosave if remote autosave fails", async () => {
|
189
|
-
// Edit, save draft, edit again.
|
190
|
-
await clickBlockAppender();
|
191
|
-
await page.keyboard.type( 'before save' );
|
192
|
-
await saveDraftWithKeyboard();
|
193
|
-
await page.keyboard.type( ' after save' );
|
194
|
-
|
195
|
-
// Trigger local autosave.
|
196
|
-
await page.evaluate( () =>
|
197
|
-
window.wp.data.dispatch( 'core/editor' ).autosave( { local: true } )
|
198
|
-
);
|
199
|
-
expect(
|
200
|
-
await page.evaluate( () => window.sessionStorage.length )
|
201
|
-
).toBe( 1 );
|
202
|
-
|
203
|
-
// Bring network down and attempt to autosave remotely.
|
204
|
-
toggleOfflineMode( true );
|
205
|
-
await page.evaluate( () =>
|
206
|
-
window.wp.data.dispatch( 'core/editor' ).autosave()
|
207
|
-
);
|
208
|
-
expect(
|
209
|
-
await page.evaluate( () => window.sessionStorage.length )
|
210
|
-
).toBe( 1 );
|
211
|
-
} );
|
212
|
-
|
213
|
-
it( 'should clear local autosave after successful save', async () => {
|
214
|
-
// Edit, save draft, edit again.
|
215
|
-
await clickBlockAppender();
|
216
|
-
await page.keyboard.type( 'before save' );
|
217
|
-
await saveDraftWithKeyboard();
|
218
|
-
await page.keyboard.type( ' after save' );
|
219
|
-
|
220
|
-
// Trigger local autosave.
|
221
|
-
await page.evaluate( () =>
|
222
|
-
window.wp.data.dispatch( 'core/editor' ).autosave( { local: true } )
|
223
|
-
);
|
224
|
-
expect(
|
225
|
-
await page.evaluate( () => window.sessionStorage.length )
|
226
|
-
).toBe( 1 );
|
227
|
-
|
228
|
-
await saveDraftWithKeyboard();
|
229
|
-
expect(
|
230
|
-
await page.evaluate( () => window.sessionStorage.length )
|
231
|
-
).toBe( 0 );
|
232
|
-
} );
|
233
|
-
|
234
|
-
it( "shouldn't clear local autosave if save fails", async () => {
|
235
|
-
// Edit, save draft, edit again.
|
236
|
-
await clickBlockAppender();
|
237
|
-
await page.keyboard.type( 'before save' );
|
238
|
-
await saveDraftWithKeyboard();
|
239
|
-
await page.keyboard.type( ' after save' );
|
240
|
-
|
241
|
-
// Trigger local autosave.
|
242
|
-
await page.evaluate( () =>
|
243
|
-
window.wp.data.dispatch( 'core/editor' ).autosave( { local: true } )
|
244
|
-
);
|
245
|
-
expect(
|
246
|
-
await page.evaluate( () => window.sessionStorage.length )
|
247
|
-
).toBeGreaterThanOrEqual( 1 );
|
248
|
-
|
249
|
-
// Bring network down and attempt to save.
|
250
|
-
toggleOfflineMode( true );
|
251
|
-
saveDraftWithKeyboard();
|
252
|
-
expect(
|
253
|
-
await page.evaluate( () => window.sessionStorage.length )
|
254
|
-
).toBeGreaterThanOrEqual( 1 );
|
255
|
-
} );
|
256
|
-
|
257
|
-
it( "shouldn't conflict with server-side autosave", async () => {
|
258
|
-
await clickBlockAppender();
|
259
|
-
await page.keyboard.type( 'before publish' );
|
260
|
-
await publishPost();
|
261
|
-
|
262
|
-
await canvas().click( '[data-type="core/paragraph"]' );
|
263
|
-
await page.keyboard.type( ' after publish' );
|
264
|
-
|
265
|
-
// Trigger remote autosave.
|
266
|
-
await page.evaluate( () =>
|
267
|
-
window.wp.data.dispatch( 'core/editor' ).autosave()
|
268
|
-
);
|
269
|
-
|
270
|
-
// Force conflicting local autosave.
|
271
|
-
await page.evaluate( () =>
|
272
|
-
window.wp.data.dispatch( 'core/editor' ).autosave( { local: true } )
|
273
|
-
);
|
274
|
-
expect(
|
275
|
-
await page.evaluate( () => window.sessionStorage.length )
|
276
|
-
).toBeGreaterThanOrEqual( 1 );
|
277
|
-
|
278
|
-
await page.reload();
|
279
|
-
await page.waitForSelector( '.edit-post-layout' );
|
280
|
-
|
281
|
-
// FIXME: Occasionally, upon reload, there is no server-provided
|
282
|
-
// autosave value available, despite our having previously explicitly
|
283
|
-
// autosaved. The reasons for this are still unknown. Since this is
|
284
|
-
// unrelated to *local* autosave, until we can understand them, we'll
|
285
|
-
// drop this test's expectations if we don't have an autosave object
|
286
|
-
// available.
|
287
|
-
const stillHasRemoteAutosave = await page.evaluate(
|
288
|
-
() =>
|
289
|
-
window.wp.data.select( 'core/editor' ).getEditorSettings()
|
290
|
-
.autosave
|
291
|
-
);
|
292
|
-
if ( ! stillHasRemoteAutosave ) {
|
293
|
-
return;
|
294
|
-
}
|
295
|
-
|
296
|
-
// Only one autosave notice should be displayed.
|
297
|
-
const notices = await page.$$( '.components-notice' );
|
298
|
-
expect( notices.length ).toBe( 1 );
|
299
|
-
const notice = await page.$eval(
|
300
|
-
'.components-notice__content',
|
301
|
-
( element ) => element.innerText
|
302
|
-
);
|
303
|
-
expect( notice ).toContain( AUTOSAVE_NOTICE_REMOTE );
|
304
|
-
} );
|
305
|
-
|
306
|
-
it( 'should clear sessionStorage upon user logout', async () => {
|
307
|
-
await clickBlockAppender();
|
308
|
-
await page.keyboard.type( 'before save' );
|
309
|
-
await saveDraft();
|
310
|
-
|
311
|
-
// Fake local autosave.
|
312
|
-
await page.evaluate(
|
313
|
-
( postId ) =>
|
314
|
-
window.sessionStorage.setItem(
|
315
|
-
`wp-autosave-block-editor-post-${ postId }`,
|
316
|
-
JSON.stringify( {
|
317
|
-
post_title: 'A',
|
318
|
-
content: 'B',
|
319
|
-
excerpt: 'C',
|
320
|
-
} )
|
321
|
-
),
|
322
|
-
await getCurrentPostId()
|
323
|
-
);
|
324
|
-
expect(
|
325
|
-
await page.evaluate( () => window.sessionStorage.length )
|
326
|
-
).toBe( 1 );
|
327
|
-
|
328
|
-
await Promise.all( [
|
329
|
-
page.waitForSelector( '#wp-admin-bar-logout', { visible: true } ),
|
330
|
-
page.hover( '#wp-admin-bar-my-account' ),
|
331
|
-
] );
|
332
|
-
await Promise.all( [
|
333
|
-
page.waitForNavigation(),
|
334
|
-
page.click( '#wp-admin-bar-logout' ),
|
335
|
-
] );
|
336
|
-
|
337
|
-
expect(
|
338
|
-
await page.evaluate( () => window.sessionStorage.length )
|
339
|
-
).toBe( 0 );
|
340
|
-
} );
|
341
|
-
|
342
|
-
afterEach( async () => {
|
343
|
-
toggleOfflineMode( false );
|
344
|
-
await clearSessionStorage();
|
345
|
-
} );
|
346
|
-
} );
|
@@ -1,417 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
clickBlockAppender,
|
6
|
-
createNewPost,
|
7
|
-
pressKeyWithModifier,
|
8
|
-
ensureSidebarOpened,
|
9
|
-
publishPost,
|
10
|
-
saveDraft,
|
11
|
-
openDocumentSettingsSidebar,
|
12
|
-
isCurrentURL,
|
13
|
-
openTypographyToolsPanelMenu,
|
14
|
-
canvas,
|
15
|
-
} from '@wordpress/e2e-test-utils';
|
16
|
-
|
17
|
-
describe( 'Change detection', () => {
|
18
|
-
let handleInterceptedRequest, hadInterceptedSave;
|
19
|
-
|
20
|
-
beforeEach( async () => {
|
21
|
-
hadInterceptedSave = false;
|
22
|
-
|
23
|
-
await createNewPost();
|
24
|
-
} );
|
25
|
-
|
26
|
-
afterEach( async () => {
|
27
|
-
if ( handleInterceptedRequest ) {
|
28
|
-
await releaseSaveIntercept();
|
29
|
-
}
|
30
|
-
} );
|
31
|
-
|
32
|
-
async function assertIsDirty( isDirty ) {
|
33
|
-
let hadDialog = false;
|
34
|
-
|
35
|
-
function handleOnDialog() {
|
36
|
-
hadDialog = true;
|
37
|
-
}
|
38
|
-
|
39
|
-
try {
|
40
|
-
page.on( 'dialog', handleOnDialog );
|
41
|
-
await page.reload();
|
42
|
-
|
43
|
-
// Ensure whether it was expected that dialog was encountered.
|
44
|
-
expect( hadDialog ).toBe( isDirty );
|
45
|
-
} catch ( error ) {
|
46
|
-
throw error;
|
47
|
-
} finally {
|
48
|
-
page.removeListener( 'dialog', handleOnDialog );
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
async function interceptSave() {
|
53
|
-
await page.setRequestInterception( true );
|
54
|
-
|
55
|
-
handleInterceptedRequest = ( interceptedRequest ) => {
|
56
|
-
if ( interceptedRequest.url().includes( '/wp/v2/posts' ) ) {
|
57
|
-
hadInterceptedSave = true;
|
58
|
-
} else {
|
59
|
-
interceptedRequest.continue();
|
60
|
-
}
|
61
|
-
};
|
62
|
-
page.on( 'request', handleInterceptedRequest );
|
63
|
-
}
|
64
|
-
|
65
|
-
async function releaseSaveIntercept() {
|
66
|
-
page.removeListener( 'request', handleInterceptedRequest );
|
67
|
-
await page.setRequestInterception( false );
|
68
|
-
hadInterceptedSave = false;
|
69
|
-
handleInterceptedRequest = null;
|
70
|
-
}
|
71
|
-
|
72
|
-
it( 'Should not save on new unsaved post', async () => {
|
73
|
-
await interceptSave();
|
74
|
-
|
75
|
-
// Keyboard shortcut Ctrl+S save.
|
76
|
-
await pressKeyWithModifier( 'primary', 'S' );
|
77
|
-
|
78
|
-
expect( hadInterceptedSave ).toBe( false );
|
79
|
-
} );
|
80
|
-
|
81
|
-
it( 'Should autosave post', async () => {
|
82
|
-
await canvas().type( '.editor-post-title__input', 'Hello World' );
|
83
|
-
|
84
|
-
// Force autosave to occur immediately.
|
85
|
-
await Promise.all( [
|
86
|
-
page.evaluate( () =>
|
87
|
-
window.wp.data.dispatch( 'core/editor' ).autosave()
|
88
|
-
),
|
89
|
-
page.waitForSelector( '.editor-post-saved-state.is-autosaving' ),
|
90
|
-
page.waitForSelector( '.editor-post-saved-state.is-saved' ),
|
91
|
-
] );
|
92
|
-
|
93
|
-
// Autosave draft as same user should do full save, i.e. not dirty.
|
94
|
-
await assertIsDirty( false );
|
95
|
-
} );
|
96
|
-
|
97
|
-
it( 'Should prompt to confirm unsaved changes for autosaved draft for non-content fields', async () => {
|
98
|
-
await canvas().type( '.editor-post-title__input', 'Hello World' );
|
99
|
-
|
100
|
-
// Toggle post as needing review (not persisted for autosave).
|
101
|
-
await ensureSidebarOpened();
|
102
|
-
|
103
|
-
const postPendingReviewButton = (
|
104
|
-
await page.$x( "//label[contains(text(), 'Pending review')]" )
|
105
|
-
)[ 0 ];
|
106
|
-
await postPendingReviewButton.click( 'button' );
|
107
|
-
|
108
|
-
// Force autosave to occur immediately.
|
109
|
-
await Promise.all( [
|
110
|
-
page.evaluate( () =>
|
111
|
-
window.wp.data.dispatch( 'core/editor' ).autosave()
|
112
|
-
),
|
113
|
-
page.waitForSelector( '.editor-post-saved-state.is-autosaving' ),
|
114
|
-
page.waitForSelector( '.editor-post-saved-state.is-saved' ),
|
115
|
-
] );
|
116
|
-
|
117
|
-
await assertIsDirty( true );
|
118
|
-
} );
|
119
|
-
|
120
|
-
it( 'Should prompt to confirm unsaved changes for autosaved published post', async () => {
|
121
|
-
await canvas().type( '.editor-post-title__input', 'Hello World' );
|
122
|
-
|
123
|
-
await publishPost();
|
124
|
-
|
125
|
-
// Close publish panel.
|
126
|
-
await Promise.all( [
|
127
|
-
page.waitForFunction(
|
128
|
-
() => ! document.querySelector( '.editor-post-publish-panel' )
|
129
|
-
),
|
130
|
-
page.click( '.editor-post-publish-panel__header button' ),
|
131
|
-
] );
|
132
|
-
|
133
|
-
// Should be dirty after autosave change of published post.
|
134
|
-
await canvas().type( '.editor-post-title__input', '!' );
|
135
|
-
|
136
|
-
await Promise.all( [
|
137
|
-
page.waitForSelector(
|
138
|
-
'.editor-post-publish-button[aria-disabled="true"]'
|
139
|
-
),
|
140
|
-
page.waitForSelector(
|
141
|
-
'.editor-post-publish-button[aria-disabled="false"]'
|
142
|
-
),
|
143
|
-
page.evaluate( () =>
|
144
|
-
window.wp.data.dispatch( 'core/editor' ).autosave()
|
145
|
-
),
|
146
|
-
] );
|
147
|
-
|
148
|
-
await assertIsDirty( true );
|
149
|
-
} );
|
150
|
-
|
151
|
-
it( 'Should not prompt to confirm unsaved changes for new post', async () => {
|
152
|
-
await assertIsDirty( false );
|
153
|
-
} );
|
154
|
-
|
155
|
-
it( 'Should prompt to confirm unsaved changes for new post with initial edits', async () => {
|
156
|
-
await createNewPost( {
|
157
|
-
title: 'My New Post',
|
158
|
-
content: 'My content',
|
159
|
-
excerpt: 'My excerpt',
|
160
|
-
} );
|
161
|
-
|
162
|
-
await assertIsDirty( true );
|
163
|
-
} );
|
164
|
-
|
165
|
-
it( 'Should prompt if property changed without save', async () => {
|
166
|
-
await canvas().type( '.editor-post-title__input', 'Hello World' );
|
167
|
-
|
168
|
-
await assertIsDirty( true );
|
169
|
-
} );
|
170
|
-
|
171
|
-
it( 'Should prompt if content added without save', async () => {
|
172
|
-
await clickBlockAppender();
|
173
|
-
await page.keyboard.type( 'Paragraph' );
|
174
|
-
|
175
|
-
await assertIsDirty( true );
|
176
|
-
} );
|
177
|
-
|
178
|
-
it( 'Should not prompt if changes saved', async () => {
|
179
|
-
await canvas().type( '.editor-post-title__input', 'Hello World' );
|
180
|
-
|
181
|
-
await saveDraft();
|
182
|
-
|
183
|
-
await assertIsDirty( false );
|
184
|
-
} );
|
185
|
-
|
186
|
-
it( 'Should not prompt if changes saved right after typing', async () => {
|
187
|
-
await clickBlockAppender();
|
188
|
-
await page.keyboard.type( 'Hello World' );
|
189
|
-
|
190
|
-
await saveDraft();
|
191
|
-
|
192
|
-
await assertIsDirty( false );
|
193
|
-
} );
|
194
|
-
|
195
|
-
it( 'Should not save if all changes saved', async () => {
|
196
|
-
await canvas().type( '.editor-post-title__input', 'Hello World' );
|
197
|
-
|
198
|
-
await saveDraft();
|
199
|
-
|
200
|
-
await interceptSave();
|
201
|
-
|
202
|
-
// Keyboard shortcut Ctrl+S save.
|
203
|
-
await pressKeyWithModifier( 'primary', 'S' );
|
204
|
-
|
205
|
-
expect( hadInterceptedSave ).toBe( false );
|
206
|
-
} );
|
207
|
-
|
208
|
-
it( 'Should prompt if save failed', async () => {
|
209
|
-
await canvas().type( '.editor-post-title__input', 'Hello World' );
|
210
|
-
|
211
|
-
await page.setOfflineMode( true );
|
212
|
-
|
213
|
-
await Promise.all( [
|
214
|
-
// Keyboard shortcut Ctrl+S save.
|
215
|
-
pressKeyWithModifier( 'primary', 'S' ),
|
216
|
-
|
217
|
-
// Ensure save update fails and presents button.
|
218
|
-
page.waitForXPath(
|
219
|
-
'//*[contains(@class, "components-notice") and contains(@class, "is-error")]/*[text()="Updating failed. You are probably offline."]'
|
220
|
-
),
|
221
|
-
page.waitForSelector( '.editor-post-save-draft' ),
|
222
|
-
] );
|
223
|
-
|
224
|
-
// Need to disable offline to allow reload.
|
225
|
-
await page.setOfflineMode( false );
|
226
|
-
|
227
|
-
await assertIsDirty( true );
|
228
|
-
|
229
|
-
expect( console ).toHaveErroredWith(
|
230
|
-
'Failed to load resource: net::ERR_INTERNET_DISCONNECTED'
|
231
|
-
);
|
232
|
-
} );
|
233
|
-
|
234
|
-
it( 'Should prompt if changes and save is in-flight', async () => {
|
235
|
-
await canvas().type( '.editor-post-title__input', 'Hello World' );
|
236
|
-
|
237
|
-
// Hold the posts request so we don't deal with race conditions of the
|
238
|
-
// save completing early. Other requests should be allowed to continue,
|
239
|
-
// for example the page reload test.
|
240
|
-
await interceptSave();
|
241
|
-
|
242
|
-
// Keyboard shortcut Ctrl+S save.
|
243
|
-
await pressKeyWithModifier( 'primary', 'S' );
|
244
|
-
|
245
|
-
await assertIsDirty( true );
|
246
|
-
|
247
|
-
await releaseSaveIntercept();
|
248
|
-
} );
|
249
|
-
|
250
|
-
it( 'Should prompt if changes made while save is in-flight', async () => {
|
251
|
-
await canvas().type( '.editor-post-title__input', 'Hello World' );
|
252
|
-
|
253
|
-
// Hold the posts request so we don't deal with race conditions of the
|
254
|
-
// save completing early. Other requests should be allowed to continue,
|
255
|
-
// for example the page reload test.
|
256
|
-
await interceptSave();
|
257
|
-
|
258
|
-
// Keyboard shortcut Ctrl+S save.
|
259
|
-
await pressKeyWithModifier( 'primary', 'S' );
|
260
|
-
|
261
|
-
await canvas().type( '.editor-post-title__input', '!' );
|
262
|
-
await page.waitForSelector( '.editor-post-save-draft' );
|
263
|
-
|
264
|
-
await releaseSaveIntercept();
|
265
|
-
|
266
|
-
await assertIsDirty( true );
|
267
|
-
} );
|
268
|
-
|
269
|
-
it( 'Should prompt if property changes made while save is in-flight, and save completes', async () => {
|
270
|
-
await canvas().type( '.editor-post-title__input', 'Hello World' );
|
271
|
-
|
272
|
-
// Hold the posts request so we don't deal with race conditions of the
|
273
|
-
// save completing early.
|
274
|
-
await interceptSave();
|
275
|
-
|
276
|
-
// Keyboard shortcut Ctrl+S save.
|
277
|
-
await pressKeyWithModifier( 'primary', 'S' );
|
278
|
-
|
279
|
-
// Start this check immediately after save since dirtying the post will
|
280
|
-
// remove the "Saved" with the Save button.
|
281
|
-
const savedPromise = page.waitForSelector(
|
282
|
-
'.editor-post-saved-state.is-saved'
|
283
|
-
);
|
284
|
-
|
285
|
-
// Dirty post while save is in-flight.
|
286
|
-
await canvas().type( '.editor-post-title__input', '!' );
|
287
|
-
|
288
|
-
// Allow save to complete. Disabling interception flushes pending.
|
289
|
-
await Promise.all( [ savedPromise, releaseSaveIntercept() ] );
|
290
|
-
|
291
|
-
await assertIsDirty( true );
|
292
|
-
} );
|
293
|
-
|
294
|
-
it( 'Should prompt if block revision is made while save is in-flight, and save completes', async () => {
|
295
|
-
await canvas().type( '.editor-post-title__input', 'Hello World' );
|
296
|
-
|
297
|
-
// Hold the posts request so we don't deal with race conditions of the
|
298
|
-
// save completing early.
|
299
|
-
await interceptSave();
|
300
|
-
|
301
|
-
// Keyboard shortcut Ctrl+S save.
|
302
|
-
await pressKeyWithModifier( 'primary', 'S' );
|
303
|
-
|
304
|
-
// Start this check immediately after save since dirtying the post will
|
305
|
-
// remove the "Saved" with the Save button.
|
306
|
-
const savedPromise = page.waitForSelector(
|
307
|
-
'.editor-post-saved-state.is-saved'
|
308
|
-
);
|
309
|
-
|
310
|
-
await clickBlockAppender();
|
311
|
-
await page.keyboard.type( 'Paragraph' );
|
312
|
-
|
313
|
-
// Allow save to complete. Disabling interception flushes pending.
|
314
|
-
await Promise.all( [ savedPromise, releaseSaveIntercept() ] );
|
315
|
-
|
316
|
-
await assertIsDirty( true );
|
317
|
-
} );
|
318
|
-
|
319
|
-
it( 'should save posts without titles and persist and overwrite the auto draft title', async () => {
|
320
|
-
// Enter content.
|
321
|
-
await clickBlockAppender();
|
322
|
-
await page.keyboard.type( 'Paragraph' );
|
323
|
-
|
324
|
-
// Save.
|
325
|
-
await saveDraft();
|
326
|
-
|
327
|
-
// Verify that the title is empty.
|
328
|
-
const title = await canvas().$eval(
|
329
|
-
'.editor-post-title__input',
|
330
|
-
// Trim padding non-breaking space.
|
331
|
-
( element ) => element.textContent.trim()
|
332
|
-
);
|
333
|
-
expect( title ).toBe( '' );
|
334
|
-
|
335
|
-
// Verify that the post is not dirty.
|
336
|
-
await assertIsDirty( false );
|
337
|
-
} );
|
338
|
-
|
339
|
-
it( 'should not prompt to confirm unsaved changes when trashing an existing post', async () => {
|
340
|
-
// Enter title.
|
341
|
-
await canvas().type( '.editor-post-title__input', 'Hello World' );
|
342
|
-
|
343
|
-
// Save.
|
344
|
-
await saveDraft();
|
345
|
-
const postId = await page.evaluate( () =>
|
346
|
-
window.wp.data.select( 'core/editor' ).getCurrentPostId()
|
347
|
-
);
|
348
|
-
|
349
|
-
// Trash post.
|
350
|
-
await openDocumentSettingsSidebar();
|
351
|
-
await page.click( '.editor-post-trash.components-button' );
|
352
|
-
await page.click( '.components-confirm-dialog .is-primary' );
|
353
|
-
|
354
|
-
await Promise.all( [
|
355
|
-
// Wait for "Saved" to confirm save complete.
|
356
|
-
await page.waitForSelector( '.editor-post-saved-state.is-saved' ),
|
357
|
-
|
358
|
-
// Make sure redirection happens.
|
359
|
-
await page.waitForNavigation(),
|
360
|
-
] );
|
361
|
-
|
362
|
-
expect(
|
363
|
-
isCurrentURL(
|
364
|
-
'/wp-admin/edit.php',
|
365
|
-
`post_type=post&ids=${ postId }`
|
366
|
-
)
|
367
|
-
).toBe( true );
|
368
|
-
} );
|
369
|
-
|
370
|
-
it( 'consecutive edits to the same attribute should mark the post as dirty after a save', async () => {
|
371
|
-
// Open the sidebar block settings.
|
372
|
-
await openDocumentSettingsSidebar();
|
373
|
-
|
374
|
-
const blockInspectorTab = await page.waitForXPath(
|
375
|
-
'//button[@role="tab"][contains(text(), "Block")]'
|
376
|
-
);
|
377
|
-
await blockInspectorTab.click();
|
378
|
-
|
379
|
-
// Insert a paragraph.
|
380
|
-
await clickBlockAppender();
|
381
|
-
await page.keyboard.type( 'Hello, World!' );
|
382
|
-
|
383
|
-
// Save and wait till the post is clean.
|
384
|
-
await Promise.all( [
|
385
|
-
page.waitForSelector( '.editor-post-saved-state.is-saved' ),
|
386
|
-
pressKeyWithModifier( 'primary', 'S' ),
|
387
|
-
] );
|
388
|
-
|
389
|
-
// Change the paragraph's `drop cap`.
|
390
|
-
await canvas().click( '[data-type="core/paragraph"]' );
|
391
|
-
|
392
|
-
await openTypographyToolsPanelMenu();
|
393
|
-
await page.click( 'button[aria-label="Show Drop cap"]' );
|
394
|
-
|
395
|
-
const [ dropCapToggle ] = await page.$x(
|
396
|
-
"//label[contains(text(), 'Drop cap')]"
|
397
|
-
);
|
398
|
-
await dropCapToggle.click();
|
399
|
-
await canvas().click( '[data-type="core/paragraph"]' );
|
400
|
-
|
401
|
-
// Check that the post is dirty.
|
402
|
-
await page.waitForSelector( '.editor-post-save-draft' );
|
403
|
-
|
404
|
-
// Save and wait till the post is clean.
|
405
|
-
await Promise.all( [
|
406
|
-
page.waitForSelector( '.editor-post-saved-state.is-saved' ),
|
407
|
-
pressKeyWithModifier( 'primary', 'S' ),
|
408
|
-
] );
|
409
|
-
|
410
|
-
// Change the paragraph's `drop cap` again.
|
411
|
-
await canvas().click( '[data-type="core/paragraph"]' );
|
412
|
-
await dropCapToggle.click();
|
413
|
-
|
414
|
-
// Check that the post is dirty.
|
415
|
-
await page.waitForSelector( '.editor-post-save-draft' );
|
416
|
-
} );
|
417
|
-
} );
|