@wordpress/e2e-tests 7.2.0 → 7.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 +2 -0
- package/package.json +7 -7
- package/plugins/iframed-enqueue-block-assets/style.css +9 -0
- package/plugins/iframed-enqueue-block-assets.php +21 -0
- package/specs/editor/plugins/iframed-equeue-block-assets.test.js +44 -0
- package/specs/editor/various/navigable-toolbar.test.js +55 -29
- package/specs/editor/plugins/custom-post-types.test.js +0 -81
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.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": "^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.3.0",
|
27
|
+
"@wordpress/jest-console": "^7.3.0",
|
28
|
+
"@wordpress/jest-puppeteer-axe": "^6.3.0",
|
29
|
+
"@wordpress/scripts": "^26.3.0",
|
30
|
+
"@wordpress/url": "^3.33.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": "6df0c62d43b8901414ccd22ffbe56eaa99d012a6"
|
49
49
|
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* Plugin Name: Gutenberg Test Iframed enqueue_block_assets
|
4
|
+
* Plugin URI: https://github.com/WordPress/gutenberg
|
5
|
+
* Author: Gutenberg Team
|
6
|
+
*
|
7
|
+
* @package gutenberg-test-iframed-iframed-enqueue-block-assets
|
8
|
+
*/
|
9
|
+
|
10
|
+
add_action(
|
11
|
+
'enqueue_block_assets',
|
12
|
+
function() {
|
13
|
+
wp_enqueue_style(
|
14
|
+
'iframed-enqueue-block-assets',
|
15
|
+
plugin_dir_url( __FILE__ ) . 'iframed-enqueue-block-assets/style.css',
|
16
|
+
array(),
|
17
|
+
filemtime( plugin_dir_path( __FILE__ ) . 'iframed-enqueue-block-assets/style.css' )
|
18
|
+
);
|
19
|
+
wp_add_inline_style( 'iframed-enqueue-block-assets', 'body{padding:20px!important}' );
|
20
|
+
}
|
21
|
+
);
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/**
|
2
|
+
* WordPress dependencies
|
3
|
+
*/
|
4
|
+
import {
|
5
|
+
activatePlugin,
|
6
|
+
createNewPost,
|
7
|
+
deactivatePlugin,
|
8
|
+
canvas,
|
9
|
+
activateTheme,
|
10
|
+
} from '@wordpress/e2e-test-utils';
|
11
|
+
|
12
|
+
async function getComputedStyle( context, selector, property ) {
|
13
|
+
return await context.evaluate(
|
14
|
+
( sel, prop ) =>
|
15
|
+
window.getComputedStyle( document.querySelector( sel ) )[ prop ],
|
16
|
+
selector,
|
17
|
+
property
|
18
|
+
);
|
19
|
+
}
|
20
|
+
|
21
|
+
describe( 'iframed inline styles', () => {
|
22
|
+
beforeEach( async () => {
|
23
|
+
// Activate the empty theme (block based theme), which is iframed.
|
24
|
+
await activateTheme( 'emptytheme' );
|
25
|
+
await activatePlugin( 'gutenberg-test-iframed-enqueue_block_assets' );
|
26
|
+
await createNewPost();
|
27
|
+
} );
|
28
|
+
|
29
|
+
afterEach( async () => {
|
30
|
+
await deactivatePlugin( 'gutenberg-test-iframed-enqueue_block_assets' );
|
31
|
+
await activateTheme( 'twentytwentyone' );
|
32
|
+
} );
|
33
|
+
|
34
|
+
it( 'should load styles added through enqueue_block_assets', async () => {
|
35
|
+
// Check stylesheet.
|
36
|
+
expect(
|
37
|
+
await getComputedStyle( canvas(), 'body', 'background-color' )
|
38
|
+
).toBe( 'rgb(33, 117, 155)' );
|
39
|
+
// Check inline style.
|
40
|
+
expect( await getComputedStyle( canvas(), 'body', 'padding' ) ).toBe(
|
41
|
+
'20px'
|
42
|
+
);
|
43
|
+
} );
|
44
|
+
} );
|
@@ -11,38 +11,12 @@ async function isInBlockToolbar() {
|
|
11
11
|
} );
|
12
12
|
}
|
13
13
|
|
14
|
-
describe
|
15
|
-
[ 'unified', true ],
|
16
|
-
[ 'contextual', false ],
|
17
|
-
] )( 'block toolbar (%s: %p)', ( label, isUnifiedToolbar ) => {
|
14
|
+
describe( 'Block Toolbar', () => {
|
18
15
|
beforeEach( async () => {
|
19
16
|
await createNewPost();
|
20
|
-
|
21
|
-
await page.evaluate( ( _isUnifiedToolbar ) => {
|
22
|
-
const { select, dispatch } = wp.data;
|
23
|
-
const isCurrentlyUnified =
|
24
|
-
select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' );
|
25
|
-
if ( isCurrentlyUnified !== _isUnifiedToolbar ) {
|
26
|
-
dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' );
|
27
|
-
}
|
28
|
-
}, isUnifiedToolbar );
|
29
17
|
} );
|
30
18
|
|
31
|
-
|
32
|
-
// Assumes new post focus starts in title. Create first new
|
33
|
-
// block by Enter.
|
34
|
-
await page.keyboard.press( 'Enter' );
|
35
|
-
|
36
|
-
// [TEMPORARY]: A new paragraph is not technically a block yet
|
37
|
-
// until starting to type within it.
|
38
|
-
await page.keyboard.type( 'Example' );
|
39
|
-
|
40
|
-
// Upward.
|
41
|
-
await pressKeyWithModifier( 'alt', 'F10' );
|
42
|
-
expect( await isInBlockToolbar() ).toBe( true );
|
43
|
-
} );
|
44
|
-
|
45
|
-
if ( ! isUnifiedToolbar ) {
|
19
|
+
describe( 'Contextual Toolbar', () => {
|
46
20
|
it( 'should not scroll page', async () => {
|
47
21
|
while (
|
48
22
|
await page.evaluate( () => {
|
@@ -74,5 +48,57 @@ describe.each( [
|
|
74
48
|
|
75
49
|
expect( scrollTopBefore ).toBe( scrollTopAfter );
|
76
50
|
} );
|
77
|
-
|
51
|
+
|
52
|
+
it( 'navigates into the toolbar by keyboard (Alt+F10)', async () => {
|
53
|
+
// Assumes new post focus starts in title. Create first new
|
54
|
+
// block by Enter.
|
55
|
+
await page.keyboard.press( 'Enter' );
|
56
|
+
|
57
|
+
// [TEMPORARY]: A new paragraph is not technically a block yet
|
58
|
+
// until starting to type within it.
|
59
|
+
await page.keyboard.type( 'Example' );
|
60
|
+
|
61
|
+
// Upward.
|
62
|
+
await pressKeyWithModifier( 'alt', 'F10' );
|
63
|
+
|
64
|
+
expect( await isInBlockToolbar() ).toBe( true );
|
65
|
+
} );
|
66
|
+
} );
|
67
|
+
|
68
|
+
describe( 'Unified Toolbar', () => {
|
69
|
+
beforeEach( async () => {
|
70
|
+
// Enable unified toolbar
|
71
|
+
await page.evaluate( () => {
|
72
|
+
const { select, dispatch } = wp.data;
|
73
|
+
const isCurrentlyUnified =
|
74
|
+
select( 'core/edit-post' ).isFeatureActive(
|
75
|
+
'fixedToolbar'
|
76
|
+
);
|
77
|
+
if ( ! isCurrentlyUnified ) {
|
78
|
+
dispatch( 'core/edit-post' ).toggleFeature(
|
79
|
+
'fixedToolbar'
|
80
|
+
);
|
81
|
+
}
|
82
|
+
} );
|
83
|
+
} );
|
84
|
+
|
85
|
+
it( 'navigates into the toolbar by keyboard (Alt+F10)', async () => {
|
86
|
+
// Assumes new post focus starts in title. Create first new
|
87
|
+
// block by Enter.
|
88
|
+
await page.keyboard.press( 'Enter' );
|
89
|
+
|
90
|
+
// [TEMPORARY]: A new paragraph is not technically a block yet
|
91
|
+
// until starting to type within it.
|
92
|
+
await page.keyboard.type( 'Example' );
|
93
|
+
|
94
|
+
// Upward.
|
95
|
+
await pressKeyWithModifier( 'alt', 'F10' );
|
96
|
+
|
97
|
+
expect(
|
98
|
+
await page.evaluate( () => {
|
99
|
+
return document.activeElement.getAttribute( 'aria-label' );
|
100
|
+
} )
|
101
|
+
).toBe( 'Show document tools' );
|
102
|
+
} );
|
103
|
+
} );
|
78
104
|
} );
|
@@ -1,81 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
createNewPost,
|
7
|
-
deactivatePlugin,
|
8
|
-
publishPost,
|
9
|
-
findSidebarPanelWithTitle,
|
10
|
-
clickBlockAppender,
|
11
|
-
} from '@wordpress/e2e-test-utils';
|
12
|
-
|
13
|
-
const openPageAttributesPanel = async () => {
|
14
|
-
const openButton = await findSidebarPanelWithTitle( 'Page Attributes' );
|
15
|
-
|
16
|
-
// Get the classes from the panel.
|
17
|
-
const buttonClassName = await (
|
18
|
-
await openButton.getProperty( 'className' )
|
19
|
-
).jsonValue();
|
20
|
-
|
21
|
-
// Open the panel if needed.
|
22
|
-
if ( -1 === buttonClassName.indexOf( 'is-opened' ) ) {
|
23
|
-
await openButton.click();
|
24
|
-
}
|
25
|
-
};
|
26
|
-
|
27
|
-
describe( 'Test Custom Post Types', () => {
|
28
|
-
beforeAll( async () => {
|
29
|
-
await activatePlugin( 'gutenberg-test-custom-post-types' );
|
30
|
-
} );
|
31
|
-
|
32
|
-
afterAll( async () => {
|
33
|
-
await deactivatePlugin( 'gutenberg-test-custom-post-types' );
|
34
|
-
} );
|
35
|
-
|
36
|
-
it( 'should be able to create an hierarchical post without title support', async () => {
|
37
|
-
const PARENT_PAGE_INPUT =
|
38
|
-
'.editor-page-attributes__parent input:not([disabled])';
|
39
|
-
const SUGGESTION =
|
40
|
-
'.editor-page-attributes__parent .components-form-token-field__suggestion:first-child';
|
41
|
-
|
42
|
-
// Create a parent post.
|
43
|
-
await createNewPost( { postType: 'hierar-no-title' } );
|
44
|
-
await clickBlockAppender();
|
45
|
-
await page.keyboard.type( 'Parent Post' );
|
46
|
-
await publishPost();
|
47
|
-
// Create a post that is a child of the previously created post.
|
48
|
-
await createNewPost( { postType: 'hierar-no-title' } );
|
49
|
-
await openPageAttributesPanel();
|
50
|
-
await page.waitForSelector( PARENT_PAGE_INPUT );
|
51
|
-
await page.click( PARENT_PAGE_INPUT );
|
52
|
-
await page.waitForSelector( SUGGESTION );
|
53
|
-
const optionToSelect = await page.$( SUGGESTION );
|
54
|
-
const valueToSelect = await page.$eval(
|
55
|
-
SUGGESTION,
|
56
|
-
( element ) => element.textContent
|
57
|
-
);
|
58
|
-
await optionToSelect.click();
|
59
|
-
await clickBlockAppender();
|
60
|
-
await page.keyboard.type( 'Child Post' );
|
61
|
-
await publishPost();
|
62
|
-
// Reload the child post and verify it is still correctly selected as a child post.
|
63
|
-
await page.reload();
|
64
|
-
await page.waitForSelector( PARENT_PAGE_INPUT );
|
65
|
-
// Wait for the list of suggestions to fetch
|
66
|
-
// There should be a better way to do that.
|
67
|
-
await page.waitForFunction(
|
68
|
-
( [ value, inputSelector ] ) =>
|
69
|
-
document.querySelector( inputSelector ).value === value,
|
70
|
-
{},
|
71
|
-
[ valueToSelect, PARENT_PAGE_INPUT ]
|
72
|
-
);
|
73
|
-
} );
|
74
|
-
it( 'should create a cpt with a legacy block in its template without WSOD', async () => {
|
75
|
-
await createNewPost( { postType: 'leg_block_in_tpl' } );
|
76
|
-
await clickBlockAppender();
|
77
|
-
await page.keyboard.type( 'Hello there' );
|
78
|
-
await page.waitForSelector( '[data-type="core/embed"]' );
|
79
|
-
await publishPost();
|
80
|
-
} );
|
81
|
-
} );
|