Skip to content

Commit

Permalink
#30373: adding useful E2E commands to justfile and to E2E documentati…
Browse files Browse the repository at this point in the history
…on (#31010)
  • Loading branch information
victoralfaro-dotcms authored Jan 2, 2025
1 parent 21eadec commit 2558218
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 10 deletions.
56 changes: 47 additions & 9 deletions e2e/dotcms-e2e-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,42 @@ Since we are only interested in the last one as we will probably deprecate the J
./mvnw -pl :dotcms-e2e-node verify -De2e.test.skip=false
```
As every other test in out projects, if it has one or more dependencies, Maven will take care of their lifecycle.
Hence you will see Docker containers for database, Elastic Search, Wiremock and (obviously) dotCMS itself being started up and killed down as the tests run.
Hence, you will see Docker containers for database, ElasticSearch, Wiremock and (obviously) dotCMS itself being started up and killed down as the tests run.

BTW, E2E will against a dotCMS container from the latest locally built image.
BTW, E2E will run against a dotCMS container from the latest locally built image.

To manually kill the E2E dependencies run:
```shell
./mvnw -pl :dotcms-e2e-java verify -De2e.test.skip=false -Pdebug-suspend-e2e-tests
./mvnw -pl :dotcms-e2e-node -Pdocker-stop -De2e.test.skip=false
```

To manually kill the E2E dependencies run:
To run a specific test file or space-delimited directory list you can run:
```shell
./mvnw -pl :dotcms-e2e-java,:dotcms-e2e-node -Pdocker-stop -De2e.test.skip=false
./mvnw -pl :dotcms-e2e-node verify \
-De2e.test.skip=false \
-De2e.test.specific=login.spec.ts
```
Or
```shell
./mvnw -pl :dotcms-e2e-node verify \
-De2e.test.skip=false \
-De2e.test.specific="frontend/tests/login/ frontend/tests/contentSearch/"
```

To debug, using `Playwright` UI mode, a specific test:
```shell
./mvnw -pl :dotcms-e2e-node verify \
-De2e.test.skip=false \
-De2e.test.debug="--ui" \
-De2e.test.specific=login.spec.ts
```

To debug, using `Playwright` debug inspector, a specific test:
```shell
./mvnw -pl :dotcms-e2e-node verify \
-De2e.test.skip=false \
-De2e.test.debug="--debug" \
-De2e.test.specific=login.spec.ts
```

Two advantages of running E2E tests this way is that:
Expand Down Expand Up @@ -55,8 +80,9 @@ Now that we have these packages installed we need to start dotCMS (with its depe
At `e2e/e2e-dotcms-node/frontend/package.json` you can find the available scripts you can call to execute the tests:

```json lines
"scripts": {
"start": "PLAYWRIGHT_JUNIT_SUITE_ID=nodee2etestsuite PLAYWRIGHT_JUNIT_SUITE_NAME='E2E Node Test Suite' PLAYWRIGHT_JUNIT_OUTPUT_FILE='../target/failsafe-reports/TEST-e2e-node-results.xml' yarn playwright test",
"scripts": {yarn playwright show-report;
"show-report": "if [[ \"$CURRENT_ENV\" != \"ci\" ]]; then fi",
"start": "PLAYWRIGHT_JUNIT_SUITE_ID=nodee2etestsuite PLAYWRIGHT_JUNIT_SUITE_NAME='E2E Node Test Suite' PLAYWRIGHT_JUNIT_OUTPUT_FILE='../target/failsafe-reports/TEST-e2e-node-results.xml' yarn playwright test ${PLAYWRIGHT_SPECIFIC} ${PLAYWRIGHT_DEBUG}; yarn run show-report",
"start-local": "CURRENT_ENV=local yarn run start",
"start-dev": "CURRENT_ENV=dev yarn run start",
"start-ci": "CURRENT_ENV=ci yarn run start",
Expand All @@ -79,10 +105,22 @@ yarn run start-dev

To run a specific E2E test:
```shell
yarn run start-dev -- login.spec.ts
yarn run start-dev login.spec.ts
```

To run E2E tests located in specific folder(s):
```shell
yarn run start-dev -- tests/login tests/contentSearch
yarn run start-dev tests/login tests/contentSearch
```

To debug, using `Playwright` UI mode, a specific test:
```shell
yarn run start-dev --ui login.spec.ts
```

To debug, using `Playwright` debug inspector, a specific test:
```shell
yarn run start-dev --debug login.spec.ts
```

When running in an environment other than `CI`, a HTML report will be opened in the browser.
3 changes: 2 additions & 1 deletion e2e/dotcms-e2e-node/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"xml2js": "^0.6.2"
},
"scripts": {
"start": "PLAYWRIGHT_JUNIT_SUITE_ID=nodee2etestsuite PLAYWRIGHT_JUNIT_SUITE_NAME='E2E Node Test Suite' PLAYWRIGHT_JUNIT_OUTPUT_FILE='../target/failsafe-reports/TEST-e2e-node-results.xml' yarn playwright test",
"show-report": "if [[ \"$CURRENT_ENV\" != \"ci\" ]]; then yarn playwright show-report; fi",
"start": "PLAYWRIGHT_JUNIT_SUITE_ID=nodee2etestsuite PLAYWRIGHT_JUNIT_SUITE_NAME='E2E Node Test Suite' PLAYWRIGHT_JUNIT_OUTPUT_FILE='../target/failsafe-reports/TEST-e2e-node-results.xml' yarn playwright test ${PLAYWRIGHT_SPECIFIC} ${PLAYWRIGHT_DEBUG}; yarn run show-report",
"start-local": "CURRENT_ENV=local yarn run start",
"start-dev": "CURRENT_ENV=dev yarn run start",
"start-ci": "CURRENT_ENV=ci yarn run start",
Expand Down
6 changes: 6 additions & 0 deletions e2e/dotcms-e2e-node/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<e2e.test.skip>true</e2e.test.skip>
<e2e.test.env>local</e2e.test.env>
<e2e.frontend.dir>./frontend</e2e.frontend.dir>
<e2e.test.debug></e2e.test.debug>
<e2e.test.specific></e2e.test.specific>
<e2e.test.cmd>run start-${e2e.test.env}</e2e.test.cmd>
<e2e.post.test.cmd>run post-testing</e2e.post.test.cmd>
<tomcat.port>8080</tomcat.port>
Expand Down Expand Up @@ -94,6 +96,10 @@
<workingDirectory>${e2e.frontend.dir}</workingDirectory>
<skip>${e2e.test.skip}</skip>
<arguments>${e2e.test.cmd}</arguments>
<environmentVariables>
<PLAYWRIGHT_SPECIFIC>${e2e.test.specific}</PLAYWRIGHT_SPECIFIC>
<PLAYWRIGHT_DEBUG>${e2e.test.debug}</PLAYWRIGHT_DEBUG>
</environmentVariables>
</configuration>
</execution>
<execution>
Expand Down
14 changes: 14 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ test-e2e-java-debug-suspend:
test-e2e-node:
./mvnw -pl :dotcms-e2e-node verify -De2e.test.skip=false

# The `e2e.test.specific` param can be a single test or a list of directories, please refer to: https://playwright.dev/docs/running-tests#run-specific-tests
test-e2e-node-specific test="login.spec.ts":
./mvnw -pl :dotcms-e2e-node verify -De2e.test.skip=false -De2e.test.specific="{{ test }}"

# Starts a de debug session using Playwright's UI mode, please refer to: https://playwright.dev/docs/test-ui-mode
# The `e2e.test.specific` param can be a single test or a list of directories, please refer to: https://playwright.dev/docs/running-tests#run-specific-tests
test-e2e-node-debug-ui test="login.spec.ts":
./mvnw -pl :dotcms-e2e-node verify -De2e.test.skip=false -De2e.test.debug="--ui" -De2e.test.specific="{{ test }}"

# Starts a de debug session using Playwright's debug inspector, please refer to: https://playwright.dev/docs/running-tests#debug-tests-with-the-playwright-inspector
# The `e2e.test.specific` param can be a single test or a list of directories, please refer to: https://playwright.dev/docs/running-tests#run-specific-tests
test-e2e-node-debug test="login.spec.ts":
./mvnw -pl :dotcms-e2e-node verify -De2e.test.skip=false -De2e.test.debug="--debug" -De2e.test.specific="{{ test }}"

# Stops E2E test services
test-e2e-stop:
./mvnw -pl :dotcms-e2e-java,:dotcms-e2e-node -Pdocker-stop -De2e.test.skip=false
Expand Down

0 comments on commit 2558218

Please sign in to comment.