Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create npm workspace for E2E tests #10119

Merged
merged 36 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
835fd58
Create E2E workspace and make scripts functional without any package …
benbowler Jan 24, 2025
f1eaef0
Update package-lock to npm version 7 format.
benbowler Jan 24, 2025
34a622a
Move E2E to npm workspace.
benbowler Jan 27, 2025
ddf20d9
Update npm version in e2e GitHub action.
benbowler Jan 27, 2025
3894782
Update npm version in e2e GitHub action.
benbowler Jan 27, 2025
60b77c2
Update npm version in JS lint GitHub action.
benbowler Jan 27, 2025
96aac9b
Apply suggestions from code review
benbowler Jan 31, 2025
b756ac7
Include dependencies shared with root package and e2e workspace.
benbowler Jan 31, 2025
846d233
Move local-env scripts to tests/e2e workspace.
benbowler Jan 31, 2025
054adf8
Update package-lock with nppm 7.
benbowler Feb 3, 2025
1a5bff0
Include other required packages in e2e/tests.
benbowler Feb 3, 2025
582f0ec
Fix paths in docker-compose and revert change in start.sh.
benbowler Feb 3, 2025
2912b48
Include npm v7 as dev dependency so developer don't need to install i…
benbowler Feb 3, 2025
4234514
Remove googlesitekit-e2e from deps.
aaemnnosttv Feb 3, 2025
762c366
Move jest-puppeteer config to workspace root.
aaemnnosttv Feb 3, 2025
2d0732d
Remove a few packages from root dev deps.
aaemnnosttv Feb 3, 2025
477444b
Update jest-puppeteer to version matching puppeteer.
aaemnnosttv Feb 3, 2025
f7b4b46
Update GH actions to use dev dependency version of npm.
benbowler Feb 4, 2025
8064c60
Revert shell script change and remove code comment.
benbowler Feb 4, 2025
f3b9a69
Update lint script to install workspace packages to fix unable to res…
benbowler Feb 4, 2025
8bf4eaf
Add npm v7 to workspace dev dependencies.
benbowler Feb 4, 2025
ed28fa2
Update package installation method.
benbowler Feb 4, 2025
7741226
Restore working base setup with global npm config.
benbowler Feb 4, 2025
226a0e1
Update local-env paths.
benbowler Feb 5, 2025
44664d8
Update workspace package.json to include all required packages and re…
benbowler Feb 5, 2025
5510bd8
Fix volume path to correctly load test plugins in Docker images.
benbowler Feb 5, 2025
1e4f326
Remove e2e packages in from the root packages.
benbowler Feb 5, 2025
d1a1de7
Revert to commit building in actions.
benbowler Feb 6, 2025
2d318a0
Revert to commit building in actions.
benbowler Feb 6, 2025
b19e8f8
Remove un-needed root dependency.
benbowler Feb 6, 2025
950e3e5
Remove un-needed root dependency.
benbowler Feb 6, 2025
7a26cb9
Remove un-needed root dependency.
benbowler Feb 6, 2025
5ff1a38
Remove un-needed root dependency.
benbowler Feb 6, 2025
94414d6
Revert "Remove un-needed root dependency."
benbowler Feb 6, 2025
d946f16
Remove un-needed root dependency.
benbowler Feb 6, 2025
b04f70b
Merge remote-tracking branch 'origin/develop' into infrastructure/100…
benbowler Feb 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ jobs:
node-version-file: '.nvmrc'
cache: 'npm'

# nvm@7 is the minimum version required for npm workspace support.
# This is needed to prevent js lint failures due to module resolution to the workspace packages.
# This can be removed once our node base version comes with nvm@7 or greater.
- name: Install npm Globally
run: npm run install-global-npm

- name: npm install
run: npm ci

Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/js-css-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ jobs:
with:
node-version-file: '.nvmrc'
cache: 'npm'

# nvm@7 is the minimum version required for npm workspace support.
# This is needed to prevent js lint failures due to module resolution to the workspace packages.
# This can be removed once our node base version comes with nvm@7 or greater.
- name: Install npm Globally
run: npm run install-global-npm

- name: npm install
run: npm ci
env:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/visual-regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ jobs:
with:
node-version-file: '.nvmrc'
cache: 'npm'

# nvm@7 is the minimum version required for npm workspace support.
# This is needed to prevent js lint failures due to module resolution to the workspace packages.
# This can be removed once our node base version comes with nvm@7 or greater.
- name: Install npm Globally
run: npm run install-global-npm

- name: npm install
run: npm ci
- name: Run Backstopjs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ export default function SetupForm() {

if (
currentClientID === '' &&
global._googlesitekitModulesData?.[ 'sign-in-with-google' ]?.[
'existingClientID'
]
global._googlesitekitModulesData?.[ 'sign-in-with-google' ]
?.existingClientID
eugene-manuilov marked this conversation as resolved.
Show resolved Hide resolved
) {
setExistingClientID(
global._googlesitekitModulesData[ 'sign-in-with-google' ]
Expand Down
170,417 changes: 117,231 additions & 53,186 deletions package-lock.json

Large diffs are not rendered by default.

25 changes: 12 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@
"test:js": "cross-env BABEL_ENV=test NODE_ENV=test jest --config=tests/js/jest.config.js --passWithNoTests",
"test:js:watch": "npm run test:js -- --watch",
"test:storybook": "npm run test:js -- --testMatch '<rootDir>/.storybook/*.test.js'",
"pretest:e2e": "./bin/local-env/env-check.sh && ./tests/e2e/bin/test-docker-connectivity",
eugene-manuilov marked this conversation as resolved.
Show resolved Hide resolved
"test:e2e": "cross-env WP_BASE_URL=http://localhost:9002 ./tests/e2e/script.js",
"test:e2e:interactive": "npm run test:e2e -- --puppeteer-interactive",
"test:e2e:watch": "npm run test:e2e -- --watch",
"test:e2e:watch:interactive": "npm run test:e2e -- --watch --puppeteer-interactive",
"test:e2e": "npm run test:e2e -w ./tests/e2e",
"test:e2e:interactive": "npm run test:e2e:interactive -w ./tests/e2e",
"test:e2e:watch": "npm run test:e2e:watch -w ./tests/e2e",
"test:e2e:watch:interactive": "npm run test:e2e:watch:interactive -w ./tests/e2e",
"storybook": "start-storybook -p 9001 -c .storybook --no-version-updates",
"storybook:vrt": "npm run storybook -- --ci --quiet",
"backstopjs": "./bin/backstop",
Expand All @@ -43,9 +42,10 @@
"lint:js-fix": "prettier --write --config .prettierrc.js --ignore-path .prettierignore \"**/*.{js,jsx,ts,tsx,.yml,.yaml}\"",
"lint:css": "stylelint ./assets/sass ./.storybook/assets/sass",
"lint:css-fix": "stylelint ./assets/sass ./.storybook/assets/sass --fix",
"env:start": "./bin/local-env/start.sh",
"env:stop": "./bin/local-env/stop.sh",
"env:reset-site": "./bin/local-env/install-wordpress.sh --reset-site",
"env:start": "npm run env:start -w ./tests/e2e",
"env:stop": "npm run env:stop -w ./tests/e2e",
"env:reset-site": "npm run env:reset-site -w ./tests/e2e",
"install-global-npm": "npm install -g npm@7.24.2",
"postinstall": "patch-package"
},
"browserslist": [
Expand Down Expand Up @@ -186,9 +186,7 @@
"@testing-library/react-hooks": "^3.3.0",
"@wordpress/babel-preset-default": "^4.17.0",
eugene-manuilov marked this conversation as resolved.
Show resolved Hide resolved
"@wordpress/browserslist-config": "^5.40.0",
"@wordpress/e2e-test-utils": "^4.11.0",
"@wordpress/eslint-plugin": "^7.1.0",
"@wordpress/jest-console": "^3.9.0",
"@wordpress/jest-preset-default": "7.1.1",
"@wordpress/prettier-config": "^2.0",
"@wordpress/stylelint-config": "^21.0.0",
Expand All @@ -214,7 +212,6 @@
"eslint-plugin-sitekit": "file:packages/eslint-plugin",
"eslint-scope": "^5.1.0",
"eslint-webpack-plugin": "^2.5.1",
"expect-puppeteer": "^4.4.0",
"faker": "^5.5.3",
"fetch-mock": "^9.10.3",
"fetch-mock-jest": "^1.3.0",
Expand All @@ -227,7 +224,6 @@
"husky": "^3.1.0",
"jest": "^26.6.3",
"jest-localstorage-mock": "^2.4.2",
"jest-puppeteer": "^4.4.0",
"jsdom": "^16.5.0",
"jsdom-testing-mocks": "^1.6.0",
"lint-staged": "^10.2.11",
Expand Down Expand Up @@ -260,5 +256,8 @@
"webpack-manifest-plugin": "^2.2.0",
"webpack-stream": "^5.2.1",
"webpackbar": "^4.0.0"
}
},
"workspaces": [
"tests/e2e"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ services:
define( 'WP_AUTO_UPDATE_CORE', false );
volumes:
- wordpress_data:/var/www/html
- ../../:/var/www/html/wp-content/plugins/google-site-kit
- ../../tests/e2e/plugins:/var/www/html/wp-content/plugins/google-site-kit-test-plugins
- ../../tests/e2e/mu-plugins:/var/www/html/wp-content/mu-plugins
- ../../../../:/var/www/html/wp-content/plugins/google-site-kit
- ../../plugins:/var/www/html/wp-content/plugins/google-site-kit-test-plugins
- ../../mu-plugins:/var/www/html/wp-content/mu-plugins
depends_on:
- mysql

Expand All @@ -35,8 +35,8 @@ services:
volumes:
- wordpress_data:/var/www/html
- ./wp-cli-php.ini:/usr/local/etc/php/conf.d/wp-cli-php.ini
- ../../:/var/www/html/wp-content/plugins/google-site-kit
- ../../tests/e2e/mu-plugins:/var/www/html/wp-content/mu-plugins
- ../../../../:/var/www/html/wp-content/plugins/google-site-kit
- ../../mu-plugins:/var/www/html/wp-content/mu-plugins
depends_on:
- mysql
- wordpress
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.
32 changes: 32 additions & 0 deletions tests/e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"scripts": {
"pretest:e2e": "./bin/local-env/env-check.sh && ./bin/test-docker-connectivity",
"test:e2e": "cross-env WP_BASE_URL=http://localhost:9002 ./script.js",
"test:e2e:interactive": "npm run test:e2e -- --puppeteer-interactive",
"test:e2e:watch": "npm run test:e2e -- --watch",
"test:e2e:watch:interactive": "npm run test:e2e -- --watch --puppeteer-interactive",
"env:start": "./bin/local-env/start.sh",
"env:stop": "./bin/local-env/stop.sh",
"env:reset-site": "./bin/local-env/install-wordpress.sh --reset-site"
},
"config": {
"puppeteer": {
"skip": {
"download": true
}
}
},
"dependencies": {
"@wordpress/babel-preset-default": "^4.17.0",
"@wordpress/e2e-test-utils": "^4.11.0",
"@wordpress/jest-console": "^3.9.0",
"amphtml-validator": "^1.0.35",
"babel-jest": "^26.6.3",
"dockerode": "^4.0.2",
"expect-puppeteer": "^4.4.0",
"jest": "^26.6.3",
"jest-puppeteer": "^6.0.1",
"jsdom": "^16.5.0",
eugene-manuilov marked this conversation as resolved.
Show resolved Hide resolved
"puppeteer": "^10.4.0"
eugene-manuilov marked this conversation as resolved.
Show resolved Hide resolved
}
eugene-manuilov marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 1 addition & 1 deletion tests/e2e/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ if ( result.status > 0 ) {
process.exit( result.status );
}

const config = [ '--config=tests/e2e/jest.config.js' ];
const config = [ '--config=jest.config.js' ];

const hasRunInBand = hasArgInCLI( '--runInBand' ) || hasArgInCLI( '-i' );
const runInBand = ! hasRunInBand ? [ '--runInBand' ] : [];
Expand Down
Loading