Skip to content

Commit b786aad

Browse files
authored
Tests: Extract e2e test utils to their own package (WordPress#13228)
* Tests: Move e2e tests dependent on plugins to their own folder * Tests: Extract e2e test utils to their own package
1 parent feb8bfc commit b786aad

File tree

192 files changed

+241
-168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+241
-168
lines changed

.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
build
22
build-module
33
node_modules
4-
packages/tests-e2e/plugins
4+
packages/e2e-tests/plugins
55
vendor
66
packages/block-serialization-spec-parser/parser.js

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ module.exports = {
182182
},
183183
overrides: [
184184
{
185-
files: [ 'packages/tests-e2e/**/*.js' ],
185+
files: [ 'packages/e2e-test*/**/*.js' ],
186186
env: {
187187
browser: true,
188188
},

.travis.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,29 +67,29 @@ jobs:
6767
install:
6868
- ./bin/setup-local-env.sh
6969
script:
70-
- $( npm bin )/wp-scripts test-e2e --testPathPattern=/packages/tests-e2e/specs/ --listTests > ~/.jest-e2e-tests
70+
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests
7171
- npm run test-e2e -- --ci --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests )
7272

7373
- name: E2E tests (Admin with plugins) (2/2)
7474
env: WP_VERSION=latest POPULAR_PLUGINS=true
7575
install:
7676
- ./bin/setup-local-env.sh
7777
script:
78-
- $( npm bin )/wp-scripts test-e2e --testPathPattern=/packages/tests-e2e/specs/ --listTests > ~/.jest-e2e-tests
78+
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests
7979
- npm run test-e2e -- --ci --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests )
8080

8181
- name: E2E tests (Author without plugins) (1/2)
8282
env: WP_VERSION=latest E2E_ROLE=author
8383
install:
8484
- ./bin/setup-local-env.sh
8585
script:
86-
- $( npm bin )/wp-scripts test-e2e --testPathPattern=/packages/tests-e2e/specs/ --listTests > ~/.jest-e2e-tests
86+
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests
8787
- npm run test-e2e -- --ci --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests )
8888

8989
- name: E2E tests (Author without plugins) (2/2)
9090
env: WP_VERSION=latest E2E_ROLE=author
9191
install:
9292
- ./bin/setup-local-env.sh
9393
script:
94-
- $( npm bin )/wp-scripts test-e2e --testPathPattern=/packages/tests-e2e/specs/ --listTests > ~/.jest-e2e-tests
94+
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests
9595
- npm run test-e2e -- --ci --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests )

docker-compose.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ services:
1212
volumes:
1313
- wordpress:/var/www/html
1414
- .:/var/www/html/wp-content/plugins/gutenberg
15-
- ./packages/tests-e2e/plugins:/var/www/html/wp-content/plugins/gutenberg-test-plugins
16-
- ./packages/tests-e2e/mu-plugins:/var/www/html/wp-content/mu-plugins
15+
- ./packages/e2e-tests/plugins:/var/www/html/wp-content/plugins/gutenberg-test-plugins
16+
- ./packages/e2e-tests/mu-plugins:/var/www/html/wp-content/mu-plugins
1717
depends_on:
1818
- mysql
1919

@@ -59,8 +59,8 @@ services:
5959
volumes:
6060
- wordpress_e2e_tests:/var/www/html
6161
- .:/var/www/html/wp-content/plugins/gutenberg
62-
- ./packages/tests-e2e/plugins:/var/www/html/wp-content/plugins/gutenberg-test-plugins
63-
- ./test/e2e/mu-plugins:/var/www/html/wp-content/mu-plugins
62+
- ./packages/e2e-tests/plugins:/var/www/html/wp-content/plugins/gutenberg-test-plugins
63+
- ./packages/e2e-tests/mu-plugins:/var/www/html/wp-content/mu-plugins
6464

6565
cli_e2e_tests:
6666
image: wordpress:cli

docs/manifest.json

+12-6
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,18 @@
593593
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/dom/README.md",
594594
"parent": "packages"
595595
},
596+
{
597+
"title": "@wordpress/e2e-test-utils",
598+
"slug": "packages-e2e-test-utils",
599+
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/e2e-test-utils/README.md",
600+
"parent": "packages"
601+
},
602+
{
603+
"title": "@wordpress/e2e-tests",
604+
"slug": "packages-e2e-tests",
605+
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/e2e-tests/README.md",
606+
"parent": "packages"
607+
},
596608
{
597609
"title": "@wordpress/edit-post",
598610
"slug": "packages-edit-post",
@@ -737,12 +749,6 @@
737749
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/shortcode/README.md",
738750
"parent": "packages"
739751
},
740-
{
741-
"title": "@wordpress/tests-e2e",
742-
"slug": "packages-tests-e2e",
743-
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/tests-e2e/README.md",
744-
"parent": "packages"
745-
},
746752
{
747753
"title": "@wordpress/token-list",
748754
"slug": "packages-token-list",

jsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"build",
1010
"build-module",
1111
"node_modules",
12-
"packages/tests-e2e/plugins",
12+
"packages/e2e-tests/plugins",
1313
"vendor"
1414
]
1515
}

package-lock.json

+21-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@
6060
"@wordpress/babel-preset-default": "file:packages/babel-preset-default",
6161
"@wordpress/browserslist-config": "file:packages/browserslist-config",
6262
"@wordpress/custom-templated-path-webpack-plugin": "file:packages/custom-templated-path-webpack-plugin",
63+
"@wordpress/e2e-test-utils": "file:packages/e2e-test-utils",
64+
"@wordpress/e2e-tests": "file:packages/e2e-tests",
6365
"@wordpress/eslint-plugin": "file:packages/eslint-plugin",
6466
"@wordpress/jest-console": "file:packages/jest-console",
6567
"@wordpress/jest-preset-default": "file:packages/jest-preset-default",
6668
"@wordpress/library-export-default-webpack-plugin": "file:packages/library-export-default-webpack-plugin",
6769
"@wordpress/npm-package-json-lint-config": "file:packages/npm-package-json-lint-config",
6870
"@wordpress/postcss-themes": "file:packages/postcss-themes",
6971
"@wordpress/scripts": "file:packages/scripts",
70-
"@wordpress/tests-e2e": "file:packages/tests-e2e",
7172
"babel-loader": "8.0.0",
7273
"benchmark": "2.1.4",
7374
"browserslist": "3.2.8",
@@ -176,7 +177,7 @@
176177
"publish:prod": "npm run build:packages && lerna publish",
177178
"test": "npm run lint && npm run test-unit",
178179
"pretest-e2e": "concurrently \"./bin/reset-e2e-tests.sh\" \"npm run build\"",
179-
"test-e2e": "wp-scripts test-e2e --setupTestFrameworkScriptFile=./packages/tests-e2e/support/setup-test-framework.js --testPathPattern=/packages/tests-e2e/specs/",
180+
"test-e2e": "wp-scripts test-e2e --config packages/e2e-tests/jest.config.js",
180181
"test-e2e:watch": "npm run test-e2e -- --watch",
181182
"test-php": "npm run lint-php && npm run test-unit-php",
182183
"test-unit": "wp-scripts test-unit-js --config test/unit/jest.config.json",
File renamed without changes.

packages/e2e-test-utils/CHANGELOG.md

+3

packages/e2e-test-utils/README.md

+13

packages/e2e-test-utils/package.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "@wordpress/e2e-test-utils",
3+
"version": "1.0.0-alpha.0",
4+
"description": "End-To-End (E2E) test utils for WordPress.",
5+
"author": "The WordPress Contributors",
6+
"license": "GPL-2.0-or-later",
7+
"keywords": [
8+
"wordpress",
9+
"e2e",
10+
"utils"
11+
],
12+
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/e2e-test-utils/README.md",
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/WordPress/gutenberg.git"
16+
},
17+
"bugs": {
18+
"url": "https://github.com/WordPress/gutenberg/issues"
19+
},
20+
"files": [
21+
"build",
22+
"build-module"
23+
],
24+
"main": "build/index.js",
25+
"module": "build-module/index.js",
26+
"dependencies": {
27+
"@wordpress/keycodes": "file:../keycodes",
28+
"@wordpress/url": "file:../url",
29+
"lodash": "^4.17.10",
30+
"node-fetch": "^1.7.3"
31+
},
32+
"peerDependencies": {
33+
"jest": ">=23.0.0",
34+
"puppeteer": ">=1.6.0"
35+
},
36+
"publishConfig": {
37+
"access": "public"
38+
}
39+
}
File renamed without changes.

packages/e2e-tests/.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

packages/e2e-tests/CHANGELOG.md

+3

packages/tests-e2e/support/setup-test-framework.js packages/e2e-tests/config/setup-test-framework.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@ import { get } from 'lodash';
88
* WordPress dependencies
99
*/
1010
import '@wordpress/jest-console';
11-
12-
/**
13-
* Internal dependencies
14-
*/
1511
import {
1612
clearLocalStorage,
1713
enablePageDialogAccept,
1814
setBrowserViewport,
1915
visitAdminPage,
20-
} from './utils';
16+
} from '@wordpress/e2e-test-utils';
2117

2218
/**
2319
* Environment variables

packages/e2e-tests/jest.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
...require( '@wordpress/scripts/config/jest-e2e.config' ),
3+
setupTestFrameworkScriptFile: '<rootDir>/config/setup-test-framework.js',
4+
};

packages/tests-e2e/package.json packages/e2e-tests/package.json

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
{
2-
"name": "@wordpress/tests-e2e",
3-
"private": true,
2+
"name": "@wordpress/e2e-tests",
43
"version": "1.0.0-alpha.0",
54
"description": "End-To-End (E2E) tests for WordPress.",
65
"author": "The WordPress Contributors",
76
"license": "GPL-2.0-or-later",
87
"keywords": [
98
"wordpress",
10-
"tests",
11-
"e2e"
9+
"e2e",
10+
"tests"
1211
],
13-
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/tests-e2e/README.md",
12+
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/e2e-tests/README.md",
1413
"repository": {
1514
"type": "git",
1615
"url": "https://github.com/WordPress/gutenberg.git"
@@ -19,12 +18,11 @@
1918
"url": "https://github.com/WordPress/gutenberg/issues"
2019
},
2120
"dependencies": {
21+
"@wordpress/e2e-test-utils": "file:../e2e-test-utils",
2222
"@wordpress/jest-console": "file:../jest-console",
23-
"@wordpress/keycodes": "file:../keycodes",
24-
"@wordpress/url": "file:../url",
23+
"@wordpress/scripts": "file:../scripts",
2524
"expect-puppeteer": "^3.2.0",
26-
"lodash": "^4.17.10",
27-
"node-fetch": "^1.7.3"
25+
"lodash": "^4.17.10"
2826
},
2927
"peerDependencies": {
3028
"jest": ">=23.0.0",

packages/tests-e2e/specs/a11y.test.js packages/e2e-tests/specs/a11y.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
2-
* Internal dependencies
2+
* WordPress dependencies
33
*/
44
import {
55
createNewPost,
66
pressKeyWithModifier,
7-
} from '../support/utils';
7+
} from '@wordpress/e2e-test-utils';
88

99
function isCloseButtonFocused() {
1010
return page.$eval( ':focus', ( focusedElement ) => {

packages/tests-e2e/specs/adding-blocks.test.js packages/e2e-tests/specs/adding-blocks.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
2-
* Internal dependencies
2+
* WordPress dependencies
33
*/
44
import {
55
createNewPost,
66
insertBlock,
77
getEditedPostContent,
88
pressKeyTimes,
9-
} from '../support/utils';
9+
} from '@wordpress/e2e-test-utils';
1010

1111
describe( 'adding blocks', () => {
1212
beforeEach( async () => {

packages/tests-e2e/specs/adding-inline-tokens.test.js packages/e2e-tests/specs/adding-inline-tokens.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import os from 'os';
77
import uuid from 'uuid/v4';
88

99
/**
10-
* Internal dependencies
10+
* WordPress dependencies
1111
*/
1212
import {
1313
clickBlockAppender,
1414
getEditedPostContent,
1515
insertBlock,
1616
createNewPost,
17-
} from '../support/utils';
17+
} from '@wordpress/e2e-test-utils';
1818

1919
describe( 'adding inline tokens', () => {
2020
beforeAll( async () => {

packages/tests-e2e/specs/block-deletion.test.js packages/e2e-tests/specs/block-deletion.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
2-
* Internal dependencies
2+
* WordPress dependencies
33
*/
44
import {
55
clickBlockAppender,
66
getEditedPostContent,
77
createNewPost,
88
pressKeyWithModifier,
9-
} from '../support/utils';
9+
} from '@wordpress/e2e-test-utils';
1010

1111
const addThreeParagraphsToNewPost = async () => {
1212
await createNewPost();

0 commit comments

Comments
 (0)