@wordpress/e2e-tests 4.8.0 → 4.9.2
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/README.md +8 -8
- package/package.json +5 -5
- package/specs/editor/blocks/quote.test.js +46 -0
- package/specs/editor/various/__snapshots__/rich-text.test.js.snap +12 -0
- package/specs/editor/various/block-editor-keyboard-shortcuts.test.js +1 -1
- package/specs/editor/various/reusable-blocks.test.js +2 -2
- package/specs/editor/various/rich-text.test.js +17 -0
- package/specs/site-editor/multi-entity-saving.test.js +3 -3
- package/specs/editor/blocks/__snapshots__/group.test.js.snap +0 -21
- package/specs/editor/blocks/group.test.js +0 -43
- package/specs/editor/blocks/missing.test.js +0 -44
- package/specs/editor/plugins/__snapshots__/deprecated-node-matcher.test.js.snap +0 -13
- package/specs/editor/plugins/deprecated-node-matcher.test.js +0 -44
- package/specs/editor/various/__snapshots__/convert-block-type.test.js.snap +0 -13
- package/specs/editor/various/convert-block-type.test.js +0 -32
package/README.md
CHANGED
@@ -18,30 +18,30 @@ The following commands are available on the Gutenberg repo:
|
|
18
18
|
|
19
19
|
```json
|
20
20
|
{
|
21
|
-
"test
|
22
|
-
"test
|
23
|
-
"test
|
21
|
+
"test:e2e": "wp-scripts test-e2e --config packages/e2e-tests/jest.config.js",
|
22
|
+
"test:e2e:debug": "wp-scripts --inspect-brk test-e2e --config packages/e2e-tests/jest.config.js --puppeteer-devtools",
|
23
|
+
"test:e2e:watch": "npm run test:e2e -- --watch"
|
24
24
|
}
|
25
25
|
```
|
26
26
|
|
27
27
|
### Run all available tests
|
28
28
|
|
29
29
|
```bash
|
30
|
-
npm run test
|
30
|
+
npm run test:e2e
|
31
31
|
```
|
32
32
|
|
33
33
|
### Run all available tests and listen for changes.
|
34
34
|
|
35
35
|
```bash
|
36
|
-
npm run test
|
36
|
+
npm run test:e2e:watch
|
37
37
|
```
|
38
38
|
|
39
39
|
### Run a specific test file
|
40
40
|
|
41
41
|
```bash
|
42
|
-
npm run test
|
42
|
+
npm run test:e2e -- packages/e2e-test/<path_to_test_file>
|
43
43
|
# Or, in order to watch for changes:
|
44
|
-
npm run test
|
44
|
+
npm run test:e2e:watch -- packages/e2e-test/<path_to_test_file>
|
45
45
|
```
|
46
46
|
|
47
47
|
### Debugging
|
@@ -49,7 +49,7 @@ npm run test-e2e:watch -- packages/e2e-test/<path_to_test_file>
|
|
49
49
|
Makes e2e tests available to debug in a Chrome Browser.
|
50
50
|
|
51
51
|
```bash
|
52
|
-
npm run test
|
52
|
+
npm run test:e2e:debug
|
53
53
|
```
|
54
54
|
|
55
55
|
After running the command, tests will be available for debugging in Chrome by going to chrome://inspect/#devices and clicking `inspect` under the path to `/test-e2e.js`.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/e2e-tests",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.9.2",
|
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": ">=12"
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
|
-
"@wordpress/e2e-test-utils": "^7.
|
26
|
+
"@wordpress/e2e-test-utils": "^7.11.0",
|
27
27
|
"@wordpress/jest-console": "^5.4.0",
|
28
28
|
"@wordpress/jest-puppeteer-axe": "^4.1.0",
|
29
|
-
"@wordpress/scripts": "^23.
|
30
|
-
"@wordpress/url": "^3.
|
29
|
+
"@wordpress/scripts": "^23.7.2",
|
30
|
+
"@wordpress/url": "^3.16.0",
|
31
31
|
"chalk": "^4.0.0",
|
32
32
|
"expect-puppeteer": "^4.4.0",
|
33
33
|
"filenamify": "^4.2.0",
|
@@ -46,5 +46,5 @@
|
|
46
46
|
"publishConfig": {
|
47
47
|
"access": "public"
|
48
48
|
},
|
49
|
-
"gitHead": "
|
49
|
+
"gitHead": "b5b9cf3926b3a3c153252e6e4bc2de41afa3ca2a"
|
50
50
|
}
|
@@ -147,4 +147,50 @@ describe( 'Quote', () => {
|
|
147
147
|
// Expect the paragraph to be deleted.
|
148
148
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
149
149
|
} );
|
150
|
+
|
151
|
+
it( 'can be unwrapped on Backspace', async () => {
|
152
|
+
await insertBlock( 'Quote' );
|
153
|
+
|
154
|
+
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
155
|
+
"<!-- wp:quote -->
|
156
|
+
<blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
|
157
|
+
<p></p>
|
158
|
+
<!-- /wp:paragraph --></blockquote>
|
159
|
+
<!-- /wp:quote -->"
|
160
|
+
` );
|
161
|
+
|
162
|
+
await page.keyboard.press( 'Backspace' );
|
163
|
+
|
164
|
+
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `""` );
|
165
|
+
} );
|
166
|
+
|
167
|
+
it( 'can be unwrapped with content on Backspace', async () => {
|
168
|
+
await insertBlock( 'Quote' );
|
169
|
+
await page.keyboard.type( '1' );
|
170
|
+
await page.keyboard.press( 'ArrowRight' );
|
171
|
+
await page.keyboard.type( '2' );
|
172
|
+
|
173
|
+
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
174
|
+
"<!-- wp:quote -->
|
175
|
+
<blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
|
176
|
+
<p>1</p>
|
177
|
+
<!-- /wp:paragraph --><cite>2</cite></blockquote>
|
178
|
+
<!-- /wp:quote -->"
|
179
|
+
` );
|
180
|
+
|
181
|
+
await page.keyboard.press( 'ArrowLeft' );
|
182
|
+
await page.keyboard.press( 'ArrowUp' );
|
183
|
+
await page.keyboard.press( 'ArrowUp' );
|
184
|
+
await page.keyboard.press( 'Backspace' );
|
185
|
+
|
186
|
+
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
187
|
+
"<!-- wp:paragraph -->
|
188
|
+
<p>1</p>
|
189
|
+
<!-- /wp:paragraph -->
|
190
|
+
|
191
|
+
<!-- wp:paragraph -->
|
192
|
+
<p>2</p>
|
193
|
+
<!-- /wp:paragraph -->"
|
194
|
+
` );
|
195
|
+
} );
|
150
196
|
} );
|
@@ -178,6 +178,18 @@ exports[`RichText should transform backtick to code 2`] = `
|
|
178
178
|
<!-- /wp:paragraph -->"
|
179
179
|
`;
|
180
180
|
|
181
|
+
exports[`RichText should transform when typing backtick over selection 1`] = `
|
182
|
+
"<!-- wp:paragraph -->
|
183
|
+
<p>A <code>selection</code> test.</p>
|
184
|
+
<!-- /wp:paragraph -->"
|
185
|
+
`;
|
186
|
+
|
187
|
+
exports[`RichText should transform when typing backtick over selection 2`] = `
|
188
|
+
"<!-- wp:paragraph -->
|
189
|
+
<p>A \`selection\` test.</p>
|
190
|
+
<!-- /wp:paragraph -->"
|
191
|
+
`;
|
192
|
+
|
181
193
|
exports[`RichText should undo backtick transform with backspace 1`] = `
|
182
194
|
"<!-- wp:paragraph -->
|
183
195
|
<p>\`a\`</p>
|
@@ -87,7 +87,7 @@ describe( 'block editor keyboard shortcuts', () => {
|
|
87
87
|
} );
|
88
88
|
it( 'should prevent deleting multiple selected blocks from inputs', async () => {
|
89
89
|
await clickBlockToolbarButton( 'Options' );
|
90
|
-
await clickMenuItem( '
|
90
|
+
await clickMenuItem( 'Create Reusable block' );
|
91
91
|
const reusableBlockNameInputSelector =
|
92
92
|
'.reusable-blocks-menu-items__convert-modal .components-text-control__input';
|
93
93
|
const nameInput = await page.waitForSelector(
|
@@ -192,7 +192,7 @@ describe( 'Reusable blocks', () => {
|
|
192
192
|
|
193
193
|
// Convert block to a reusable block.
|
194
194
|
await clickBlockToolbarButton( 'Options' );
|
195
|
-
await clickMenuItem( '
|
195
|
+
await clickMenuItem( 'Create Reusable block' );
|
196
196
|
|
197
197
|
// Set title.
|
198
198
|
const nameInput = await page.waitForSelector(
|
@@ -373,7 +373,7 @@ describe( 'Reusable blocks', () => {
|
|
373
373
|
|
374
374
|
// Convert to reusable.
|
375
375
|
await clickBlockToolbarButton( 'Options' );
|
376
|
-
await clickMenuItem( '
|
376
|
+
await clickMenuItem( 'Create Reusable block' );
|
377
377
|
const nameInput = await page.waitForSelector(
|
378
378
|
reusableBlockNameInputSelector
|
379
379
|
);
|
@@ -148,6 +148,23 @@ describe( 'RichText', () => {
|
|
148
148
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
149
149
|
} );
|
150
150
|
|
151
|
+
it( 'should transform when typing backtick over selection', async () => {
|
152
|
+
await clickBlockAppender();
|
153
|
+
await page.keyboard.type( 'A selection test.' );
|
154
|
+
await page.keyboard.press( 'Home' );
|
155
|
+
await page.keyboard.press( 'ArrowRight' );
|
156
|
+
await page.keyboard.press( 'ArrowRight' );
|
157
|
+
await pressKeyWithModifier( 'shiftAlt', 'ArrowRight' );
|
158
|
+
await page.keyboard.type( '`' );
|
159
|
+
|
160
|
+
expect( await getEditedPostContent() ).toMatchSnapshot();
|
161
|
+
|
162
|
+
// Should undo the transform.
|
163
|
+
await pressKeyWithModifier( 'primary', 'z' );
|
164
|
+
|
165
|
+
expect( await getEditedPostContent() ).toMatchSnapshot();
|
166
|
+
} );
|
167
|
+
|
151
168
|
it( 'should only mutate text data on input', async () => {
|
152
169
|
await clickBlockAppender();
|
153
170
|
await page.keyboard.type( '1' );
|
@@ -207,15 +207,15 @@ describe( 'Multi-entity save flow', () => {
|
|
207
207
|
await page.keyboard.type( '...' );
|
208
208
|
|
209
209
|
await insertBlock( 'Site Tagline' );
|
210
|
-
//
|
210
|
+
// Wait for the placeholder.
|
211
211
|
await page.waitForXPath(
|
212
|
-
'//
|
212
|
+
'//span[@data-rich-text-placeholder="Write site tagline…"]'
|
213
213
|
);
|
214
214
|
const editableSiteTagLineSelector =
|
215
215
|
'.wp-block-site-tagline[contenteditable="true"]';
|
216
216
|
await page.waitForSelector( editableSiteTagLineSelector );
|
217
217
|
await page.focus( editableSiteTagLineSelector );
|
218
|
-
await page.keyboard.type( '
|
218
|
+
await page.keyboard.type( 'Just another WordPress site' );
|
219
219
|
|
220
220
|
await clickButton( 'Publish' );
|
221
221
|
await page.waitForSelector( savePanelSelector );
|
@@ -1,21 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`Group can be created using the block inserter 1`] = `
|
4
|
-
"<!-- wp:group -->
|
5
|
-
<div class=\\"wp-block-group\\"></div>
|
6
|
-
<!-- /wp:group -->"
|
7
|
-
`;
|
8
|
-
|
9
|
-
exports[`Group can be created using the slash inserter 1`] = `
|
10
|
-
"<!-- wp:group -->
|
11
|
-
<div class=\\"wp-block-group\\"></div>
|
12
|
-
<!-- /wp:group -->"
|
13
|
-
`;
|
14
|
-
|
15
|
-
exports[`Group can have other blocks appended to it using the button appender 1`] = `
|
16
|
-
"<!-- wp:group -->
|
17
|
-
<div class=\\"wp-block-group\\"><!-- wp:paragraph -->
|
18
|
-
<p>Group Block with a Paragraph</p>
|
19
|
-
<!-- /wp:paragraph --></div>
|
20
|
-
<!-- /wp:group -->"
|
21
|
-
`;
|
@@ -1,43 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
clickBlockAppender,
|
6
|
-
searchForBlock,
|
7
|
-
getEditedPostContent,
|
8
|
-
createNewPost,
|
9
|
-
} from '@wordpress/e2e-test-utils';
|
10
|
-
|
11
|
-
describe( 'Group', () => {
|
12
|
-
beforeEach( async () => {
|
13
|
-
await createNewPost();
|
14
|
-
} );
|
15
|
-
|
16
|
-
it( 'can be created using the block inserter', async () => {
|
17
|
-
await searchForBlock( 'Group' );
|
18
|
-
await page.click( '.editor-block-list-item-group' );
|
19
|
-
|
20
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
21
|
-
} );
|
22
|
-
|
23
|
-
it( 'can be created using the slash inserter', async () => {
|
24
|
-
await clickBlockAppender();
|
25
|
-
await page.keyboard.type( '/group' );
|
26
|
-
await page.waitForXPath(
|
27
|
-
`//*[contains(@class, "components-autocomplete__result") and contains(@class, "is-selected") and contains(text(), 'Group')]`
|
28
|
-
);
|
29
|
-
await page.keyboard.press( 'Enter' );
|
30
|
-
|
31
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
32
|
-
} );
|
33
|
-
|
34
|
-
it( 'can have other blocks appended to it using the button appender', async () => {
|
35
|
-
await searchForBlock( 'Group' );
|
36
|
-
await page.click( '.editor-block-list-item-group' );
|
37
|
-
await page.click( '.block-editor-button-block-appender' );
|
38
|
-
await page.click( '.editor-block-list-item-paragraph' );
|
39
|
-
await page.keyboard.type( 'Group Block with a Paragraph' );
|
40
|
-
|
41
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
42
|
-
} );
|
43
|
-
} );
|
@@ -1,44 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import { createNewPost, setPostContent } from '@wordpress/e2e-test-utils';
|
5
|
-
|
6
|
-
describe( 'missing block', () => {
|
7
|
-
beforeEach( async () => {
|
8
|
-
await createNewPost();
|
9
|
-
} );
|
10
|
-
|
11
|
-
it( 'should strip potentially malicious on* attributes', async () => {
|
12
|
-
let hasAlert = false;
|
13
|
-
|
14
|
-
page.on( 'dialog', () => {
|
15
|
-
hasAlert = true;
|
16
|
-
} );
|
17
|
-
|
18
|
-
await setPostContent(
|
19
|
-
`<!-- wp:non-existing-block-here --><img src onerror=alert(1)>`
|
20
|
-
);
|
21
|
-
|
22
|
-
// Give the browser time to show the alert.
|
23
|
-
await page.evaluate( () => new Promise( window.requestIdleCallback ) );
|
24
|
-
|
25
|
-
expect( hasAlert ).toBe( false );
|
26
|
-
} );
|
27
|
-
|
28
|
-
it( 'hould strip potentially malicious script tags', async () => {
|
29
|
-
let hasAlert = false;
|
30
|
-
|
31
|
-
page.on( 'dialog', () => {
|
32
|
-
hasAlert = true;
|
33
|
-
} );
|
34
|
-
|
35
|
-
await setPostContent(
|
36
|
-
`<!-- wp:non-existing-block-here --><script>alert("EVIL");</script>`
|
37
|
-
);
|
38
|
-
|
39
|
-
// Give the browser time to show the alert.
|
40
|
-
await page.evaluate( () => new Promise( window.requestIdleCallback ) );
|
41
|
-
|
42
|
-
expect( hasAlert ).toBe( false );
|
43
|
-
} );
|
44
|
-
} );
|
@@ -1,13 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`Deprecated Node Matcher should insert block with children source 1`] = `
|
4
|
-
"<!-- wp:deprecated-children-matcher -->
|
5
|
-
<p class=\\"wp-block-deprecated-children-matcher\\">test<br/><strong>a</strong></p>
|
6
|
-
<!-- /wp:deprecated-children-matcher -->"
|
7
|
-
`;
|
8
|
-
|
9
|
-
exports[`Deprecated Node Matcher should insert block with node source 1`] = `
|
10
|
-
"<!-- wp:deprecated-node-matcher -->
|
11
|
-
<blockquote class=\\"wp-block-deprecated-node-matcher\\"><p>test</p><p></p></blockquote>
|
12
|
-
<!-- /wp:deprecated-node-matcher -->"
|
13
|
-
`;
|
@@ -1,44 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
createNewPost,
|
7
|
-
deactivatePlugin,
|
8
|
-
getEditedPostContent,
|
9
|
-
insertBlock,
|
10
|
-
pressKeyWithModifier,
|
11
|
-
} from '@wordpress/e2e-test-utils';
|
12
|
-
|
13
|
-
describe( 'Deprecated Node Matcher', () => {
|
14
|
-
beforeAll( async () => {
|
15
|
-
await activatePlugin( 'gutenberg-test-deprecated-node-matcher' );
|
16
|
-
} );
|
17
|
-
|
18
|
-
beforeEach( async () => {
|
19
|
-
await createNewPost();
|
20
|
-
} );
|
21
|
-
|
22
|
-
afterAll( async () => {
|
23
|
-
await deactivatePlugin( 'gutenberg-test-deprecated-node-matcher' );
|
24
|
-
} );
|
25
|
-
|
26
|
-
it( 'should insert block with node source', async () => {
|
27
|
-
await insertBlock( 'Deprecated Node Matcher' );
|
28
|
-
await page.keyboard.type( 'test' );
|
29
|
-
await page.keyboard.press( 'Enter' );
|
30
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
31
|
-
} );
|
32
|
-
|
33
|
-
it( 'should insert block with children source', async () => {
|
34
|
-
await insertBlock( 'Deprecated Children Matcher' );
|
35
|
-
await page.keyboard.type( 'test' );
|
36
|
-
await page.keyboard.press( 'Enter' );
|
37
|
-
await page.keyboard.type( 'a' );
|
38
|
-
await page.keyboard.down( 'Shift' );
|
39
|
-
await page.keyboard.press( 'ArrowLeft' );
|
40
|
-
await page.keyboard.up( 'Shift' );
|
41
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
42
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
43
|
-
} );
|
44
|
-
} );
|
@@ -1,13 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`Code block should convert to a preformatted block 1`] = `
|
4
|
-
"<!-- wp:code -->
|
5
|
-
<pre class=\\"wp-block-code\\"><code>print \\"Hello Dolly!\\"</code></pre>
|
6
|
-
<!-- /wp:code -->"
|
7
|
-
`;
|
8
|
-
|
9
|
-
exports[`Code block should convert to a preformatted block 2`] = `
|
10
|
-
"<!-- wp:preformatted -->
|
11
|
-
<pre class=\\"wp-block-preformatted\\">print \\"Hello Dolly!\\"</pre>
|
12
|
-
<!-- /wp:preformatted -->"
|
13
|
-
`;
|
@@ -1,32 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
getEditedPostContent,
|
6
|
-
createNewPost,
|
7
|
-
insertBlock,
|
8
|
-
transformBlockTo,
|
9
|
-
} from '@wordpress/e2e-test-utils';
|
10
|
-
|
11
|
-
describe( 'Code block', () => {
|
12
|
-
beforeEach( async () => {
|
13
|
-
await createNewPost();
|
14
|
-
} );
|
15
|
-
|
16
|
-
it( 'should convert to a preformatted block', async () => {
|
17
|
-
const code = 'print "Hello Dolly!"';
|
18
|
-
|
19
|
-
await insertBlock( 'Code' );
|
20
|
-
await page.keyboard.type( code );
|
21
|
-
|
22
|
-
// Verify the content starts out as a Code block.
|
23
|
-
const originalPostContent = await getEditedPostContent();
|
24
|
-
expect( originalPostContent ).toMatchSnapshot();
|
25
|
-
|
26
|
-
await transformBlockTo( 'Preformatted' );
|
27
|
-
|
28
|
-
// The content should now be a Preformatted block with no data loss.
|
29
|
-
const convertedPostContent = await getEditedPostContent();
|
30
|
-
expect( convertedPostContent ).toMatchSnapshot();
|
31
|
-
} );
|
32
|
-
} );
|