@wordpress/e2e-tests 2.5.0 → 2.5.1
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 +2 -2
- package/config/flaky-tests-reporter.js +94 -0
- package/config/setup-test-framework.js +7 -0
- package/jest.config.js +11 -1
- package/package.json +6 -5
- package/plugins/iframed-block/block.json +16 -0
- package/plugins/iframed-block/editor.css +6 -0
- package/plugins/iframed-block/editor.js +18 -0
- package/plugins/iframed-block/jquery.test.js +7 -0
- package/plugins/iframed-block/script.js +7 -0
- package/plugins/iframed-block/style.css +9 -0
- package/plugins/iframed-block.php +46 -0
- package/specs/editor/plugins/__snapshots__/iframed-block.test.js.snap +7 -0
- package/specs/editor/plugins/align-hook.test.js +116 -105
- package/specs/editor/plugins/iframed-block.test.js +58 -0
- package/specs/editor/various/__snapshots__/copy-cut-paste-whole-blocks.test.js.snap +28 -0
- package/specs/editor/various/__snapshots__/rich-text.test.js.snap +15 -3
- package/specs/editor/various/block-grouping.test.js +2 -2
- package/specs/editor/various/copy-cut-paste-whole-blocks.test.js +92 -0
- package/specs/editor/various/embedding.test.js +1 -1
- package/specs/editor/various/inserting-blocks.test.js +23 -0
- package/specs/editor/various/rich-text.test.js +29 -1
- package/specs/editor/various/writing-flow.test.js +4 -2
- package/specs/experiments/__snapshots__/navigation-editor.test.js.snap +27 -33
- package/specs/experiments/blocks/__snapshots__/navigation.test.js.snap +29 -19
- package/specs/experiments/blocks/navigation.test.js +93 -17
- package/specs/experiments/fixtures/menu-items-request-fixture.json +84 -0
- package/specs/experiments/navigation-editor.test.js +332 -233
- package/specs/experiments/template-revert.test.js +1 -1
- package/specs/performance/site-editor.test.js +2 -17
- package/specs/widgets/customizing-widgets.test.js +94 -1
- package/specs/widgets/editing-widgets.test.js +6 -0
package/README.md
CHANGED
@@ -54,10 +54,10 @@ Debugging in a Chrome browser can be replaced with `vscode`'s debugger by adding
|
|
54
54
|
"type": "node",
|
55
55
|
"request": "launch",
|
56
56
|
"name": "Debug current e2e test",
|
57
|
-
"program": "${
|
57
|
+
"program": "${workspaceFolder}/node_modules/@wordpress/scripts/bin/wp-scripts.js",
|
58
58
|
"args": [
|
59
59
|
"test-e2e",
|
60
|
-
"--config=${
|
60
|
+
"--config=${workspaceFolder}/packages/e2e-tests/jest.config.js",
|
61
61
|
"--verbose=true",
|
62
62
|
"--runInBand",
|
63
63
|
"--watch",
|
@@ -0,0 +1,94 @@
|
|
1
|
+
/**
|
2
|
+
* A **flaky** test is defined as a test which passed after auto-retrying.
|
3
|
+
* - By default, all tests run once if they pass.
|
4
|
+
* - If a test fails, it will automatically re-run at most 2 times.
|
5
|
+
* - If it pass after retrying (below 2 times), then it's marked as **flaky**
|
6
|
+
* but displayed as **passed** in the original test suite.
|
7
|
+
* - If it fail all 3 times, then it's a **failed** test.
|
8
|
+
*/
|
9
|
+
/**
|
10
|
+
* External dependencies
|
11
|
+
*/
|
12
|
+
const fs = require( 'fs' ).promises;
|
13
|
+
const path = require( 'path' );
|
14
|
+
const { formatResultsErrors } = require( 'jest-message-util' );
|
15
|
+
|
16
|
+
class FlakyTestsReporter {
|
17
|
+
constructor( globalConfig, options ) {
|
18
|
+
this._globalConfig = globalConfig;
|
19
|
+
this._options = options;
|
20
|
+
|
21
|
+
this.failingTestCaseResults = new Map();
|
22
|
+
}
|
23
|
+
|
24
|
+
async onRunStart() {
|
25
|
+
try {
|
26
|
+
fs.mkdir( 'flaky-tests' );
|
27
|
+
} catch ( err ) {
|
28
|
+
// Ignore the error if the directory already exists.
|
29
|
+
if ( err.code !== 'EEXIST' ) {
|
30
|
+
throw err;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
async onTestCaseResult( test, testCaseResult ) {
|
36
|
+
const testPath = path.relative( this._globalConfig.rootDir, test.path );
|
37
|
+
const testTitle = testCaseResult.title;
|
38
|
+
|
39
|
+
switch ( testCaseResult.status ) {
|
40
|
+
case 'failed': {
|
41
|
+
if ( ! this.failingTestCaseResults.has( testTitle ) ) {
|
42
|
+
this.failingTestCaseResults.set( testTitle, [] );
|
43
|
+
}
|
44
|
+
this.failingTestCaseResults
|
45
|
+
.get( testTitle )
|
46
|
+
.push( testCaseResult );
|
47
|
+
break;
|
48
|
+
}
|
49
|
+
case 'passed': {
|
50
|
+
if ( this.failingTestCaseResults.has( testTitle ) ) {
|
51
|
+
const failingResults = this.failingTestCaseResults.get(
|
52
|
+
testTitle
|
53
|
+
);
|
54
|
+
|
55
|
+
await fs.writeFile(
|
56
|
+
`flaky-tests/${ testTitle }.json`,
|
57
|
+
JSON.stringify( {
|
58
|
+
title: testTitle,
|
59
|
+
path: testPath,
|
60
|
+
results: failingResults,
|
61
|
+
} ),
|
62
|
+
'utf-8'
|
63
|
+
);
|
64
|
+
|
65
|
+
// Don't silence flaky error messages for debugging reason.
|
66
|
+
// eslint-disable-next-line no-console
|
67
|
+
console.error(
|
68
|
+
`Test passed after ${ failingResults.length } failed ${
|
69
|
+
failingResults.length === 1 ? 'attempt' : 'attempts'
|
70
|
+
}:`
|
71
|
+
);
|
72
|
+
// eslint-disable-next-line no-console
|
73
|
+
console.error(
|
74
|
+
formatResultsErrors(
|
75
|
+
failingResults,
|
76
|
+
this._globalConfig,
|
77
|
+
{},
|
78
|
+
test.path
|
79
|
+
)
|
80
|
+
);
|
81
|
+
}
|
82
|
+
break;
|
83
|
+
}
|
84
|
+
default:
|
85
|
+
break;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
onRunComplete() {
|
90
|
+
this.failingTestCaseResults.clear();
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
module.exports = FlakyTestsReporter;
|
@@ -68,6 +68,13 @@ const pageEvents = [];
|
|
68
68
|
// The Jest timeout is increased because these tests are a bit slow
|
69
69
|
jest.setTimeout( PUPPETEER_TIMEOUT || 100000 );
|
70
70
|
|
71
|
+
// Retry failed tests at most 2 times in CI.
|
72
|
+
// This enables `flaky-tests-reporter` and `report-flaky-tests` GitHub action
|
73
|
+
// to mark test as flaky and automatically create a tracking issue about it.
|
74
|
+
if ( process.env.CI ) {
|
75
|
+
jest.retryTimes( 2 );
|
76
|
+
}
|
77
|
+
|
71
78
|
async function setupBrowser() {
|
72
79
|
await clearLocalStorage();
|
73
80
|
await setBrowserViewport( 'large' );
|
package/jest.config.js
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
+
/**
|
2
|
+
* WordPress dependencies
|
3
|
+
*/
|
4
|
+
const baseConfig = require( '@wordpress/scripts/config/jest-e2e.config' );
|
5
|
+
|
1
6
|
module.exports = {
|
2
|
-
...
|
7
|
+
...baseConfig,
|
3
8
|
setupFiles: [ '<rootDir>/config/gutenberg-phase.js' ],
|
4
9
|
setupFilesAfterEnv: [
|
5
10
|
'<rootDir>/config/setup-test-framework.js',
|
@@ -12,4 +17,9 @@ module.exports = {
|
|
12
17
|
'/node_modules/',
|
13
18
|
'e2e-tests/specs/performance/',
|
14
19
|
],
|
20
|
+
reporters: [
|
21
|
+
...baseConfig.reporters,
|
22
|
+
// Report flaky tests results into artifacts for used in `report-flaky-tests` action.
|
23
|
+
process.env.CI && '<rootDir>/config/flaky-tests-reporter.js',
|
24
|
+
].filter( Boolean ),
|
15
25
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/e2e-tests",
|
3
|
-
"version": "2.5.
|
3
|
+
"version": "2.5.1",
|
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,13 +23,14 @@
|
|
23
23
|
"node": ">=12"
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
|
-
"@wordpress/e2e-test-utils": "^5.4.
|
26
|
+
"@wordpress/e2e-test-utils": "^5.4.4",
|
27
27
|
"@wordpress/jest-console": "^4.1.0",
|
28
28
|
"@wordpress/jest-puppeteer-axe": "^3.1.0",
|
29
|
-
"@wordpress/scripts": "^18.0
|
30
|
-
"@wordpress/url": "^3.2.
|
29
|
+
"@wordpress/scripts": "^18.1.0",
|
30
|
+
"@wordpress/url": "^3.2.3",
|
31
31
|
"chalk": "^4.0.0",
|
32
32
|
"expect-puppeteer": "^4.4.0",
|
33
|
+
"jest-message-util": "^27.0.6",
|
33
34
|
"lodash": "^4.17.21",
|
34
35
|
"puppeteer-testing-library": "^0.5.0",
|
35
36
|
"uuid": "^8.3.0"
|
@@ -42,5 +43,5 @@
|
|
42
43
|
"publishConfig": {
|
43
44
|
"access": "public"
|
44
45
|
},
|
45
|
-
"gitHead": "
|
46
|
+
"gitHead": "8f7f052bc04e3f4eb50f479ced14be1489b9fa79"
|
46
47
|
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"apiVersion": 2,
|
3
|
+
"name": "test/iframed-block",
|
4
|
+
"title": "Iframed Block",
|
5
|
+
"category": "text",
|
6
|
+
"icon": "smiley",
|
7
|
+
"description": "",
|
8
|
+
"supports": {
|
9
|
+
"html": false
|
10
|
+
},
|
11
|
+
"textdomain": "iframed-block",
|
12
|
+
"editorScript": "iframed-block-editor",
|
13
|
+
"editorStyle": "file:./editor.css",
|
14
|
+
"style": "file:./style.css",
|
15
|
+
"script": "iframed-block-script"
|
16
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
( ( { wp: { element, blocks, blockEditor, compose }, jQuery: $ } ) => {
|
2
|
+
const { createElement: el } = element;
|
3
|
+
const { registerBlockType } = blocks;
|
4
|
+
const { useBlockProps } = blockEditor;
|
5
|
+
const { useRefEffect } = compose;
|
6
|
+
|
7
|
+
registerBlockType( 'test/iframed-block', {
|
8
|
+
edit: function Edit() {
|
9
|
+
const ref = useRefEffect( ( node ) => {
|
10
|
+
$( node ).test();
|
11
|
+
}, [] );
|
12
|
+
return el( 'p', useBlockProps( { ref } ), 'Iframed Block (edit)' );
|
13
|
+
},
|
14
|
+
save: function Save() {
|
15
|
+
return el( 'p', useBlockProps.save(), 'Iframed Block (saved)' );
|
16
|
+
},
|
17
|
+
} );
|
18
|
+
} )( window );
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* Plugin Name: Gutenberg Test Iframed Block
|
4
|
+
* Plugin URI: https://github.com/WordPress/gutenberg
|
5
|
+
* Author: Gutenberg Team
|
6
|
+
*
|
7
|
+
* @package gutenberg-test-iframed-block
|
8
|
+
*/
|
9
|
+
|
10
|
+
add_action(
|
11
|
+
'setup_theme',
|
12
|
+
function() {
|
13
|
+
add_theme_support( 'block-templates' );
|
14
|
+
}
|
15
|
+
);
|
16
|
+
|
17
|
+
add_action(
|
18
|
+
'init',
|
19
|
+
function() {
|
20
|
+
wp_register_script(
|
21
|
+
'iframed-block-jquery-test',
|
22
|
+
plugin_dir_url( __FILE__ ) . 'iframed-block/jquery.test.js',
|
23
|
+
array( 'jquery' ),
|
24
|
+
filemtime( plugin_dir_path( __FILE__ ) . 'iframed-block/jquery.test.js' )
|
25
|
+
);
|
26
|
+
wp_register_script(
|
27
|
+
'iframed-block-editor',
|
28
|
+
plugin_dir_url( __FILE__ ) . 'iframed-block/editor.js',
|
29
|
+
array(
|
30
|
+
'wp-blocks',
|
31
|
+
'wp-block-editor',
|
32
|
+
'wp-element',
|
33
|
+
'wp-compose',
|
34
|
+
'iframed-block-jquery-test',
|
35
|
+
),
|
36
|
+
filemtime( plugin_dir_path( __FILE__ ) . 'iframed-block/editor.js' )
|
37
|
+
);
|
38
|
+
wp_register_script(
|
39
|
+
'iframed-block-script',
|
40
|
+
plugin_dir_url( __FILE__ ) . 'iframed-block/script.js',
|
41
|
+
array( 'iframed-block-jquery-test' ),
|
42
|
+
filemtime( plugin_dir_path( __FILE__ ) . 'iframed-block/script.js' )
|
43
|
+
);
|
44
|
+
register_block_type_from_metadata( __DIR__ . '/iframed-block' );
|
45
|
+
}
|
46
|
+
);
|
@@ -0,0 +1,7 @@
|
|
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
|
+
`;
|
@@ -14,6 +14,7 @@ import {
|
|
14
14
|
} from '@wordpress/e2e-test-utils';
|
15
15
|
|
16
16
|
const alignLabels = {
|
17
|
+
none: 'None',
|
17
18
|
left: 'Align left',
|
18
19
|
center: 'Align center',
|
19
20
|
right: 'Align right',
|
@@ -21,114 +22,129 @@ const alignLabels = {
|
|
21
22
|
full: 'Full width',
|
22
23
|
};
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
/**
|
26
|
+
* Helper function to get the `labels` of align control. It actually evaluates the
|
27
|
+
* basic label of the button without the `info` text node if exists.
|
28
|
+
*
|
29
|
+
* @param {Object} options Options for the util function
|
30
|
+
* @param {boolean} [options.getActiveButtonLabels=false] Flag for returning the active buttons labels only.
|
31
|
+
* @return {string[]} The matched labels.
|
32
|
+
*/
|
33
|
+
const getAlignmentToolbarLabels = async ( {
|
34
|
+
getActiveButtonLabels = false,
|
35
|
+
} = {} ) => {
|
36
|
+
const selector = `.components-dropdown-menu__menu button${
|
37
|
+
getActiveButtonLabels ? '.is-active' : ''
|
38
|
+
} .components-menu-item__item`;
|
39
|
+
return page.evaluate( ( _selector ) => {
|
40
|
+
return (
|
41
|
+
Array.from( document.querySelectorAll( _selector ) )
|
42
|
+
/**
|
43
|
+
* We neede this for now because conditionally there could be two nodes
|
44
|
+
* with the same class(). This should be removed when the following
|
45
|
+
* issue is resolved.
|
46
|
+
*
|
47
|
+
* @see https://github.com/WordPress/gutenberg/issues/34838
|
48
|
+
*/
|
49
|
+
.filter( ( contentNode ) => ! contentNode.childElementCount )
|
50
|
+
.map( ( contentNode ) => {
|
51
|
+
return contentNode.innerText;
|
52
|
+
} )
|
53
|
+
);
|
54
|
+
}, selector );
|
55
|
+
};
|
56
|
+
|
57
|
+
const expectActiveButtonLabelToBe = async ( expected ) => {
|
58
|
+
await clickBlockToolbarButton( 'Align' );
|
59
|
+
const activeButtonLabels = await getAlignmentToolbarLabels( {
|
60
|
+
getActiveButtonLabels: true,
|
27
61
|
} );
|
62
|
+
expect( activeButtonLabels ).toHaveLength( 1 );
|
63
|
+
expect( activeButtonLabels[ 0 ] ).toEqual( expected );
|
64
|
+
};
|
28
65
|
|
29
|
-
|
30
|
-
|
66
|
+
const createShowsTheExpectedButtonsTest = ( blockName, buttonLabels ) => {
|
67
|
+
it( 'Shows the expected buttons on the alignment toolbar', async () => {
|
68
|
+
await insertBlock( blockName );
|
69
|
+
await clickBlockToolbarButton( 'Align' );
|
70
|
+
expect( await getAlignmentToolbarLabels() ).toEqual(
|
71
|
+
expect.arrayContaining( buttonLabels )
|
72
|
+
);
|
31
73
|
} );
|
74
|
+
};
|
32
75
|
|
33
|
-
|
34
|
-
|
76
|
+
const createAppliesNoneAlignmentByDefaultTest = ( blockName ) => {
|
77
|
+
it( 'applies none alignment by default', async () => {
|
78
|
+
await insertBlock( blockName );
|
79
|
+
await expectActiveButtonLabelToBe( alignLabels.none );
|
35
80
|
} );
|
81
|
+
};
|
82
|
+
|
83
|
+
const verifyMarkupIsValid = async ( htmlMarkup ) => {
|
84
|
+
await setPostContent( htmlMarkup );
|
85
|
+
const blocks = await getAllBlocks();
|
86
|
+
expect( blocks ).toHaveLength( 1 );
|
87
|
+
expect( blocks[ 0 ].isValid ).toBeTruthy();
|
88
|
+
};
|
89
|
+
|
90
|
+
const createCorrectlyAppliesAndRemovesAlignmentTest = (
|
91
|
+
blockName,
|
92
|
+
alignment
|
93
|
+
) => {
|
94
|
+
it( 'Correctly applies the selected alignment and correctly removes the alignment', async () => {
|
95
|
+
const BUTTON_XPATH = `//button[contains(@class,'components-dropdown-menu__menu-item')]//span[contains(text(), '${ alignLabels[ alignment ] }')]`;
|
36
96
|
|
37
|
-
|
97
|
+
// set the specified alignment.
|
98
|
+
await insertBlock( blockName );
|
38
99
|
await clickBlockToolbarButton( 'Align' );
|
39
|
-
|
40
|
-
return Array.from(
|
41
|
-
document.querySelectorAll(
|
42
|
-
'.components-dropdown-menu__menu button'
|
43
|
-
)
|
44
|
-
).map( ( button ) => {
|
45
|
-
return button.innerText;
|
46
|
-
} );
|
47
|
-
} );
|
48
|
-
return buttonLabels;
|
49
|
-
};
|
100
|
+
await ( await page.$x( BUTTON_XPATH ) )[ 0 ].click();
|
50
101
|
|
51
|
-
|
52
|
-
|
53
|
-
await insertBlock( blockName );
|
54
|
-
expect( await getAlignmentToolbarLabels() ).toEqual( buttonLabels );
|
55
|
-
} );
|
56
|
-
};
|
102
|
+
// verify the button of the specified alignment is pressed.
|
103
|
+
await expectActiveButtonLabelToBe( alignLabels[ alignment ] );
|
57
104
|
|
58
|
-
|
59
|
-
it( 'Does not apply any alignment by default', async () => {
|
60
|
-
await insertBlock( blockName );
|
61
|
-
await clickBlockToolbarButton( 'Align' );
|
62
|
-
const pressedButtons = await page.$$(
|
63
|
-
'.components-dropdown-menu__menu button.is-active'
|
64
|
-
);
|
65
|
-
expect( pressedButtons ).toHaveLength( 0 );
|
66
|
-
} );
|
67
|
-
};
|
68
|
-
|
69
|
-
const verifyMarkupIsValid = async ( htmlMarkup ) => {
|
70
|
-
await setPostContent( htmlMarkup );
|
71
|
-
const blocks = await getAllBlocks();
|
72
|
-
expect( blocks ).toHaveLength( 1 );
|
73
|
-
expect( blocks[ 0 ].isValid ).toBeTruthy();
|
74
|
-
};
|
75
|
-
|
76
|
-
const createCorrectlyAppliesAndRemovesAlignmentTest = (
|
77
|
-
blockName,
|
78
|
-
alignment
|
79
|
-
) => {
|
80
|
-
it( 'Correctly applies the selected alignment and correctly removes the alignment', async () => {
|
81
|
-
const BUTTON_XPATH = `//button[contains(@class,'components-dropdown-menu__menu-item') and contains(text(), '${ alignLabels[ alignment ] }')]`;
|
82
|
-
const BUTTON_PRESSED_SELECTOR =
|
83
|
-
'.components-dropdown-menu__menu button.is-active';
|
84
|
-
// set the specified alignment.
|
85
|
-
await insertBlock( blockName );
|
86
|
-
await clickBlockToolbarButton( 'Align' );
|
87
|
-
await ( await page.$x( BUTTON_XPATH ) )[ 0 ].click();
|
105
|
+
let htmlMarkup = await getEditedPostContent();
|
88
106
|
|
89
|
-
|
90
|
-
|
91
|
-
let pressedButtons = await page.$$( BUTTON_PRESSED_SELECTOR );
|
92
|
-
expect( pressedButtons ).toHaveLength( 1 );
|
107
|
+
// verify the markup of the selected alignment was generated.
|
108
|
+
expect( htmlMarkup ).toMatchSnapshot();
|
93
109
|
|
94
|
-
|
110
|
+
// verify the markup can be correctly parsed
|
111
|
+
await verifyMarkupIsValid( htmlMarkup );
|
95
112
|
|
96
|
-
|
97
|
-
expect( htmlMarkup ).toMatchSnapshot();
|
113
|
+
await selectBlockByClientId( ( await getAllBlocks() )[ 0 ].clientId );
|
98
114
|
|
99
|
-
|
100
|
-
|
115
|
+
// remove the alignment.
|
116
|
+
await clickBlockToolbarButton( 'Align' );
|
117
|
+
await ( await page.$x( BUTTON_XPATH ) )[ 0 ].click();
|
101
118
|
|
102
|
-
|
103
|
-
|
104
|
-
);
|
119
|
+
// verify 'none' alignment button is in pressed state.
|
120
|
+
await expectActiveButtonLabelToBe( alignLabels.none );
|
105
121
|
|
106
|
-
|
107
|
-
|
108
|
-
|
122
|
+
// verify alignment markup was removed from the block.
|
123
|
+
htmlMarkup = await getEditedPostContent();
|
124
|
+
expect( htmlMarkup ).toMatchSnapshot();
|
109
125
|
|
110
|
-
|
111
|
-
|
112
|
-
pressedButtons = await page.$$( BUTTON_PRESSED_SELECTOR );
|
113
|
-
expect( pressedButtons ).toHaveLength( 0 );
|
126
|
+
// verify the markup when no alignment is set is valid
|
127
|
+
await verifyMarkupIsValid( htmlMarkup );
|
114
128
|
|
115
|
-
|
116
|
-
htmlMarkup = await getEditedPostContent();
|
117
|
-
expect( htmlMarkup ).toMatchSnapshot();
|
129
|
+
await selectBlockByClientId( ( await getAllBlocks() )[ 0 ].clientId );
|
118
130
|
|
119
|
-
|
120
|
-
|
131
|
+
// verify alignment `none` button is in pressed state after parsing the block.
|
132
|
+
await expectActiveButtonLabelToBe( alignLabels.none );
|
133
|
+
} );
|
134
|
+
};
|
121
135
|
|
122
|
-
|
123
|
-
|
124
|
-
|
136
|
+
describe( 'Align Hook Works As Expected', () => {
|
137
|
+
beforeAll( async () => {
|
138
|
+
await activatePlugin( 'gutenberg-test-align-hook' );
|
139
|
+
} );
|
125
140
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
141
|
+
beforeEach( async () => {
|
142
|
+
await createNewPost();
|
143
|
+
} );
|
144
|
+
|
145
|
+
afterAll( async () => {
|
146
|
+
await deactivatePlugin( 'gutenberg-test-align-hook' );
|
147
|
+
} );
|
132
148
|
|
133
149
|
describe( 'Block with no alignment set', () => {
|
134
150
|
const BLOCK_NAME = 'Test No Alignment Set';
|
@@ -151,15 +167,12 @@ describe( 'Align Hook Works As Expected', () => {
|
|
151
167
|
describe( 'Block with align true', () => {
|
152
168
|
const BLOCK_NAME = 'Test Align True';
|
153
169
|
|
154
|
-
createShowsTheExpectedButtonsTest(
|
155
|
-
|
156
|
-
alignLabels
|
157
|
-
|
158
|
-
alignLabels.wide,
|
159
|
-
alignLabels.full,
|
160
|
-
] );
|
170
|
+
createShowsTheExpectedButtonsTest(
|
171
|
+
BLOCK_NAME,
|
172
|
+
Object.values( alignLabels )
|
173
|
+
);
|
161
174
|
|
162
|
-
|
175
|
+
createAppliesNoneAlignmentByDefaultTest( BLOCK_NAME );
|
163
176
|
|
164
177
|
createCorrectlyAppliesAndRemovesAlignmentTest( BLOCK_NAME, 'right' );
|
165
178
|
} );
|
@@ -168,11 +181,12 @@ describe( 'Align Hook Works As Expected', () => {
|
|
168
181
|
const BLOCK_NAME = 'Test Align Array';
|
169
182
|
|
170
183
|
createShowsTheExpectedButtonsTest( BLOCK_NAME, [
|
184
|
+
alignLabels.none,
|
171
185
|
alignLabels.left,
|
172
186
|
alignLabels.center,
|
173
187
|
] );
|
174
188
|
|
175
|
-
|
189
|
+
createAppliesNoneAlignmentByDefaultTest( BLOCK_NAME );
|
176
190
|
|
177
191
|
createCorrectlyAppliesAndRemovesAlignmentTest( BLOCK_NAME, 'center' );
|
178
192
|
} );
|
@@ -180,14 +194,11 @@ describe( 'Align Hook Works As Expected', () => {
|
|
180
194
|
describe( 'Block with default align', () => {
|
181
195
|
const BLOCK_NAME = 'Test Default Align';
|
182
196
|
const SELECTED_ALIGNMENT_CONTROL_SELECTOR =
|
183
|
-
'//div[contains(@class, "components-dropdown-menu__menu")]//button[contains(@class, "is-active")][text()="Align right"]';
|
184
|
-
createShowsTheExpectedButtonsTest(
|
185
|
-
|
186
|
-
alignLabels
|
187
|
-
|
188
|
-
alignLabels.wide,
|
189
|
-
alignLabels.full,
|
190
|
-
] );
|
197
|
+
'//div[contains(@class, "components-dropdown-menu__menu")]//button[contains(@class, "is-active")]/span[text()="Align right"]';
|
198
|
+
createShowsTheExpectedButtonsTest(
|
199
|
+
BLOCK_NAME,
|
200
|
+
Object.values( alignLabels )
|
201
|
+
);
|
191
202
|
|
192
203
|
it( 'Applies the selected alignment by default', async () => {
|
193
204
|
await insertBlock( BLOCK_NAME );
|
@@ -0,0 +1,58 @@
|
|
1
|
+
/**
|
2
|
+
* WordPress dependencies
|
3
|
+
*/
|
4
|
+
import {
|
5
|
+
activatePlugin,
|
6
|
+
createNewPost,
|
7
|
+
deactivatePlugin,
|
8
|
+
insertBlock,
|
9
|
+
getEditedPostContent,
|
10
|
+
openDocumentSettingsSidebar,
|
11
|
+
clickButton,
|
12
|
+
canvas,
|
13
|
+
} from '@wordpress/e2e-test-utils';
|
14
|
+
|
15
|
+
describe( 'changing image size', () => {
|
16
|
+
beforeEach( async () => {
|
17
|
+
await activatePlugin( 'gutenberg-test-iframed-block' );
|
18
|
+
await createNewPost( { postType: 'page' } );
|
19
|
+
} );
|
20
|
+
|
21
|
+
afterEach( async () => {
|
22
|
+
await deactivatePlugin( 'gutenberg-test-iframed-block' );
|
23
|
+
} );
|
24
|
+
|
25
|
+
it( 'should load script and dependencies in iframe', async () => {
|
26
|
+
await insertBlock( 'Iframed Block' );
|
27
|
+
|
28
|
+
expect( await getEditedPostContent() ).toMatchSnapshot();
|
29
|
+
|
30
|
+
const element = await page.waitForSelector(
|
31
|
+
'.wp-block-test-iframed-block'
|
32
|
+
);
|
33
|
+
const text = await element.evaluate( ( el ) => el.textContent );
|
34
|
+
|
35
|
+
expect( text ).toBe( 'Iframed Block (set with jQuery)' );
|
36
|
+
|
37
|
+
await openDocumentSettingsSidebar();
|
38
|
+
await clickButton( 'Page' );
|
39
|
+
await clickButton( 'Template' );
|
40
|
+
await clickButton( 'New' );
|
41
|
+
await page.keyboard.press( 'Tab' );
|
42
|
+
await page.keyboard.press( 'Tab' );
|
43
|
+
await page.keyboard.type( 'Iframed Test' );
|
44
|
+
await clickButton( 'Create' );
|
45
|
+
await page.waitForSelector( 'iframe[name="editor-canvas"]' );
|
46
|
+
|
47
|
+
const iframeElement = await canvas().waitForSelector(
|
48
|
+
'.wp-block-test-iframed-block'
|
49
|
+
);
|
50
|
+
const iframedText = await iframeElement.evaluate(
|
51
|
+
( el ) => el.textContent
|
52
|
+
);
|
53
|
+
|
54
|
+
// Expect the script to load in the iframe, which replaces the block
|
55
|
+
// text.
|
56
|
+
expect( iframedText ).toBe( 'Iframed Block (set with jQuery)' );
|
57
|
+
} );
|
58
|
+
} );
|