From 278ba7fbd483fe9c49b93d10c9260338248a446d Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 7 Nov 2023 14:19:10 -0500 Subject: [PATCH] Convert E2E infrastructure to ESM (#33846) Playwright uses a Nodejs loader hook, and the combination of that hook and changes in Node 20 results in several bugs when it comes to loading CommonJS files. It's not even clear whether the bugs are in Playwright or Node. On the other hand, we can avoid all the bugs (whoever they belong to) by converting everything over to ESM syntax. So let's do that. --- .github/workflows/e2e-tests.yml | 2 +- .../changelog/update-convert-e2e-tests-to-esm | 5 ++ .../resources/playwright/1-37-failed.json | 2 +- .../resources/playwright/1-4-failed.json | 2 +- .../resources/playwright/all-passed.json | 2 +- .../changelog/update-convert-e2e-tests-to-esm | 5 ++ .../boost/tests/e2e/lib/env/prerequisites.js | 4 +- .../lib/pages/wp-admin/JetpackBoostPage.js | 2 +- .../boost/tests/e2e/playwright.config.mjs | 2 +- .../boost/tests/e2e/specs/base/common.test.js | 4 +- .../tests/e2e/specs/base/get-started.test.ts | 2 +- .../specs/critical-css/critical-css.test.js | 2 +- .../e2e/specs/modules/modules-common.test.js | 2 +- .../specs/modules/render-blocking-js.test.js | 2 +- .../specs/modules/score-auto-refresh.test.js | 2 +- .../changelog/update-convert-e2e-tests-to-esm | 5 ++ .../jetpack/tests/e2e/helpers/sync-helper.js | 4 +- .../jetpack/tests/e2e/helpers/waf-helper.js | 4 +- .../plugins/jetpack/tests/e2e/package.json | 2 +- .../jetpack/tests/e2e/playwright.config.cjs | 1 - .../jetpack/tests/e2e/playwright.config.mjs | 1 + .../e2e/specs/blocks/free-blocks.test.js | 2 +- .../tests/e2e/specs/blocks/pro-blocks.test.js | 2 +- .../post-connection/recommendations.test.js | 2 +- .../post-connection/waf-blocking.test.js | 4 +- .../pre-connection/pre-connection.test.js | 4 +- .../jetpack/tests/e2e/specs/sync/sync.test.js | 6 +- .../e2e/specs/update/plugin-update.test.js | 2 +- .../changelog/update-convert-e2e-tests-to-esm | 5 ++ .../plugins/migration/tests/e2e/package.json | 2 +- .../migration/tests/e2e/playwright.config.cjs | 1 - .../migration/tests/e2e/playwright.config.mjs | 1 + .../migration/tests/e2e/specs/start.test.js | 2 +- .../changelog/update-convert-e2e-tests-to-esm | 5 ++ .../search/tests/e2e/helpers/search-helper.js | 4 +- .../plugins/search/tests/e2e/package.json | 2 +- .../search/tests/e2e/pages/search-homepage.js | 5 +- .../e2e/pages/wp-admin/search-configure.js | 2 +- .../e2e/pages/wp-admin/search-dashboard.js | 2 +- .../search/tests/e2e/playwright.config.cjs | 1 - .../search/tests/e2e/playwright.config.mjs | 1 + .../tests/e2e/specs/search-configure.test.js | 2 +- .../tests/e2e/specs/search-dashboard.test.js | 2 +- .../search/tests/e2e/specs/search.test.js | 4 +- .../changelog/update-convert-e2e-tests-to-esm | 5 ++ .../social/tests/e2e/flows/connection.js | 2 +- .../plugins/social/tests/e2e/package.json | 2 +- .../e2e/pages/wp-admin/jetpack-social.js | 4 +- .../social/tests/e2e/playwright.config.cjs | 1 - .../social/tests/e2e/playwright.config.mjs | 1 + .../changelog/update-convert-e2e-tests-to-esm | 5 ++ .../starter-plugin/tests/e2e/package.json | 2 +- .../tests/e2e/playwright.config.cjs | 1 - .../tests/e2e/playwright.config.mjs | 1 + .../tests/e2e/specs/start.test.js | 2 +- .../changelog/update-convert-e2e-tests-to-esm | 5 ++ .../plugins/videopress/tests/e2e/package.json | 2 +- .../tests/e2e/playwright.config.cjs | 1 - .../tests/e2e/playwright.config.mjs | 1 + .../videopress/tests/e2e/specs/start.test.js | 2 +- tools/e2e-commons/README.md | 2 +- .../e2e-commons/bin/e2e-jetpack-connector.js | 2 +- tools/e2e-commons/bin/performance.js | 2 +- .../e2e-commons/bin/{tunnel.cjs => tunnel.js} | 21 ++--- tools/e2e-commons/bin/tunnel.sh | 6 +- ...eta-version.cjs => update-beta-version.js} | 8 +- ...ault.cjs => playwright.config.default.mjs} | 14 ++-- tools/e2e-commons/env/prerequisites.js | 4 +- tools/e2e-commons/fixtures/base-test.js | 4 +- tools/e2e-commons/flows/jetpack-connect.js | 6 +- tools/e2e-commons/flows/log-in.js | 11 ++- tools/e2e-commons/helpers/blocks-helper.js | 2 +- .../helpers/partner-provisioning.js | 4 +- tools/e2e-commons/helpers/plan-helper.js | 4 +- .../{utils-helper.cjs => utils-helper.js} | 77 +++++++------------ tools/e2e-commons/{logger.cjs => logger.js} | 8 +- .../pages/frontend/postFrontend.js | 2 +- tools/e2e-commons/pages/frontend/site-page.js | 2 +- tools/e2e-commons/pages/page-actions.js | 4 +- .../pages/wp-admin/block-editor.js | 4 +- .../e2e-commons/pages/wp-admin/blocks/form.js | 2 +- .../pages/wp-admin/blocks/mailchimp.js | 4 +- tools/e2e-commons/pages/wp-admin/dashboard.js | 2 +- .../pages/wp-admin/jetpack-dashboard.js | 4 +- .../pages/wp-admin/jetpack-my-plan.js | 4 +- tools/e2e-commons/pages/wp-admin/jetpack.js | 4 +- tools/e2e-commons/pages/wp-admin/login.js | 4 +- tools/e2e-commons/pages/wp-admin/plugins.js | 2 +- .../pages/wp-admin/recommendations.js | 2 +- .../e2e-commons/pages/wp-admin/site-editor.js | 4 +- tools/e2e-commons/pages/wpcom/authorize.js | 2 +- .../e2e-commons/pages/wpcom/complete-plan.js | 2 +- tools/e2e-commons/pages/wpcom/connections.js | 2 +- tools/e2e-commons/pages/wpcom/login.js | 4 +- tools/e2e-commons/pages/wpcom/pick-a-plan.js | 2 +- tools/e2e-commons/playwright.config.cjs | 1 - tools/e2e-commons/playwright.config.mjs | 1 + tools/e2e-commons/reporters/index.js | 2 +- .../reporters/{reporter.cjs => reporter.js} | 5 +- .../{screenshot.cjs => screenshot.js} | 14 ++-- 100 files changed, 216 insertions(+), 195 deletions(-) create mode 100644 projects/github-actions/test-results-to-slack/changelog/update-convert-e2e-tests-to-esm create mode 100644 projects/plugins/boost/changelog/update-convert-e2e-tests-to-esm create mode 100644 projects/plugins/jetpack/changelog/update-convert-e2e-tests-to-esm delete mode 100644 projects/plugins/jetpack/tests/e2e/playwright.config.cjs create mode 100644 projects/plugins/jetpack/tests/e2e/playwright.config.mjs create mode 100644 projects/plugins/migration/changelog/update-convert-e2e-tests-to-esm delete mode 100644 projects/plugins/migration/tests/e2e/playwright.config.cjs create mode 100644 projects/plugins/migration/tests/e2e/playwright.config.mjs create mode 100644 projects/plugins/search/changelog/update-convert-e2e-tests-to-esm delete mode 100644 projects/plugins/search/tests/e2e/playwright.config.cjs create mode 100644 projects/plugins/search/tests/e2e/playwright.config.mjs create mode 100644 projects/plugins/social/changelog/update-convert-e2e-tests-to-esm delete mode 100644 projects/plugins/social/tests/e2e/playwright.config.cjs create mode 100644 projects/plugins/social/tests/e2e/playwright.config.mjs create mode 100644 projects/plugins/starter-plugin/changelog/update-convert-e2e-tests-to-esm delete mode 100644 projects/plugins/starter-plugin/tests/e2e/playwright.config.cjs create mode 100644 projects/plugins/starter-plugin/tests/e2e/playwright.config.mjs create mode 100644 projects/plugins/videopress/changelog/update-convert-e2e-tests-to-esm delete mode 100644 projects/plugins/videopress/tests/e2e/playwright.config.cjs create mode 100644 projects/plugins/videopress/tests/e2e/playwright.config.mjs rename tools/e2e-commons/bin/{tunnel.cjs => tunnel.js} (92%) rename tools/e2e-commons/bin/{update-beta-version.cjs => update-beta-version.js} (92%) rename tools/e2e-commons/config/{playwright.config.default.cjs => playwright.config.default.mjs} (86%) rename tools/e2e-commons/helpers/{utils-helper.cjs => utils-helper.js} (83%) rename tools/e2e-commons/{logger.cjs => logger.js} (89%) delete mode 100644 tools/e2e-commons/playwright.config.cjs create mode 100644 tools/e2e-commons/playwright.config.mjs rename tools/e2e-commons/reporters/{reporter.cjs => reporter.js} (90%) rename tools/e2e-commons/reporters/{screenshot.cjs => screenshot.js} (69%) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index eef524ed6e8a5..54e16b75edf63 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -250,7 +250,7 @@ jobs: echo "TEST_SITE=${SITE}" >> $GITHUB_ENV # Wait for the site to pick up latest tag version (DISPATCH_REF_NAME) - TEST_SITE="${SITE}" node "$GITHUB_WORKSPACE/tools/e2e-commons/bin/update-beta-version.cjs" $DISPATCH_REF_TYPE $DISPATCH_REF_NAME + TEST_SITE="${SITE}" node "$GITHUB_WORKSPACE/tools/e2e-commons/bin/update-beta-version.js" $DISPATCH_REF_TYPE $DISPATCH_REF_NAME - name: Set up VIP site if: ${{ matrix.suite == 'vip' }} diff --git a/projects/github-actions/test-results-to-slack/changelog/update-convert-e2e-tests-to-esm b/projects/github-actions/test-results-to-slack/changelog/update-convert-e2e-tests-to-esm new file mode 100644 index 0000000000000..deda74b2e92f3 --- /dev/null +++ b/projects/github-actions/test-results-to-slack/changelog/update-convert-e2e-tests-to-esm @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Convert E2E configs to ESM. No change to the plugin itself. + + diff --git a/projects/github-actions/test-results-to-slack/tests/resources/playwright/1-37-failed.json b/projects/github-actions/test-results-to-slack/tests/resources/playwright/1-37-failed.json index 80ee173992acc..fab9440fd99fa 100755 --- a/projects/github-actions/test-results-to-slack/tests/resources/playwright/1-37-failed.json +++ b/projects/github-actions/test-results-to-slack/tests/resources/playwright/1-37-failed.json @@ -34,7 +34,7 @@ "/home/runner/work/jetpack/jetpack/node_modules/.pnpm/allure-playwright@2.0.0-beta.19/node_modules/allure-playwright/dist/index.js", null ], - [ "/home/runner/work/jetpack/jetpack/tools/e2e-commons/reporters/reporter.cjs", null ], + [ "/home/runner/work/jetpack/jetpack/tools/e2e-commons/reporters/reporter.js", null ], [ "github", null ] ], "reportSlowTests": null, diff --git a/projects/github-actions/test-results-to-slack/tests/resources/playwright/1-4-failed.json b/projects/github-actions/test-results-to-slack/tests/resources/playwright/1-4-failed.json index b0dfd94ed7833..ddeb90e9f2298 100755 --- a/projects/github-actions/test-results-to-slack/tests/resources/playwright/1-4-failed.json +++ b/projects/github-actions/test-results-to-slack/tests/resources/playwright/1-4-failed.json @@ -34,7 +34,7 @@ "/home/runner/work/jetpack/jetpack/node_modules/.pnpm/allure-playwright@2.0.0-beta.19/node_modules/allure-playwright/dist/index.js", null ], - [ "/home/runner/work/jetpack/jetpack/tools/e2e-commons/reporters/reporter.cjs", null ], + [ "/home/runner/work/jetpack/jetpack/tools/e2e-commons/reporters/reporter.js", null ], [ "github", null ] ], "reportSlowTests": null, diff --git a/projects/github-actions/test-results-to-slack/tests/resources/playwright/all-passed.json b/projects/github-actions/test-results-to-slack/tests/resources/playwright/all-passed.json index 4182ee3a48244..75d5ac312b438 100755 --- a/projects/github-actions/test-results-to-slack/tests/resources/playwright/all-passed.json +++ b/projects/github-actions/test-results-to-slack/tests/resources/playwright/all-passed.json @@ -34,7 +34,7 @@ "/home/runner/work/jetpack/jetpack/node_modules/.pnpm/allure-playwright@2.0.0-beta.19/node_modules/allure-playwright/dist/index.js", null ], - [ "/home/runner/work/jetpack/jetpack/tools/e2e-commons/reporters/reporter.cjs", null ], + [ "/home/runner/work/jetpack/jetpack/tools/e2e-commons/reporters/reporter.js", null ], [ "github", null ] ], "reportSlowTests": null, diff --git a/projects/plugins/boost/changelog/update-convert-e2e-tests-to-esm b/projects/plugins/boost/changelog/update-convert-e2e-tests-to-esm new file mode 100644 index 0000000000000..deda74b2e92f3 --- /dev/null +++ b/projects/plugins/boost/changelog/update-convert-e2e-tests-to-esm @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Convert E2E configs to ESM. No change to the plugin itself. + + diff --git a/projects/plugins/boost/tests/e2e/lib/env/prerequisites.js b/projects/plugins/boost/tests/e2e/lib/env/prerequisites.js index 3ec69f460bfdc..ecec72b8cff5f 100644 --- a/projects/plugins/boost/tests/e2e/lib/env/prerequisites.js +++ b/projects/plugins/boost/tests/e2e/lib/env/prerequisites.js @@ -1,5 +1,5 @@ -import logger from 'jetpack-e2e-commons/logger.cjs'; -import { execWpCommand } from 'jetpack-e2e-commons/helpers/utils-helper.cjs'; +import logger from 'jetpack-e2e-commons/logger.js'; +import { execWpCommand } from 'jetpack-e2e-commons/helpers/utils-helper.js'; import { expect } from '@playwright/test'; import { JetpackBoostPage } from '../pages/index.js'; diff --git a/projects/plugins/boost/tests/e2e/lib/pages/wp-admin/JetpackBoostPage.js b/projects/plugins/boost/tests/e2e/lib/pages/wp-admin/JetpackBoostPage.js index 820d2e289f57a..696b2856ef589 100644 --- a/projects/plugins/boost/tests/e2e/lib/pages/wp-admin/JetpackBoostPage.js +++ b/projects/plugins/boost/tests/e2e/lib/pages/wp-admin/JetpackBoostPage.js @@ -1,5 +1,5 @@ import WpPage from 'jetpack-e2e-commons/pages/wp-page.js'; -import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.cjs'; +import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.js'; const apiEndpointsRegex = { 'modules-state': /jetpack-boost-ds\/modules-state\/merge/, diff --git a/projects/plugins/boost/tests/e2e/playwright.config.mjs b/projects/plugins/boost/tests/e2e/playwright.config.mjs index e768ff74a325a..56d22771f7342 100644 --- a/projects/plugins/boost/tests/e2e/playwright.config.mjs +++ b/projects/plugins/boost/tests/e2e/playwright.config.mjs @@ -1,4 +1,4 @@ -import config from 'jetpack-e2e-commons/config/playwright.config.default.cjs'; +import config from 'jetpack-e2e-commons/config/playwright.config.default.mjs'; config.globalSetup = './lib/setupTests.js'; diff --git a/projects/plugins/boost/tests/e2e/specs/base/common.test.js b/projects/plugins/boost/tests/e2e/specs/base/common.test.js index 8f87df0052e23..afd9881558609 100644 --- a/projects/plugins/boost/tests/e2e/specs/base/common.test.js +++ b/projects/plugins/boost/tests/e2e/specs/base/common.test.js @@ -1,10 +1,10 @@ import { test, expect } from 'jetpack-e2e-commons/fixtures/base-test.js'; import { DashboardPage, PluginsPage, Sidebar } from 'jetpack-e2e-commons/pages/wp-admin/index.js'; -import { execWpCommand } from 'jetpack-e2e-commons/helpers/utils-helper.cjs'; +import { execWpCommand } from 'jetpack-e2e-commons/helpers/utils-helper.js'; import { boostPrerequisitesBuilder } from '../../lib/env/prerequisites.js'; import { prerequisitesBuilder } from 'jetpack-e2e-commons/env/prerequisites.js'; import { JetpackBoostPage } from '../../lib/pages/index.js'; -import playwrightConfig from 'jetpack-e2e-commons/playwright.config.cjs'; +import playwrightConfig from 'jetpack-e2e-commons/playwright.config.mjs'; test.afterAll( async ( { browser } ) => { const page = await browser.newPage( playwrightConfig.use ); diff --git a/projects/plugins/boost/tests/e2e/specs/base/get-started.test.ts b/projects/plugins/boost/tests/e2e/specs/base/get-started.test.ts index cae5707ead9c9..5539420458675 100644 --- a/projects/plugins/boost/tests/e2e/specs/base/get-started.test.ts +++ b/projects/plugins/boost/tests/e2e/specs/base/get-started.test.ts @@ -1,5 +1,5 @@ import { test, expect } from 'jetpack-e2e-commons/fixtures/base-test.js'; -import playwrightConfig from 'jetpack-e2e-commons/playwright.config.cjs'; +import playwrightConfig from 'jetpack-e2e-commons/playwright.config.mjs'; import { boostPrerequisitesBuilder } from '../../lib/env/prerequisites.js'; import { JetpackBoostPage } from '../../lib/pages/index.js'; diff --git a/projects/plugins/boost/tests/e2e/specs/critical-css/critical-css.test.js b/projects/plugins/boost/tests/e2e/specs/critical-css/critical-css.test.js index caf35974b8114..80050e38d18b3 100644 --- a/projects/plugins/boost/tests/e2e/specs/critical-css/critical-css.test.js +++ b/projects/plugins/boost/tests/e2e/specs/critical-css/critical-css.test.js @@ -3,7 +3,7 @@ import { boostPrerequisitesBuilder } from '../../lib/env/prerequisites.js'; import { JetpackBoostPage } from '../../lib/pages/index.js'; import { PostFrontendPage } from 'jetpack-e2e-commons/pages/index.js'; import { DashboardPage, ThemesPage, Sidebar } from 'jetpack-e2e-commons/pages/wp-admin/index.js'; -import playwrightConfig from 'jetpack-e2e-commons/playwright.config.cjs'; +import playwrightConfig from 'jetpack-e2e-commons/playwright.config.mjs'; test.describe( 'Critical CSS module', () => { let page; diff --git a/projects/plugins/boost/tests/e2e/specs/modules/modules-common.test.js b/projects/plugins/boost/tests/e2e/specs/modules/modules-common.test.js index 378962fac5b56..048c5d2f6509f 100644 --- a/projects/plugins/boost/tests/e2e/specs/modules/modules-common.test.js +++ b/projects/plugins/boost/tests/e2e/specs/modules/modules-common.test.js @@ -1,7 +1,7 @@ import { boostPrerequisitesBuilder } from '../../lib/env/prerequisites.js'; import { test, expect } from 'jetpack-e2e-commons/fixtures/base-test.js'; import { JetpackBoostPage } from '../../lib/pages/index.js'; -import playwrightConfig from 'jetpack-e2e-commons/playwright.config.cjs'; +import playwrightConfig from 'jetpack-e2e-commons/playwright.config.mjs'; const modules = [ // ['MODULE_NAME', 'DEFAULT STATE'], diff --git a/projects/plugins/boost/tests/e2e/specs/modules/render-blocking-js.test.js b/projects/plugins/boost/tests/e2e/specs/modules/render-blocking-js.test.js index 8c1cd95bfc6b7..321dc91fd7743 100644 --- a/projects/plugins/boost/tests/e2e/specs/modules/render-blocking-js.test.js +++ b/projects/plugins/boost/tests/e2e/specs/modules/render-blocking-js.test.js @@ -1,7 +1,7 @@ import { test, expect } from 'jetpack-e2e-commons/fixtures/base-test.js'; import { boostPrerequisitesBuilder } from '../../lib/env/prerequisites.js'; import { PostFrontendPage } from 'jetpack-e2e-commons/pages/index.js'; -import playwrightConfig from 'jetpack-e2e-commons/playwright.config.cjs'; +import playwrightConfig from 'jetpack-e2e-commons/playwright.config.mjs'; const testPostTitle = 'Hello World with JavaScript'; diff --git a/projects/plugins/boost/tests/e2e/specs/modules/score-auto-refresh.test.js b/projects/plugins/boost/tests/e2e/specs/modules/score-auto-refresh.test.js index 637304e0890b0..dd5d9ad5a424c 100644 --- a/projects/plugins/boost/tests/e2e/specs/modules/score-auto-refresh.test.js +++ b/projects/plugins/boost/tests/e2e/specs/modules/score-auto-refresh.test.js @@ -1,6 +1,6 @@ import { test, expect } from 'jetpack-e2e-commons/fixtures/base-test.js'; import { boostPrerequisitesBuilder } from '../../lib/env/prerequisites.js'; -import playwrightConfig from 'jetpack-e2e-commons/playwright.config.cjs'; +import playwrightConfig from 'jetpack-e2e-commons/playwright.config.mjs'; import { JetpackBoostPage } from '../../lib/pages/index.js'; test.describe( 'Auto refresh of speed scores', () => { diff --git a/projects/plugins/jetpack/changelog/update-convert-e2e-tests-to-esm b/projects/plugins/jetpack/changelog/update-convert-e2e-tests-to-esm new file mode 100644 index 0000000000000..c0d4679166f8a --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-convert-e2e-tests-to-esm @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: Convert E2E configs to ESM. No change to the plugin itself. + + diff --git a/projects/plugins/jetpack/tests/e2e/helpers/sync-helper.js b/projects/plugins/jetpack/tests/e2e/helpers/sync-helper.js index 131fa0ee7c55b..f1eb4f3bf960f 100644 --- a/projects/plugins/jetpack/tests/e2e/helpers/sync-helper.js +++ b/projects/plugins/jetpack/tests/e2e/helpers/sync-helper.js @@ -1,5 +1,5 @@ -import { execWpCommand } from 'jetpack-e2e-commons/helpers/utils-helper.cjs'; -import logger from 'jetpack-e2e-commons/logger.cjs'; +import { execWpCommand } from 'jetpack-e2e-commons/helpers/utils-helper.js'; +import logger from 'jetpack-e2e-commons/logger.js'; export async function enableSync() { logger.sync( 'Enabling sync' ); diff --git a/projects/plugins/jetpack/tests/e2e/helpers/waf-helper.js b/projects/plugins/jetpack/tests/e2e/helpers/waf-helper.js index f278fd8371b73..c98dcfac97637 100644 --- a/projects/plugins/jetpack/tests/e2e/helpers/waf-helper.js +++ b/projects/plugins/jetpack/tests/e2e/helpers/waf-helper.js @@ -1,5 +1,5 @@ -import { execWpCommand } from 'jetpack-e2e-commons/helpers/utils-helper.cjs'; -import logger from 'jetpack-e2e-commons/logger.cjs'; +import { execWpCommand } from 'jetpack-e2e-commons/helpers/utils-helper.js'; +import logger from 'jetpack-e2e-commons/logger.js'; export async function enableAutomaticRules() { logger.sync( 'Enabling automatic firewall rules' ); diff --git a/projects/plugins/jetpack/tests/e2e/package.json b/projects/plugins/jetpack/tests/e2e/package.json index 0016b1d011ad8..2f06de11add96 100644 --- a/projects/plugins/jetpack/tests/e2e/package.json +++ b/projects/plugins/jetpack/tests/e2e/package.json @@ -27,7 +27,7 @@ "tunnel:reset": "tunnel reset", "tunnel:down": "tunnel down", "pretest:run": "pnpm run clean", - "test:run": ". ./node_modules/jetpack-e2e-commons/bin/app-password.sh && playwright install && NODE_CONFIG_DIR='./config' ALLURE_RESULTS_DIR=./output/allure-results NODE_PATH=\"$PWD/node_modules\" playwright test --config=playwright.config.cjs", + "test:run": ". ./node_modules/jetpack-e2e-commons/bin/app-password.sh && playwright install && NODE_CONFIG_DIR='./config' ALLURE_RESULTS_DIR=./output/allure-results NODE_PATH=\"$PWD/node_modules\" playwright test --config=playwright.config.mjs", "test-decrypt-default-config": "openssl enc -md sha1 -aes-256-cbc -d -pass env:CONFIG_KEY -in ./node_modules/jetpack-e2e-commons/config/encrypted.enc -out ./node_modules/jetpack-e2e-commons/config/local.cjs", "test-decrypt-config": "openssl enc -md sha1 -aes-256-cbc -d -pass env:CONFIG_KEY -in ./config/encrypted.enc -out config/local.cjs", "test-decrypt-all-config": "pnpm test-decrypt-default-config && pnpm test-decrypt-config", diff --git a/projects/plugins/jetpack/tests/e2e/playwright.config.cjs b/projects/plugins/jetpack/tests/e2e/playwright.config.cjs deleted file mode 100644 index 25d579d4333e7..0000000000000 --- a/projects/plugins/jetpack/tests/e2e/playwright.config.cjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require( 'jetpack-e2e-commons/config/playwright.config.default.cjs' ); diff --git a/projects/plugins/jetpack/tests/e2e/playwright.config.mjs b/projects/plugins/jetpack/tests/e2e/playwright.config.mjs new file mode 100644 index 0000000000000..b5d057df1a7b8 --- /dev/null +++ b/projects/plugins/jetpack/tests/e2e/playwright.config.mjs @@ -0,0 +1 @@ +export { default } from 'jetpack-e2e-commons/config/playwright.config.default.mjs'; diff --git a/projects/plugins/jetpack/tests/e2e/specs/blocks/free-blocks.test.js b/projects/plugins/jetpack/tests/e2e/specs/blocks/free-blocks.test.js index 594a0928ef1b7..aeae68abe0778 100644 --- a/projects/plugins/jetpack/tests/e2e/specs/blocks/free-blocks.test.js +++ b/projects/plugins/jetpack/tests/e2e/specs/blocks/free-blocks.test.js @@ -11,7 +11,7 @@ import { import { PostFrontendPage } from 'jetpack-e2e-commons/pages/index.js'; import config from 'config'; import { prerequisitesBuilder, Plans } from 'jetpack-e2e-commons/env/index.js'; -import playwrightConfig from '../../playwright.config.cjs'; +import playwrightConfig from '../../playwright.config.mjs'; test.beforeAll( async ( { browser } ) => { const page = await browser.newPage( playwrightConfig.use ); diff --git a/projects/plugins/jetpack/tests/e2e/specs/blocks/pro-blocks.test.js b/projects/plugins/jetpack/tests/e2e/specs/blocks/pro-blocks.test.js index 20ded930c37e7..b461c9e9c6217 100644 --- a/projects/plugins/jetpack/tests/e2e/specs/blocks/pro-blocks.test.js +++ b/projects/plugins/jetpack/tests/e2e/specs/blocks/pro-blocks.test.js @@ -7,7 +7,7 @@ import { } from 'jetpack-e2e-commons/pages/wp-admin/index.js'; import { PostFrontendPage } from 'jetpack-e2e-commons/pages/index.js'; import { prerequisitesBuilder, Plans } from 'jetpack-e2e-commons/env/index.js'; -import playwrightConfig from '../../playwright.config.cjs'; +import playwrightConfig from '../../playwright.config.mjs'; let blockEditor; test.beforeAll( async ( { browser } ) => { diff --git a/projects/plugins/jetpack/tests/e2e/specs/post-connection/recommendations.test.js b/projects/plugins/jetpack/tests/e2e/specs/post-connection/recommendations.test.js index dd5a332bace80..dafc6426c7b78 100644 --- a/projects/plugins/jetpack/tests/e2e/specs/post-connection/recommendations.test.js +++ b/projects/plugins/jetpack/tests/e2e/specs/post-connection/recommendations.test.js @@ -1,7 +1,7 @@ import { test, expect } from 'jetpack-e2e-commons/fixtures/base-test.js'; import { RecommendationsPage } from 'jetpack-e2e-commons/pages/wp-admin/index.js'; import { Plans, prerequisitesBuilder } from 'jetpack-e2e-commons/env/index.js'; -import playwrightConfig from '../../playwright.config.cjs'; +import playwrightConfig from '../../playwright.config.mjs'; test.beforeAll( async ( { browser } ) => { const page = await browser.newPage( playwrightConfig.use ); diff --git a/projects/plugins/jetpack/tests/e2e/specs/post-connection/waf-blocking.test.js b/projects/plugins/jetpack/tests/e2e/specs/post-connection/waf-blocking.test.js index 80fc067ca943e..aaa0a5aed7b04 100644 --- a/projects/plugins/jetpack/tests/e2e/specs/post-connection/waf-blocking.test.js +++ b/projects/plugins/jetpack/tests/e2e/specs/post-connection/waf-blocking.test.js @@ -1,8 +1,8 @@ import { test, expect } from 'jetpack-e2e-commons/fixtures/base-test.js'; import { WpPage } from 'jetpack-e2e-commons/pages/index.js'; -import playwrightConfig from '../../playwright.config.cjs'; +import playwrightConfig from '../../playwright.config.mjs'; import { Plans, prerequisitesBuilder } from 'jetpack-e2e-commons/env/index.js'; -import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.cjs'; +import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.js'; import { enableAutomaticRules, generateRules } from '../../helpers/waf-helper.js'; test.describe.parallel( 'WAF Blocking', () => { diff --git a/projects/plugins/jetpack/tests/e2e/specs/pre-connection/pre-connection.test.js b/projects/plugins/jetpack/tests/e2e/specs/pre-connection/pre-connection.test.js index 5c6b8510c07e7..369f31bb57968 100644 --- a/projects/plugins/jetpack/tests/e2e/specs/pre-connection/pre-connection.test.js +++ b/projects/plugins/jetpack/tests/e2e/specs/pre-connection/pre-connection.test.js @@ -4,10 +4,10 @@ import { DashboardPage, JetpackPage, } from 'jetpack-e2e-commons/pages/wp-admin/index.js'; -import { execWpCommand } from 'jetpack-e2e-commons/helpers/utils-helper.cjs'; +import { execWpCommand } from 'jetpack-e2e-commons/helpers/utils-helper.js'; import { prerequisitesBuilder } from 'jetpack-e2e-commons/env/index.js'; import { test, expect } from 'jetpack-e2e-commons/fixtures/base-test.js'; -import playwrightConfig from '../../playwright.config.cjs'; +import playwrightConfig from '../../playwright.config.mjs'; test.beforeAll( async ( { browser } ) => { const page = await browser.newPage( playwrightConfig.use ); diff --git a/projects/plugins/jetpack/tests/e2e/specs/sync/sync.test.js b/projects/plugins/jetpack/tests/e2e/specs/sync/sync.test.js index 12b1e06383bb4..caaeecea6a381 100644 --- a/projects/plugins/jetpack/tests/e2e/specs/sync/sync.test.js +++ b/projects/plugins/jetpack/tests/e2e/specs/sync/sync.test.js @@ -1,5 +1,5 @@ import { test, expect } from 'jetpack-e2e-commons/fixtures/base-test.js'; -import { execWpCommand } from 'jetpack-e2e-commons/helpers/utils-helper.cjs'; +import { execWpCommand } from 'jetpack-e2e-commons/helpers/utils-helper.js'; import { enableSync, disableSync, @@ -10,8 +10,8 @@ import { } from '../../helpers/sync-helper.js'; import { BlockEditorPage } from 'jetpack-e2e-commons/pages/wp-admin/index.js'; import { prerequisitesBuilder } from 'jetpack-e2e-commons/env/index.js'; -import playwrightConfig from '../../playwright.config.cjs'; -import logger from 'jetpack-e2e-commons/logger.cjs'; +import playwrightConfig from '../../playwright.config.mjs'; +import logger from 'jetpack-e2e-commons/logger.js'; test.describe( 'Sync', () => { const wpcomRestAPIBase = 'https://public-api.wordpress.com/rest/'; diff --git a/projects/plugins/jetpack/tests/e2e/specs/update/plugin-update.test.js b/projects/plugins/jetpack/tests/e2e/specs/update/plugin-update.test.js index f6d64eadb1120..0cbbcce71fb8e 100644 --- a/projects/plugins/jetpack/tests/e2e/specs/update/plugin-update.test.js +++ b/projects/plugins/jetpack/tests/e2e/specs/update/plugin-update.test.js @@ -2,7 +2,7 @@ import { execShellCommand, resolveSiteUrl, execContainerShellCommand, -} from 'jetpack-e2e-commons/helpers/utils-helper.cjs'; +} from 'jetpack-e2e-commons/helpers/utils-helper.js'; import { PluginsPage, JetpackDashboardPage } from 'jetpack-e2e-commons/pages/wp-admin/index.js'; import { test, expect } from 'jetpack-e2e-commons/fixtures/base-test.js'; import { prerequisitesBuilder } from 'jetpack-e2e-commons/env/index.js'; diff --git a/projects/plugins/migration/changelog/update-convert-e2e-tests-to-esm b/projects/plugins/migration/changelog/update-convert-e2e-tests-to-esm new file mode 100644 index 0000000000000..deda74b2e92f3 --- /dev/null +++ b/projects/plugins/migration/changelog/update-convert-e2e-tests-to-esm @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Convert E2E configs to ESM. No change to the plugin itself. + + diff --git a/projects/plugins/migration/tests/e2e/package.json b/projects/plugins/migration/tests/e2e/package.json index c6b0431c7be24..deb618fe34803 100644 --- a/projects/plugins/migration/tests/e2e/package.json +++ b/projects/plugins/migration/tests/e2e/package.json @@ -26,7 +26,7 @@ "tunnel:reset": "tunnel reset", "tunnel:down": "tunnel down", "pretest:run": "pnpm run clean", - "test:run": ". ./node_modules/jetpack-e2e-commons/bin/app-password.sh && playwright install && NODE_CONFIG_DIR='./config' ALLURE_RESULTS_DIR=./output/allure-results NODE_PATH=\"$PWD/node_modules\" playwright test --config=./playwright.config.cjs" + "test:run": ". ./node_modules/jetpack-e2e-commons/bin/app-password.sh && playwright install && NODE_CONFIG_DIR='./config' ALLURE_RESULTS_DIR=./output/allure-results NODE_PATH=\"$PWD/node_modules\" playwright test --config=./playwright.config.mjs" }, "devDependencies": { "@playwright/test": "1.39.0", diff --git a/projects/plugins/migration/tests/e2e/playwright.config.cjs b/projects/plugins/migration/tests/e2e/playwright.config.cjs deleted file mode 100644 index 25d579d4333e7..0000000000000 --- a/projects/plugins/migration/tests/e2e/playwright.config.cjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require( 'jetpack-e2e-commons/config/playwright.config.default.cjs' ); diff --git a/projects/plugins/migration/tests/e2e/playwright.config.mjs b/projects/plugins/migration/tests/e2e/playwright.config.mjs new file mode 100644 index 0000000000000..b5d057df1a7b8 --- /dev/null +++ b/projects/plugins/migration/tests/e2e/playwright.config.mjs @@ -0,0 +1 @@ +export { default } from 'jetpack-e2e-commons/config/playwright.config.default.mjs'; diff --git a/projects/plugins/migration/tests/e2e/specs/start.test.js b/projects/plugins/migration/tests/e2e/specs/start.test.js index f16fc99862684..ebf9e08da5043 100644 --- a/projects/plugins/migration/tests/e2e/specs/start.test.js +++ b/projects/plugins/migration/tests/e2e/specs/start.test.js @@ -1,7 +1,7 @@ import { test } from '@playwright/test'; import { Sidebar, DashboardPage } from 'jetpack-e2e-commons/pages/wp-admin/index.js'; import { prerequisitesBuilder } from 'jetpack-e2e-commons/env/prerequisites.js'; -import playwrightConfig from '../playwright.config.cjs'; +import playwrightConfig from '../playwright.config.mjs'; test.describe( 'Starter plugin!', () => { test.beforeEach( async ( { browser } ) => { diff --git a/projects/plugins/search/changelog/update-convert-e2e-tests-to-esm b/projects/plugins/search/changelog/update-convert-e2e-tests-to-esm new file mode 100644 index 0000000000000..deda74b2e92f3 --- /dev/null +++ b/projects/plugins/search/changelog/update-convert-e2e-tests-to-esm @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Convert E2E configs to ESM. No change to the plugin itself. + + diff --git a/projects/plugins/search/tests/e2e/helpers/search-helper.js b/projects/plugins/search/tests/e2e/helpers/search-helper.js index dcd92419da070..170b2724d297c 100644 --- a/projects/plugins/search/tests/e2e/helpers/search-helper.js +++ b/projects/plugins/search/tests/e2e/helpers/search-helper.js @@ -1,5 +1,5 @@ -import { execWpCommand } from 'jetpack-e2e-commons/helpers/utils-helper.cjs'; -import logger from 'jetpack-e2e-commons/logger.cjs'; +import { execWpCommand } from 'jetpack-e2e-commons/helpers/utils-helper.js'; +import logger from 'jetpack-e2e-commons/logger.js'; import { SearchHomepage } from '../pages/index.js'; export async function enableInstantSearch() { diff --git a/projects/plugins/search/tests/e2e/package.json b/projects/plugins/search/tests/e2e/package.json index 0a840d1425e01..da78b4f2bdb29 100644 --- a/projects/plugins/search/tests/e2e/package.json +++ b/projects/plugins/search/tests/e2e/package.json @@ -24,7 +24,7 @@ "tunnel:reset": "tunnel reset", "tunnel:down": "tunnel down", "pretest:run": "pnpm run clean", - "test:run": ". ./node_modules/jetpack-e2e-commons/bin/app-password.sh && playwright install && NODE_CONFIG_DIR='./config' ALLURE_RESULTS_DIR=./output/allure-results NODE_PATH=\"$PWD/node_modules\" playwright test --config=playwright.config.cjs" + "test:run": ". ./node_modules/jetpack-e2e-commons/bin/app-password.sh && playwright install && NODE_CONFIG_DIR='./config' ALLURE_RESULTS_DIR=./output/allure-results NODE_PATH=\"$PWD/node_modules\" playwright test --config=playwright.config.mjs" }, "devDependencies": { "@playwright/test": "1.39.0", diff --git a/projects/plugins/search/tests/e2e/pages/search-homepage.js b/projects/plugins/search/tests/e2e/pages/search-homepage.js index ebf2841bf2dee..2d5900c6a032f 100644 --- a/projects/plugins/search/tests/e2e/pages/search-homepage.js +++ b/projects/plugins/search/tests/e2e/pages/search-homepage.js @@ -1,8 +1,9 @@ import WpPage from 'jetpack-e2e-commons/pages/wp-page.js'; -import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.cjs'; +import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.js'; export default class SearchHomepage extends WpPage { - static SEARCH_API_PATTERN = /^https:\/\/public-api\.wordpress.com\/rest\/v1.3\/sites\/\d+\/search.*/; + static SEARCH_API_PATTERN = + /^https:\/\/public-api\.wordpress.com\/rest\/v1.3\/sites\/\d+\/search.*/; constructor( page ) { const url = `${ resolveSiteUrl() }/?result_format=expanded`; diff --git a/projects/plugins/search/tests/e2e/pages/wp-admin/search-configure.js b/projects/plugins/search/tests/e2e/pages/wp-admin/search-configure.js index bd3fbcc947f84..b19e03e92676b 100644 --- a/projects/plugins/search/tests/e2e/pages/wp-admin/search-configure.js +++ b/projects/plugins/search/tests/e2e/pages/wp-admin/search-configure.js @@ -1,5 +1,5 @@ import WpPage from 'jetpack-e2e-commons/pages/wp-page.js'; -import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.cjs'; +import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.js'; export default class SearchConfigure extends WpPage { static SEARCH_SETTING_API_PATTERN = /^https?:\/\/.*%2Fwp%2Fv2%2Fsettings/; diff --git a/projects/plugins/search/tests/e2e/pages/wp-admin/search-dashboard.js b/projects/plugins/search/tests/e2e/pages/wp-admin/search-dashboard.js index 1990cafb958cc..a2ab41089ff8a 100644 --- a/projects/plugins/search/tests/e2e/pages/wp-admin/search-dashboard.js +++ b/projects/plugins/search/tests/e2e/pages/wp-admin/search-dashboard.js @@ -1,5 +1,5 @@ import WpPage from 'jetpack-e2e-commons/pages/wp-page.js'; -import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.cjs'; +import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.js'; export default class SearchDashboard extends WpPage { static SEARCH_SETTING_API_PATTERN = /^https?:\/\/.*jetpack\/v4\/search\/settings/; diff --git a/projects/plugins/search/tests/e2e/playwright.config.cjs b/projects/plugins/search/tests/e2e/playwright.config.cjs deleted file mode 100644 index 25d579d4333e7..0000000000000 --- a/projects/plugins/search/tests/e2e/playwright.config.cjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require( 'jetpack-e2e-commons/config/playwright.config.default.cjs' ); diff --git a/projects/plugins/search/tests/e2e/playwright.config.mjs b/projects/plugins/search/tests/e2e/playwright.config.mjs new file mode 100644 index 0000000000000..b5d057df1a7b8 --- /dev/null +++ b/projects/plugins/search/tests/e2e/playwright.config.mjs @@ -0,0 +1 @@ +export { default } from 'jetpack-e2e-commons/config/playwright.config.default.mjs'; diff --git a/projects/plugins/search/tests/e2e/specs/search-configure.test.js b/projects/plugins/search/tests/e2e/specs/search-configure.test.js index 9578ff037bb1a..da98fac7a6b9f 100644 --- a/projects/plugins/search/tests/e2e/specs/search-configure.test.js +++ b/projects/plugins/search/tests/e2e/specs/search-configure.test.js @@ -11,7 +11,7 @@ import { clearSearchPlanInfo, } from '../helpers/search-helper.js'; import { prerequisitesBuilder, Plans } from 'jetpack-e2e-commons/env/index.js'; -import playwrightConfig from '../playwright.config.cjs'; +import playwrightConfig from '../playwright.config.mjs'; test.describe( 'Search Configure', () => { let searchConfigure; diff --git a/projects/plugins/search/tests/e2e/specs/search-dashboard.test.js b/projects/plugins/search/tests/e2e/specs/search-dashboard.test.js index e63bb3397ea7a..25f7b1e478359 100644 --- a/projects/plugins/search/tests/e2e/specs/search-dashboard.test.js +++ b/projects/plugins/search/tests/e2e/specs/search-dashboard.test.js @@ -6,7 +6,7 @@ import { clearSearchPlanInfo, } from '../helpers/search-helper.js'; import { prerequisitesBuilder, Plans } from 'jetpack-e2e-commons/env/index.js'; -import playwrightConfig from '../playwright.config.cjs'; +import playwrightConfig from '../playwright.config.mjs'; test.describe( 'Search Dashboard', () => { let searchDashboard; diff --git a/projects/plugins/search/tests/e2e/specs/search.test.js b/projects/plugins/search/tests/e2e/specs/search.test.js index c39db09a6d8a2..bb4c90df9d4eb 100644 --- a/projects/plugins/search/tests/e2e/specs/search.test.js +++ b/projects/plugins/search/tests/e2e/specs/search.test.js @@ -8,8 +8,8 @@ import { clearSearchPlanInfo, } from '../helpers/search-helper.js'; import { prerequisitesBuilder, Plans } from 'jetpack-e2e-commons/env/index.js'; -import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.cjs'; -import playwrightConfig from '../playwright.config.cjs'; +import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.js'; +import playwrightConfig from '../playwright.config.mjs'; test.describe( 'Instant Search', () => { let homepage; diff --git a/projects/plugins/social/changelog/update-convert-e2e-tests-to-esm b/projects/plugins/social/changelog/update-convert-e2e-tests-to-esm new file mode 100644 index 0000000000000..deda74b2e92f3 --- /dev/null +++ b/projects/plugins/social/changelog/update-convert-e2e-tests-to-esm @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Convert E2E configs to ESM. No change to the plugin itself. + + diff --git a/projects/plugins/social/tests/e2e/flows/connection.js b/projects/plugins/social/tests/e2e/flows/connection.js index f8d4f50ab8775..f48853634787d 100644 --- a/projects/plugins/social/tests/e2e/flows/connection.js +++ b/projects/plugins/social/tests/e2e/flows/connection.js @@ -1,5 +1,5 @@ import { AuthorizePage } from 'jetpack-e2e-commons/pages/wpcom/index.js'; -import logger from 'jetpack-e2e-commons/logger.cjs'; +import logger from 'jetpack-e2e-commons/logger.js'; import { JetpackSocialPage } from '../pages/index.js'; export async function connect( page, premium = false ) { diff --git a/projects/plugins/social/tests/e2e/package.json b/projects/plugins/social/tests/e2e/package.json index 9f387d718761d..2478f73b2b483 100644 --- a/projects/plugins/social/tests/e2e/package.json +++ b/projects/plugins/social/tests/e2e/package.json @@ -28,7 +28,7 @@ "tunnel:reset": "tunnel reset", "tunnel:down": "tunnel down", "pretest:run": "pnpm run clean", - "test:run": ". ./node_modules/jetpack-e2e-commons/bin/app-password.sh && playwright install && NODE_CONFIG_DIR='./config' ALLURE_RESULTS_DIR=./output/allure-results NODE_PATH=\"$PWD/node_modules\" playwright test --config=./playwright.config.cjs" + "test:run": ". ./node_modules/jetpack-e2e-commons/bin/app-password.sh && playwright install && NODE_CONFIG_DIR='./config' ALLURE_RESULTS_DIR=./output/allure-results NODE_PATH=\"$PWD/node_modules\" playwright test --config=./playwright.config.mjs" }, "devDependencies": { "@playwright/test": "1.39.0", diff --git a/projects/plugins/social/tests/e2e/pages/wp-admin/jetpack-social.js b/projects/plugins/social/tests/e2e/pages/wp-admin/jetpack-social.js index 47d7ccd58bb0f..feeac708e1151 100644 --- a/projects/plugins/social/tests/e2e/pages/wp-admin/jetpack-social.js +++ b/projects/plugins/social/tests/e2e/pages/wp-admin/jetpack-social.js @@ -1,6 +1,6 @@ import WpPage from 'jetpack-e2e-commons/pages/wp-page.js'; -import logger from 'jetpack-e2e-commons/logger.cjs'; -import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.cjs'; +import logger from 'jetpack-e2e-commons/logger.js'; +import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.js'; export default class JetpackSocialPage extends WpPage { constructor( page ) { diff --git a/projects/plugins/social/tests/e2e/playwright.config.cjs b/projects/plugins/social/tests/e2e/playwright.config.cjs deleted file mode 100644 index 25d579d4333e7..0000000000000 --- a/projects/plugins/social/tests/e2e/playwright.config.cjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require( 'jetpack-e2e-commons/config/playwright.config.default.cjs' ); diff --git a/projects/plugins/social/tests/e2e/playwright.config.mjs b/projects/plugins/social/tests/e2e/playwright.config.mjs new file mode 100644 index 0000000000000..b5d057df1a7b8 --- /dev/null +++ b/projects/plugins/social/tests/e2e/playwright.config.mjs @@ -0,0 +1 @@ +export { default } from 'jetpack-e2e-commons/config/playwright.config.default.mjs'; diff --git a/projects/plugins/starter-plugin/changelog/update-convert-e2e-tests-to-esm b/projects/plugins/starter-plugin/changelog/update-convert-e2e-tests-to-esm new file mode 100644 index 0000000000000..deda74b2e92f3 --- /dev/null +++ b/projects/plugins/starter-plugin/changelog/update-convert-e2e-tests-to-esm @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Convert E2E configs to ESM. No change to the plugin itself. + + diff --git a/projects/plugins/starter-plugin/tests/e2e/package.json b/projects/plugins/starter-plugin/tests/e2e/package.json index 18f22d0f6691e..5af3c5bc6436d 100644 --- a/projects/plugins/starter-plugin/tests/e2e/package.json +++ b/projects/plugins/starter-plugin/tests/e2e/package.json @@ -26,7 +26,7 @@ "tunnel:reset": "tunnel reset", "tunnel:down": "tunnel down", "pretest:run": "pnpm run clean", - "test:run": ". ./node_modules/jetpack-e2e-commons/bin/app-password.sh && playwright install && NODE_CONFIG_DIR='./config' ALLURE_RESULTS_DIR=./output/allure-results NODE_PATH=\"$PWD/node_modules\" playwright test --config=./playwright.config.cjs" + "test:run": ". ./node_modules/jetpack-e2e-commons/bin/app-password.sh && playwright install && NODE_CONFIG_DIR='./config' ALLURE_RESULTS_DIR=./output/allure-results NODE_PATH=\"$PWD/node_modules\" playwright test --config=./playwright.config.mjs" }, "devDependencies": { "@playwright/test": "1.39.0", diff --git a/projects/plugins/starter-plugin/tests/e2e/playwright.config.cjs b/projects/plugins/starter-plugin/tests/e2e/playwright.config.cjs deleted file mode 100644 index 25d579d4333e7..0000000000000 --- a/projects/plugins/starter-plugin/tests/e2e/playwright.config.cjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require( 'jetpack-e2e-commons/config/playwright.config.default.cjs' ); diff --git a/projects/plugins/starter-plugin/tests/e2e/playwright.config.mjs b/projects/plugins/starter-plugin/tests/e2e/playwright.config.mjs new file mode 100644 index 0000000000000..b5d057df1a7b8 --- /dev/null +++ b/projects/plugins/starter-plugin/tests/e2e/playwright.config.mjs @@ -0,0 +1 @@ +export { default } from 'jetpack-e2e-commons/config/playwright.config.default.mjs'; diff --git a/projects/plugins/starter-plugin/tests/e2e/specs/start.test.js b/projects/plugins/starter-plugin/tests/e2e/specs/start.test.js index f16fc99862684..ebf9e08da5043 100644 --- a/projects/plugins/starter-plugin/tests/e2e/specs/start.test.js +++ b/projects/plugins/starter-plugin/tests/e2e/specs/start.test.js @@ -1,7 +1,7 @@ import { test } from '@playwright/test'; import { Sidebar, DashboardPage } from 'jetpack-e2e-commons/pages/wp-admin/index.js'; import { prerequisitesBuilder } from 'jetpack-e2e-commons/env/prerequisites.js'; -import playwrightConfig from '../playwright.config.cjs'; +import playwrightConfig from '../playwright.config.mjs'; test.describe( 'Starter plugin!', () => { test.beforeEach( async ( { browser } ) => { diff --git a/projects/plugins/videopress/changelog/update-convert-e2e-tests-to-esm b/projects/plugins/videopress/changelog/update-convert-e2e-tests-to-esm new file mode 100644 index 0000000000000..deda74b2e92f3 --- /dev/null +++ b/projects/plugins/videopress/changelog/update-convert-e2e-tests-to-esm @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Convert E2E configs to ESM. No change to the plugin itself. + + diff --git a/projects/plugins/videopress/tests/e2e/package.json b/projects/plugins/videopress/tests/e2e/package.json index b35005fdf1b92..a957834ba34a9 100644 --- a/projects/plugins/videopress/tests/e2e/package.json +++ b/projects/plugins/videopress/tests/e2e/package.json @@ -26,7 +26,7 @@ "tunnel:reset": "tunnel reset", "tunnel:down": "tunnel down", "pretest:run": "pnpm run clean", - "test:run": ". ./node_modules/jetpack-e2e-commons/bin/app-password.sh && playwright install && NODE_CONFIG_DIR='./config' ALLURE_RESULTS_DIR=./output/allure-results NODE_PATH=\"$PWD/node_modules\" playwright test --config=./playwright.config.cjs" + "test:run": ". ./node_modules/jetpack-e2e-commons/bin/app-password.sh && playwright install && NODE_CONFIG_DIR='./config' ALLURE_RESULTS_DIR=./output/allure-results NODE_PATH=\"$PWD/node_modules\" playwright test --config=./playwright.config.mjs" }, "devDependencies": { "@playwright/test": "1.39.0", diff --git a/projects/plugins/videopress/tests/e2e/playwright.config.cjs b/projects/plugins/videopress/tests/e2e/playwright.config.cjs deleted file mode 100644 index 25d579d4333e7..0000000000000 --- a/projects/plugins/videopress/tests/e2e/playwright.config.cjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require( 'jetpack-e2e-commons/config/playwright.config.default.cjs' ); diff --git a/projects/plugins/videopress/tests/e2e/playwright.config.mjs b/projects/plugins/videopress/tests/e2e/playwright.config.mjs new file mode 100644 index 0000000000000..b5d057df1a7b8 --- /dev/null +++ b/projects/plugins/videopress/tests/e2e/playwright.config.mjs @@ -0,0 +1 @@ +export { default } from 'jetpack-e2e-commons/config/playwright.config.default.mjs'; diff --git a/projects/plugins/videopress/tests/e2e/specs/start.test.js b/projects/plugins/videopress/tests/e2e/specs/start.test.js index f16fc99862684..ebf9e08da5043 100644 --- a/projects/plugins/videopress/tests/e2e/specs/start.test.js +++ b/projects/plugins/videopress/tests/e2e/specs/start.test.js @@ -1,7 +1,7 @@ import { test } from '@playwright/test'; import { Sidebar, DashboardPage } from 'jetpack-e2e-commons/pages/wp-admin/index.js'; import { prerequisitesBuilder } from 'jetpack-e2e-commons/env/prerequisites.js'; -import playwrightConfig from '../playwright.config.cjs'; +import playwrightConfig from '../playwright.config.mjs'; test.describe( 'Starter plugin!', () => { test.beforeEach( async ( { browser } ) => { diff --git a/tools/e2e-commons/README.md b/tools/e2e-commons/README.md index 14a5dcbe85b36..4a8a331c550c9 100644 --- a/tools/e2e-commons/README.md +++ b/tools/e2e-commons/README.md @@ -162,7 +162,7 @@ constructor( page ) { ## Reporting -A few [reporters](https://playwright.dev/docs/test-reporters) are configured by default, check `config/playwright.config.default.cjs` for details. +A few [reporters](https://playwright.dev/docs/test-reporters) are configured by default, check `config/playwright.config.default.mjs` for details. ### Allure reporter diff --git a/tools/e2e-commons/bin/e2e-jetpack-connector.js b/tools/e2e-commons/bin/e2e-jetpack-connector.js index 21ad43dd144d3..b8d13a29851e9 100755 --- a/tools/e2e-commons/bin/e2e-jetpack-connector.js +++ b/tools/e2e-commons/bin/e2e-jetpack-connector.js @@ -1,5 +1,5 @@ import { prerequisitesBuilder } from '../env/prerequisites.js'; -import { resolveSiteUrl } from '../helpers/utils-helper.cjs'; +import { resolveSiteUrl } from '../helpers/utils-helper.js'; global.siteUrl = resolveSiteUrl(); prerequisitesBuilder().withConnection( true ).build(); diff --git a/tools/e2e-commons/bin/performance.js b/tools/e2e-commons/bin/performance.js index e94c17bd12fac..5400b346ac8fb 100644 --- a/tools/e2e-commons/bin/performance.js +++ b/tools/e2e-commons/bin/performance.js @@ -1,6 +1,6 @@ import { readFileSync, writeFileSync } from 'fs'; import { prerequisitesBuilder } from '../env/prerequisites.js'; -import { execSyncShellCommand, execWpCommand, resolveSiteUrl } from '../helpers/utils-helper.cjs'; +import { execSyncShellCommand, execWpCommand, resolveSiteUrl } from '../helpers/utils-helper.js'; import _ from 'lodash'; const numAttempts = 3; diff --git a/tools/e2e-commons/bin/tunnel.cjs b/tools/e2e-commons/bin/tunnel.js similarity index 92% rename from tools/e2e-commons/bin/tunnel.cjs rename to tools/e2e-commons/bin/tunnel.js index 29c327af97689..7f697fde75b81 100755 --- a/tools/e2e-commons/bin/tunnel.cjs +++ b/tools/e2e-commons/bin/tunnel.js @@ -1,18 +1,21 @@ #!/usr/bin/env node -const fs = require( 'fs' ); -const childProcess = require( 'child_process' ); -const config = require( 'config' ); +import fs from 'fs'; +import childProcess from 'child_process'; +import { fileURLToPath } from 'url'; +import config from 'config'; +import { getReusableUrlFromFile } from '../helpers/utils-helper.js'; +import axios from 'axios'; +import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; +import localtunnel from 'localtunnel'; + const tunnelConfig = config.get( 'tunnel' ); -const { getReusableUrlFromFile } = require( '../helpers/utils-helper.cjs' ); -const axios = require( 'axios' ); -const yargs = require( 'yargs' ); -const localtunnel = require( 'localtunnel' ); fs.mkdirSync( config.get( 'dirs.temp' ), { recursive: true } ); // eslint-disable-next-line no-unused-expressions -yargs +yargs( hideBin( process.argv ) ) .usage( 'Usage: $0 ' ) .demandCommand( 1, 1 ) .command( @@ -49,7 +52,7 @@ async function tunnelOn( argv ) { } ); } - const cp = childProcess.fork( __filename, [ 'child' ], { + const cp = childProcess.fork( fileURLToPath( import.meta.url ), [ 'child' ], { detached: true, stdio: [ 'ignore', s, s, 'ipc' ], } ); diff --git a/tools/e2e-commons/bin/tunnel.sh b/tools/e2e-commons/bin/tunnel.sh index d46985199d4f1..2ee6f619cd1c7 100755 --- a/tools/e2e-commons/bin/tunnel.sh +++ b/tools/e2e-commons/bin/tunnel.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Wrapper over tunnel.cjs script +# Wrapper over tunnel.js script set -e @@ -22,11 +22,11 @@ export PATH="$BASE_DIR/../node_modules/.bin:$PATH" function up() { down - node "$BASE_DIR"/tunnel.cjs on "$@" + node "$BASE_DIR"/tunnel.js on "$@" } function down() { - node "$BASE_DIR"/tunnel.cjs off + node "$BASE_DIR"/tunnel.js off } function reset() { diff --git a/tools/e2e-commons/bin/update-beta-version.cjs b/tools/e2e-commons/bin/update-beta-version.js similarity index 92% rename from tools/e2e-commons/bin/update-beta-version.cjs rename to tools/e2e-commons/bin/update-beta-version.js index 9800503432284..ca3abb4b41e41 100755 --- a/tools/e2e-commons/bin/update-beta-version.cjs +++ b/tools/e2e-commons/bin/update-beta-version.js @@ -1,9 +1,9 @@ -const path = require( 'path' ); -const fetch = require( 'node-fetch' ); +import { fileURLToPath } from 'url'; +import fetch from 'node-fetch'; // Below call should be BEFORE requiring config, so library wil pick it up. -process.env.NODE_CONFIG_DIR = path.resolve( __dirname, '../config' ); -const { resolveSiteUrl, getSiteCredentials } = require( '../helpers/utils-helper.cjs' ); +process.env.NODE_CONFIG_DIR = fileURLToPath( new URL( '../config', import.meta.url ) ); +const { resolveSiteUrl, getSiteCredentials } = await import( '../helpers/utils-helper.js' ); function getAuthHeader() { const credentials = getSiteCredentials(); diff --git a/tools/e2e-commons/config/playwright.config.default.cjs b/tools/e2e-commons/config/playwright.config.default.mjs similarity index 86% rename from tools/e2e-commons/config/playwright.config.default.cjs rename to tools/e2e-commons/config/playwright.config.default.mjs index d7ae3ef262145..cf1af1be4f218 100644 --- a/tools/e2e-commons/config/playwright.config.default.cjs +++ b/tools/e2e-commons/config/playwright.config.default.mjs @@ -1,12 +1,16 @@ -const config = require( 'config' ); -const fs = require( 'fs' ); -const path = require( 'path' ); +import config from 'config'; +import fs from 'fs'; +import { fileURLToPath } from 'url'; const reporter = [ [ 'list' ], [ 'json', { outputFile: `${ config.get( 'dirs.output' ) }/summary.json` } ], [ 'allure-playwright' ], - [ `${ path.resolve( __dirname, '../', config.get( 'dirs.reporters' ) ) }/reporter.cjs` ], + [ + `${ fileURLToPath( + new URL( '../' + config.get( 'dirs.reporters' ), import.meta.url ) + ) }/reporter.js`, + ], ]; if ( process.env.CI ) { @@ -55,4 +59,4 @@ const playwrightConfig = { reportSlowTests: null, }; -module.exports = playwrightConfig; +export default playwrightConfig; diff --git a/tools/e2e-commons/env/prerequisites.js b/tools/e2e-commons/env/prerequisites.js index 45dd30b0923c4..70f1b8dadcdca 100644 --- a/tools/e2e-commons/env/prerequisites.js +++ b/tools/e2e-commons/env/prerequisites.js @@ -1,11 +1,11 @@ -import logger from '../logger.cjs'; +import logger from '../logger.js'; import { syncJetpackPlanData, loginToWpCom, loginToWpSite } from '../flows/index.js'; import { execWpCommand, getDotComCredentials, isLocalSite, resetWordpressInstall, -} from '../helpers/utils-helper.cjs'; +} from '../helpers/utils-helper.js'; import { provisionJetpackStartConnection } from '../helpers/partner-provisioning.js'; import fs from 'fs'; import config from 'config'; diff --git a/tools/e2e-commons/fixtures/base-test.js b/tools/e2e-commons/fixtures/base-test.js index 05bb1e302fec0..0b87790f5e56f 100644 --- a/tools/e2e-commons/fixtures/base-test.js +++ b/tools/e2e-commons/fixtures/base-test.js @@ -1,8 +1,8 @@ import { allure } from 'allure-playwright'; import { test as baseTest } from '@playwright/test'; import config from 'config'; -import logger from '../logger.cjs'; -import { execWpCommand } from '../helpers/utils-helper.cjs'; +import logger from '../logger.js'; +import { execWpCommand } from '../helpers/utils-helper.js'; export { expect } from '@playwright/test'; const test = baseTest.extend( { diff --git a/tools/e2e-commons/flows/jetpack-connect.js b/tools/e2e-commons/flows/jetpack-connect.js index 5e18e61267c79..3fa37c4f9b487 100644 --- a/tools/e2e-commons/flows/jetpack-connect.js +++ b/tools/e2e-commons/flows/jetpack-connect.js @@ -12,9 +12,9 @@ import { ThankYouPage, LoginPage, } from '../pages/wpcom/index.js'; -import { execWpCommand } from '../helpers/utils-helper.cjs'; +import { execWpCommand } from '../helpers/utils-helper.js'; import { persistPlanData, syncPlanData } from '../helpers/plan-helper.js'; -import logger from '../logger.cjs'; +import logger from '../logger.js'; import { expect } from '@playwright/test'; const cardCredentials = config.get( 'testCardCredentials' ); @@ -42,7 +42,7 @@ export async function doSiteLevelConnection( page ) { await ( await PickAPlanPage.init( page ) ).select( 'free' ); const isPageVisible = await ( await RecommendationsPage.visit( page ) - ).areSiteTypeQuestionsVisible(); + ).areSiteTypeQuestionsVisible(); expect( isPageVisible ).toBeTruthy(); await ( await Sidebar.init( page ) ).selectJetpack(); } diff --git a/tools/e2e-commons/flows/log-in.js b/tools/e2e-commons/flows/log-in.js index 718d7d4023ac4..94994fcd5b7a3 100644 --- a/tools/e2e-commons/flows/log-in.js +++ b/tools/e2e-commons/flows/log-in.js @@ -1,8 +1,8 @@ import config from 'config'; import { DashboardPage, WPLoginPage } from '../pages/wp-admin/index.js'; import { LoginPage } from '../pages/wpcom/index.js'; -import logger from '../logger.cjs'; -import { resolveSiteUrl } from '../helpers/utils-helper.cjs'; +import logger from '../logger.js'; +import { resolveSiteUrl } from '../helpers/utils-helper.js'; const cookie = config.get( 'storeSandboxCookieValue' ); @@ -25,10 +25,9 @@ export async function loginToWpSite( page, mockPlanData ) { await ( await WPLoginPage.init( page ) ).login(); if ( ! mockPlanData ) { - await ( await DashboardPage.init( page ) ).setSandboxModeForPayments( - cookie, - new URL( resolveSiteUrl() ).host - ); + await ( + await DashboardPage.init( page ) + ).setSandboxModeForPayments( cookie, new URL( resolveSiteUrl() ).host ); } } diff --git a/tools/e2e-commons/helpers/blocks-helper.js b/tools/e2e-commons/helpers/blocks-helper.js index ee3c00a2005c1..5a705591f6144 100644 --- a/tools/e2e-commons/helpers/blocks-helper.js +++ b/tools/e2e-commons/helpers/blocks-helper.js @@ -1,4 +1,4 @@ -import logger from '../logger.cjs'; +import logger from '../logger.js'; export async function waitForBlock( blockSlug, page ) { let block = await findAvailableBlock( blockSlug, page ); diff --git a/tools/e2e-commons/helpers/partner-provisioning.js b/tools/e2e-commons/helpers/partner-provisioning.js index 87b2498100f1f..f9d1056ff2af9 100644 --- a/tools/e2e-commons/helpers/partner-provisioning.js +++ b/tools/e2e-commons/helpers/partner-provisioning.js @@ -1,8 +1,8 @@ import config from 'config'; import path from 'path'; import shellescape from 'shell-escape'; -import logger from '../logger.cjs'; -import { execSyncShellCommand, execWpCommand, resolveSiteUrl } from './utils-helper.cjs'; +import logger from '../logger.js'; +import { execSyncShellCommand, execWpCommand, resolveSiteUrl } from './utils-helper.js'; import * as url from 'url'; /** diff --git a/tools/e2e-commons/helpers/plan-helper.js b/tools/e2e-commons/helpers/plan-helper.js index 5544ef27b2790..780a5ec9b66ad 100644 --- a/tools/e2e-commons/helpers/plan-helper.js +++ b/tools/e2e-commons/helpers/plan-helper.js @@ -1,6 +1,6 @@ import fs from 'fs'; -import { execWpCommand, resolveSiteUrl } from './utils-helper.cjs'; -import logger from '../logger.cjs'; +import { execWpCommand, resolveSiteUrl } from './utils-helper.js'; +import logger from '../logger.js'; import config from 'config'; import path from 'path'; diff --git a/tools/e2e-commons/helpers/utils-helper.cjs b/tools/e2e-commons/helpers/utils-helper.js similarity index 83% rename from tools/e2e-commons/helpers/utils-helper.cjs rename to tools/e2e-commons/helpers/utils-helper.js index 480e43fddea31..638d100a2b220 100644 --- a/tools/e2e-commons/helpers/utils-helper.cjs +++ b/tools/e2e-commons/helpers/utils-helper.js @@ -1,12 +1,11 @@ -const { execSync, exec } = require( 'child_process' ); -const config = require( 'config' ); -const fetch = require( 'node-fetch' ); -const fs = require( 'fs' ); -const path = require( 'path' ); -const logger = require( '../logger.cjs' ); -const { join } = require( 'path' ); +import { execSync, exec } from 'child_process'; +import config from 'config'; +import fetch from 'node-fetch'; +import fs from 'fs'; +import path from 'path'; +import logger from '../logger.js'; const { E2E_DEBUG } = process.env; -const BASE_DOCKER_CMD = 'pnpm jetpack docker --type e2e --name t1'; +export const BASE_DOCKER_CMD = 'pnpm jetpack docker --type e2e --name t1'; /** * Executes a shell command and return it as a Promise. @@ -14,7 +13,7 @@ const BASE_DOCKER_CMD = 'pnpm jetpack docker --type e2e --name t1'; * @param {string} cmd shell command * @return {Promise} output */ -async function execShellCommand( cmd ) { +export async function execShellCommand( cmd ) { return new Promise( resolve => { let result = ''; const cmdExec = exec( cmd, error => { @@ -36,11 +35,11 @@ async function execShellCommand( cmd ) { } ); } -function execSyncShellCommand( cmd ) { +export function execSyncShellCommand( cmd ) { return execSync( cmd ).toString(); } -async function resetWordpressInstall() { +export async function resetWordpressInstall() { const cmd = 'pnpm e2e-env reset'; await cancelPartnerPlan(); execSyncShellCommand( cmd ); @@ -59,7 +58,7 @@ async function cancelPartnerPlan() { * @param {page} page Playwright page object * @param {string} module Jetpack module name */ -async function activateModule( page, module ) { +export async function activateModule( page, module ) { const cliCmd = `jetpack module activate ${ module }`; const activeModulesCmd = 'option get jetpack_active_modules --format=json'; await execWpCommand( cliCmd ); @@ -73,7 +72,7 @@ async function activateModule( page, module ) { return true; } -async function execWpCommand( wpCmd, sendUrl = true ) { +export async function execWpCommand( wpCmd, sendUrl = true ) { const urlArgument = sendUrl ? `--url="${ resolveSiteUrl() }"` : ''; const cmd = `${ BASE_DOCKER_CMD } wp -- ${ wpCmd } ${ urlArgument }`; let result = await execShellCommand( cmd ); @@ -92,11 +91,11 @@ async function execWpCommand( wpCmd, sendUrl = true ) { return result; } -async function execContainerShellCommand( cmd ) { +export async function execContainerShellCommand( cmd ) { return execShellCommand( `${ BASE_DOCKER_CMD } -v exec-silent ${ cmd }` ); } -async function logDebugLog() { +export async function logDebugLog() { let log; try { log = execSyncShellCommand( `${ BASE_DOCKER_CMD } exec-silent cat wp-content/debug.log` ); @@ -126,7 +125,7 @@ async function logDebugLog() { } } -async function logAccessLog() { +export async function logAccessLog() { // const apacheLog = execSyncShellCommand( 'pnpm wp-env logs tests --watch=false' ); const apacheLog = 'EMPTY'; const escapedDate = new Date().toISOString().split( '.' )[ 0 ].replace( /:/g, '-' ); @@ -141,7 +140,7 @@ async function logAccessLog() { * @param {boolean} includeTimestamp if true, the current timestamp will be added as a prefix * @return {string} the formatted file path */ -function fileNameFormatter( filePath, includeTimestamp = true ) { +export function fileNameFormatter( filePath, includeTimestamp = true ) { const parts = path.parse( path.normalize( filePath ) ); let fileName = parts.name; const ext = parts.ext; @@ -162,12 +161,12 @@ function getConfigTestSite() { return config.get( `testSites.${ testSite }` ); } -function getSiteCredentials() { +export function getSiteCredentials() { const site = getConfigTestSite(); return { username: site.username, password: site.password, apiPassword: site.apiPassword }; } -function getDotComCredentials() { +export function getDotComCredentials() { const site = getConfigTestSite(); return { username: site.dotComAccount[ 0 ], @@ -177,7 +176,7 @@ function getDotComCredentials() { }; } -function getMailchimpCredentials() { +export function getMailchimpCredentials() { const site = getConfigTestSite(); return { username: site.mailchimpLogin[ 0 ], @@ -192,7 +191,7 @@ function getMailchimpCredentials() { * * @return {string} the file content, or undefined in file doesn't exist or cannot be read */ -function getReusableUrlFromFile() { +export function getReusableUrlFromFile() { let urlFromFile; try { urlFromFile = fs @@ -215,7 +214,7 @@ function getReusableUrlFromFile() { * 2. Configure a test site in local config and use a TEST_SITE env variable with the config property name. This overrides any value written in file * If none of the above is valid we throw an error */ -function resolveSiteUrl() { +export function resolveSiteUrl() { let url; if ( process.env.TEST_SITE ) { @@ -235,7 +234,7 @@ function resolveSiteUrl() { * * @param {string} url the string to to be validated as URL */ -function validateUrl( url ) { +export function validateUrl( url ) { if ( ! new URL( url ) ) { throw new Error( `Undefined or invalid url!` ); } @@ -246,13 +245,13 @@ function validateUrl( url ) { * * @return {boolean} true if site is local */ -function isLocalSite() { +export function isLocalSite() { return ! process.env.TEST_SITE; } -async function logEnvironment() { +export async function logEnvironment() { try { - const envFilePath = join( `${ config.get( 'dirs.output' ) }`, 'environment.json' ); + const envFilePath = path.join( `${ config.get( 'dirs.output' ) }`, 'environment.json' ); let env = { plugins: [] }; @@ -283,11 +282,11 @@ async function logEnvironment() { } } -async function getJetpackVersion() { +export async function getJetpackVersion() { let version; try { - const envFilePath = join( `${ config.get( 'dirs.output' ) }`, 'environment.json' ); + const envFilePath = path.join( `${ config.get( 'dirs.output' ) }`, 'environment.json' ); if ( ! fs.existsSync( envFilePath ) ) { await logEnvironment(); @@ -313,25 +312,3 @@ async function getJetpackVersion() { return version; } - -module.exports = { - execShellCommand, - execSyncShellCommand, - execContainerShellCommand, - resetWordpressInstall, - BASE_DOCKER_CMD, - activateModule, - execWpCommand, - logDebugLog, - logAccessLog, - fileNameFormatter, - getReusableUrlFromFile, - resolveSiteUrl, - validateUrl, - isLocalSite, - getSiteCredentials, - getDotComCredentials, - getMailchimpCredentials, - logEnvironment, - getJetpackVersion, -}; diff --git a/tools/e2e-commons/logger.cjs b/tools/e2e-commons/logger.js similarity index 89% rename from tools/e2e-commons/logger.cjs rename to tools/e2e-commons/logger.js index a485bb5572fff..93b6be4ca0e61 100644 --- a/tools/e2e-commons/logger.cjs +++ b/tools/e2e-commons/logger.js @@ -1,6 +1,6 @@ -const { createLogger, format, transports, addColors } = require( 'winston' ); -const config = require( 'config' ); -const path = require( 'path' ); +import { createLogger, format, transports, addColors } from 'winston'; +import config from 'config'; +import path from 'path'; const myCustomLevels = { levels: { @@ -47,7 +47,7 @@ const stringFormat = format.combine( ); // eslint-disable-next-line no-unused-vars -module.exports = createLogger( { +export default createLogger( { levels: myCustomLevels.levels, format: format.combine( format.timestamp( { diff --git a/tools/e2e-commons/pages/frontend/postFrontend.js b/tools/e2e-commons/pages/frontend/postFrontend.js index 87bd40de61bd4..ea6121c199946 100644 --- a/tools/e2e-commons/pages/frontend/postFrontend.js +++ b/tools/e2e-commons/pages/frontend/postFrontend.js @@ -1,5 +1,5 @@ import WpPage from '../wp-page.js'; -import { resolveSiteUrl } from '../../helpers/utils-helper.cjs'; +import { resolveSiteUrl } from '../../helpers/utils-helper.js'; export default class PostFrontendPage extends WpPage { constructor( page ) { diff --git a/tools/e2e-commons/pages/frontend/site-page.js b/tools/e2e-commons/pages/frontend/site-page.js index fa5de4d606f48..60d6f35d75a14 100644 --- a/tools/e2e-commons/pages/frontend/site-page.js +++ b/tools/e2e-commons/pages/frontend/site-page.js @@ -1,5 +1,5 @@ import WpPage from '../wp-page.js'; -import { resolveSiteUrl } from '../../helpers/utils-helper.cjs'; +import { resolveSiteUrl } from '../../helpers/utils-helper.js'; export default class SitePage extends WpPage { constructor( page ) { diff --git a/tools/e2e-commons/pages/page-actions.js b/tools/e2e-commons/pages/page-actions.js index d7c5d6f4212c6..a11ae974e318a 100644 --- a/tools/e2e-commons/pages/page-actions.js +++ b/tools/e2e-commons/pages/page-actions.js @@ -1,7 +1,7 @@ -import logger from '../logger.cjs'; +import logger from '../logger.js'; import chalk from 'chalk'; import config from 'config'; -import pwConfig from '../playwright.config.cjs'; +import pwConfig from '../playwright.config.mjs'; /** * This is an abstraction for most important page actions diff --git a/tools/e2e-commons/pages/wp-admin/block-editor.js b/tools/e2e-commons/pages/wp-admin/block-editor.js index ac0a9f3f68b26..969c698bb1102 100644 --- a/tools/e2e-commons/pages/wp-admin/block-editor.js +++ b/tools/e2e-commons/pages/wp-admin/block-editor.js @@ -1,6 +1,6 @@ import WpPage from '../wp-page.js'; -import logger from '../../logger.cjs'; -import { resolveSiteUrl } from '../../helpers/utils-helper.cjs'; +import logger from '../../logger.js'; +import { resolveSiteUrl } from '../../helpers/utils-helper.js'; import { waitForBlock } from '../../helpers/blocks-helper.js'; import { EditorCanvas } from './index.js'; diff --git a/tools/e2e-commons/pages/wp-admin/blocks/form.js b/tools/e2e-commons/pages/wp-admin/blocks/form.js index c15fb31e1fa8b..577e0231b4f0e 100644 --- a/tools/e2e-commons/pages/wp-admin/blocks/form.js +++ b/tools/e2e-commons/pages/wp-admin/blocks/form.js @@ -1,5 +1,5 @@ import EditorCanvas from './editor-canvas.js'; -import logger from '../../../logger.cjs'; +import logger from '../../../logger.js'; export default class FormBlock extends EditorCanvas { constructor( blockId, page ) { super( page, 'Form block' ); diff --git a/tools/e2e-commons/pages/wp-admin/blocks/mailchimp.js b/tools/e2e-commons/pages/wp-admin/blocks/mailchimp.js index eaeeb01523523..56412a163fc36 100644 --- a/tools/e2e-commons/pages/wp-admin/blocks/mailchimp.js +++ b/tools/e2e-commons/pages/wp-admin/blocks/mailchimp.js @@ -1,8 +1,8 @@ import { LoginPage, ConnectionsPage } from '../../wpcom/index.js'; -import logger from '../../../logger.cjs'; +import logger from '../../../logger.js'; import EditorCanvas from './editor-canvas.js'; import axios from 'axios'; -import { resolveSiteUrl } from '../../../helpers/utils-helper.cjs'; +import { resolveSiteUrl } from '../../../helpers/utils-helper.js'; export default class MailchimpBlock extends EditorCanvas { constructor( blockId, page ) { diff --git a/tools/e2e-commons/pages/wp-admin/dashboard.js b/tools/e2e-commons/pages/wp-admin/dashboard.js index 815d4d45d85dd..29d3d1e2d4f52 100644 --- a/tools/e2e-commons/pages/wp-admin/dashboard.js +++ b/tools/e2e-commons/pages/wp-admin/dashboard.js @@ -1,5 +1,5 @@ import WpPage from '../wp-page.js'; -import { resolveSiteUrl } from '../../helpers/utils-helper.cjs'; +import { resolveSiteUrl } from '../../helpers/utils-helper.js'; import PageActions from '../page-actions.js'; export default class DashboardPage extends WpPage { diff --git a/tools/e2e-commons/pages/wp-admin/jetpack-dashboard.js b/tools/e2e-commons/pages/wp-admin/jetpack-dashboard.js index d93fe96d6c0ff..72a0d7304ec30 100644 --- a/tools/e2e-commons/pages/wp-admin/jetpack-dashboard.js +++ b/tools/e2e-commons/pages/wp-admin/jetpack-dashboard.js @@ -1,6 +1,6 @@ import WpPage from '../wp-page.js'; -import logger from '../../logger.cjs'; -import { resolveSiteUrl } from '../../helpers/utils-helper.cjs'; +import logger from '../../logger.js'; +import { resolveSiteUrl } from '../../helpers/utils-helper.js'; export default class JetpackDashboardPage extends WpPage { constructor( page ) { diff --git a/tools/e2e-commons/pages/wp-admin/jetpack-my-plan.js b/tools/e2e-commons/pages/wp-admin/jetpack-my-plan.js index 2d71bf6c9a5be..10a2048a15d7e 100644 --- a/tools/e2e-commons/pages/wp-admin/jetpack-my-plan.js +++ b/tools/e2e-commons/pages/wp-admin/jetpack-my-plan.js @@ -1,6 +1,6 @@ import WpPage from '../wp-page.js'; -import logger from '../../logger.cjs'; -import { resolveSiteUrl } from '../../helpers/utils-helper.cjs'; +import logger from '../../logger.js'; +import { resolveSiteUrl } from '../../helpers/utils-helper.js'; export default class JetpackMyPlanPage extends WpPage { constructor( page ) { diff --git a/tools/e2e-commons/pages/wp-admin/jetpack.js b/tools/e2e-commons/pages/wp-admin/jetpack.js index fac0c55ef9481..e458b1c2b650a 100644 --- a/tools/e2e-commons/pages/wp-admin/jetpack.js +++ b/tools/e2e-commons/pages/wp-admin/jetpack.js @@ -1,6 +1,6 @@ import WpPage from '../wp-page.js'; -import logger from '../../logger.cjs'; -import { resolveSiteUrl } from '../../helpers/utils-helper.cjs'; +import logger from '../../logger.js'; +import { resolveSiteUrl } from '../../helpers/utils-helper.js'; export default class JetpackPage extends WpPage { constructor( page ) { diff --git a/tools/e2e-commons/pages/wp-admin/login.js b/tools/e2e-commons/pages/wp-admin/login.js index 79d06595cebba..541d0cdc3fbc6 100644 --- a/tools/e2e-commons/pages/wp-admin/login.js +++ b/tools/e2e-commons/pages/wp-admin/login.js @@ -1,7 +1,7 @@ import WpPage from '../wp-page.js'; -import logger from '../../logger.cjs'; +import logger from '../../logger.js'; import { takeScreenshot } from '../../reporters/index.js'; -import { getSiteCredentials, resolveSiteUrl } from '../../helpers/utils-helper.cjs'; +import { getSiteCredentials, resolveSiteUrl } from '../../helpers/utils-helper.js'; export default class WPLoginPage extends WpPage { constructor( page ) { diff --git a/tools/e2e-commons/pages/wp-admin/plugins.js b/tools/e2e-commons/pages/wp-admin/plugins.js index d89507bf4c4ab..697b78c948eaf 100644 --- a/tools/e2e-commons/pages/wp-admin/plugins.js +++ b/tools/e2e-commons/pages/wp-admin/plugins.js @@ -1,5 +1,5 @@ import WpPage from '../wp-page.js'; -import { resolveSiteUrl } from '../../helpers/utils-helper.cjs'; +import { resolveSiteUrl } from '../../helpers/utils-helper.js'; export default class PluginsPage extends WpPage { constructor( page ) { diff --git a/tools/e2e-commons/pages/wp-admin/recommendations.js b/tools/e2e-commons/pages/wp-admin/recommendations.js index 5009c12e9f0cc..1bb043928b057 100644 --- a/tools/e2e-commons/pages/wp-admin/recommendations.js +++ b/tools/e2e-commons/pages/wp-admin/recommendations.js @@ -1,5 +1,5 @@ import WpPage from '../wp-page.js'; -import { resolveSiteUrl } from '../../helpers/utils-helper.cjs'; +import { resolveSiteUrl } from '../../helpers/utils-helper.js'; export default class RecommendationsPage extends WpPage { constructor( page ) { diff --git a/tools/e2e-commons/pages/wp-admin/site-editor.js b/tools/e2e-commons/pages/wp-admin/site-editor.js index ee2f806939a9c..3cd4724db0b04 100644 --- a/tools/e2e-commons/pages/wp-admin/site-editor.js +++ b/tools/e2e-commons/pages/wp-admin/site-editor.js @@ -1,6 +1,6 @@ import WpPage from '../wp-page.js'; -import logger from '../../logger.cjs'; -import { resolveSiteUrl } from '../../helpers/utils-helper.cjs'; +import logger from '../../logger.js'; +import { resolveSiteUrl } from '../../helpers/utils-helper.js'; import { waitForBlock } from '../../helpers/blocks-helper.js'; import { EditorCanvas } from './index.js'; import { expect } from '@playwright/test'; diff --git a/tools/e2e-commons/pages/wpcom/authorize.js b/tools/e2e-commons/pages/wpcom/authorize.js index dfb7e5dca5a1a..7285770d47f57 100644 --- a/tools/e2e-commons/pages/wpcom/authorize.js +++ b/tools/e2e-commons/pages/wpcom/authorize.js @@ -1,5 +1,5 @@ import WpPage from '../wp-page.js'; -import logger from '../../logger.cjs'; +import logger from '../../logger.js'; export default class AuthorizePage extends WpPage { constructor( page ) { diff --git a/tools/e2e-commons/pages/wpcom/complete-plan.js b/tools/e2e-commons/pages/wpcom/complete-plan.js index 0c7f096a9f530..d8b5fce569ae9 100644 --- a/tools/e2e-commons/pages/wpcom/complete-plan.js +++ b/tools/e2e-commons/pages/wpcom/complete-plan.js @@ -1,5 +1,5 @@ import WpPage from '../wp-page.js'; -import logger from '../../logger.cjs'; +import logger from '../../logger.js'; export default class CompletePage extends WpPage { constructor( page ) { diff --git a/tools/e2e-commons/pages/wpcom/connections.js b/tools/e2e-commons/pages/wpcom/connections.js index c5526bb82b474..18f49794b8ee1 100644 --- a/tools/e2e-commons/pages/wpcom/connections.js +++ b/tools/e2e-commons/pages/wpcom/connections.js @@ -1,5 +1,5 @@ import WpPage from '../wp-page.js'; -import { getMailchimpCredentials } from '../../helpers/utils-helper.cjs'; +import { getMailchimpCredentials } from '../../helpers/utils-helper.js'; export default class ConnectionsPage extends WpPage { constructor( page ) { diff --git a/tools/e2e-commons/pages/wpcom/login.js b/tools/e2e-commons/pages/wpcom/login.js index 6cb52117536b8..f5701dbd54af9 100644 --- a/tools/e2e-commons/pages/wpcom/login.js +++ b/tools/e2e-commons/pages/wpcom/login.js @@ -1,6 +1,6 @@ import WpPage from '../wp-page.js'; -import logger from '../../logger.cjs'; -import { getDotComCredentials } from '../../helpers/utils-helper.cjs'; +import logger from '../../logger.js'; +import { getDotComCredentials } from '../../helpers/utils-helper.js'; import PageActions from '../page-actions.js'; export default class LoginPage extends WpPage { diff --git a/tools/e2e-commons/pages/wpcom/pick-a-plan.js b/tools/e2e-commons/pages/wpcom/pick-a-plan.js index 4dfc602d79d70..828e7a6410d76 100644 --- a/tools/e2e-commons/pages/wpcom/pick-a-plan.js +++ b/tools/e2e-commons/pages/wpcom/pick-a-plan.js @@ -1,5 +1,5 @@ import WpPage from '../wp-page.js'; -import logger from '../../logger.cjs'; +import logger from '../../logger.js'; export default class PickAPlanPage extends WpPage { constructor( page ) { diff --git a/tools/e2e-commons/playwright.config.cjs b/tools/e2e-commons/playwright.config.cjs deleted file mode 100644 index 227ea023ce3e1..0000000000000 --- a/tools/e2e-commons/playwright.config.cjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require( './config/playwright.config.default.cjs' ); diff --git a/tools/e2e-commons/playwright.config.mjs b/tools/e2e-commons/playwright.config.mjs new file mode 100644 index 0000000000000..6e727dd077f5d --- /dev/null +++ b/tools/e2e-commons/playwright.config.mjs @@ -0,0 +1 @@ +export { default } from './config/playwright.config.default.mjs'; diff --git a/tools/e2e-commons/reporters/index.js b/tools/e2e-commons/reporters/index.js index 1f87805b285ea..b66b42c9ed9d8 100644 --- a/tools/e2e-commons/reporters/index.js +++ b/tools/e2e-commons/reporters/index.js @@ -1,3 +1,3 @@ -import { takeScreenshot } from './screenshot.cjs'; +import { takeScreenshot } from './screenshot.js'; export { takeScreenshot }; diff --git a/tools/e2e-commons/reporters/reporter.cjs b/tools/e2e-commons/reporters/reporter.js similarity index 90% rename from tools/e2e-commons/reporters/reporter.cjs rename to tools/e2e-commons/reporters/reporter.js index ca065de750003..9e24c60dbf489 100644 --- a/tools/e2e-commons/reporters/reporter.cjs +++ b/tools/e2e-commons/reporters/reporter.js @@ -1,6 +1,6 @@ -const logger = require( '../logger.cjs' ); +import logger from '../logger.js'; -class LogReporter { +export default class LogReporter { onBegin( config, suite ) { logger.debug( `Starting the run for ${ this.getSuiteName( suite ) }` ); } @@ -38,4 +38,3 @@ class LogReporter { return level.titlePath().join( ' ' ).trim(); } } -module.exports = LogReporter; diff --git a/tools/e2e-commons/reporters/screenshot.cjs b/tools/e2e-commons/reporters/screenshot.js similarity index 69% rename from tools/e2e-commons/reporters/screenshot.cjs rename to tools/e2e-commons/reporters/screenshot.js index eee217f105ebc..bd995fa47fea2 100644 --- a/tools/e2e-commons/reporters/screenshot.cjs +++ b/tools/e2e-commons/reporters/screenshot.js @@ -1,8 +1,8 @@ -const path = require( 'path' ); -const config = require( 'config' ); -const logger = require( '../logger.cjs' ); -const fs = require( 'fs' ); -const { fileNameFormatter } = require( '../helpers/utils-helper.cjs' ); +import path from 'path'; +import config from 'config'; +import logger from '../logger.js'; +import fs from 'fs'; +import { fileNameFormatter } from '../helpers/utils-helper.js'; /** * Takes a screenshot of the given page @@ -12,7 +12,7 @@ const { fileNameFormatter } = require( '../helpers/utils-helper.cjs' ); * @param {Object} allure instance of allure reporter * @return {Promise} */ -async function takeScreenshot( page, fileName, allure ) { +export async function takeScreenshot( page, fileName, allure ) { let filePath; try { @@ -32,5 +32,3 @@ async function takeScreenshot( page, fileName, allure ) { return filePath; } - -module.exports = { takeScreenshot };