@wordpress/e2e-tests 4.3.0 → 4.6.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/config/flaky-tests-reporter.js +3 -3
- package/package.json +6 -6
- package/specs/editor/blocks/cover.test.js +10 -14
- package/specs/editor/blocks/heading.test.js +1 -5
- package/specs/editor/blocks/navigation.test.js +72 -23
- package/specs/editor/plugins/cpt-locking.test.js +2 -3
- package/specs/editor/plugins/iframed-block.test.js +3 -2
- package/specs/editor/plugins/iframed-inline-styles.test.js +1 -0
- package/specs/editor/plugins/iframed-masonry-block.test.js +3 -2
- package/specs/editor/plugins/inner-blocks-allowed-blocks.test.js +3 -1
- package/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap +1 -1
- package/specs/editor/various/datepicker.test.js +30 -18
- package/specs/editor/various/embedding.test.js +2 -4
- package/specs/editor/various/links.test.js +2 -3
- package/specs/editor/various/navigable-toolbar.test.js +2 -3
- package/specs/editor/various/post-visibility.test.js +1 -1
- package/specs/editor/various/publishing.test.js +4 -2
- package/specs/editor/various/scheduling.test.js +2 -2
- package/specs/editor/various/sidebar.test.js +4 -6
- package/specs/editor/various/switch-to-draft.test.js +1 -1
- package/specs/editor/various/taxonomies.test.js +8 -7
- package/specs/editor/various/writing-flow.test.js +19 -0
- package/specs/experiments/navigation-editor.test.js +4 -6
- package/specs/performance/post-editor.test.js +10 -14
- package/specs/performance/site-editor.test.js +2 -5
- package/specs/widgets/editing-widgets.test.js +12 -8
- package/specs/editor/blocks/__snapshots__/buttons.test.js.snap +0 -33
- package/specs/editor/blocks/__snapshots__/code.test.js.snap +0 -14
- package/specs/editor/blocks/__snapshots__/html.test.js.snap +0 -8
- package/specs/editor/blocks/__snapshots__/preformatted.test.js.snap +0 -24
- package/specs/editor/blocks/__snapshots__/separator.test.js.snap +0 -7
- package/specs/editor/blocks/__snapshots__/spacer.test.js.snap +0 -13
- package/specs/editor/blocks/__snapshots__/table.test.js.snap +0 -61
- package/specs/editor/blocks/buttons.test.js +0 -95
- package/specs/editor/blocks/code.test.js +0 -48
- package/specs/editor/blocks/html.test.js +0 -31
- package/specs/editor/blocks/preformatted.test.js +0 -62
- package/specs/editor/blocks/separator.test.js +0 -22
- package/specs/editor/blocks/spacer.test.js +0 -48
- package/specs/editor/blocks/table.test.js +0 -296
- package/specs/editor/various/__snapshots__/rtl.test.js.snap +0 -63
- package/specs/editor/various/preview.test.js +0 -425
- package/specs/editor/various/rtl.test.js +0 -129
- package/specs/site-editor/style-variations.test.js +0 -213
- package/specs/site-editor/template-part.test.js +0 -346
- package/specs/site-editor/template-revert.test.js +0 -209
- package/themes/style-variations/block-templates/index.html +0 -11
- package/themes/style-variations/index.php +0 -0
- package/themes/style-variations/style.css +0 -15
- package/themes/style-variations/styles/pink.json +0 -33
- package/themes/style-variations/styles/yellow.json +0 -12
- package/themes/style-variations/theme.json +0 -8
@@ -1,425 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
clickOnCloseModalButton,
|
7
|
-
clickOnMoreMenuItem,
|
8
|
-
createNewPost,
|
9
|
-
createURL,
|
10
|
-
deactivatePlugin,
|
11
|
-
publishPost,
|
12
|
-
saveDraft,
|
13
|
-
openPreviewPage,
|
14
|
-
pressKeyWithModifier,
|
15
|
-
} from '@wordpress/e2e-test-utils';
|
16
|
-
|
17
|
-
/** @typedef {import('puppeteer-core').Page} Page */
|
18
|
-
|
19
|
-
/**
|
20
|
-
* Given the Page instance for the editor, opens preview drodpdown, and
|
21
|
-
* awaits the presence of the external preview selector.
|
22
|
-
*
|
23
|
-
* @param {Page} editorPage current editor page.
|
24
|
-
*
|
25
|
-
* @return {Promise} Promise resolving once selector is visible on page.
|
26
|
-
*/
|
27
|
-
async function waitForPreviewDropdownOpen( editorPage ) {
|
28
|
-
await editorPage.click( '.block-editor-post-preview__button-toggle' );
|
29
|
-
return editorPage.waitForSelector(
|
30
|
-
'.edit-post-header-preview__button-external'
|
31
|
-
);
|
32
|
-
}
|
33
|
-
|
34
|
-
/**
|
35
|
-
* Given a Puppeteer Page instance for a preview window, clicks Preview, and
|
36
|
-
* awaits the window navigation.
|
37
|
-
*
|
38
|
-
* @param {Page} previewPage Page on which to await navigation.
|
39
|
-
*
|
40
|
-
* @return {Promise} Promise resolving once navigation completes.
|
41
|
-
*/
|
42
|
-
async function waitForPreviewNavigation( previewPage ) {
|
43
|
-
await page.click( '.edit-post-header-preview__button-external' );
|
44
|
-
return previewPage.waitForNavigation();
|
45
|
-
}
|
46
|
-
|
47
|
-
/**
|
48
|
-
* Enables or disables the custom fields option.
|
49
|
-
*
|
50
|
-
* Note that this is implemented separately from the `togglePreferencesOption`
|
51
|
-
* utility, since the custom fields option triggers a page reload and requires
|
52
|
-
* extra async logic to wait for navigation to complete.
|
53
|
-
*
|
54
|
-
* @param {boolean} shouldBeChecked If true, turns the option on. If false, off.
|
55
|
-
*/
|
56
|
-
async function toggleCustomFieldsOption( shouldBeChecked ) {
|
57
|
-
const baseXPath = '//*[contains(@class, "interface-preferences-modal")]';
|
58
|
-
const paneslXPath = `${ baseXPath }//button[contains(text(), "Panels")]`;
|
59
|
-
const checkboxXPath = `${ baseXPath }//label[contains(text(), "Custom fields")]`;
|
60
|
-
await clickOnMoreMenuItem( 'Preferences' );
|
61
|
-
await page.waitForXPath( paneslXPath );
|
62
|
-
const [ tabHandle ] = await page.$x( paneslXPath );
|
63
|
-
await tabHandle.click();
|
64
|
-
|
65
|
-
await page.waitForXPath( checkboxXPath );
|
66
|
-
const [ checkboxHandle ] = await page.$x( checkboxXPath );
|
67
|
-
|
68
|
-
const isChecked = await page.evaluate(
|
69
|
-
( element ) => element.control.checked,
|
70
|
-
checkboxHandle
|
71
|
-
);
|
72
|
-
|
73
|
-
if ( isChecked !== shouldBeChecked ) {
|
74
|
-
await checkboxHandle.click();
|
75
|
-
const [ saveButton ] = await page.$x(
|
76
|
-
shouldBeChecked
|
77
|
-
? '//button[text()="Enable & Reload"]'
|
78
|
-
: '//button[text()="Disable & Reload"]'
|
79
|
-
);
|
80
|
-
const navigationCompleted = page.waitForNavigation();
|
81
|
-
saveButton.click();
|
82
|
-
await navigationCompleted;
|
83
|
-
return;
|
84
|
-
}
|
85
|
-
|
86
|
-
await clickOnCloseModalButton( '.interface-preferences-modal' );
|
87
|
-
}
|
88
|
-
|
89
|
-
describe( 'Preview', () => {
|
90
|
-
beforeEach( async () => {
|
91
|
-
await createNewPost();
|
92
|
-
} );
|
93
|
-
|
94
|
-
it( 'should open a preview window for a new post', async () => {
|
95
|
-
const editorPage = page;
|
96
|
-
|
97
|
-
// Disabled until content present.
|
98
|
-
const isPreviewDisabled = await editorPage.$$eval(
|
99
|
-
'.block-editor-post-preview__button-toggle:not( :disabled ):not( [aria-disabled="true"] )',
|
100
|
-
( enabledButtons ) => ! enabledButtons.length
|
101
|
-
);
|
102
|
-
expect( isPreviewDisabled ).toBe( true );
|
103
|
-
|
104
|
-
await editorPage.type( '.editor-post-title__input', 'Hello World' );
|
105
|
-
|
106
|
-
const previewPage = await openPreviewPage( editorPage );
|
107
|
-
await previewPage.waitForSelector( '.entry-title' );
|
108
|
-
|
109
|
-
// When autosave completes for a new post, the URL of the editor should
|
110
|
-
// update to include the ID. Use this to assert on preview URL.
|
111
|
-
const [ , postId ] = await (
|
112
|
-
await editorPage.waitForFunction( () => {
|
113
|
-
return window.location.search.match( /[\?&]post=(\d+)/ );
|
114
|
-
} )
|
115
|
-
).jsonValue();
|
116
|
-
|
117
|
-
const expectedPreviewURL = createURL(
|
118
|
-
'',
|
119
|
-
`?p=${ postId }&preview=true`
|
120
|
-
);
|
121
|
-
expect( previewPage.url() ).toBe( expectedPreviewURL );
|
122
|
-
|
123
|
-
// Title in preview should match input.
|
124
|
-
let previewTitle = await previewPage.$eval(
|
125
|
-
'.entry-title',
|
126
|
-
( node ) => node.textContent
|
127
|
-
);
|
128
|
-
expect( previewTitle ).toBe( 'Hello World' );
|
129
|
-
|
130
|
-
// Return to editor to change title.
|
131
|
-
await editorPage.bringToFront();
|
132
|
-
await editorPage.type( '.editor-post-title__input', '!' );
|
133
|
-
await waitForPreviewDropdownOpen( editorPage );
|
134
|
-
await waitForPreviewNavigation( previewPage );
|
135
|
-
|
136
|
-
// Title in preview should match updated input.
|
137
|
-
previewTitle = await previewPage.$eval(
|
138
|
-
'.entry-title',
|
139
|
-
( node ) => node.textContent
|
140
|
-
);
|
141
|
-
expect( previewTitle ).toBe( 'Hello World!' );
|
142
|
-
|
143
|
-
// Pressing preview without changes should bring same preview window to
|
144
|
-
// front and reload, but should not show interstitial.
|
145
|
-
await editorPage.bringToFront();
|
146
|
-
await waitForPreviewNavigation( previewPage );
|
147
|
-
previewTitle = await previewPage.$eval(
|
148
|
-
'.entry-title',
|
149
|
-
( node ) => node.textContent
|
150
|
-
);
|
151
|
-
expect( previewTitle ).toBe( 'Hello World!' );
|
152
|
-
|
153
|
-
// Preview for published post (no unsaved changes) directs to canonical URL for post.
|
154
|
-
await editorPage.bringToFront();
|
155
|
-
/**
|
156
|
-
* Temp workaround until we find a reliable solution for `publishPost` util.
|
157
|
-
*
|
158
|
-
* @see https://github.com/WordPress/gutenberg/pull/35565
|
159
|
-
*/
|
160
|
-
await editorPage.click( '.components-snackbar' );
|
161
|
-
await publishPost();
|
162
|
-
|
163
|
-
// Return to editor to change title.
|
164
|
-
await editorPage.bringToFront();
|
165
|
-
await editorPage.waitForSelector( '.editor-post-title__input' );
|
166
|
-
await editorPage.click( '.editor-post-title__input' );
|
167
|
-
await pressKeyWithModifier( 'primary', 'A' );
|
168
|
-
await editorPage.keyboard.press( 'ArrowRight' );
|
169
|
-
await editorPage.keyboard.type( ' And more.' );
|
170
|
-
await waitForPreviewDropdownOpen( editorPage );
|
171
|
-
await waitForPreviewNavigation( previewPage );
|
172
|
-
|
173
|
-
// Title in preview should match updated input.
|
174
|
-
previewTitle = await previewPage.$eval(
|
175
|
-
'.entry-title',
|
176
|
-
( node ) => node.textContent
|
177
|
-
);
|
178
|
-
expect( previewTitle ).toBe( 'Hello World! And more.' );
|
179
|
-
|
180
|
-
// Published preview URL should include ID and nonce parameters.
|
181
|
-
const { searchParams } = new URL( previewPage.url() );
|
182
|
-
expect( searchParams.has( 'preview_id' ) ).toBe( true );
|
183
|
-
expect( searchParams.has( 'preview_nonce' ) ).toBe( true );
|
184
|
-
|
185
|
-
// Return to editor. Previewing already-autosaved preview tab should
|
186
|
-
// reuse the opened tab, skipping interstitial. This resolves an edge
|
187
|
-
// cases where the post is dirty but not autosaveable (because the
|
188
|
-
// autosave is already up-to-date).
|
189
|
-
//
|
190
|
-
// See: https://github.com/WordPress/gutenberg/issues/7561
|
191
|
-
await editorPage.bringToFront();
|
192
|
-
await waitForPreviewNavigation( previewPage );
|
193
|
-
|
194
|
-
// Title in preview should match updated input.
|
195
|
-
previewTitle = await previewPage.$eval(
|
196
|
-
'.entry-title',
|
197
|
-
( node ) => node.textContent
|
198
|
-
);
|
199
|
-
expect( previewTitle ).toBe( 'Hello World! And more.' );
|
200
|
-
|
201
|
-
await previewPage.close();
|
202
|
-
} );
|
203
|
-
|
204
|
-
it( 'should not revert title during a preview right after a save draft', async () => {
|
205
|
-
const editorPage = page;
|
206
|
-
|
207
|
-
// Type aaaaa in the title field.
|
208
|
-
await editorPage.type( '.editor-post-title__input', 'aaaaa' );
|
209
|
-
await editorPage.keyboard.press( 'Tab' );
|
210
|
-
|
211
|
-
// Save the post as a draft.
|
212
|
-
await editorPage.waitForSelector( '.editor-post-save-draft' );
|
213
|
-
await saveDraft();
|
214
|
-
|
215
|
-
// Open the preview page.
|
216
|
-
const previewPage = await openPreviewPage( editorPage );
|
217
|
-
await previewPage.waitForSelector( '.entry-title' );
|
218
|
-
|
219
|
-
// Title in preview should match input.
|
220
|
-
let previewTitle = await previewPage.$eval(
|
221
|
-
'.entry-title',
|
222
|
-
( node ) => node.textContent
|
223
|
-
);
|
224
|
-
expect( previewTitle ).toBe( 'aaaaa' );
|
225
|
-
|
226
|
-
// Return to editor.
|
227
|
-
await editorPage.bringToFront();
|
228
|
-
|
229
|
-
// Append bbbbb to the title, and tab away from the title so blur event is triggered.
|
230
|
-
await editorPage.focus( '.editor-post-title__input' );
|
231
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
232
|
-
await editorPage.keyboard.press( 'ArrowRight' );
|
233
|
-
await editorPage.keyboard.type( 'bbbbb' );
|
234
|
-
await editorPage.keyboard.press( 'Tab' );
|
235
|
-
|
236
|
-
// Save draft and open the preview page right after.
|
237
|
-
await editorPage.waitForSelector( '.editor-post-save-draft' );
|
238
|
-
await saveDraft();
|
239
|
-
await waitForPreviewDropdownOpen( editorPage );
|
240
|
-
await waitForPreviewNavigation( previewPage );
|
241
|
-
|
242
|
-
// Title in preview should match updated input.
|
243
|
-
previewTitle = await previewPage.$eval(
|
244
|
-
'.entry-title',
|
245
|
-
( node ) => node.textContent
|
246
|
-
);
|
247
|
-
expect( previewTitle ).toBe( 'aaaaabbbbb' );
|
248
|
-
|
249
|
-
await previewPage.close();
|
250
|
-
} );
|
251
|
-
|
252
|
-
// Verify correct preview. See: https://github.com/WordPress/gutenberg/issues/33616
|
253
|
-
it( 'should display the correct preview when switching between published and draft statuses', async () => {
|
254
|
-
const editorPage = page;
|
255
|
-
|
256
|
-
// Type Lorem in the title field.
|
257
|
-
await editorPage.type( '[aria-label="Add title"]', 'Lorem' );
|
258
|
-
|
259
|
-
// Open the preview page.
|
260
|
-
const previewPage = await openPreviewPage( editorPage );
|
261
|
-
await previewPage.waitForSelector( '.entry-title' );
|
262
|
-
|
263
|
-
// Title in preview should match input.
|
264
|
-
let previewTitle = await previewPage.$eval(
|
265
|
-
'.entry-title',
|
266
|
-
( node ) => node.textContent
|
267
|
-
);
|
268
|
-
expect( previewTitle ).toBe( 'Lorem' );
|
269
|
-
|
270
|
-
// Return to editor and publish post.
|
271
|
-
await editorPage.bringToFront();
|
272
|
-
await publishPost();
|
273
|
-
|
274
|
-
// Close the panel.
|
275
|
-
await page.waitForSelector(
|
276
|
-
'.editor-post-publish-panel button[aria-label="Close panel"]'
|
277
|
-
);
|
278
|
-
await page.click(
|
279
|
-
'.editor-post-publish-panel button[aria-label="Close panel"]'
|
280
|
-
);
|
281
|
-
|
282
|
-
// Change the title and preview again.
|
283
|
-
await editorPage.type( '[aria-label="Add title"]', ' Ipsum' );
|
284
|
-
await editorPage.keyboard.press( 'Tab' );
|
285
|
-
await waitForPreviewDropdownOpen( editorPage );
|
286
|
-
await waitForPreviewNavigation( previewPage );
|
287
|
-
|
288
|
-
// Title in preview should match updated input.
|
289
|
-
previewTitle = await previewPage.$eval(
|
290
|
-
'.entry-title',
|
291
|
-
( node ) => node.textContent
|
292
|
-
);
|
293
|
-
|
294
|
-
expect( previewTitle ).toBe( 'Lorem Ipsum' );
|
295
|
-
|
296
|
-
// Return to editor and switch to Draft.
|
297
|
-
await editorPage.bringToFront();
|
298
|
-
await editorPage.waitForSelector( '.editor-post-switch-to-draft' );
|
299
|
-
await editorPage.click( '.editor-post-switch-to-draft' );
|
300
|
-
await page.keyboard.press( 'Enter' );
|
301
|
-
|
302
|
-
// Change the title.
|
303
|
-
await editorPage.type( '[aria-label="Add title"]', 'Draft ' );
|
304
|
-
await editorPage.keyboard.press( 'Tab' );
|
305
|
-
|
306
|
-
// Open the preview page.
|
307
|
-
await waitForPreviewDropdownOpen( editorPage );
|
308
|
-
await waitForPreviewNavigation( previewPage );
|
309
|
-
|
310
|
-
// Title in preview should match updated input.
|
311
|
-
previewTitle = await previewPage.$eval(
|
312
|
-
'.entry-title',
|
313
|
-
( node ) => node.textContent
|
314
|
-
);
|
315
|
-
|
316
|
-
expect( previewTitle ).toBe( 'Draft Lorem Ipsum' );
|
317
|
-
|
318
|
-
await previewPage.close();
|
319
|
-
} );
|
320
|
-
} );
|
321
|
-
|
322
|
-
describe( 'Preview with Custom Fields enabled', () => {
|
323
|
-
beforeEach( async () => {
|
324
|
-
await createNewPost();
|
325
|
-
await toggleCustomFieldsOption( true );
|
326
|
-
} );
|
327
|
-
|
328
|
-
afterEach( async () => {
|
329
|
-
await toggleCustomFieldsOption( false );
|
330
|
-
} );
|
331
|
-
|
332
|
-
// Catch regressions of https://github.com/WordPress/gutenberg/issues/12617
|
333
|
-
it( 'displays edits to the post title and content in the preview', async () => {
|
334
|
-
const editorPage = page;
|
335
|
-
|
336
|
-
// Make sure input is mounted in editor before adding content.
|
337
|
-
await editorPage.waitForSelector( '.editor-post-title__input' );
|
338
|
-
// Add an initial title and content.
|
339
|
-
await editorPage.type( '.editor-post-title__input', 'title 1' );
|
340
|
-
await editorPage.keyboard.press( 'Tab' );
|
341
|
-
await editorPage.keyboard.type( 'content 1' );
|
342
|
-
|
343
|
-
// Publish the post and then close the publish panel.
|
344
|
-
await publishPost();
|
345
|
-
await page.waitForSelector( '.editor-post-publish-panel' );
|
346
|
-
await page.click( '.editor-post-publish-panel__header button' );
|
347
|
-
|
348
|
-
// Open the preview page.
|
349
|
-
const previewPage = await openPreviewPage( editorPage );
|
350
|
-
await previewPage.waitForSelector( '.entry-title' );
|
351
|
-
|
352
|
-
// Check the title and preview match.
|
353
|
-
let previewTitle = await previewPage.$eval(
|
354
|
-
'.entry-title',
|
355
|
-
( node ) => node.textContent
|
356
|
-
);
|
357
|
-
expect( previewTitle ).toBe( 'title 1' );
|
358
|
-
let previewContent = await previewPage.$eval(
|
359
|
-
'.entry-content p',
|
360
|
-
( node ) => node.textContent
|
361
|
-
);
|
362
|
-
expect( previewContent ).toBe( 'content 1' );
|
363
|
-
|
364
|
-
// Return to editor and modify the title and content.
|
365
|
-
await editorPage.bringToFront();
|
366
|
-
await editorPage.click( '.editor-post-title__input' );
|
367
|
-
await editorPage.keyboard.press( 'End' );
|
368
|
-
await editorPage.keyboard.press( 'Backspace' );
|
369
|
-
await editorPage.keyboard.type( '2' );
|
370
|
-
await editorPage.keyboard.press( 'Tab' );
|
371
|
-
await editorPage.keyboard.press( 'End' );
|
372
|
-
await editorPage.keyboard.press( 'Backspace' );
|
373
|
-
await editorPage.keyboard.type( '2' );
|
374
|
-
|
375
|
-
// Open the preview page.
|
376
|
-
await waitForPreviewDropdownOpen( editorPage );
|
377
|
-
await waitForPreviewNavigation( previewPage );
|
378
|
-
|
379
|
-
// Title in preview should match input.
|
380
|
-
previewTitle = await previewPage.$eval(
|
381
|
-
'.entry-title',
|
382
|
-
( node ) => node.textContent
|
383
|
-
);
|
384
|
-
expect( previewTitle ).toBe( 'title 2' );
|
385
|
-
previewContent = await previewPage.$eval(
|
386
|
-
'.entry-content p',
|
387
|
-
( node ) => node.textContent
|
388
|
-
);
|
389
|
-
expect( previewContent ).toBe( 'content 2' );
|
390
|
-
|
391
|
-
// Make sure the editor is active for the afterEach function.
|
392
|
-
await editorPage.bringToFront();
|
393
|
-
} );
|
394
|
-
} );
|
395
|
-
|
396
|
-
describe( 'Preview with private custom post type', () => {
|
397
|
-
beforeAll( async () => {
|
398
|
-
await activatePlugin( 'gutenberg-test-custom-post-types' );
|
399
|
-
} );
|
400
|
-
|
401
|
-
afterAll( async () => {
|
402
|
-
await deactivatePlugin( 'gutenberg-test-custom-post-types' );
|
403
|
-
} );
|
404
|
-
|
405
|
-
it( 'should not show the Preview Externally link', async () => {
|
406
|
-
await createNewPost( { postType: 'not_public' } );
|
407
|
-
|
408
|
-
// Type in the title filed.
|
409
|
-
await page.type( '.editor-post-title__input', 'aaaaa' );
|
410
|
-
await page.keyboard.press( 'Tab' );
|
411
|
-
|
412
|
-
// Open the preview menu.
|
413
|
-
await page.click( '.block-editor-post-preview__button-toggle' );
|
414
|
-
|
415
|
-
const previewDropdownContents = await page.$(
|
416
|
-
'.block-editor-post-preview__dropdown-content'
|
417
|
-
);
|
418
|
-
|
419
|
-
// Expect the Preview Externally link not to be present.
|
420
|
-
const previewExternallyLink = await previewDropdownContents.$x(
|
421
|
-
'//a[contains(text(), "Preview externally")]'
|
422
|
-
);
|
423
|
-
expect( previewExternallyLink.length ).toBe( 0 );
|
424
|
-
} );
|
425
|
-
} );
|
@@ -1,129 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
createNewPost,
|
6
|
-
getEditedPostContent,
|
7
|
-
pressKeyWithModifier,
|
8
|
-
activatePlugin,
|
9
|
-
deactivatePlugin,
|
10
|
-
} from '@wordpress/e2e-test-utils';
|
11
|
-
|
12
|
-
// Avoid using three, as it looks too much like two with some fonts.
|
13
|
-
const ARABIC_ZERO = '٠';
|
14
|
-
const ARABIC_ONE = '١';
|
15
|
-
const ARABIC_TWO = '٢';
|
16
|
-
|
17
|
-
describe( 'RTL', () => {
|
18
|
-
beforeAll( async () => {
|
19
|
-
await activatePlugin( 'gutenberg-test-plugin-activate-rtl' );
|
20
|
-
} );
|
21
|
-
|
22
|
-
beforeEach( async () => {
|
23
|
-
await createNewPost();
|
24
|
-
} );
|
25
|
-
|
26
|
-
afterAll( async () => {
|
27
|
-
await deactivatePlugin( 'gutenberg-test-plugin-activate-rtl' );
|
28
|
-
} );
|
29
|
-
|
30
|
-
it( 'should arrow navigate', async () => {
|
31
|
-
await page.keyboard.press( 'Enter' );
|
32
|
-
|
33
|
-
// We need at least three characters as arrow navigation *from* the
|
34
|
-
// edges might be handled differently.
|
35
|
-
await page.keyboard.type( ARABIC_ONE );
|
36
|
-
await page.keyboard.type( ARABIC_TWO );
|
37
|
-
await page.keyboard.press( 'ArrowRight' );
|
38
|
-
// This is the important key press: arrow nav *from* the middle.
|
39
|
-
await page.keyboard.press( 'ArrowRight' );
|
40
|
-
await page.keyboard.type( ARABIC_ZERO );
|
41
|
-
|
42
|
-
// Expect: ARABIC_ZERO + ARABIC_ONE + ARABIC_TWO (<p>٠١٢</p>).
|
43
|
-
// N.b.: HTML is LTR, so direction will be reversed!
|
44
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
45
|
-
} );
|
46
|
-
|
47
|
-
it( 'should split', async () => {
|
48
|
-
await page.keyboard.press( 'Enter' );
|
49
|
-
|
50
|
-
await page.keyboard.type( ARABIC_ZERO );
|
51
|
-
await page.keyboard.type( ARABIC_ONE );
|
52
|
-
await page.keyboard.press( 'ArrowRight' );
|
53
|
-
await page.keyboard.press( 'Enter' );
|
54
|
-
|
55
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
56
|
-
} );
|
57
|
-
|
58
|
-
it( 'should merge backward', async () => {
|
59
|
-
await page.keyboard.press( 'Enter' );
|
60
|
-
|
61
|
-
await page.keyboard.type( ARABIC_ZERO );
|
62
|
-
await page.keyboard.press( 'Enter' );
|
63
|
-
await page.keyboard.type( ARABIC_ONE );
|
64
|
-
await page.keyboard.press( 'ArrowRight' );
|
65
|
-
await page.keyboard.press( 'Backspace' );
|
66
|
-
|
67
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
68
|
-
} );
|
69
|
-
|
70
|
-
it( 'should merge forward', async () => {
|
71
|
-
await page.keyboard.press( 'Enter' );
|
72
|
-
|
73
|
-
await page.keyboard.type( ARABIC_ZERO );
|
74
|
-
await page.keyboard.press( 'Enter' );
|
75
|
-
await page.keyboard.type( ARABIC_ONE );
|
76
|
-
await page.keyboard.press( 'ArrowRight' );
|
77
|
-
await page.keyboard.press( 'ArrowRight' );
|
78
|
-
await page.keyboard.press( 'Delete' );
|
79
|
-
|
80
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
81
|
-
} );
|
82
|
-
|
83
|
-
it( 'should arrow navigate between blocks', async () => {
|
84
|
-
await page.keyboard.press( 'Enter' );
|
85
|
-
|
86
|
-
await page.keyboard.type( ARABIC_ZERO );
|
87
|
-
await page.keyboard.press( 'Enter' );
|
88
|
-
await page.keyboard.type( ARABIC_ONE );
|
89
|
-
await pressKeyWithModifier( 'shift', 'Enter' );
|
90
|
-
await page.keyboard.type( ARABIC_TWO );
|
91
|
-
await page.keyboard.press( 'ArrowRight' );
|
92
|
-
await page.keyboard.press( 'ArrowRight' );
|
93
|
-
await page.keyboard.press( 'ArrowRight' );
|
94
|
-
|
95
|
-
// Move to the previous block with two lines in the current block.
|
96
|
-
await page.keyboard.press( 'ArrowRight' );
|
97
|
-
await pressKeyWithModifier( 'shift', 'Enter' );
|
98
|
-
await page.keyboard.type( ARABIC_ONE );
|
99
|
-
|
100
|
-
// Move to the next block with two lines in the current block.
|
101
|
-
await page.keyboard.press( 'ArrowLeft' );
|
102
|
-
await page.keyboard.type( ARABIC_ZERO );
|
103
|
-
await pressKeyWithModifier( 'shift', 'Enter' );
|
104
|
-
|
105
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
106
|
-
} );
|
107
|
-
|
108
|
-
it( 'should navigate inline boundaries', async () => {
|
109
|
-
await page.keyboard.press( 'Enter' );
|
110
|
-
|
111
|
-
// Wait for rich text editor to load.
|
112
|
-
await page.waitForSelector( '.block-editor-rich-text__editable' );
|
113
|
-
|
114
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
115
|
-
await page.keyboard.type( ARABIC_ONE );
|
116
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
117
|
-
await page.keyboard.type( ARABIC_TWO );
|
118
|
-
|
119
|
-
// Insert a character at each boundary position.
|
120
|
-
for ( let i = 4; i > 0; i-- ) {
|
121
|
-
await page.keyboard.press( 'ArrowRight' );
|
122
|
-
await page.keyboard.type( ARABIC_ZERO );
|
123
|
-
|
124
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
125
|
-
|
126
|
-
await page.keyboard.press( 'Backspace' );
|
127
|
-
}
|
128
|
-
} );
|
129
|
-
} );
|