Skip to content

Commit

Permalink
Tests: Extract e2e test utils to their own package
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Jan 15, 2019
1 parent 91ef77b commit deed0e1
Show file tree
Hide file tree
Showing 193 changed files with 241 additions and 171 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build
build-module
node_modules
packages/tests-e2e/plugins
packages/e2e-tests/plugins
vendor
packages/block-serialization-spec-parser/parser.js
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ module.exports = {
},
overrides: [
{
files: [ 'packages/tests-e2e/**/*.js' ],
files: [ 'packages/e2e-test*/**/*.js' ],
env: {
browser: true,
},
Expand Down
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,29 @@ jobs:
install:
- ./bin/setup-local-env.sh
script:
- $( npm bin )/wp-scripts test-e2e --testPathPattern=/packages/tests-e2e/specs/ --listTests > ~/.jest-e2e-tests
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests
- npm run test-e2e -- --ci --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests )

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

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

- name: E2E tests (Author without plugins) (2/2)
env: WP_VERSION=latest E2E_ROLE=author
install:
- ./bin/setup-local-env.sh
script:
- $( npm bin )/wp-scripts test-e2e --testPathPattern=/packages/tests-e2e/specs/ --listTests > ~/.jest-e2e-tests
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests
- npm run test-e2e -- --ci --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests )
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ services:
volumes:
- wordpress:/var/www/html
- .:/var/www/html/wp-content/plugins/gutenberg
- ./packages/tests-e2e/plugins:/var/www/html/wp-content/plugins/gutenberg-test-plugins
- ./packages/tests-e2e/mu-plugins:/var/www/html/wp-content/mu-plugins
- ./packages/e2e-tests/plugins:/var/www/html/wp-content/plugins/gutenberg-test-plugins
- ./packages/e2e-tests/mu-plugins:/var/www/html/wp-content/mu-plugins
depends_on:
- mysql

Expand Down Expand Up @@ -59,8 +59,8 @@ services:
volumes:
- wordpress_e2e_tests:/var/www/html
- .:/var/www/html/wp-content/plugins/gutenberg
- ./packages/tests-e2e/plugins:/var/www/html/wp-content/plugins/gutenberg-test-plugins
- ./test/e2e/mu-plugins:/var/www/html/wp-content/mu-plugins
- ./packages/e2e-tests/plugins:/var/www/html/wp-content/plugins/gutenberg-test-plugins
- ./packages/e2e-tests/mu-plugins:/var/www/html/wp-content/mu-plugins

cli_e2e_tests:
image: wordpress:cli
Expand Down
18 changes: 12 additions & 6 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,18 @@
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/dom/README.md",
"parent": "packages"
},
{
"title": "@wordpress/e2e-test-utils",
"slug": "packages-e2e-test-utils",
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/e2e-test-utils/README.md",
"parent": "packages"
},
{
"title": "@wordpress/e2e-tests",
"slug": "packages-e2e-tests",
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/e2e-tests/README.md",
"parent": "packages"
},
{
"title": "@wordpress/edit-post",
"slug": "packages-edit-post",
Expand Down Expand Up @@ -737,12 +749,6 @@
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/shortcode/README.md",
"parent": "packages"
},
{
"title": "@wordpress/tests-e2e",
"slug": "packages-tests-e2e",
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/tests-e2e/README.md",
"parent": "packages"
},
{
"title": "@wordpress/token-list",
"slug": "packages-token-list",
Expand Down
2 changes: 1 addition & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build",
"build-module",
"node_modules",
"packages/tests-e2e/plugins",
"packages/e2e-tests/plugins",
"vendor"
]
}
33 changes: 21 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@
"@wordpress/babel-preset-default": "file:packages/babel-preset-default",
"@wordpress/browserslist-config": "file:packages/browserslist-config",
"@wordpress/custom-templated-path-webpack-plugin": "file:packages/custom-templated-path-webpack-plugin",
"@wordpress/e2e-test-utils": "file:packages/e2e-test-utils",
"@wordpress/e2e-tests": "file:packages/e2e-tests",
"@wordpress/eslint-plugin": "file:packages/eslint-plugin",
"@wordpress/jest-console": "file:packages/jest-console",
"@wordpress/jest-preset-default": "file:packages/jest-preset-default",
"@wordpress/library-export-default-webpack-plugin": "file:packages/library-export-default-webpack-plugin",
"@wordpress/npm-package-json-lint-config": "file:packages/npm-package-json-lint-config",
"@wordpress/postcss-themes": "file:packages/postcss-themes",
"@wordpress/scripts": "file:packages/scripts",
"@wordpress/tests-e2e": "file:packages/tests-e2e",
"babel-loader": "8.0.0",
"benchmark": "2.1.4",
"browserslist": "3.2.8",
Expand Down Expand Up @@ -176,7 +177,7 @@
"publish:prod": "npm run build:packages && lerna publish",
"test": "npm run lint && npm run test-unit",
"pretest-e2e": "concurrently \"./bin/reset-e2e-tests.sh\" \"npm run build\"",
"test-e2e": "wp-scripts test-e2e --setupTestFrameworkScriptFile=./packages/tests-e2e/support/setup-test-framework.js --testPathPattern=/packages/tests-e2e/specs/",
"test-e2e": "wp-scripts test-e2e --config packages/e2e-tests/jest.config.js",
"test-e2e:watch": "npm run test-e2e -- --watch",
"test-php": "npm run lint-php && npm run test-unit-php",
"test-unit": "wp-scripts test-unit-js --config test/unit/jest.config.json",
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions packages/e2e-test-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0 (Unreleased)

- Initial release.
13 changes: 13 additions & 0 deletions packages/e2e-test-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# E2E Test Utils

End-To-End (E2E) test utils for WordPress.

## Installation

Install the module

```bash
npm install @wordpress/e2e-test-utils --save-dev
```

<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
39 changes: 39 additions & 0 deletions packages/e2e-test-utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "@wordpress/e2e-test-utils",
"version": "1.0.0-alpha.0",
"description": "End-To-End (E2E) test utils for WordPress.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
"keywords": [
"wordpress",
"e2e",
"utils"
],
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/e2e-test-utils/README.md",
"repository": {
"type": "git",
"url": "https://github.com/WordPress/gutenberg.git"
},
"bugs": {
"url": "https://github.com/WordPress/gutenberg/issues"
},
"files": [
"build",
"build-module"
],
"main": "build/index.js",
"module": "build-module/index.js",
"dependencies": {
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/url": "file:../url",
"lodash": "^4.17.10",
"node-fetch": "^1.7.3"
},
"peerDependencies": {
"jest": ">=23.0.0",
"puppeteer": ">=1.6.0"
},
"publishConfig": {
"access": "public"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions packages/e2e-tests/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
3 changes: 3 additions & 0 deletions packages/e2e-tests/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0 (Unreleased)

- Initial release.
4 changes: 2 additions & 2 deletions packages/tests-e2e/README.md → packages/e2e-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tests E2E
# E2E Tests

End-To-End (E2E) tests for WordPress.

Expand All @@ -7,7 +7,7 @@ End-To-End (E2E) tests for WordPress.
Install the module

```bash
npm install @wordpress/tests-e2e --save-dev
npm install @wordpress/e2e-tests --save-dev
```

<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ import { get } from 'lodash';
* WordPress dependencies
*/
import '@wordpress/jest-console';

/**
* Internal dependencies
*/
import {
clearLocalStorage,
enablePageDialogAccept,
setBrowserViewport,
visitAdminPage,
} from './utils';
} from '@wordpress/e2e-test-utils';

/**
* Environment variables
Expand Down
4 changes: 4 additions & 0 deletions packages/e2e-tests/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
...require( '@wordpress/scripts/config/jest-e2e.config' ),
setupTestFrameworkScriptFile: '<rootDir>/config/setup-test-framework.js',
};
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"name": "@wordpress/tests-e2e",
"private": true,
"name": "@wordpress/e2e-tests",
"version": "1.0.0-alpha.0",
"description": "End-To-End (E2E) tests for WordPress.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
"keywords": [
"wordpress",
"tests",
"e2e"
"e2e",
"tests"
],
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/tests-e2e/README.md",
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/e2e-tests/README.md",
"repository": {
"type": "git",
"url": "https://github.com/WordPress/gutenberg.git"
Expand All @@ -19,12 +18,11 @@
"url": "https://github.com/WordPress/gutenberg/issues"
},
"dependencies": {
"@wordpress/e2e-test-utils": "file:../e2e-test-utils",
"@wordpress/jest-console": "file:../jest-console",
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/url": "file:../url",
"@wordpress/scripts": "file:../scripts",
"expect-puppeteer": "^3.2.0",
"lodash": "^4.17.10",
"node-fetch": "^1.7.3"
"lodash": "^4.17.10"
},
"peerDependencies": {
"jest": ">=23.0.0",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* Internal dependencies
* WordPress dependencies
*/
import {
createNewPost,
pressKeyWithModifier,
} from '../support/utils';
} from '@wordpress/e2e-test-utils';

function isCloseButtonFocused() {
return page.$eval( ':focus', ( focusedElement ) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Internal dependencies
* WordPress dependencies
*/
import {
createNewPost,
insertBlock,
getEditedPostContent,
pressKeyTimes,
} from '../support/utils';
} from '@wordpress/e2e-test-utils';

describe( 'adding blocks', () => {
beforeEach( async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import os from 'os';
import uuid from 'uuid/v4';

/**
* Internal dependencies
* WordPress dependencies
*/
import {
clickBlockAppender,
getEditedPostContent,
insertBlock,
createNewPost,
} from '../support/utils';
} from '@wordpress/e2e-test-utils';

describe( 'adding inline tokens', () => {
beforeAll( async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Internal dependencies
* WordPress dependencies
*/
import {
clickBlockAppender,
getEditedPostContent,
createNewPost,
pressKeyWithModifier,
} from '../support/utils';
} from '@wordpress/e2e-test-utils';

const addThreeParagraphsToNewPost = async () => {
await createNewPost();
Expand Down
Loading

0 comments on commit deed0e1

Please sign in to comment.