Skip to content

Commit

Permalink
update folder structure, use WordPress 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rrennick committed Apr 28, 2020
1 parent da494be commit d41fbc7
Show file tree
Hide file tree
Showing 57 changed files with 59 additions and 29 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ tests/cli/vendor
# Unit tests
/tmp
/tests/bin/tmp
/tests/e2e-tests/config/local-*.json
/tests/e2e-tests/config/local.json
/tests/e2e-tests/docker
/tests/e2e-env/docker/wp-cli/initialize.sh
/tests/e2e/config/local-*.json
/tests/e2e/config/local.json
/tests/e2e/docker
/tests/e2e/env/docker/wp-cli/initialize.sh

# Logs
/logs
Expand Down
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ matrix:
php: 7.4
env: WP_VERSION=latest WP_MULTISITE=0
script:
- bash tests/e2e-env/bin/before-script-CI.sh
- bash tests/e2e/env/bin/before-script-CI.sh
- composer require wp-cli/i18n-command
- npm install
- npm run build
- npm explore @woocommerce/e2e-env -- npm run docker:up
- npm explore @woocommerce/e2e-env -- npm run test:e2e
- npm run docker:up
- npm run test:e2e
after_script:
- npm explore @woocommerce/e2e-env -- npm run docker:down
- npm run docker:down
- name: "Unit tests code coverage"
php: 7.4
env: WP_VERSION=latest WP_MULTISITE=0 RUN_CODE_COVERAGE=1
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ services:
wordpress-www:
volumes:
# This path is relative to the first config file
# which is in tests/e2e-env or node_modules/@woocommerce/e2e-env
- "../../:/var/www/html/wp-content/plugins/woocommerce"
# which is in tests/e2e/env or node_modules/@woocommerce/e2e-env
- "../../../:/var/www/html/wp-content/plugins/woocommerce"

wordpress-cli:
volumes:
- "../../:/var/www/html/wp-content/plugins/woocommerce"
- "../../../:/var/www/html/wp-content/plugins/woocommerce"

33 changes: 31 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@babel/preset-env": "7.9.0",
"@babel/register": "7.9.0",
"@jest/test-sequencer": "^25.0.0",
"@woocommerce/e2e-env": "file:tests/e2e-env",
"@woocommerce/e2e-env": "file:tests/e2e/env",
"@wordpress/e2e-test-utils": "4.3.1",
"autoprefixer": "9.7.5",
"babel-eslint": "10.1.0",
Expand Down
1 change: 0 additions & 1 deletion tests/e2e-env/docker/wordpress/Dockerfile

This file was deleted.

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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions tests/e2e-env/README.md → tests/e2e/env/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports = {
};
```

**NOTE:** Your project's Jest config file is expected to found at: `tests/e2e-tests/config/jest.config.js`.
**NOTE:** Your project's Jest config file is expected to found at: `tests/e2e/config/jest.config.js`.

### Webpack Config

Expand All @@ -109,14 +109,14 @@ module.exports = {
The E2E environment will look for a `docker-compose.yaml` file in your project root. This will be combined with the base Docker config in the package. This is where you'll map your local project files into the Docker container(s).

```yaml
version: '3.3'
version: '3.7'

services:

wordpress-www:
volumes:
# This path is relative to the first config file
# which is in node_modules/@woocommerce/e2e-env
# which is in node_modules/@woocommerce/e2e/env
- "../../../:/var/www/html/wp-content/plugins/your-project-here"

wordpress-cli:
Expand All @@ -126,7 +126,7 @@ services:
#### Docker Container Initialization Script
You can provide an initialization script that will run in the WP-CLI Docker container. Place an executable file at `tests/e2e-tests/docker/initialize.sh` in your project and it will be copied into the container and executed. While you can run any commands you wish, the intent here is to use WP-CLI to set up your testing environment. E.g.:
You can provide an initialization script that will run in the WP-CLI Docker container. Place an executable file at `tests/e2e/docker/initialize.sh` in your project and it will be copied into the container and executed. While you can run any commands you wish, the intent here is to use WP-CLI to set up your testing environment. E.g.:

```
#!/bin/bash
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if ( appPath ) {

if ( 'up' === command ) {
// Look for an initialization script in the dependent app.
const appInitFile = path.resolve( appPath, 'tests/e2e-tests/docker/initialize.sh' );
const appInitFile = path.resolve( appPath, 'tests/e2e/docker/initialize.sh' );

// If found, copy it into the wp-cli Docker context so
// it gets picked up by the entrypoint script.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const nodeConfigDirs = [

if ( appPath ) {
nodeConfigDirs.unshift(
path.resolve( appPath, 'tests/e2e-tests/config' )
path.resolve( appPath, 'tests/e2e/config' )
);
}

Expand Down Expand Up @@ -55,7 +55,7 @@ let configPath = path.resolve( __dirname, '../config/jest.config.js' );

// Look for a Jest config in the dependent app's path.
if ( appPath ) {
const appConfig = path.resolve( appPath, 'tests/e2e-tests/config/jest.config.js' );
const appConfig = path.resolve( appPath, 'tests/e2e/config/jest.config.js' );

if ( fs.existsSync( appConfig ) ) {
configPath = appConfig;
Expand Down
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
Expand Up @@ -7,7 +7,7 @@ module.exports = {

moduleNameMapper: {
'@woocommerce/e2e-tests/(.*)':
'<rootDir>/node_modules/woocommerce/tests/e2e-tests/$1',
'<rootDir>/node_modules/woocommerce/tests/e2e/$1',
},

preset: 'jest-puppeteer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let jestTimeoutInMilliSeconds = 30000;
// Use `await jestPuppeteer.debug()` in test code to pause execution.
if (
process.env.JEST_PUPPETEER_CONFIG ===
'tests/e2e-tests/config/jest-puppeteer.dev.config.js'
'tests/e2e/config/jest-puppeteer.dev.config.js'
) {
jestTimeoutInMilliSeconds = 120000;
}
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions tests/e2e/env/docker/wordpress/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM wordpress:5.4
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
Expand Up @@ -2,15 +2,15 @@ const path = require( 'path' );

const getAppRoot = () => {
// Figure out where we're installed.
// Typically will be in node_modules/, but WooCommerce Admin
// uses a local file path (packages/e2e-env).
// Typically will be in node_modules/, but WooCommerce
// uses a local file path (tests/e2e/env).
let appPath = false;
const moduleDir = path.dirname( require.resolve( '@woocommerce/e2e-env' ) );

if ( -1 < moduleDir.indexOf( 'node_modules' ) ) {
appPath = moduleDir.split( 'node_modules' )[ 0 ];
} else if ( -1 < moduleDir.indexOf( 'tests/e2e-env' ) ) {
appPath = moduleDir.split( 'tests/e2e-env' )[ 0 ];
} else if ( -1 < moduleDir.indexOf( 'tests/e2e/env' ) ) {
appPath = moduleDir.split( 'tests/e2e/env' )[ 0 ];
}

return appPath;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ const path = require( 'path' );
module.exports = {
'@woocommerce/e2e-tests': path.resolve(
__dirname,
'node_modules/woocommerce/tests/e2e-tests'
'node_modules/woocommerce/tests/e2e'
),
};
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d41fbc7

Please sign in to comment.