@wordpress/e2e-tests 4.1.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/flaky-tests-reporter.js +1 -0
- package/config/setup-test-framework.js +3 -0
- package/package.json +6 -6
- package/specs/editor/blocks/__snapshots__/buttons.test.js.snap +4 -4
- package/specs/editor/blocks/__snapshots__/heading.test.js.snap +0 -6
- package/specs/editor/blocks/{comments-query.test.js → comments.test.js} +5 -13
- package/specs/editor/blocks/heading.test.js +7 -7
- package/specs/editor/blocks/navigation.test.js +58 -10
- package/specs/editor/blocks/table.test.js +14 -1
- package/specs/editor/fixtures/menu-items-response-fixture.json +48 -144
- package/specs/editor/plugins/iframed-inline-styles.test.js +1 -0
- package/specs/editor/plugins/nonce.test.js +6 -7
- package/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap +1 -1
- package/specs/editor/various/block-switcher.test.js +3 -0
- package/specs/editor/various/datepicker.test.js +19 -7
- package/specs/editor/various/inserting-blocks.test.js +1 -1
- package/specs/editor/various/keyboard-navigable-blocks.test.js +0 -3
- package/specs/editor/various/multi-block-selection.test.js +48 -0
- package/specs/editor/various/post-visibility.test.js +1 -1
- package/specs/editor/various/scheduling.test.js +2 -2
- package/specs/editor/various/switch-to-draft.test.js +1 -1
- package/specs/editor/various/writing-flow.test.js +52 -19
- package/specs/experiments/blocks/post-comments-form.test.js +46 -0
- 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__/image.test.js.snap +0 -25
- 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/code.test.js +0 -48
- package/specs/editor/blocks/html.test.js +0 -31
- package/specs/editor/blocks/image.test.js +0 -373
- package/specs/editor/blocks/paragraph.test.js +0 -26
- package/specs/editor/blocks/preformatted.test.js +0 -62
- package/specs/editor/blocks/separator.test.js +0 -22
- package/specs/editor/plugins/image-size.test.js +0 -71
- package/specs/editor/various/block-locking.test.js +0 -120
- package/specs/editor/various/popovers.test.js +0 -27
- package/specs/site-editor/template-part.test.js +0 -346
- package/specs/site-editor/template-revert.test.js +0 -209
@@ -1,373 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* External dependencies
|
3
|
-
*/
|
4
|
-
import path from 'path';
|
5
|
-
import fs from 'fs';
|
6
|
-
import os from 'os';
|
7
|
-
import { v4 as uuid } from 'uuid';
|
8
|
-
|
9
|
-
/**
|
10
|
-
* WordPress dependencies
|
11
|
-
*/
|
12
|
-
import {
|
13
|
-
insertBlock,
|
14
|
-
getEditedPostContent,
|
15
|
-
createNewPost,
|
16
|
-
clickButton,
|
17
|
-
clickBlockToolbarButton,
|
18
|
-
clickMenuItem,
|
19
|
-
openDocumentSettingsSidebar,
|
20
|
-
pressKeyWithModifier,
|
21
|
-
} from '@wordpress/e2e-test-utils';
|
22
|
-
|
23
|
-
async function upload( selector ) {
|
24
|
-
await page.waitForSelector( selector );
|
25
|
-
const inputElement = await page.$( selector );
|
26
|
-
const testImagePath = path.join(
|
27
|
-
__dirname,
|
28
|
-
'..',
|
29
|
-
'..',
|
30
|
-
'..',
|
31
|
-
'assets',
|
32
|
-
'10x10_e2e_test_image_z9T8jK.png'
|
33
|
-
);
|
34
|
-
const filename = uuid();
|
35
|
-
const tmpFileName = path.join( os.tmpdir(), filename + '.png' );
|
36
|
-
fs.copyFileSync( testImagePath, tmpFileName );
|
37
|
-
await inputElement.uploadFile( tmpFileName );
|
38
|
-
return filename;
|
39
|
-
}
|
40
|
-
|
41
|
-
async function waitForImage( filename ) {
|
42
|
-
await page.waitForSelector(
|
43
|
-
`.wp-block-image img[src$="${ filename }.png"]`
|
44
|
-
);
|
45
|
-
}
|
46
|
-
|
47
|
-
async function getSrc( elementHandle ) {
|
48
|
-
return elementHandle.evaluate( ( node ) => node.src );
|
49
|
-
}
|
50
|
-
async function getDataURL( elementHandle ) {
|
51
|
-
return elementHandle.evaluate( ( node ) => {
|
52
|
-
const canvas = document.createElement( 'canvas' );
|
53
|
-
const context = canvas.getContext( '2d' );
|
54
|
-
canvas.width = node.width;
|
55
|
-
canvas.height = node.height;
|
56
|
-
context.drawImage( node, 0, 0 );
|
57
|
-
return canvas.toDataURL( 'image/jpeg' );
|
58
|
-
} );
|
59
|
-
}
|
60
|
-
|
61
|
-
describe( 'Image', () => {
|
62
|
-
beforeEach( async () => {
|
63
|
-
await createNewPost();
|
64
|
-
} );
|
65
|
-
|
66
|
-
it( 'can be inserted', async () => {
|
67
|
-
await insertBlock( 'Image' );
|
68
|
-
const filename = await upload( '.wp-block-image input[type="file"]' );
|
69
|
-
await waitForImage( filename );
|
70
|
-
|
71
|
-
const regex = new RegExp(
|
72
|
-
`<!-- wp:image {"id":\\d+,"sizeSlug":"full","linkDestination":"none"} -->\\s*<figure class="wp-block-image size-full"><img src="[^"]+\\/${ filename }\\.png" alt="" class="wp-image-\\d+"/></figure>\\s*<!-- \\/wp:image -->`
|
73
|
-
);
|
74
|
-
expect( await getEditedPostContent() ).toMatch( regex );
|
75
|
-
} );
|
76
|
-
|
77
|
-
it( 'should replace, reset size, and keep selection', async () => {
|
78
|
-
await insertBlock( 'Image' );
|
79
|
-
const filename1 = await upload( '.wp-block-image input[type="file"]' );
|
80
|
-
await waitForImage( filename1 );
|
81
|
-
|
82
|
-
const regex1 = new RegExp(
|
83
|
-
`<!-- wp:image {"id":\\d+,"sizeSlug":"full","linkDestination":"none"} -->\\s*<figure class="wp-block-image size-full"><img src="[^"]+\\/${ filename1 }\\.png" alt="" class="wp-image-\\d+"/></figure>\\s*<!-- \\/wp:image -->`
|
84
|
-
);
|
85
|
-
expect( await getEditedPostContent() ).toMatch( regex1 );
|
86
|
-
|
87
|
-
await openDocumentSettingsSidebar();
|
88
|
-
await page.click( '[aria-label="Image size presets"] button' );
|
89
|
-
|
90
|
-
const regex2 = new RegExp(
|
91
|
-
`<!-- wp:image {"id":\\d+,"width":3,"height":3,"sizeSlug":"full","linkDestination":"none"} -->\\s*<figure class="wp-block-image size-full is-resized"><img src="[^"]+\\/${ filename1 }\\.png" alt="" class="wp-image-\\d+" width="3" height="3"\\/><\\/figure>\\s*<!-- /wp:image -->`
|
92
|
-
);
|
93
|
-
|
94
|
-
expect( await getEditedPostContent() ).toMatch( regex2 );
|
95
|
-
|
96
|
-
await clickButton( 'Replace' );
|
97
|
-
const filename2 = await upload(
|
98
|
-
'.block-editor-media-replace-flow__options input[type="file"]'
|
99
|
-
);
|
100
|
-
await waitForImage( filename2 );
|
101
|
-
|
102
|
-
const regex3 = new RegExp(
|
103
|
-
`<!-- wp:image {"id":\\d+,"sizeSlug":"full","linkDestination":"none"} -->\\s*<figure class="wp-block-image size-full"><img src="[^"]+\\/${ filename2 }\\.png" alt="" class="wp-image-\\d+"/></figure>\\s*<!-- \\/wp:image -->`
|
104
|
-
);
|
105
|
-
expect( await getEditedPostContent() ).toMatch( regex3 );
|
106
|
-
// Focus outside the block to avoid the image caption being selected
|
107
|
-
// It can happen on CI specially.
|
108
|
-
await page.click( '.wp-block-post-title' );
|
109
|
-
await page.click( '.wp-block-image img' );
|
110
|
-
await page.keyboard.press( 'Backspace' );
|
111
|
-
|
112
|
-
expect( await getEditedPostContent() ).toBe( '' );
|
113
|
-
} );
|
114
|
-
|
115
|
-
it.skip( 'should place caret at end of caption after merging empty paragraph', async () => {
|
116
|
-
await insertBlock( 'Image' );
|
117
|
-
const fileName = await upload( '.wp-block-image input[type="file"]' );
|
118
|
-
await waitForImage( fileName );
|
119
|
-
await page.keyboard.type( '1' );
|
120
|
-
await page.keyboard.press( 'Enter' );
|
121
|
-
await page.keyboard.press( 'Backspace' );
|
122
|
-
await page.keyboard.type( '2' );
|
123
|
-
|
124
|
-
expect(
|
125
|
-
await page.evaluate( () => document.activeElement.innerHTML )
|
126
|
-
).toBe( '12' );
|
127
|
-
} );
|
128
|
-
|
129
|
-
it( 'should allow soft line breaks in caption', async () => {
|
130
|
-
await insertBlock( 'Image' );
|
131
|
-
const fileName = await upload( '.wp-block-image input[type="file"]' );
|
132
|
-
await waitForImage( fileName );
|
133
|
-
await page.keyboard.type( '12' );
|
134
|
-
await page.keyboard.press( 'ArrowLeft' );
|
135
|
-
await page.keyboard.press( 'Enter' );
|
136
|
-
|
137
|
-
expect(
|
138
|
-
await page.evaluate( () => document.activeElement.innerHTML )
|
139
|
-
).toBe( '1<br data-rich-text-line-break="true">2' );
|
140
|
-
} );
|
141
|
-
|
142
|
-
it( 'should have keyboard navigable toolbar for caption', async () => {
|
143
|
-
await insertBlock( 'Image' );
|
144
|
-
const fileName = await upload( '.wp-block-image input[type="file"]' );
|
145
|
-
await waitForImage( fileName );
|
146
|
-
// Navigate to More, Link, Italic and finally Bold.
|
147
|
-
await pressKeyWithModifier( 'shift', 'Tab' );
|
148
|
-
await pressKeyWithModifier( 'shift', 'Tab' );
|
149
|
-
await pressKeyWithModifier( 'shift', 'Tab' );
|
150
|
-
await pressKeyWithModifier( 'shift', 'Tab' );
|
151
|
-
await page.keyboard.press( 'Space' );
|
152
|
-
await page.keyboard.press( 'a' );
|
153
|
-
await page.keyboard.press( 'ArrowRight' );
|
154
|
-
|
155
|
-
expect(
|
156
|
-
await page.evaluate( () => document.activeElement.innerHTML )
|
157
|
-
).toBe( '<strong>a</strong>' );
|
158
|
-
} );
|
159
|
-
|
160
|
-
it( 'should drag and drop files into media placeholder', async () => {
|
161
|
-
await page.keyboard.press( 'Enter' );
|
162
|
-
await insertBlock( 'Image' );
|
163
|
-
|
164
|
-
// Confirm correct setup.
|
165
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
166
|
-
|
167
|
-
const image = await page.$( '[data-type="core/image"]' );
|
168
|
-
|
169
|
-
await image.evaluate( () => {
|
170
|
-
const input = document.createElement( 'input' );
|
171
|
-
input.type = 'file';
|
172
|
-
input.id = 'wp-temp-test-input';
|
173
|
-
document.body.appendChild( input );
|
174
|
-
} );
|
175
|
-
|
176
|
-
const fileName = await upload( '#wp-temp-test-input' );
|
177
|
-
|
178
|
-
const paragraphRect = await image.boundingBox();
|
179
|
-
const pX = paragraphRect.x + paragraphRect.width / 2;
|
180
|
-
const pY = paragraphRect.y + paragraphRect.height / 3;
|
181
|
-
|
182
|
-
await image.evaluate(
|
183
|
-
( element, clientX, clientY ) => {
|
184
|
-
const input = document.getElementById( 'wp-temp-test-input' );
|
185
|
-
const dataTransfer = new DataTransfer();
|
186
|
-
dataTransfer.items.add( input.files[ 0 ] );
|
187
|
-
const event = new DragEvent( 'drop', {
|
188
|
-
bubbles: true,
|
189
|
-
clientX,
|
190
|
-
clientY,
|
191
|
-
dataTransfer,
|
192
|
-
} );
|
193
|
-
element.dispatchEvent( event );
|
194
|
-
},
|
195
|
-
pX,
|
196
|
-
pY
|
197
|
-
);
|
198
|
-
|
199
|
-
await waitForImage( fileName );
|
200
|
-
} );
|
201
|
-
|
202
|
-
it( 'allows zooming using the crop tools', async () => {
|
203
|
-
// Insert the block, upload a file and crop.
|
204
|
-
await insertBlock( 'Image' );
|
205
|
-
const filename = await upload( '.wp-block-image input[type="file"]' );
|
206
|
-
await waitForImage( filename );
|
207
|
-
|
208
|
-
// Assert that the image is initially unscaled and unedited.
|
209
|
-
const initialImage = await page.$( '.wp-block-image img' );
|
210
|
-
const initialImageSrc = await getSrc( initialImage );
|
211
|
-
const initialImageDataURL = await getDataURL( initialImage );
|
212
|
-
expect( initialImageDataURL ).toMatchSnapshot();
|
213
|
-
|
214
|
-
// Zoom in to twice the amount using the zoom input.
|
215
|
-
await clickBlockToolbarButton( 'Crop' );
|
216
|
-
await clickBlockToolbarButton( 'Zoom' );
|
217
|
-
await page.waitForFunction( () =>
|
218
|
-
document.activeElement.classList.contains(
|
219
|
-
'components-range-control__slider'
|
220
|
-
)
|
221
|
-
);
|
222
|
-
await page.keyboard.press( 'Tab' );
|
223
|
-
await page.waitForFunction( () =>
|
224
|
-
document.activeElement.classList.contains(
|
225
|
-
'components-input-control__input'
|
226
|
-
)
|
227
|
-
);
|
228
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
229
|
-
await page.keyboard.type( '200' );
|
230
|
-
await page.keyboard.press( 'Escape' );
|
231
|
-
await clickBlockToolbarButton( 'Apply', 'content' );
|
232
|
-
|
233
|
-
// Wait for the cropping tools to disappear.
|
234
|
-
await page.waitForSelector(
|
235
|
-
'.wp-block-image img:not( .reactEasyCrop_Image )'
|
236
|
-
);
|
237
|
-
|
238
|
-
// Assert that the image is edited.
|
239
|
-
const updatedImage = await page.$( '.wp-block-image img' );
|
240
|
-
const updatedImageSrc = await getSrc( updatedImage );
|
241
|
-
expect( initialImageSrc ).not.toEqual( updatedImageSrc );
|
242
|
-
const updatedImageDataURL = await getDataURL( updatedImage );
|
243
|
-
expect( initialImageDataURL ).not.toEqual( updatedImageDataURL );
|
244
|
-
expect( updatedImageDataURL ).toMatchSnapshot();
|
245
|
-
} );
|
246
|
-
|
247
|
-
it( 'allows changing aspect ratio using the crop tools', async () => {
|
248
|
-
// Insert the block, upload a file and crop.
|
249
|
-
await insertBlock( 'Image' );
|
250
|
-
const filename = await upload( '.wp-block-image input[type="file"]' );
|
251
|
-
await waitForImage( filename );
|
252
|
-
|
253
|
-
// Assert that the image is initially unscaled and unedited.
|
254
|
-
const initialImage = await page.$( '.wp-block-image img' );
|
255
|
-
const initialImageSrc = await getSrc( initialImage );
|
256
|
-
const initialImageDataURL = await getDataURL( initialImage );
|
257
|
-
expect( initialImageDataURL ).toMatchSnapshot();
|
258
|
-
|
259
|
-
// Zoom in to twice the amount using the zoom input.
|
260
|
-
await clickBlockToolbarButton( 'Crop' );
|
261
|
-
await clickBlockToolbarButton( 'Aspect Ratio' );
|
262
|
-
await page.waitForFunction( () =>
|
263
|
-
document.activeElement.classList.contains(
|
264
|
-
'components-menu-item__button'
|
265
|
-
)
|
266
|
-
);
|
267
|
-
await clickMenuItem( '16:10' );
|
268
|
-
await clickBlockToolbarButton( 'Apply', 'content' );
|
269
|
-
|
270
|
-
// Wait for the cropping tools to disappear.
|
271
|
-
await page.waitForSelector(
|
272
|
-
'.wp-block-image img:not( .reactEasyCrop_Image )'
|
273
|
-
);
|
274
|
-
|
275
|
-
// Assert that the image is edited.
|
276
|
-
const updatedImage = await page.$( '.wp-block-image img' );
|
277
|
-
const updatedImageSrc = await getSrc( updatedImage );
|
278
|
-
expect( initialImageSrc ).not.toEqual( updatedImageSrc );
|
279
|
-
const updatedImageDataURL = await getDataURL( updatedImage );
|
280
|
-
expect( initialImageDataURL ).not.toEqual( updatedImageDataURL );
|
281
|
-
expect( updatedImageDataURL ).toMatchSnapshot();
|
282
|
-
} );
|
283
|
-
|
284
|
-
it( 'allows rotating using the crop tools', async () => {
|
285
|
-
// Insert the block, upload a file and crop.
|
286
|
-
await insertBlock( 'Image' );
|
287
|
-
const filename = await upload( '.wp-block-image input[type="file"]' );
|
288
|
-
await waitForImage( filename );
|
289
|
-
|
290
|
-
// Assert that the image is initially unscaled and unedited.
|
291
|
-
const initialImage = await page.$( '.wp-block-image img' );
|
292
|
-
const initialImageDataURL = await getDataURL( initialImage );
|
293
|
-
expect( initialImageDataURL ).toMatchSnapshot();
|
294
|
-
|
295
|
-
// Double the image's size using the zoom input.
|
296
|
-
await clickBlockToolbarButton( 'Crop' );
|
297
|
-
await page.waitForSelector( '.wp-block-image img.reactEasyCrop_Image' );
|
298
|
-
await clickBlockToolbarButton( 'Rotate' );
|
299
|
-
await clickBlockToolbarButton( 'Apply', 'content' );
|
300
|
-
|
301
|
-
await page.waitForSelector(
|
302
|
-
'.wp-block-image img:not( .reactEasyCrop_Image )'
|
303
|
-
);
|
304
|
-
|
305
|
-
// Assert that the image is edited.
|
306
|
-
const updatedImage = await page.$( '.wp-block-image img' );
|
307
|
-
const updatedImageDataURL = await getDataURL( updatedImage );
|
308
|
-
expect( initialImageDataURL ).not.toEqual( updatedImageDataURL );
|
309
|
-
expect( updatedImageDataURL ).toMatchSnapshot();
|
310
|
-
} );
|
311
|
-
|
312
|
-
it( 'Should reset dimensions on change URL', async () => {
|
313
|
-
const imageUrl = '/wp-includes/images/w-logo-blue.png';
|
314
|
-
|
315
|
-
await insertBlock( 'Image' );
|
316
|
-
|
317
|
-
// Upload an initial image.
|
318
|
-
const filename = await upload( '.wp-block-image input[type="file"]' );
|
319
|
-
await waitForImage( filename );
|
320
|
-
// Resize the Uploaded Image.
|
321
|
-
await openDocumentSettingsSidebar();
|
322
|
-
await page.waitForSelector(
|
323
|
-
'[aria-label="Image size presets"] button:first-child',
|
324
|
-
{ visible: true }
|
325
|
-
);
|
326
|
-
await page.click(
|
327
|
-
'[aria-label="Image size presets"] button:first-child'
|
328
|
-
);
|
329
|
-
|
330
|
-
const regexBefore = new RegExp(
|
331
|
-
`<!-- wp:image {"id":\\d+,"width":3,"height":3,"sizeSlug":"full","linkDestination":"none"} -->\\s*<figure class="wp-block-image size-full is-resized"><img src="[^"]+\\/${ filename }\\.png" alt="" class="wp-image-\\d+" width="3" height="3"\\/><\\/figure>\\s*<!-- /wp:image -->`
|
332
|
-
);
|
333
|
-
|
334
|
-
// Check if dimensions are changed.
|
335
|
-
expect( await getEditedPostContent() ).toMatch( regexBefore );
|
336
|
-
|
337
|
-
// Replace uploaded image with an URL.
|
338
|
-
await clickButton( 'Replace' );
|
339
|
-
|
340
|
-
const [ editButton ] = await page.$x(
|
341
|
-
'//button[contains(@aria-label, "Edit")]'
|
342
|
-
);
|
343
|
-
await editButton.click();
|
344
|
-
|
345
|
-
await page.waitForSelector( '.block-editor-url-input__input' );
|
346
|
-
|
347
|
-
// Clear the input field. Delay added to account for typing delays.
|
348
|
-
const inputField = await page.$( '.block-editor-url-input__input' );
|
349
|
-
await inputField.click( { clickCount: 3, delay: 200 } );
|
350
|
-
|
351
|
-
// Replace the url. Delay added to account for typing delays.
|
352
|
-
await page.focus( '.block-editor-url-input__input' );
|
353
|
-
await page.keyboard.type( imageUrl, { delay: 100 } );
|
354
|
-
await page.click( '.block-editor-link-control__search-submit' );
|
355
|
-
|
356
|
-
const regexAfter = new RegExp(
|
357
|
-
`<!-- wp:image {"sizeSlug":"large","linkDestination":"none"} -->\\s*<figure class="wp-block-image size-large"><img src="${ imageUrl }" alt=""/></figure>\\s*<!-- /wp:image -->`
|
358
|
-
);
|
359
|
-
|
360
|
-
// Check if dimensions are reset.
|
361
|
-
expect( await getEditedPostContent() ).toMatch( regexAfter );
|
362
|
-
} );
|
363
|
-
|
364
|
-
it( 'should undo without broken temporary state', async () => {
|
365
|
-
await insertBlock( 'Image' );
|
366
|
-
const fileName = await upload( '.wp-block-image input[type="file"]' );
|
367
|
-
await waitForImage( fileName );
|
368
|
-
await pressKeyWithModifier( 'primary', 'z' );
|
369
|
-
// Expect an empty image block (placeholder) rather than one with a
|
370
|
-
// broken temporary URL.
|
371
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
372
|
-
} );
|
373
|
-
} );
|
@@ -1,26 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import { createNewPost, insertBlock } from '@wordpress/e2e-test-utils';
|
5
|
-
|
6
|
-
describe( 'Paragraph', () => {
|
7
|
-
beforeEach( async () => {
|
8
|
-
await createNewPost();
|
9
|
-
} );
|
10
|
-
|
11
|
-
it( 'should output unwrapped editable paragraph', async () => {
|
12
|
-
await insertBlock( 'Paragraph' );
|
13
|
-
await page.keyboard.type( '1' );
|
14
|
-
|
15
|
-
const firstBlockTagName = await page.evaluate( () => {
|
16
|
-
return document.querySelector(
|
17
|
-
'.block-editor-block-list__layout .wp-block'
|
18
|
-
).tagName;
|
19
|
-
} );
|
20
|
-
|
21
|
-
// The outer element should be a paragraph. Blocks should never have any
|
22
|
-
// additional div wrappers so the markup remains simple and easy to
|
23
|
-
// style.
|
24
|
-
expect( firstBlockTagName ).toBe( 'P' );
|
25
|
-
} );
|
26
|
-
} );
|
@@ -1,62 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
clickBlockToolbarButton,
|
6
|
-
clickMenuItem,
|
7
|
-
getEditedPostContent,
|
8
|
-
createNewPost,
|
9
|
-
insertBlock,
|
10
|
-
clickBlockAppender,
|
11
|
-
} from '@wordpress/e2e-test-utils';
|
12
|
-
|
13
|
-
describe( 'Preformatted', () => {
|
14
|
-
beforeEach( async () => {
|
15
|
-
await createNewPost();
|
16
|
-
} );
|
17
|
-
|
18
|
-
it( 'should preserve character newlines', async () => {
|
19
|
-
await insertBlock( 'Custom HTML' );
|
20
|
-
await page.keyboard.type( '<pre>1' );
|
21
|
-
await page.keyboard.press( 'Enter' );
|
22
|
-
await page.keyboard.type( '2</pre>' );
|
23
|
-
|
24
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
25
|
-
|
26
|
-
await clickBlockToolbarButton( 'Options' );
|
27
|
-
await clickMenuItem( 'Convert to Blocks' );
|
28
|
-
// Once it's edited, it should be saved as BR tags.
|
29
|
-
await page.keyboard.type( '0' );
|
30
|
-
await page.keyboard.press( 'Enter' );
|
31
|
-
await clickBlockToolbarButton( 'Options' );
|
32
|
-
await clickMenuItem( 'Edit as HTML' );
|
33
|
-
|
34
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
35
|
-
} );
|
36
|
-
|
37
|
-
it( 'should preserve white space when merging', async () => {
|
38
|
-
await insertBlock( 'Preformatted' );
|
39
|
-
await page.keyboard.type( '1' );
|
40
|
-
await page.keyboard.press( 'Enter' );
|
41
|
-
await page.keyboard.type( '2' );
|
42
|
-
await page.keyboard.press( 'Enter' );
|
43
|
-
await clickBlockAppender();
|
44
|
-
await page.keyboard.type( '3' );
|
45
|
-
await page.keyboard.press( 'ArrowLeft' );
|
46
|
-
await page.keyboard.press( 'Backspace' );
|
47
|
-
|
48
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
49
|
-
} );
|
50
|
-
|
51
|
-
it( 'should delete block when backspace in an empty preformatted', async () => {
|
52
|
-
await insertBlock( 'Preformatted' );
|
53
|
-
|
54
|
-
await page.keyboard.type( 'a' );
|
55
|
-
|
56
|
-
await page.keyboard.press( 'Backspace' );
|
57
|
-
await page.keyboard.press( 'Backspace' );
|
58
|
-
|
59
|
-
// Expect preformatted block to be deleted.
|
60
|
-
expect( await getEditedPostContent() ).toBe( '' );
|
61
|
-
} );
|
62
|
-
} );
|
@@ -1,22 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
clickBlockAppender,
|
6
|
-
getEditedPostContent,
|
7
|
-
createNewPost,
|
8
|
-
} from '@wordpress/e2e-test-utils';
|
9
|
-
|
10
|
-
describe( 'Separator', () => {
|
11
|
-
beforeEach( async () => {
|
12
|
-
await createNewPost();
|
13
|
-
} );
|
14
|
-
|
15
|
-
it( 'can be created by three dashes and enter', async () => {
|
16
|
-
await clickBlockAppender();
|
17
|
-
await page.keyboard.type( '---' );
|
18
|
-
await page.keyboard.press( 'Enter' );
|
19
|
-
|
20
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
21
|
-
} );
|
22
|
-
} );
|
@@ -1,71 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* External dependencies
|
3
|
-
*/
|
4
|
-
import path from 'path';
|
5
|
-
import fs from 'fs';
|
6
|
-
import os from 'os';
|
7
|
-
import { v4 as uuid } from 'uuid';
|
8
|
-
|
9
|
-
/**
|
10
|
-
* WordPress dependencies
|
11
|
-
*/
|
12
|
-
import {
|
13
|
-
activatePlugin,
|
14
|
-
createNewPost,
|
15
|
-
deactivatePlugin,
|
16
|
-
insertBlock,
|
17
|
-
openDocumentSettingsSidebar,
|
18
|
-
} from '@wordpress/e2e-test-utils';
|
19
|
-
|
20
|
-
describe( 'changing image size', () => {
|
21
|
-
beforeEach( async () => {
|
22
|
-
await activatePlugin( 'gutenberg-test-image-size' );
|
23
|
-
await createNewPost();
|
24
|
-
} );
|
25
|
-
|
26
|
-
afterEach( async () => {
|
27
|
-
await deactivatePlugin( 'gutenberg-test-image-size' );
|
28
|
-
} );
|
29
|
-
|
30
|
-
it( 'should insert and change my image size', async () => {
|
31
|
-
await insertBlock( 'Image' );
|
32
|
-
const inputElement = await page.waitForSelector(
|
33
|
-
'figure[aria-label="Block: Image"] input[type=file]'
|
34
|
-
);
|
35
|
-
const testImagePath = path.join(
|
36
|
-
__dirname,
|
37
|
-
'..',
|
38
|
-
'..',
|
39
|
-
'..',
|
40
|
-
'assets',
|
41
|
-
'1024x768_e2e_test_image_size.jpg'
|
42
|
-
);
|
43
|
-
const filename = uuid();
|
44
|
-
const tmpFileName = path.join( os.tmpdir(), filename + '.jpg' );
|
45
|
-
fs.copyFileSync( testImagePath, tmpFileName );
|
46
|
-
await inputElement.uploadFile( tmpFileName );
|
47
|
-
|
48
|
-
// Wait for upload to finish.
|
49
|
-
await page.waitForXPath( `//img[contains(@src, "${ filename }")]` );
|
50
|
-
|
51
|
-
// Select the new size updated with the plugin.
|
52
|
-
await openDocumentSettingsSidebar();
|
53
|
-
const imageSizeLabel = await page.waitForXPath(
|
54
|
-
'//label[text()="Image size"]'
|
55
|
-
);
|
56
|
-
await imageSizeLabel.click();
|
57
|
-
const imageSizeSelect = await page.evaluateHandle(
|
58
|
-
() => document.activeElement
|
59
|
-
);
|
60
|
-
await imageSizeSelect.select( 'custom-size-one' );
|
61
|
-
|
62
|
-
// Verify that the custom size was applied to the image.
|
63
|
-
await page.waitForSelector( '.wp-block-image.size-custom-size-one' );
|
64
|
-
await page.waitForFunction(
|
65
|
-
() =>
|
66
|
-
document.querySelector(
|
67
|
-
'.block-editor-image-size-control__width input'
|
68
|
-
).value === '499'
|
69
|
-
);
|
70
|
-
} );
|
71
|
-
} );
|
@@ -1,120 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
createNewPost,
|
6
|
-
clickButton,
|
7
|
-
clickMenuItem,
|
8
|
-
clickBlockToolbarButton,
|
9
|
-
getEditedPostContent,
|
10
|
-
insertBlock,
|
11
|
-
} from '@wordpress/e2e-test-utils';
|
12
|
-
|
13
|
-
describe( 'Block Grouping', () => {
|
14
|
-
beforeEach( async () => {
|
15
|
-
await createNewPost();
|
16
|
-
} );
|
17
|
-
|
18
|
-
describe( 'General', () => {
|
19
|
-
it( 'can prevent removal', async () => {
|
20
|
-
await insertBlock( 'Paragraph' );
|
21
|
-
await page.keyboard.type( 'Some paragraph' );
|
22
|
-
|
23
|
-
await clickBlockToolbarButton( 'Options' );
|
24
|
-
await clickMenuItem( 'Lock' );
|
25
|
-
|
26
|
-
const [ checkbox ] = await page.$x(
|
27
|
-
'//label[contains(text(), "Prevent removal")]'
|
28
|
-
);
|
29
|
-
await checkbox.click();
|
30
|
-
|
31
|
-
await clickButton( 'Apply' );
|
32
|
-
|
33
|
-
const [ removeBlock ] = await page.$x(
|
34
|
-
'//*[@role="menu"]//*[text()="Remove Paragraph"]'
|
35
|
-
);
|
36
|
-
|
37
|
-
expect( removeBlock ).toBeFalsy();
|
38
|
-
} );
|
39
|
-
|
40
|
-
it( 'can disable movement', async () => {
|
41
|
-
await insertBlock( 'Paragraph' );
|
42
|
-
await page.keyboard.type( 'First paragraph' );
|
43
|
-
|
44
|
-
await insertBlock( 'Paragraph' );
|
45
|
-
await page.keyboard.type( 'Second paragraph' );
|
46
|
-
|
47
|
-
await clickBlockToolbarButton( 'Options' );
|
48
|
-
await clickMenuItem( 'Lock' );
|
49
|
-
|
50
|
-
const [ checkbox ] = await page.$x(
|
51
|
-
'//label[contains(text(), "Disable movement")]'
|
52
|
-
);
|
53
|
-
await checkbox.click();
|
54
|
-
|
55
|
-
await clickButton( 'Apply' );
|
56
|
-
|
57
|
-
// Hide options.
|
58
|
-
await clickBlockToolbarButton( 'Options' );
|
59
|
-
|
60
|
-
const blockMover = await page.$( '.block-editor-block-mover' );
|
61
|
-
expect( blockMover ).toBeNull();
|
62
|
-
|
63
|
-
const [ lockButton ] = await page.$x(
|
64
|
-
'//button[@aria-label="Unlock Paragraph"]'
|
65
|
-
);
|
66
|
-
expect( lockButton ).toBeTruthy();
|
67
|
-
} );
|
68
|
-
|
69
|
-
it( 'can lock everything', async () => {
|
70
|
-
await insertBlock( 'Paragraph' );
|
71
|
-
await page.keyboard.type( 'Some paragraph' );
|
72
|
-
|
73
|
-
await clickBlockToolbarButton( 'Options' );
|
74
|
-
await clickMenuItem( 'Lock' );
|
75
|
-
|
76
|
-
const [ checkbox ] = await page.$x(
|
77
|
-
'//label//*[contains(text(), "Lock all")]'
|
78
|
-
);
|
79
|
-
await checkbox.click();
|
80
|
-
|
81
|
-
await clickButton( 'Apply' );
|
82
|
-
|
83
|
-
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
84
|
-
"<!-- wp:paragraph {\\"lock\\":{\\"move\\":true,\\"remove\\":true}} -->
|
85
|
-
<p>Some paragraph</p>
|
86
|
-
<!-- /wp:paragraph -->"
|
87
|
-
` );
|
88
|
-
} );
|
89
|
-
|
90
|
-
it( 'can unlock from toolbar', async () => {
|
91
|
-
await insertBlock( 'Paragraph' );
|
92
|
-
await page.keyboard.type( 'Some paragraph' );
|
93
|
-
|
94
|
-
await clickBlockToolbarButton( 'Options' );
|
95
|
-
await clickMenuItem( 'Lock' );
|
96
|
-
|
97
|
-
const [ lockCheckbox ] = await page.$x(
|
98
|
-
'//label//*[contains(text(), "Lock all")]'
|
99
|
-
);
|
100
|
-
await lockCheckbox.click();
|
101
|
-
|
102
|
-
await clickButton( 'Apply' );
|
103
|
-
|
104
|
-
await clickBlockToolbarButton( 'Unlock Paragraph' );
|
105
|
-
|
106
|
-
const [ unlockCheckbox ] = await page.$x(
|
107
|
-
'//label//*[contains(text(), "Lock all")]'
|
108
|
-
);
|
109
|
-
await unlockCheckbox.click();
|
110
|
-
|
111
|
-
await clickButton( 'Apply' );
|
112
|
-
|
113
|
-
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
114
|
-
"<!-- wp:paragraph {\\"lock\\":{\\"move\\":false,\\"remove\\":false}} -->
|
115
|
-
<p>Some paragraph</p>
|
116
|
-
<!-- /wp:paragraph -->"
|
117
|
-
` );
|
118
|
-
} );
|
119
|
-
} );
|
120
|
-
} );
|