@wordpress/e2e-tests 7.14.0 → 7.15.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 +2 -0
- package/package.json +7 -7
- package/specs/editor/blocks/post-title.test.js +0 -36
- package/specs/editor/various/__snapshots__/links.test.js.snap +0 -49
- package/specs/editor/various/format-library/__snapshots__/text-color.test.js.snap +0 -13
- package/specs/editor/various/format-library/text-color.test.js +0 -46
- package/specs/editor/various/links.test.js +0 -916
- package/specs/local/demo.test.js +0 -50
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.15.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.15.0",
|
27
|
+
"@wordpress/jest-console": "^7.15.0",
|
28
|
+
"@wordpress/jest-puppeteer-axe": "^6.15.0",
|
29
|
+
"@wordpress/scripts": "^26.15.0",
|
30
|
+
"@wordpress/url": "^3.45.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": "f83bb1a71e8fa416131b81a9f282a72a1dc6c694"
|
49
49
|
}
|
@@ -1,36 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
createNewPost,
|
6
|
-
insertBlock,
|
7
|
-
saveDraft,
|
8
|
-
canvas,
|
9
|
-
} from '@wordpress/e2e-test-utils';
|
10
|
-
|
11
|
-
describe( 'Post Title block', () => {
|
12
|
-
beforeEach( async () => {
|
13
|
-
await createNewPost();
|
14
|
-
} );
|
15
|
-
|
16
|
-
it( 'Can edit the post title', async () => {
|
17
|
-
// Create a block with some text that will trigger a list creation.
|
18
|
-
await insertBlock( 'Title' );
|
19
|
-
const editablePostTitleSelector =
|
20
|
-
'.wp-block-post-title[contenteditable="true"]';
|
21
|
-
await canvas().waitForSelector( editablePostTitleSelector );
|
22
|
-
await canvas().focus( editablePostTitleSelector );
|
23
|
-
|
24
|
-
// Create a second list item.
|
25
|
-
await page.keyboard.type( 'Just tweaking the post title' );
|
26
|
-
|
27
|
-
await saveDraft();
|
28
|
-
await page.reload();
|
29
|
-
await page.waitForSelector( '.edit-post-layout' );
|
30
|
-
const title = await canvas().$eval(
|
31
|
-
'.editor-post-title__input',
|
32
|
-
( element ) => element.textContent
|
33
|
-
);
|
34
|
-
expect( title ).toEqual( 'Just tweaking the post title' );
|
35
|
-
} );
|
36
|
-
} );
|
@@ -1,49 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`Links allows use of escape key to dismiss the url popover 1`] = `
|
4
|
-
"<!-- wp:paragraph -->
|
5
|
-
<p>This is Gutenberg.</p>
|
6
|
-
<!-- /wp:paragraph -->"
|
7
|
-
`;
|
8
|
-
|
9
|
-
exports[`Links can be created by selecting text and clicking Link 1`] = `
|
10
|
-
"<!-- wp:paragraph -->
|
11
|
-
<p>This is <a href="https://wordpress.org/gutenberg">Gutenberg</a></p>
|
12
|
-
<!-- /wp:paragraph -->"
|
13
|
-
`;
|
14
|
-
|
15
|
-
exports[`Links can be created instantly when a URL is selected 1`] = `
|
16
|
-
"<!-- wp:paragraph -->
|
17
|
-
<p>This is Gutenberg: <a href="https://wordpress.org/gutenberg">https://wordpress.org/gutenberg</a></p>
|
18
|
-
<!-- /wp:paragraph -->"
|
19
|
-
`;
|
20
|
-
|
21
|
-
exports[`Links can be created without any text selected 1`] = `
|
22
|
-
"<!-- wp:paragraph -->
|
23
|
-
<p>This is Gutenberg: <a href="https://wordpress.org/gutenberg">https://wordpress.org/gutenberg</a></p>
|
24
|
-
<!-- /wp:paragraph -->"
|
25
|
-
`;
|
26
|
-
|
27
|
-
exports[`Links can be edited 1`] = `
|
28
|
-
"<!-- wp:paragraph -->
|
29
|
-
<p>This is <a href="https://wordpress.org/gutenberg/handbook">Gutenberg</a></p>
|
30
|
-
<!-- /wp:paragraph -->"
|
31
|
-
`;
|
32
|
-
|
33
|
-
exports[`Links can be edited with collapsed selection 1`] = `
|
34
|
-
"<!-- wp:paragraph -->
|
35
|
-
<p>This is <a href="https://wordpress.org/gutenberg/handbook">Gutenberg</a></p>
|
36
|
-
<!-- /wp:paragraph -->"
|
37
|
-
`;
|
38
|
-
|
39
|
-
exports[`Links can be modified using the keyboard once a link has been set 1`] = `
|
40
|
-
"<!-- wp:paragraph -->
|
41
|
-
<p>This is <a href="https://wordpress.org/gutenberg">Gutenberg</a>.</p>
|
42
|
-
<!-- /wp:paragraph -->"
|
43
|
-
`;
|
44
|
-
|
45
|
-
exports[`Links can be removed 1`] = `
|
46
|
-
"<!-- wp:paragraph -->
|
47
|
-
<p>This is Gutenberg</p>
|
48
|
-
<!-- /wp:paragraph -->"
|
49
|
-
`;
|
@@ -1,13 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`RichText should remove highlighting element 1`] = `
|
4
|
-
"<!-- wp:paragraph -->
|
5
|
-
<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-cyan-bluish-gray-color">1</mark></p>
|
6
|
-
<!-- /wp:paragraph -->"
|
7
|
-
`;
|
8
|
-
|
9
|
-
exports[`RichText should remove highlighting element 2`] = `
|
10
|
-
"<!-- wp:paragraph -->
|
11
|
-
<p>1</p>
|
12
|
-
<!-- /wp:paragraph -->"
|
13
|
-
`;
|
@@ -1,46 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
createNewPost,
|
6
|
-
getEditedPostContent,
|
7
|
-
clickBlockAppender,
|
8
|
-
pressKeyWithModifier,
|
9
|
-
clickBlockToolbarButton,
|
10
|
-
} from '@wordpress/e2e-test-utils';
|
11
|
-
|
12
|
-
describe( 'RichText', () => {
|
13
|
-
beforeEach( async () => {
|
14
|
-
await createNewPost();
|
15
|
-
} );
|
16
|
-
|
17
|
-
it( 'should remove highlighting element', async () => {
|
18
|
-
await clickBlockAppender();
|
19
|
-
|
20
|
-
// Add text and select to color.
|
21
|
-
await page.keyboard.type( '1' );
|
22
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
23
|
-
await clickBlockToolbarButton( 'More' );
|
24
|
-
|
25
|
-
const button = await page.waitForXPath(
|
26
|
-
`//button[text()='Highlight']`
|
27
|
-
);
|
28
|
-
// Clicks may fail if the button is out of view. Assure it is before click.
|
29
|
-
await button.evaluate( ( element ) => element.scrollIntoView() );
|
30
|
-
await button.click();
|
31
|
-
|
32
|
-
// Use a color name with multiple words to ensure that it becomes
|
33
|
-
// active. Previously we had a broken regular expression.
|
34
|
-
const option = await page.waitForSelector(
|
35
|
-
'[aria-label="Color: Cyan bluish gray"]'
|
36
|
-
);
|
37
|
-
|
38
|
-
await option.click();
|
39
|
-
|
40
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
41
|
-
|
42
|
-
await option.click();
|
43
|
-
|
44
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
45
|
-
} );
|
46
|
-
} );
|
@@ -1,916 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
clickBlockAppender,
|
6
|
-
clickBlockToolbarButton,
|
7
|
-
getEditedPostContent,
|
8
|
-
createNewPost,
|
9
|
-
pressKeyWithModifier,
|
10
|
-
showBlockToolbar,
|
11
|
-
pressKeyTimes,
|
12
|
-
canvas,
|
13
|
-
} from '@wordpress/e2e-test-utils';
|
14
|
-
|
15
|
-
describe( 'Links', () => {
|
16
|
-
beforeEach( async () => {
|
17
|
-
await createNewPost();
|
18
|
-
} );
|
19
|
-
|
20
|
-
const waitForURLFieldAutoFocus = async () => {
|
21
|
-
await page.waitForFunction( () => {
|
22
|
-
const input = document.querySelector(
|
23
|
-
'.block-editor-url-input__input'
|
24
|
-
);
|
25
|
-
if ( input ) {
|
26
|
-
input.focus();
|
27
|
-
return true;
|
28
|
-
}
|
29
|
-
return false;
|
30
|
-
} );
|
31
|
-
};
|
32
|
-
|
33
|
-
it( 'will use Post title as link text if link to existing post is created without any text selected', async () => {
|
34
|
-
const titleText = 'Post to create a link to';
|
35
|
-
await createPostWithTitle( titleText );
|
36
|
-
|
37
|
-
await createNewPost();
|
38
|
-
await clickBlockAppender();
|
39
|
-
|
40
|
-
// Now in a new post and try to create a link from an autocomplete suggestion using the keyboard.
|
41
|
-
await page.keyboard.type( 'Here comes a link: ' );
|
42
|
-
|
43
|
-
// Press Cmd+K to insert a link.
|
44
|
-
await pressKeyWithModifier( 'primary', 'K' );
|
45
|
-
|
46
|
-
// Wait for the URL field to auto-focus.
|
47
|
-
await waitForURLFieldAutoFocus();
|
48
|
-
expect(
|
49
|
-
await page.$(
|
50
|
-
'.components-popover__content .block-editor-link-control'
|
51
|
-
)
|
52
|
-
).not.toBeNull();
|
53
|
-
|
54
|
-
// Trigger the autocomplete suggestion list and select the first suggestion.
|
55
|
-
await page.keyboard.type( titleText.substr( 0, titleText.length - 2 ) );
|
56
|
-
await page.waitForSelector( '.block-editor-link-control__search-item' );
|
57
|
-
await page.keyboard.press( 'ArrowDown' );
|
58
|
-
|
59
|
-
await page.keyboard.press( 'Enter' );
|
60
|
-
|
61
|
-
const actualText = await canvas().evaluate(
|
62
|
-
() =>
|
63
|
-
document.querySelector( '.block-editor-rich-text__editable a' )
|
64
|
-
.textContent
|
65
|
-
);
|
66
|
-
expect( actualText ).toBe( titleText );
|
67
|
-
} );
|
68
|
-
|
69
|
-
it( 'can be created by selecting text and clicking Link', async () => {
|
70
|
-
// Create a block with some text.
|
71
|
-
await clickBlockAppender();
|
72
|
-
await page.keyboard.type( 'This is Gutenberg' );
|
73
|
-
|
74
|
-
// Select some text.
|
75
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
76
|
-
|
77
|
-
// Click on the Link button.
|
78
|
-
await page.click( 'button[aria-label="Link"]' );
|
79
|
-
|
80
|
-
// Wait for the URL field to auto-focus.
|
81
|
-
await waitForURLFieldAutoFocus();
|
82
|
-
|
83
|
-
// Type a URL.
|
84
|
-
await page.keyboard.type( 'https://wordpress.org/gutenberg' );
|
85
|
-
|
86
|
-
// Submit the link.
|
87
|
-
await page.keyboard.press( 'Enter' );
|
88
|
-
|
89
|
-
// The link should have been inserted.
|
90
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
91
|
-
} );
|
92
|
-
|
93
|
-
it( 'will not automatically create a link if selected text is not a valid HTTP based URL', async () => {
|
94
|
-
// Create a block with some text.
|
95
|
-
await clickBlockAppender();
|
96
|
-
await page.keyboard.type( 'This: is not a link' );
|
97
|
-
|
98
|
-
// Select some text.
|
99
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
100
|
-
|
101
|
-
// Click on the Link button.
|
102
|
-
await page.click( 'button[aria-label="Link"]' );
|
103
|
-
|
104
|
-
// Wait for the URL field to auto-focus.
|
105
|
-
await waitForURLFieldAutoFocus();
|
106
|
-
|
107
|
-
const urlInputValue = await page.evaluate(
|
108
|
-
() =>
|
109
|
-
document.querySelector( '.block-editor-url-input__input' ).value
|
110
|
-
);
|
111
|
-
|
112
|
-
expect( urlInputValue ).toBe( '' );
|
113
|
-
} );
|
114
|
-
|
115
|
-
it( 'can be created without any text selected', async () => {
|
116
|
-
// Create a block with some text.
|
117
|
-
await clickBlockAppender();
|
118
|
-
await page.keyboard.type( 'This is Gutenberg: ' );
|
119
|
-
|
120
|
-
// Press Cmd+K to insert a link.
|
121
|
-
await pressKeyWithModifier( 'primary', 'K' );
|
122
|
-
|
123
|
-
// Wait for the URL field to auto-focus.
|
124
|
-
await waitForURLFieldAutoFocus();
|
125
|
-
|
126
|
-
// Type a URL.
|
127
|
-
await page.keyboard.type( 'https://wordpress.org/gutenberg' );
|
128
|
-
|
129
|
-
// Press Enter to apply the link.
|
130
|
-
await page.keyboard.press( 'Enter' );
|
131
|
-
|
132
|
-
// A link with the URL as its text should have been inserted.
|
133
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
134
|
-
} );
|
135
|
-
|
136
|
-
it( 'can be created instantly when a URL is selected', async () => {
|
137
|
-
// Create a block with some text.
|
138
|
-
await clickBlockAppender();
|
139
|
-
await page.keyboard.type(
|
140
|
-
'This is Gutenberg: https://wordpress.org/gutenberg'
|
141
|
-
);
|
142
|
-
|
143
|
-
// Select the URL.
|
144
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
145
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
146
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
147
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
148
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
149
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
150
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
151
|
-
|
152
|
-
// Click on the Link button.
|
153
|
-
await page.click( 'button[aria-label="Link"]' );
|
154
|
-
|
155
|
-
// A link with the selected URL as its href should have been inserted.
|
156
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
157
|
-
} );
|
158
|
-
|
159
|
-
it( 'is not created when we click away from the link input', async () => {
|
160
|
-
// Create a block with some text.
|
161
|
-
await clickBlockAppender();
|
162
|
-
await page.keyboard.type( 'This is Gutenberg' );
|
163
|
-
|
164
|
-
// Select some text.
|
165
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
166
|
-
|
167
|
-
// Click on the Link button.
|
168
|
-
await page.click( 'button[aria-label="Link"]' );
|
169
|
-
|
170
|
-
// Wait for the URL field to auto-focus.
|
171
|
-
await waitForURLFieldAutoFocus();
|
172
|
-
|
173
|
-
// Type a URL.
|
174
|
-
await page.keyboard.type( 'https://wordpress.org/gutenberg' );
|
175
|
-
|
176
|
-
// Click somewhere else - it doesn't really matter where.
|
177
|
-
await canvas().click( '.editor-post-title' );
|
178
|
-
} );
|
179
|
-
|
180
|
-
const createAndReselectLink = async () => {
|
181
|
-
// Create a block with some text.
|
182
|
-
await clickBlockAppender();
|
183
|
-
await page.keyboard.type( 'This is Gutenberg' );
|
184
|
-
|
185
|
-
// Select some text.
|
186
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
187
|
-
|
188
|
-
// Click on the Link button.
|
189
|
-
await page.click( 'button[aria-label="Link"]' );
|
190
|
-
|
191
|
-
// Wait for the URL field to auto-focus.
|
192
|
-
await waitForURLFieldAutoFocus();
|
193
|
-
|
194
|
-
// Type a URL.
|
195
|
-
await page.keyboard.type( 'https://wordpress.org/gutenberg' );
|
196
|
-
|
197
|
-
// Click on the Submit button.
|
198
|
-
await page.keyboard.press( 'Enter' );
|
199
|
-
|
200
|
-
// Reselect the link.
|
201
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
202
|
-
};
|
203
|
-
|
204
|
-
it( 'can be edited', async () => {
|
205
|
-
await createAndReselectLink();
|
206
|
-
|
207
|
-
// Click on the Edit button.
|
208
|
-
const [ editButton ] = await page.$x(
|
209
|
-
'//button[contains(@aria-label, "Edit")]'
|
210
|
-
);
|
211
|
-
await editButton.click();
|
212
|
-
|
213
|
-
// Wait for the URL field to auto-focus.
|
214
|
-
await waitForURLFieldAutoFocus();
|
215
|
-
|
216
|
-
// Change the URL.
|
217
|
-
await page.keyboard.type( '/handbook' );
|
218
|
-
|
219
|
-
// Submit the link.
|
220
|
-
await page.keyboard.press( 'Enter' );
|
221
|
-
|
222
|
-
// The link should have been updated.
|
223
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
224
|
-
} );
|
225
|
-
|
226
|
-
it( 'can be removed', async () => {
|
227
|
-
await createAndReselectLink();
|
228
|
-
|
229
|
-
// Click on the Unlink button
|
230
|
-
// await page.click( 'button[aria-label="Unlink"]' );
|
231
|
-
|
232
|
-
// Unlick via shortcut
|
233
|
-
// we do this to avoid an layout edge case whereby
|
234
|
-
// the rich link preview popover will obscure the block toolbar
|
235
|
-
// under very specific circumstances and screensizes.
|
236
|
-
await pressKeyWithModifier( 'primaryShift', 'K' );
|
237
|
-
|
238
|
-
// The link should have been removed.
|
239
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
240
|
-
} );
|
241
|
-
|
242
|
-
const toggleFixedToolbar = async ( isFixed ) => {
|
243
|
-
await page.evaluate( ( _isFixed ) => {
|
244
|
-
const { select, dispatch } = wp.data;
|
245
|
-
const isCurrentlyFixed =
|
246
|
-
select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' );
|
247
|
-
if ( isCurrentlyFixed !== _isFixed ) {
|
248
|
-
dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' );
|
249
|
-
}
|
250
|
-
}, isFixed );
|
251
|
-
};
|
252
|
-
|
253
|
-
it( 'allows Left to be pressed during creation when the toolbar is fixed to top', async () => {
|
254
|
-
await toggleFixedToolbar( true );
|
255
|
-
|
256
|
-
await clickBlockAppender();
|
257
|
-
await page.keyboard.type( 'Text' );
|
258
|
-
await page.click( 'button[aria-label="Link"]' );
|
259
|
-
|
260
|
-
// Typing "left" should not close the dialog.
|
261
|
-
await page.keyboard.press( 'ArrowLeft' );
|
262
|
-
let popover = await page.$(
|
263
|
-
'.components-popover__content .block-editor-link-control'
|
264
|
-
);
|
265
|
-
expect( popover ).not.toBeNull();
|
266
|
-
|
267
|
-
// Escape should close the dialog still.
|
268
|
-
await page.keyboard.press( 'Escape' );
|
269
|
-
popover = await page.$(
|
270
|
-
'.components-popover__content .block-editor-link-control'
|
271
|
-
);
|
272
|
-
expect( popover ).toBeNull();
|
273
|
-
} );
|
274
|
-
|
275
|
-
it( 'allows Left to be pressed during creation in "Docked Toolbar" mode', async () => {
|
276
|
-
await toggleFixedToolbar( false );
|
277
|
-
|
278
|
-
await clickBlockAppender();
|
279
|
-
await page.keyboard.type( 'Text' );
|
280
|
-
|
281
|
-
await clickBlockToolbarButton( 'Link' );
|
282
|
-
|
283
|
-
// Typing "left" should not close the dialog.
|
284
|
-
await page.keyboard.press( 'ArrowLeft' );
|
285
|
-
let popover = await page.$(
|
286
|
-
'.components-popover__content .block-editor-link-control'
|
287
|
-
);
|
288
|
-
expect( popover ).not.toBeNull();
|
289
|
-
|
290
|
-
// Escape should close the dialog still.
|
291
|
-
await page.keyboard.press( 'Escape' );
|
292
|
-
popover = await page.$(
|
293
|
-
'.components-popover__content .block-editor-link-control'
|
294
|
-
);
|
295
|
-
expect( popover ).toBeNull();
|
296
|
-
} );
|
297
|
-
|
298
|
-
it( 'can be edited with collapsed selection', async () => {
|
299
|
-
await createAndReselectLink();
|
300
|
-
// Make a collapsed selection inside the link
|
301
|
-
await page.keyboard.press( 'ArrowLeft' );
|
302
|
-
await page.keyboard.press( 'ArrowRight' );
|
303
|
-
await showBlockToolbar();
|
304
|
-
const [ editButton ] = await page.$x(
|
305
|
-
'//button[contains(@aria-label, "Edit")]'
|
306
|
-
);
|
307
|
-
await editButton.click();
|
308
|
-
await waitForURLFieldAutoFocus();
|
309
|
-
await page.keyboard.type( '/handbook' );
|
310
|
-
await page.keyboard.press( 'Enter' );
|
311
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
312
|
-
} );
|
313
|
-
|
314
|
-
const createPostWithTitle = async ( titleText ) => {
|
315
|
-
await createNewPost();
|
316
|
-
await canvas().type( '.editor-post-title__input', titleText );
|
317
|
-
await page.click( '.editor-post-publish-panel__toggle' );
|
318
|
-
|
319
|
-
// Disable reason: Wait for the animation to complete, since otherwise the
|
320
|
-
// click attempt may occur at the wrong point.
|
321
|
-
// eslint-disable-next-line no-restricted-syntax
|
322
|
-
await page.waitForTimeout( 100 );
|
323
|
-
|
324
|
-
// Publish the post.
|
325
|
-
await page.click( '.editor-post-publish-button' );
|
326
|
-
|
327
|
-
// Return the URL of the new post.
|
328
|
-
await page.waitForSelector(
|
329
|
-
'.post-publish-panel__postpublish-post-address input'
|
330
|
-
);
|
331
|
-
return page.evaluate(
|
332
|
-
() =>
|
333
|
-
document.querySelector(
|
334
|
-
'.post-publish-panel__postpublish-post-address input'
|
335
|
-
).value
|
336
|
-
);
|
337
|
-
};
|
338
|
-
|
339
|
-
it( 'allows use of escape key to dismiss the url popover', async () => {
|
340
|
-
const titleText = 'Test post escape';
|
341
|
-
await createPostWithTitle( titleText );
|
342
|
-
|
343
|
-
await createNewPost();
|
344
|
-
await clickBlockAppender();
|
345
|
-
|
346
|
-
// Now in a new post and try to create a link from an autocomplete suggestion using the keyboard.
|
347
|
-
await page.keyboard.type( 'This is Gutenberg' );
|
348
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
349
|
-
|
350
|
-
// Press Cmd+K to insert a link.
|
351
|
-
await pressKeyWithModifier( 'primary', 'K' );
|
352
|
-
|
353
|
-
// Wait for the URL field to auto-focus.
|
354
|
-
await waitForURLFieldAutoFocus();
|
355
|
-
expect(
|
356
|
-
await page.$(
|
357
|
-
'.components-popover__content .block-editor-link-control'
|
358
|
-
)
|
359
|
-
).not.toBeNull();
|
360
|
-
|
361
|
-
// Trigger the autocomplete suggestion list and select the first suggestion.
|
362
|
-
await page.keyboard.type( titleText );
|
363
|
-
await page.waitForSelector( '.block-editor-link-control__search-item' );
|
364
|
-
await page.keyboard.press( 'ArrowDown' );
|
365
|
-
|
366
|
-
// Expect the escape key to dismiss the popover when the autocomplete suggestion list is open.
|
367
|
-
await page.keyboard.press( 'Escape' );
|
368
|
-
expect(
|
369
|
-
await page.$(
|
370
|
-
'.components-popover__content .block-editor-link-control'
|
371
|
-
)
|
372
|
-
).toBeNull();
|
373
|
-
|
374
|
-
// Confirm that selection is returned to where it was before launching
|
375
|
-
// the link editor, with "Gutenberg" as an uncollapsed selection.
|
376
|
-
await page.keyboard.press( 'ArrowRight' );
|
377
|
-
await page.keyboard.type( '.' );
|
378
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
379
|
-
|
380
|
-
// Press Cmd+K to insert a link.
|
381
|
-
await pressKeyWithModifier( 'primary', 'K' );
|
382
|
-
|
383
|
-
// Wait for the URL field to auto-focus.
|
384
|
-
await waitForURLFieldAutoFocus();
|
385
|
-
expect(
|
386
|
-
await page.$(
|
387
|
-
'.components-popover__content .block-editor-link-control'
|
388
|
-
)
|
389
|
-
).not.toBeNull();
|
390
|
-
|
391
|
-
// Expect the escape key to dismiss the popover normally.
|
392
|
-
await page.keyboard.press( 'Escape' );
|
393
|
-
expect(
|
394
|
-
await page.$(
|
395
|
-
'.components-popover__content .block-editor-link-control'
|
396
|
-
)
|
397
|
-
).toBeNull();
|
398
|
-
|
399
|
-
// Press Cmd+K to insert a link.
|
400
|
-
await pressKeyWithModifier( 'primary', 'K' );
|
401
|
-
|
402
|
-
// Wait for the URL field to auto-focus.
|
403
|
-
await waitForURLFieldAutoFocus();
|
404
|
-
expect(
|
405
|
-
await page.$(
|
406
|
-
'.components-popover__content .block-editor-link-control'
|
407
|
-
)
|
408
|
-
).not.toBeNull();
|
409
|
-
|
410
|
-
// Tab to the "Open in new tab" toggle.
|
411
|
-
await page.keyboard.press( 'Tab' );
|
412
|
-
await page.keyboard.press( 'Tab' );
|
413
|
-
|
414
|
-
// Expect the escape key to dismiss the popover normally.
|
415
|
-
await page.keyboard.press( 'Escape' );
|
416
|
-
expect(
|
417
|
-
await page.$(
|
418
|
-
'.components-popover__content .block-editor-link-control'
|
419
|
-
)
|
420
|
-
).toBeNull();
|
421
|
-
} );
|
422
|
-
|
423
|
-
it( 'can be modified using the keyboard once a link has been set', async () => {
|
424
|
-
const URL = 'https://wordpress.org/gutenberg';
|
425
|
-
|
426
|
-
// Create a block with some text and format it as a link.
|
427
|
-
await clickBlockAppender();
|
428
|
-
await page.keyboard.type( 'This is Gutenberg' );
|
429
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
430
|
-
await pressKeyWithModifier( 'primary', 'K' );
|
431
|
-
await waitForURLFieldAutoFocus();
|
432
|
-
await page.keyboard.type( URL );
|
433
|
-
await page.keyboard.press( 'Enter' );
|
434
|
-
|
435
|
-
// Deselect the link text by moving the caret to the end of the line
|
436
|
-
// and the link popover should not be displayed.
|
437
|
-
await page.keyboard.press( 'End' );
|
438
|
-
expect(
|
439
|
-
await page.$(
|
440
|
-
'.components-popover__content .block-editor-link-control'
|
441
|
-
)
|
442
|
-
).toBeNull();
|
443
|
-
|
444
|
-
// Move the caret back into the link text and the link popover
|
445
|
-
// should be displayed.
|
446
|
-
await page.keyboard.press( 'ArrowLeft' );
|
447
|
-
expect(
|
448
|
-
await page.$(
|
449
|
-
'.components-popover__content .block-editor-link-control'
|
450
|
-
)
|
451
|
-
).not.toBeNull();
|
452
|
-
|
453
|
-
// Press Cmd+K to edit the link and the url-input should become
|
454
|
-
// focused with the value previously inserted.
|
455
|
-
await pressKeyWithModifier( 'primary', 'K' );
|
456
|
-
await waitForURLFieldAutoFocus();
|
457
|
-
const isInURLInput = await page.evaluate(
|
458
|
-
() => !! document.activeElement.closest( '.block-editor-url-input' )
|
459
|
-
);
|
460
|
-
expect( isInURLInput ).toBe( true );
|
461
|
-
const activeElementValue = await page.evaluate(
|
462
|
-
() => document.activeElement.value
|
463
|
-
);
|
464
|
-
expect( activeElementValue ).toBe( URL );
|
465
|
-
|
466
|
-
// Confirm that submitting the input without any changes keeps the same
|
467
|
-
// value and moves focus back to the paragraph.
|
468
|
-
await page.keyboard.press( 'Enter' );
|
469
|
-
await page.keyboard.press( 'ArrowRight' );
|
470
|
-
await page.keyboard.type( '.' );
|
471
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
472
|
-
} );
|
473
|
-
|
474
|
-
it( 'adds an assertive message for screenreader users when an invalid link is set', async () => {
|
475
|
-
await clickBlockAppender();
|
476
|
-
await page.keyboard.type( 'This is Gutenberg' );
|
477
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
478
|
-
await pressKeyWithModifier( 'primary', 'K' );
|
479
|
-
await waitForURLFieldAutoFocus();
|
480
|
-
await page.keyboard.type( 'http://#test.com' );
|
481
|
-
await page.keyboard.press( 'Enter' );
|
482
|
-
const assertiveContent = await page.evaluate(
|
483
|
-
() => document.querySelector( '#a11y-speak-assertive' ).textContent
|
484
|
-
);
|
485
|
-
expect( assertiveContent.trim() ).toBe(
|
486
|
-
'Warning: the link has been inserted but may have errors. Please test it.'
|
487
|
-
);
|
488
|
-
} );
|
489
|
-
|
490
|
-
describe( 'Editing link text', () => {
|
491
|
-
it( 'should not display text input when initially creating the link', async () => {
|
492
|
-
// Create a block with some text.
|
493
|
-
await clickBlockAppender();
|
494
|
-
await page.keyboard.type( 'This is Gutenberg: ' );
|
495
|
-
|
496
|
-
// Press Cmd+K to insert a link.
|
497
|
-
await pressKeyWithModifier( 'primary', 'K' );
|
498
|
-
|
499
|
-
const [ settingsToggle ] = await page.$x(
|
500
|
-
'//button[contains(text(), "Advanced")]'
|
501
|
-
);
|
502
|
-
await settingsToggle.click();
|
503
|
-
|
504
|
-
const textInput = await page
|
505
|
-
.waitForXPath(
|
506
|
-
'//[contains(@class, "block-editor-link-control__search-input-wrapper")]//label[contains(text(), "Text")]',
|
507
|
-
{
|
508
|
-
timeout: 1000,
|
509
|
-
}
|
510
|
-
)
|
511
|
-
.catch( () => false );
|
512
|
-
|
513
|
-
expect( textInput ).toBeFalsy();
|
514
|
-
} );
|
515
|
-
|
516
|
-
it( 'should display text input when the link has a valid URL value', async () => {
|
517
|
-
await createAndReselectLink();
|
518
|
-
|
519
|
-
// Make a collapsed selection inside the link. This is used
|
520
|
-
// as a stress test to ensure we can find the link text from a
|
521
|
-
// collapsed RichTextValue that contains a link format.
|
522
|
-
await page.keyboard.press( 'ArrowLeft' );
|
523
|
-
await page.keyboard.press( 'ArrowRight' );
|
524
|
-
|
525
|
-
const [ editButton ] = await page.$x(
|
526
|
-
'//button[contains(@aria-label, "Edit")]'
|
527
|
-
);
|
528
|
-
await editButton.click();
|
529
|
-
|
530
|
-
await waitForURLFieldAutoFocus();
|
531
|
-
|
532
|
-
await pressKeyWithModifier( 'shift', 'Tab' );
|
533
|
-
|
534
|
-
// Tabbing should land us in the text input.
|
535
|
-
const { isTextInput, textValue } = await page.evaluate( () => {
|
536
|
-
const el = document.activeElement;
|
537
|
-
|
538
|
-
return {
|
539
|
-
isTextInput: el.matches( 'input[type="text"]' ),
|
540
|
-
textValue: el.value,
|
541
|
-
};
|
542
|
-
} );
|
543
|
-
|
544
|
-
// Let's check we've focused a text input.
|
545
|
-
expect( isTextInput ).toBe( true );
|
546
|
-
|
547
|
-
// Link was created on text value "Gutenberg". We expect
|
548
|
-
// the text input to reflect that value.
|
549
|
-
expect( textValue ).toBe( 'Gutenberg' );
|
550
|
-
} );
|
551
|
-
|
552
|
-
it( 'should preserve trailing/leading whitespace from linked text in text input', async () => {
|
553
|
-
const textToSelect = ` spaces `;
|
554
|
-
const textWithWhitespace = `Text with leading and trailing${ textToSelect }`;
|
555
|
-
|
556
|
-
// Create a block with some text.
|
557
|
-
await clickBlockAppender();
|
558
|
-
await page.keyboard.type( textWithWhitespace );
|
559
|
-
|
560
|
-
// Use arrow keys to select only the text with the leading
|
561
|
-
// and trailing whitespace.
|
562
|
-
for ( let index = 0; index < textToSelect.length; index++ ) {
|
563
|
-
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
|
564
|
-
}
|
565
|
-
|
566
|
-
// Click on the Link button.
|
567
|
-
await page.click( 'button[aria-label="Link"]' );
|
568
|
-
|
569
|
-
// Wait for the URL field to auto-focus.
|
570
|
-
await waitForURLFieldAutoFocus();
|
571
|
-
|
572
|
-
// Type a URL.
|
573
|
-
await page.keyboard.type( 'https://wordpress.org/gutenberg' );
|
574
|
-
|
575
|
-
// Click on the Submit button.
|
576
|
-
await page.keyboard.press( 'Enter' );
|
577
|
-
|
578
|
-
// Reselect the link.
|
579
|
-
await page.keyboard.press( 'ArrowLeft' );
|
580
|
-
|
581
|
-
await showBlockToolbar();
|
582
|
-
|
583
|
-
const [ editButton ] = await page.$x(
|
584
|
-
'//button[contains(@aria-label, "Edit")]'
|
585
|
-
);
|
586
|
-
|
587
|
-
await editButton.click();
|
588
|
-
|
589
|
-
await waitForURLFieldAutoFocus();
|
590
|
-
|
591
|
-
// Tabbing backward should land us in the "Text" input.
|
592
|
-
await pressKeyWithModifier( 'shift', 'Tab' );
|
593
|
-
|
594
|
-
const textInputValue = await page.evaluate(
|
595
|
-
() => document.activeElement.value
|
596
|
-
);
|
597
|
-
|
598
|
-
expect( textInputValue ).toBe( textToSelect );
|
599
|
-
} );
|
600
|
-
|
601
|
-
it( 'should allow for modification of link text via Link UI', async () => {
|
602
|
-
const originalLinkText = 'Gutenberg';
|
603
|
-
const changedLinkText =
|
604
|
-
' link text that was modified via the Link UI to include spaces ';
|
605
|
-
|
606
|
-
await createAndReselectLink();
|
607
|
-
|
608
|
-
// Make a collapsed selection inside the link. This is used
|
609
|
-
// as a stress test to ensure we can find the link text from a
|
610
|
-
// collapsed RichTextValue that contains a link format.
|
611
|
-
await page.keyboard.press( 'ArrowLeft' );
|
612
|
-
await page.keyboard.press( 'ArrowRight' );
|
613
|
-
|
614
|
-
await showBlockToolbar();
|
615
|
-
const [ editButton ] = await page.$x(
|
616
|
-
'//button[contains(@aria-label, "Edit")]'
|
617
|
-
);
|
618
|
-
await editButton.click();
|
619
|
-
|
620
|
-
await waitForURLFieldAutoFocus();
|
621
|
-
|
622
|
-
await pressKeyWithModifier( 'shift', 'Tab' );
|
623
|
-
|
624
|
-
const textInputValue = await page.evaluate(
|
625
|
-
() => document.activeElement.value
|
626
|
-
);
|
627
|
-
|
628
|
-
// At this point, we still expect the text input
|
629
|
-
// to reflect the original value with no modifications.
|
630
|
-
expect( textInputValue ).toBe( originalLinkText );
|
631
|
-
|
632
|
-
// Select all the link text in the input.
|
633
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
634
|
-
|
635
|
-
// Modify the link text value.
|
636
|
-
await page.keyboard.type( changedLinkText );
|
637
|
-
|
638
|
-
// Submit the change.
|
639
|
-
await page.keyboard.press( 'Enter' );
|
640
|
-
|
641
|
-
// Check the created link reflects the link text.
|
642
|
-
const actualLinkText = await canvas().evaluate(
|
643
|
-
() =>
|
644
|
-
document.querySelector(
|
645
|
-
'.block-editor-rich-text__editable a'
|
646
|
-
).textContent
|
647
|
-
);
|
648
|
-
expect( actualLinkText ).toBe( changedLinkText );
|
649
|
-
} );
|
650
|
-
|
651
|
-
it( 'should display (capture the) text from the currently active link even if there is a rich text selection', async () => {
|
652
|
-
const originalLinkText = 'Gutenberg';
|
653
|
-
|
654
|
-
await createAndReselectLink();
|
655
|
-
|
656
|
-
// Make a collapsed selection inside the link in order
|
657
|
-
// to activate the Link UI.
|
658
|
-
await page.keyboard.press( 'ArrowLeft' );
|
659
|
-
await page.keyboard.press( 'ArrowRight' );
|
660
|
-
|
661
|
-
const [ editButton ] = await page.$x(
|
662
|
-
'//button[contains(@aria-label, "Edit")]'
|
663
|
-
);
|
664
|
-
await editButton.click();
|
665
|
-
await waitForURLFieldAutoFocus();
|
666
|
-
|
667
|
-
const [ settingsToggle ] = await page.$x(
|
668
|
-
'//button[contains(text(), "Advanced")]'
|
669
|
-
);
|
670
|
-
await settingsToggle.click();
|
671
|
-
|
672
|
-
// Wait for settings to open.
|
673
|
-
await page.waitForXPath( `//label[text()='Open in new tab']` );
|
674
|
-
|
675
|
-
// Move focus back to RichText for the underlying link.
|
676
|
-
await pressKeyWithModifier( 'shift', 'Tab' );
|
677
|
-
await pressKeyWithModifier( 'shift', 'Tab' );
|
678
|
-
await pressKeyWithModifier( 'shift', 'Tab' );
|
679
|
-
|
680
|
-
// Make a selection within the RichText.
|
681
|
-
await pressKeyWithModifier( 'shift', 'ArrowRight' );
|
682
|
-
await pressKeyWithModifier( 'shift', 'ArrowRight' );
|
683
|
-
await pressKeyWithModifier( 'shift', 'ArrowRight' );
|
684
|
-
|
685
|
-
// Move back to the text input.
|
686
|
-
await pressKeyTimes( 'Tab', 1 );
|
687
|
-
|
688
|
-
// Tabbing back should land us in the text input.
|
689
|
-
const textInputValue = await page.evaluate(
|
690
|
-
() => document.activeElement.value
|
691
|
-
);
|
692
|
-
|
693
|
-
// Making a selection within the link text whilst the Link UI
|
694
|
-
// is open should not alter the value in the Link UI's text
|
695
|
-
// input. It should remain as the full text of the currently
|
696
|
-
// focused link format.
|
697
|
-
expect( textInputValue ).toBe( originalLinkText );
|
698
|
-
} );
|
699
|
-
} );
|
700
|
-
|
701
|
-
describe( 'Disabling Link UI active state', () => {
|
702
|
-
it( 'should not show the Link UI when selection extends beyond link boundary', async () => {
|
703
|
-
const linkedText = `Gutenberg`;
|
704
|
-
const textBeyondLinkedText = ` and more text.`;
|
705
|
-
|
706
|
-
// Create a block with some text.
|
707
|
-
await clickBlockAppender();
|
708
|
-
await page.keyboard.type(
|
709
|
-
`This is ${ linkedText }${ textBeyondLinkedText }`
|
710
|
-
);
|
711
|
-
|
712
|
-
// Move cursor next to end of `linkedText`
|
713
|
-
for (
|
714
|
-
let index = 0;
|
715
|
-
index < textBeyondLinkedText.length;
|
716
|
-
index++
|
717
|
-
) {
|
718
|
-
await page.keyboard.press( 'ArrowLeft' );
|
719
|
-
}
|
720
|
-
|
721
|
-
// Select the linkedText.
|
722
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
723
|
-
|
724
|
-
// Click on the Link button.
|
725
|
-
await page.click( 'button[aria-label="Link"]' );
|
726
|
-
|
727
|
-
// Wait for the URL field to auto-focus.
|
728
|
-
await waitForURLFieldAutoFocus();
|
729
|
-
|
730
|
-
// Type a URL.
|
731
|
-
await page.keyboard.type( 'https://wordpress.org/gutenberg' );
|
732
|
-
|
733
|
-
// Update the link.
|
734
|
-
await page.keyboard.press( 'Enter' );
|
735
|
-
|
736
|
-
await page.keyboard.press( 'ArrowLeft' );
|
737
|
-
await page.keyboard.press( 'ArrowLeft' );
|
738
|
-
|
739
|
-
expect(
|
740
|
-
await page.$(
|
741
|
-
'.components-popover__content .block-editor-link-control'
|
742
|
-
)
|
743
|
-
).not.toBeNull();
|
744
|
-
|
745
|
-
// Make selection starting within the link and moving beyond boundary to the left.
|
746
|
-
for ( let index = 0; index < linkedText.length; index++ ) {
|
747
|
-
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
|
748
|
-
}
|
749
|
-
|
750
|
-
// The Link UI should have disappeared (i.e. be inactive).
|
751
|
-
expect(
|
752
|
-
await page.$(
|
753
|
-
'.components-popover__content .block-editor-link-control'
|
754
|
-
)
|
755
|
-
).toBeNull();
|
756
|
-
|
757
|
-
// Cancel selection and move back within the Link.
|
758
|
-
await page.keyboard.press( 'ArrowRight' );
|
759
|
-
|
760
|
-
// We should see the Link UI displayed again.
|
761
|
-
expect(
|
762
|
-
await page.$(
|
763
|
-
'.components-popover__content .block-editor-link-control'
|
764
|
-
)
|
765
|
-
).not.toBeNull();
|
766
|
-
|
767
|
-
// Make selection starting within the link and moving beyond boundary to the right.
|
768
|
-
await pressKeyWithModifier( 'shift', 'ArrowRight' );
|
769
|
-
await pressKeyWithModifier( 'shift', 'ArrowRight' );
|
770
|
-
await pressKeyWithModifier( 'shift', 'ArrowRight' );
|
771
|
-
|
772
|
-
// The Link UI should have disappeared (i.e. be inactive).
|
773
|
-
expect(
|
774
|
-
await page.$(
|
775
|
-
'.components-popover__content .block-editor-link-control'
|
776
|
-
)
|
777
|
-
).toBeNull();
|
778
|
-
} );
|
779
|
-
|
780
|
-
it( 'should not show the Link UI when selection extends into another link', async () => {
|
781
|
-
const linkedTextOne = `Gutenberg`;
|
782
|
-
const linkedTextTwo = `Block Editor`;
|
783
|
-
const linkOneURL = 'https://wordpress.org';
|
784
|
-
const linkTwoURL = 'https://wordpress.org/gutenberg';
|
785
|
-
|
786
|
-
// Create a block with some text.
|
787
|
-
await clickBlockAppender();
|
788
|
-
await page.keyboard.type(
|
789
|
-
`This is the ${ linkedTextOne }${ linkedTextTwo }`
|
790
|
-
);
|
791
|
-
|
792
|
-
// Select the linkedTextTwo.
|
793
|
-
for ( let index = 0; index < linkedTextTwo.length; index++ ) {
|
794
|
-
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
|
795
|
-
}
|
796
|
-
|
797
|
-
// Click on the Link button.
|
798
|
-
await page.click( 'button[aria-label="Link"]' );
|
799
|
-
|
800
|
-
// Wait for the URL field to auto-focus.
|
801
|
-
await waitForURLFieldAutoFocus();
|
802
|
-
|
803
|
-
// Type a URL.
|
804
|
-
await page.keyboard.type( linkTwoURL );
|
805
|
-
|
806
|
-
// Update the link.
|
807
|
-
await page.keyboard.press( 'Enter' );
|
808
|
-
|
809
|
-
// Move cursor next to the **end** of `linkTextOne`
|
810
|
-
for ( let index = 0; index < linkedTextTwo.length + 2; index++ ) {
|
811
|
-
await page.keyboard.press( 'ArrowLeft' );
|
812
|
-
}
|
813
|
-
|
814
|
-
// Select `linkTextOne`
|
815
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
|
816
|
-
|
817
|
-
// Click on the Link button.
|
818
|
-
await page.click( 'button[aria-label="Link"]' );
|
819
|
-
|
820
|
-
// Wait for the URL field to auto-focus.
|
821
|
-
await waitForURLFieldAutoFocus();
|
822
|
-
|
823
|
-
// Type a URL.
|
824
|
-
await page.keyboard.type( linkOneURL );
|
825
|
-
|
826
|
-
// Update the link.
|
827
|
-
await page.keyboard.press( 'Enter' );
|
828
|
-
|
829
|
-
// Move cursor within `linkTextOne`
|
830
|
-
for ( let index = 0; index < 3; index++ ) {
|
831
|
-
await page.keyboard.press( 'ArrowLeft' );
|
832
|
-
}
|
833
|
-
|
834
|
-
// Link UI should activate for `linkTextOne`
|
835
|
-
expect(
|
836
|
-
await page.$(
|
837
|
-
'.components-popover__content .block-editor-link-control'
|
838
|
-
)
|
839
|
-
).not.toBeNull();
|
840
|
-
|
841
|
-
// Expand selection so that it overlaps with `linkTextTwo`
|
842
|
-
for ( let index = 0; index < 3; index++ ) {
|
843
|
-
await pressKeyWithModifier( 'shift', 'ArrowRight' );
|
844
|
-
}
|
845
|
-
|
846
|
-
// Link UI should be inactive.
|
847
|
-
expect(
|
848
|
-
await page.$(
|
849
|
-
'.components-popover__content .block-editor-link-control'
|
850
|
-
)
|
851
|
-
).toBeNull();
|
852
|
-
} );
|
853
|
-
|
854
|
-
// Based on issue reported in https://github.com/WordPress/gutenberg/issues/41771/.
|
855
|
-
it( 'should correctly replace targetted links text within rich text value when multiple matching values exist', async () => {
|
856
|
-
// Create a block with some text.
|
857
|
-
await clickBlockAppender();
|
858
|
-
|
859
|
-
// Note the two instances of the string "a".
|
860
|
-
await page.keyboard.type( `a b c a` );
|
861
|
-
|
862
|
-
// Select the last "a" only.
|
863
|
-
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
|
864
|
-
|
865
|
-
// Click on the Link button.
|
866
|
-
await page.click( 'button[aria-label="Link"]' );
|
867
|
-
|
868
|
-
// Wait for the URL field to auto-focus.
|
869
|
-
await waitForURLFieldAutoFocus();
|
870
|
-
|
871
|
-
// Type a URL.
|
872
|
-
await page.keyboard.type( 'www.wordpress.org' );
|
873
|
-
|
874
|
-
// Update the link.
|
875
|
-
await page.keyboard.press( 'Enter' );
|
876
|
-
|
877
|
-
await page.keyboard.press( 'ArrowLeft' );
|
878
|
-
|
879
|
-
// Move to "Edit" button in Link UI
|
880
|
-
await page.keyboard.press( 'Tab' );
|
881
|
-
await page.keyboard.press( 'Tab' );
|
882
|
-
await page.keyboard.press( 'Enter' );
|
883
|
-
|
884
|
-
await waitForURLFieldAutoFocus();
|
885
|
-
|
886
|
-
// Move to "Text" field.
|
887
|
-
await pressKeyWithModifier( 'shift', 'Tab' );
|
888
|
-
|
889
|
-
// Delete existing value from "Text" field
|
890
|
-
await page.keyboard.press( 'Delete' );
|
891
|
-
|
892
|
-
// Change text to "z"
|
893
|
-
await page.keyboard.type( 'z' );
|
894
|
-
|
895
|
-
await page.keyboard.press( 'Enter' );
|
896
|
-
|
897
|
-
const richTextText = await canvas().evaluate(
|
898
|
-
() =>
|
899
|
-
document.querySelector(
|
900
|
-
'.block-editor-rich-text__editable'
|
901
|
-
).textContent
|
902
|
-
);
|
903
|
-
// Check that the correct (i.e. last) instance of "a" was replaced with "z".
|
904
|
-
expect( richTextText ).toBe( 'a b c z' );
|
905
|
-
|
906
|
-
const richTextLink = await canvas().evaluate(
|
907
|
-
() =>
|
908
|
-
document.querySelector(
|
909
|
-
'.block-editor-rich-text__editable a'
|
910
|
-
).textContent
|
911
|
-
);
|
912
|
-
// Check that the correct (i.e. last) instance of "a" was replaced with "z".
|
913
|
-
expect( richTextLink ).toBe( 'z' );
|
914
|
-
} );
|
915
|
-
} );
|
916
|
-
} );
|
package/specs/local/demo.test.js
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
createEmbeddingMatcher,
|
6
|
-
createJSONResponse,
|
7
|
-
createNewPost,
|
8
|
-
setUpResponseMocking,
|
9
|
-
visitAdminPage,
|
10
|
-
} from '@wordpress/e2e-test-utils';
|
11
|
-
|
12
|
-
const MOCK_VIMEO_RESPONSE = {
|
13
|
-
url: 'https://vimeo.com/22439234',
|
14
|
-
html: '<iframe width="16" height="9"></iframe>',
|
15
|
-
type: 'video',
|
16
|
-
provider_name: 'Vimeo',
|
17
|
-
provider_url: 'https://vimeo.com',
|
18
|
-
version: '1.0',
|
19
|
-
};
|
20
|
-
|
21
|
-
describe( 'new editor state', () => {
|
22
|
-
beforeAll( async () => {
|
23
|
-
// First, make sure that the block editor is properly configured.
|
24
|
-
await createNewPost();
|
25
|
-
|
26
|
-
await setUpResponseMocking( [
|
27
|
-
{
|
28
|
-
match: createEmbeddingMatcher( 'https://vimeo.com/22439234' ),
|
29
|
-
onRequestMatch: createJSONResponse( MOCK_VIMEO_RESPONSE ),
|
30
|
-
},
|
31
|
-
] );
|
32
|
-
|
33
|
-
await Promise.all( [
|
34
|
-
visitAdminPage( 'post-new.php', 'gutenberg-demo' ),
|
35
|
-
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
36
|
-
] );
|
37
|
-
} );
|
38
|
-
|
39
|
-
it( 'content should load, making the post dirty', async () => {
|
40
|
-
const isDirty = await page.evaluate( () => {
|
41
|
-
const { select } = window.wp.data;
|
42
|
-
return select( 'core/editor' ).isEditedPostDirty();
|
43
|
-
} );
|
44
|
-
expect( isDirty ).toBeTruthy();
|
45
|
-
|
46
|
-
await page.waitForSelector( 'button.editor-post-save-draft' );
|
47
|
-
|
48
|
-
expect( await page.$( 'button.editor-post-save-draft' ) ).toBeTruthy();
|
49
|
-
} );
|
50
|
-
} );
|