@wordpress/e2e-tests 5.2.0 → 5.3.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 +6 -0
- package/package.json +7 -7
- package/plugins/class-test-widget.php +1 -1
- package/plugins/test-autocompleter/index.js +55 -0
- package/plugins/test-autocompleter.php +27 -0
- package/specs/editor/various/reusable-blocks.test.js +1 -2
- package/specs/editor/plugins/__snapshots__/iframed-block.test.js.snap +0 -7
- package/specs/editor/plugins/iframed-block.test.js +0 -49
- package/specs/editor/various/mentions.test.js +0 -69
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/e2e-tests",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.3.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": "^8.
|
27
|
-
"@wordpress/jest-console": "^6.
|
28
|
-
"@wordpress/jest-puppeteer-axe": "^5.
|
29
|
-
"@wordpress/scripts": "^24.
|
30
|
-
"@wordpress/url": "^3.
|
26
|
+
"@wordpress/e2e-test-utils": "^8.3.0",
|
27
|
+
"@wordpress/jest-console": "^6.2.0",
|
28
|
+
"@wordpress/jest-puppeteer-axe": "^5.2.0",
|
29
|
+
"@wordpress/scripts": "^24.3.0",
|
30
|
+
"@wordpress/url": "^3.20.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": "8d42d2febb7d0ba8372a33e560a62f5a5f6a9112"
|
50
50
|
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
(function () {
|
2
|
+
const fruits = {
|
3
|
+
name: 'fruit',
|
4
|
+
// The prefix that triggers this completer
|
5
|
+
triggerPrefix: '~',
|
6
|
+
// The option data
|
7
|
+
options: [
|
8
|
+
{ visual: '🍎', name: 'Apple', id: 1 },
|
9
|
+
{ visual: '🍊', name: 'Orange', id: 2 },
|
10
|
+
{ visual: '🍇', name: 'Grapes', id: 3 },
|
11
|
+
{ visual: '🥭', name: 'Mango', id: 4 },
|
12
|
+
{ visual: '🍓', name: 'Strawberry', id: 5 },
|
13
|
+
{ visual: '🫐', name: 'Blueberry', id: 6 },
|
14
|
+
{ visual: '🍒', name: 'Cherry', id: 7 },
|
15
|
+
],
|
16
|
+
// Returns a label for an option like "🍊 Orange"
|
17
|
+
getOptionLabel: ( option ) => `${ option.visual } ${ option.name }`,
|
18
|
+
// Declares that options should be matched by their name
|
19
|
+
getOptionKeywords: ( option ) => [ option.name ],
|
20
|
+
// Declares that the Grapes option is disabled
|
21
|
+
isOptionDisabled: ( option ) => option.name === 'Grapes',
|
22
|
+
// Declares completions should be inserted as abbreviations
|
23
|
+
getOptionCompletion: ( option ) => (
|
24
|
+
option.visual
|
25
|
+
),
|
26
|
+
};
|
27
|
+
|
28
|
+
function duplicateUserMentions( completers ) {
|
29
|
+
const [ users ] = completers.filter(
|
30
|
+
( completer ) => completer.name === 'users'
|
31
|
+
);
|
32
|
+
return {
|
33
|
+
...users,
|
34
|
+
name: 'users-copy',
|
35
|
+
triggerPrefix: '+',
|
36
|
+
getOptionCompletion: ( user ) => `+${ user.slug }`,
|
37
|
+
};
|
38
|
+
}
|
39
|
+
|
40
|
+
function appendTestCompleters( completers, blockName ) {
|
41
|
+
const copiedUsers = duplicateUserMentions( completers );
|
42
|
+
return blockName === 'core/paragraph'
|
43
|
+
? [ ...completers, fruits, copiedUsers ]
|
44
|
+
: completers;
|
45
|
+
}
|
46
|
+
|
47
|
+
// Adding the filter with a priority of 11
|
48
|
+
// to ensure it fires after the default user mentions are added.
|
49
|
+
wp.hooks.addFilter(
|
50
|
+
'editor.Autocomplete.completers',
|
51
|
+
'editor/autocompleters/test',
|
52
|
+
appendTestCompleters,
|
53
|
+
11
|
54
|
+
);
|
55
|
+
})()
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* Plugin Name: Gutenberg Test Autocompleter
|
4
|
+
* Plugin URI: https://github.com/WordPress/gutenberg
|
5
|
+
* Author: Gutenberg Team
|
6
|
+
*
|
7
|
+
* @package gutenberg-test-autocompleter
|
8
|
+
*/
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Registers a custom script for the plugin.
|
12
|
+
*/
|
13
|
+
function enqueue_test_autocompleter_plugin_script() {
|
14
|
+
wp_enqueue_script(
|
15
|
+
'gutenberg-test-autocompleter',
|
16
|
+
plugins_url( 'test-autocompleter/index.js', __FILE__ ),
|
17
|
+
array(
|
18
|
+
'wp-hooks',
|
19
|
+
'wp-element',
|
20
|
+
'wp-block-editor',
|
21
|
+
),
|
22
|
+
filemtime( plugin_dir_path( __FILE__ ) . 'test-autocompleter/index.js' ),
|
23
|
+
false
|
24
|
+
);
|
25
|
+
}
|
26
|
+
|
27
|
+
add_action( 'init', 'enqueue_test_autocompleter_plugin_script' );
|
@@ -363,9 +363,8 @@ describe( 'Reusable blocks', () => {
|
|
363
363
|
const quoteBlock = await page.waitForSelector(
|
364
364
|
'.block-editor-block-list__block[aria-label="Block: Quote"]'
|
365
365
|
);
|
366
|
-
await quoteBlock.click();
|
367
366
|
// Select the quote block.
|
368
|
-
await
|
367
|
+
await quoteBlock.focus();
|
369
368
|
await openDocumentSettingsSidebar();
|
370
369
|
await page.waitForXPath(
|
371
370
|
'//*[@role="region"][@aria-label="Editor settings"]//button[.="Styles"]'
|
@@ -1,7 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`changing image size should load script and dependencies in iframe 1`] = `
|
4
|
-
"<!-- wp:test/iframed-block -->
|
5
|
-
<p class=\\"wp-block-test-iframed-block\\">Iframed Block (saved)</p>
|
6
|
-
<!-- /wp:test/iframed-block -->"
|
7
|
-
`;
|
@@ -1,49 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
createNewPost,
|
7
|
-
deactivatePlugin,
|
8
|
-
insertBlock,
|
9
|
-
getEditedPostContent,
|
10
|
-
canvas,
|
11
|
-
createNewTemplate,
|
12
|
-
} from '@wordpress/e2e-test-utils';
|
13
|
-
|
14
|
-
describe( 'changing image size', () => {
|
15
|
-
beforeEach( async () => {
|
16
|
-
await activatePlugin( 'gutenberg-test-iframed-block' );
|
17
|
-
await createNewPost( { postType: 'page' } );
|
18
|
-
} );
|
19
|
-
|
20
|
-
afterEach( async () => {
|
21
|
-
await deactivatePlugin( 'gutenberg-test-iframed-block' );
|
22
|
-
} );
|
23
|
-
|
24
|
-
it( 'should load script and dependencies in iframe', async () => {
|
25
|
-
await insertBlock( 'Iframed Block' );
|
26
|
-
|
27
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
28
|
-
|
29
|
-
const element = await page.waitForSelector(
|
30
|
-
'.wp-block-test-iframed-block'
|
31
|
-
);
|
32
|
-
const text = await element.evaluate( ( el ) => el.textContent );
|
33
|
-
|
34
|
-
expect( text ).toBe( 'Iframed Block (set with jQuery)' );
|
35
|
-
|
36
|
-
await createNewTemplate( 'Iframed Test' );
|
37
|
-
|
38
|
-
const iframeElement = await canvas().waitForSelector(
|
39
|
-
'.wp-block-test-iframed-block'
|
40
|
-
);
|
41
|
-
const iframedText = await iframeElement.evaluate(
|
42
|
-
( el ) => el.textContent
|
43
|
-
);
|
44
|
-
|
45
|
-
// Expect the script to load in the iframe, which replaces the block
|
46
|
-
// text.
|
47
|
-
expect( iframedText ).toBe( 'Iframed Block (set with jQuery)' );
|
48
|
-
} );
|
49
|
-
} );
|
@@ -1,69 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
clickBlockAppender,
|
6
|
-
createNewPost,
|
7
|
-
createUser,
|
8
|
-
deleteUser,
|
9
|
-
getEditedPostContent,
|
10
|
-
pressKeyTimes,
|
11
|
-
} from '@wordpress/e2e-test-utils';
|
12
|
-
|
13
|
-
describe( 'autocomplete mentions', () => {
|
14
|
-
beforeAll( async () => {
|
15
|
-
await createUser( 'testuser', { firstName: 'Jane', lastName: 'Doe' } );
|
16
|
-
} );
|
17
|
-
|
18
|
-
beforeEach( async () => {
|
19
|
-
await createNewPost();
|
20
|
-
} );
|
21
|
-
|
22
|
-
afterAll( async () => {
|
23
|
-
await deleteUser( 'testuser' );
|
24
|
-
} );
|
25
|
-
|
26
|
-
it( 'should insert mention', async () => {
|
27
|
-
await clickBlockAppender();
|
28
|
-
await page.keyboard.type( 'I am @a' );
|
29
|
-
await page.waitForSelector( '.components-autocomplete__result' );
|
30
|
-
await page.keyboard.press( 'Enter' );
|
31
|
-
await page.keyboard.type( '.' );
|
32
|
-
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
33
|
-
"<!-- wp:paragraph -->
|
34
|
-
<p>I am @admin.</p>
|
35
|
-
<!-- /wp:paragraph -->"
|
36
|
-
` );
|
37
|
-
} );
|
38
|
-
|
39
|
-
it( 'should insert mention between two other words', async () => {
|
40
|
-
await clickBlockAppender();
|
41
|
-
await page.keyboard.type( 'Stuck in the middle with you.' );
|
42
|
-
await pressKeyTimes( 'ArrowLeft', 'you.'.length );
|
43
|
-
await page.keyboard.type( '@j' );
|
44
|
-
await page.waitForSelector( '.components-autocomplete__result' );
|
45
|
-
await page.keyboard.press( 'Enter' );
|
46
|
-
await page.keyboard.type( ' ' );
|
47
|
-
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
48
|
-
"<!-- wp:paragraph -->
|
49
|
-
<p>Stuck in the middle with @testuser you.</p>
|
50
|
-
<!-- /wp:paragraph -->"
|
51
|
-
` );
|
52
|
-
} );
|
53
|
-
|
54
|
-
it( 'should insert two subsequent mentions', async () => {
|
55
|
-
await clickBlockAppender();
|
56
|
-
await page.keyboard.type( 'I am @j' );
|
57
|
-
await page.waitForSelector( '.components-autocomplete__result' );
|
58
|
-
await page.keyboard.press( 'Enter' );
|
59
|
-
await page.keyboard.type( ' @a' );
|
60
|
-
await page.waitForSelector( '.components-autocomplete__result' );
|
61
|
-
await page.keyboard.press( 'Enter' );
|
62
|
-
await page.keyboard.type( '.' );
|
63
|
-
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
64
|
-
"<!-- wp:paragraph -->
|
65
|
-
<p>I am @testuser @admin.</p>
|
66
|
-
<!-- /wp:paragraph -->"
|
67
|
-
` );
|
68
|
-
} );
|
69
|
-
} );
|