diff --git a/.github/actions/e2e/run-log-tests/action.yml b/.github/actions/e2e/run-log-tests/action.yml index 8707bc46394..7265d598b40 100644 --- a/.github/actions/e2e/run-log-tests/action.yml +++ b/.github/actions/e2e/run-log-tests/action.yml @@ -9,10 +9,10 @@ runs: # Use +e to trap errors when running E2E tests. shell: /bin/bash +e {0} run: | - npm run test:e2e -- --json --outputFile="$E2E_RESULT_FILEPATH" --NODE_ENV="$NODE_ENV" + npm run test:e2e-ci if [[ -f "$E2E_RESULT_FILEPATH" ]]; then - E2E_NUM_FAILED_TEST_SUITES=$(cat "$E2E_RESULT_FILEPATH" | jq '.numFailedTestSuites') + E2E_NUM_FAILED_TEST_SUITES=$(cat "$E2E_RESULT_FILEPATH" | jq '.stats["unexpected"]') echo "FIRST_RUN_FAILED_TEST_SUITES=$(echo $E2E_NUM_FAILED_TEST_SUITES)" >> $GITHUB_OUTPUT if [[ ${E2E_NUM_FAILED_TEST_SUITES} -gt 0 ]]; then echo "::notice::${E2E_NUM_FAILED_TEST_SUITES} test suite(s) failed in the first run but we will try (it) them again in the second run." @@ -30,11 +30,11 @@ runs: shell: bash # Filter failed E2E files from the result JSON file, and re-run them. run: | - cat "$E2E_RESULT_FILEPATH" | jq '.testResults[] | select(.status == "failed") | .name' | xargs npm run test:e2e -- --NODE_ENV="$NODE_ENV" + npm run test:e2e-ci $(cat $E2E_RESULT_FILEPATH | jq -r '[.suites[] | (if has("suites") then .suites[] | .specs[] else .specs[] end) | select(.tests[].status == "unexpected") | .file] | unique | .[]') # Archive screenshots if any - name: Archive e2e test screenshots & logs - if: ${{ failure() }} + if: ${{ always() }} uses: actions/upload-artifact@v4 with: name: wp(${{ env.E2E_WP_VERSION }})-wc(${{ env.E2E_WC_VERSION }})-${{ env.E2E_GROUP }}-${{ env.E2E_BRANCH }} @@ -42,6 +42,7 @@ runs: screenshots tests/e2e/screenshots tests/e2e/docker/wordpress/wp-content/debug.log + tests/e2e-pw/test-results ${{ env.E2E_RESULT_FILEPATH }} if-no-files-found: ignore retention-days: 14 diff --git a/.github/workflows/e2e-pull-request.yml b/.github/workflows/e2e-pull-request.yml index 4ed61a3882b..afb5dfecdfb 100644 --- a/.github/workflows/e2e-pull-request.yml +++ b/.github/workflows/e2e-pull-request.yml @@ -30,7 +30,7 @@ env: E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }} E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }} E2E_USE_LOCAL_SERVER: false - E2E_RESULT_FILEPATH: 'tests/e2e/results.json' + E2E_RESULT_FILEPATH: 'tests/e2e-pw/results.json' WCPAY_USE_BUILD_ARTIFACT: ${{ inputs.wcpay-use-build-artifact }} WCPAY_ARTIFACT_DIRECTORY: 'zipfile' NODE_ENV: 'test' @@ -74,5 +74,9 @@ jobs: - name: Setup E2E environment uses: ./.github/actions/e2e/env-setup + - name: Install Playwright + shell: bash + run: npx playwright install chromium + - name: Run tests, upload screenshots & logs uses: ./.github/actions/e2e/run-log-tests diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 1d1f0b1bd71..c68a4d61a81 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -22,7 +22,7 @@ env: E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }} E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }} E2E_USE_LOCAL_SERVER: false - E2E_RESULT_FILEPATH: 'tests/e2e/results.json' + E2E_RESULT_FILEPATH: 'tests/e2e-pw/results.json' WC_MIN_SUPPORTED_VERSION: '7.6.0' NODE_ENV: 'test' FORCE_E2E_DEPS_SETUP: true @@ -64,6 +64,10 @@ jobs: - name: Setup E2E environment uses: ./.github/actions/e2e/env-setup + - name: Install Playwright + shell: bash + run: npx playwright install chromium + - name: Run tests, upload screenshots & logs uses: ./.github/actions/e2e/run-log-tests @@ -116,5 +120,9 @@ jobs: - name: Setup E2E environment uses: ./.github/actions/e2e/env-setup + - name: Install Playwright + shell: bash + run: npx playwright install chromium + - name: Run tests, upload screenshots & logs uses: ./.github/actions/e2e/run-log-tests diff --git a/changelog/dev-10238-update-e2e-tests-all-workflow b/changelog/dev-10238-update-e2e-tests-all-workflow new file mode 100644 index 00000000000..6861f616e0d --- /dev/null +++ b/changelog/dev-10238-update-e2e-tests-all-workflow @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Update Github actions and workflows. Change e2e tests directory structure. diff --git a/tests/e2e-pw/playwright.config.ts b/tests/e2e-pw/playwright.config.ts index f5911d09ede..b44483820da 100644 --- a/tests/e2e-pw/playwright.config.ts +++ b/tests/e2e-pw/playwright.config.ts @@ -9,7 +9,30 @@ import path from 'path'; config( { path: path.resolve( __dirname, '../e2e/config', '.env' ) } ); config( { path: path.resolve( __dirname, '../e2e/config', 'local.env' ) } ); -const { BASE_URL } = process.env; +const { BASE_URL, E2E_GROUP, E2E_BRANCH } = process.env; + +const validGroups = [ 'wcpay', 'subscriptions' ]; +const validBranches = [ 'merchant', 'shopper' ]; + +const buildTestDir = ( group: string, branch: string ) => { + const baseDir = `\/specs`; + + if ( ! group || ! validGroups.includes( group ) ) { + return baseDir; + } + + if ( ! branch || ! validBranches.includes( branch ) ) { + return `${ baseDir }\/${ group }`; + } + + return `${ baseDir }\/${ group }\/${ branch }`; +}; + +const getTestMatch = ( group: string, branch: string ) => { + const testDir = buildTestDir( group, branch ); + + return new RegExp( `${ testDir }\/.*\.spec\.ts` ); +}; /** * See https://playwright.dev/docs/test-configuration. @@ -29,6 +52,7 @@ export default defineConfig( { ? [ // If running on CI, also use the GitHub Actions reporter [ 'github' ], + [ 'json', { outputFile: 'results.json' } ], [ 'html' ], ] : [ [ 'html', { open: 'never' } ] ], @@ -43,12 +67,17 @@ export default defineConfig( { }, timeout: 120 * 1000, // Default is 30s, somteimes it is not enough for local tests due to long setup. expect: { - toHaveScreenshot: { maxDiffPixelRatio: 0.025 }, + toHaveScreenshot: { + maxDiffPixelRatio: + process.env.E2E_WC_VERSION === '7.7.0' ? 0.035 : 0.025, + }, //=* Increase expect timeout to 10 seconds. See https://playwright.dev/docs/test-timeouts#set-expect-timeout-in-the-config.*/ timeout: 20 * 1000, }, snapshotPathTemplate: '{testDir}/__snapshots__/{testFilePath}/{arg}{ext}', + testMatch: getTestMatch( E2E_GROUP, E2E_BRANCH ), + /* Configure projects for major browsers */ projects: [ { @@ -58,15 +87,8 @@ export default defineConfig( { dependencies: [ 'setup' ], }, { - name: 'merchant', - use: { ...devices[ 'Desktop Chrome' ] }, - testDir: './specs/merchant', - dependencies: [ 'setup' ], - }, - { - name: 'shopper', + name: 'chromium', use: { ...devices[ 'Desktop Chrome' ] }, - testDir: './specs/shopper', dependencies: [ 'setup' ], }, // Setup project diff --git a/tests/e2e-pw/specs/merchant/__snapshots__/merchant-admin-analytics.spec.ts/Admin-order-analytics-should-load-without-any-errors-1.png b/tests/e2e-pw/specs/__snapshots__/wcpay/merchant/merchant-admin-analytics.spec.ts/Admin-order-analytics-should-load-without-any-errors-1.png similarity index 100% rename from tests/e2e-pw/specs/merchant/__snapshots__/merchant-admin-analytics.spec.ts/Admin-order-analytics-should-load-without-any-errors-1.png rename to tests/e2e-pw/specs/__snapshots__/wcpay/merchant/merchant-admin-analytics.spec.ts/Admin-order-analytics-should-load-without-any-errors-1.png diff --git a/tests/e2e-pw/specs/merchant/__snapshots__/merchant-admin-deposits.spec.ts/Merchant-deposits-Select-deposits-list-advanced-filters-1.png b/tests/e2e-pw/specs/__snapshots__/wcpay/merchant/merchant-admin-deposits.spec.ts/Merchant-deposits-Select-deposits-list-advanced-filters-1.png similarity index 100% rename from tests/e2e-pw/specs/merchant/__snapshots__/merchant-admin-deposits.spec.ts/Merchant-deposits-Select-deposits-list-advanced-filters-1.png rename to tests/e2e-pw/specs/__snapshots__/wcpay/merchant/merchant-admin-deposits.spec.ts/Merchant-deposits-Select-deposits-list-advanced-filters-1.png diff --git a/tests/e2e-pw/specs/merchant/__snapshots__/merchant-admin-transactions.spec.ts/Admin-transactions-page-should-load-without-errors-1.png b/tests/e2e-pw/specs/__snapshots__/wcpay/merchant/merchant-admin-transactions.spec.ts/Admin-transactions-page-should-load-without-errors-1.png similarity index 100% rename from tests/e2e-pw/specs/merchant/__snapshots__/merchant-admin-transactions.spec.ts/Admin-transactions-page-should-load-without-errors-1.png rename to tests/e2e-pw/specs/__snapshots__/wcpay/merchant/merchant-admin-transactions.spec.ts/Admin-transactions-page-should-load-without-errors-1.png diff --git a/tests/e2e-pw/specs/merchant/__snapshots__/merchant-disputes-view-details-via-order-notice.spec.ts/Disputes-View-dispute-details-via-disputed-o-f9e9d-ils-when-disputed-order-notice-button-clicked-1.png b/tests/e2e-pw/specs/__snapshots__/wcpay/merchant/merchant-disputes-view-details-via-order-notice.spec.ts/Disputes-View-dispute-details-via-disputed-o-f9e9d-ils-when-disputed-order-notice-button-clicked-1.png similarity index 100% rename from tests/e2e-pw/specs/merchant/__snapshots__/merchant-disputes-view-details-via-order-notice.spec.ts/Disputes-View-dispute-details-via-disputed-o-f9e9d-ils-when-disputed-order-notice-button-clicked-1.png rename to tests/e2e-pw/specs/__snapshots__/wcpay/merchant/merchant-disputes-view-details-via-order-notice.spec.ts/Disputes-View-dispute-details-via-disputed-o-f9e9d-ils-when-disputed-order-notice-button-clicked-1.png diff --git a/tests/e2e-pw/specs/merchant/__snapshots__/multi-currency-on-boarding.spec.ts/Multi-currency-on-boarding-Currency-selection--7b0d9-submit-button-when-no-currencies-are-selected-1.png b/tests/e2e-pw/specs/__snapshots__/wcpay/merchant/multi-currency-on-boarding.spec.ts/Multi-currency-on-boarding-Currency-selection--7b0d9-submit-button-when-no-currencies-are-selected-1.png similarity index 100% rename from tests/e2e-pw/specs/merchant/__snapshots__/multi-currency-on-boarding.spec.ts/Multi-currency-on-boarding-Currency-selection--7b0d9-submit-button-when-no-currencies-are-selected-1.png rename to tests/e2e-pw/specs/__snapshots__/wcpay/merchant/multi-currency-on-boarding.spec.ts/Multi-currency-on-boarding-Currency-selection--7b0d9-submit-button-when-no-currencies-are-selected-1.png diff --git a/tests/e2e-pw/specs/merchant/__snapshots__/multi-currency-on-boarding.spec.ts/Multi-currency-on-boarding-Geolocation-feature-83665-tch-by-geolocation-correctly-with-USD-and-GBP-1.png b/tests/e2e-pw/specs/__snapshots__/wcpay/merchant/multi-currency-on-boarding.spec.ts/Multi-currency-on-boarding-Geolocation-feature-83665-tch-by-geolocation-correctly-with-USD-and-GBP-1.png similarity index 100% rename from tests/e2e-pw/specs/merchant/__snapshots__/multi-currency-on-boarding.spec.ts/Multi-currency-on-boarding-Geolocation-feature-83665-tch-by-geolocation-correctly-with-USD-and-GBP-1.png rename to tests/e2e-pw/specs/__snapshots__/wcpay/merchant/multi-currency-on-boarding.spec.ts/Multi-currency-on-boarding-Geolocation-feature-83665-tch-by-geolocation-correctly-with-USD-and-GBP-1.png diff --git a/tests/e2e-pw/specs/merchant/__snapshots__/multi-currency-on-boarding.spec.ts/Multi-currency-on-boarding-Geolocation-feature-d8568-tch-by-geolocation-correctly-with-USD-and-GBP-2.png b/tests/e2e-pw/specs/__snapshots__/wcpay/merchant/multi-currency-on-boarding.spec.ts/Multi-currency-on-boarding-Geolocation-feature-d8568-tch-by-geolocation-correctly-with-USD-and-GBP-2.png similarity index 100% rename from tests/e2e-pw/specs/merchant/__snapshots__/multi-currency-on-boarding.spec.ts/Multi-currency-on-boarding-Geolocation-feature-d8568-tch-by-geolocation-correctly-with-USD-and-GBP-2.png rename to tests/e2e-pw/specs/__snapshots__/wcpay/merchant/multi-currency-on-boarding.spec.ts/Multi-currency-on-boarding-Geolocation-feature-d8568-tch-by-geolocation-correctly-with-USD-and-GBP-2.png diff --git a/tests/e2e-pw/specs/merchant/__snapshots__/multi-currency.spec.ts/Multi-currency-page-load-without-any-errors-1.png b/tests/e2e-pw/specs/__snapshots__/wcpay/merchant/multi-currency.spec.ts/Multi-currency-page-load-without-any-errors-1.png similarity index 100% rename from tests/e2e-pw/specs/merchant/__snapshots__/multi-currency.spec.ts/Multi-currency-page-load-without-any-errors-1.png rename to tests/e2e-pw/specs/__snapshots__/wcpay/merchant/multi-currency.spec.ts/Multi-currency-page-load-without-any-errors-1.png diff --git a/tests/e2e-pw/specs/merchant/merchant-subscriptions-renew-action-scheduler.spec.ts b/tests/e2e-pw/specs/subscriptions/merchant/merchant-subscriptions-renew-action-scheduler.spec.ts similarity index 78% rename from tests/e2e-pw/specs/merchant/merchant-subscriptions-renew-action-scheduler.spec.ts rename to tests/e2e-pw/specs/subscriptions/merchant/merchant-subscriptions-renew-action-scheduler.spec.ts index 09f91cde677..380f8014393 100644 --- a/tests/e2e-pw/specs/merchant/merchant-subscriptions-renew-action-scheduler.spec.ts +++ b/tests/e2e-pw/specs/subscriptions/merchant/merchant-subscriptions-renew-action-scheduler.spec.ts @@ -6,18 +6,18 @@ import { test, expect } from '@playwright/test'; /** * Internal dependencies */ -import { describeif, getMerchant, getShopper } from '../../utils/helpers'; -import * as shopper from '../../utils/shopper'; -import { config } from '../../config/default'; +import { describeif, getMerchant, getShopper } from '../../../utils/helpers'; +import * as shopper from '../../../utils/shopper'; +import { config } from '../../../config/default'; import { products, shouldRunActionSchedulerTests, shouldRunSubscriptionsTests, -} from '../../utils/constants'; +} from '../../../utils/constants'; import { goToActionScheduler, goToSubscriptions, -} from '../../utils/merchant-navigation'; +} from '../../../utils/merchant-navigation'; // Run the tests if the two 'skip' environment variables are not set. describeif( shouldRunSubscriptionsTests && shouldRunActionSchedulerTests )( @@ -29,8 +29,6 @@ describeif( shouldRunSubscriptionsTests && shouldRunActionSchedulerTests )( const customerBillingConfig = config.addresses[ 'subscriptions-customer' ].billing; - let subscriptionId: string; - test.beforeAll( async ( { browser }, { project } ) => { const { shopperPage } = await getShopper( browser, @@ -48,10 +46,6 @@ describeif( shouldRunSubscriptionsTests && shouldRunActionSchedulerTests )( await expect( shopperPage.getByRole( 'heading', { name: 'Order received' } ) ).toBeVisible(); - - subscriptionId = await shopperPage - .getByLabel( 'View subscription number' ) - .innerText(); } ); test( 'should renew a subscription with action scheduler', async ( { @@ -81,12 +75,8 @@ describeif( shouldRunSubscriptionsTests && shouldRunActionSchedulerTests )( // Go to Subscriptions and verify the subscription renewal await goToSubscriptions( merchantPage ); - const numericSubscriptionId = subscriptionId.substring( 1 ); - await expect( - merchantPage - .locator( `#order-${ numericSubscriptionId }` ) - .getByRole( 'cell', { name: '2', exact: true } ) + merchantPage.getByRole( 'cell', { name: '2', exact: true } ) ).toBeVisible(); } ); } diff --git a/tests/e2e-pw/specs/merchant/merchant-subscriptions-renew.spec.ts b/tests/e2e-pw/specs/subscriptions/merchant/merchant-subscriptions-renew.spec.ts similarity index 85% rename from tests/e2e-pw/specs/merchant/merchant-subscriptions-renew.spec.ts rename to tests/e2e-pw/specs/subscriptions/merchant/merchant-subscriptions-renew.spec.ts index dc8c8e0f89d..8661d460b03 100644 --- a/tests/e2e-pw/specs/merchant/merchant-subscriptions-renew.spec.ts +++ b/tests/e2e-pw/specs/subscriptions/merchant/merchant-subscriptions-renew.spec.ts @@ -6,19 +6,19 @@ import { test, expect } from '@playwright/test'; /** * Internal dependencies */ -import RestAPI from '../../utils/rest-api'; -import { config } from '../../config/default'; -import { describeif, getMerchant, getShopper } from '../../utils/helpers'; +import RestAPI from '../../../utils/rest-api'; +import { config } from '../../../config/default'; +import { describeif, getMerchant, getShopper } from '../../../utils/helpers'; import { emptyCart, fillCardDetails, focusPlaceOrderButton, placeOrder, setupProductCheckout, -} from '../../utils/shopper'; -import { goToShop } from '../../utils/shopper-navigation'; -import { goToSubscriptionPage } from '../../utils/merchant-navigation'; -import { shouldRunSubscriptionsTests } from '../../utils/constants'; +} from '../../../utils/shopper'; +import { goToShop } from '../../../utils/shopper-navigation'; +import { goToSubscriptionPage } from '../../../utils/merchant-navigation'; +import { shouldRunSubscriptionsTests } from '../../../utils/constants'; const productName = 'Subscription signup fee product'; const customerBillingConfig = diff --git a/tests/e2e-pw/specs/merchant/merchant-subscriptions-settings.spec.ts b/tests/e2e-pw/specs/subscriptions/merchant/merchant-subscriptions-settings.spec.ts similarity index 68% rename from tests/e2e-pw/specs/merchant/merchant-subscriptions-settings.spec.ts rename to tests/e2e-pw/specs/subscriptions/merchant/merchant-subscriptions-settings.spec.ts index a2cfe8fcfcf..a685727c0cb 100644 --- a/tests/e2e-pw/specs/merchant/merchant-subscriptions-settings.spec.ts +++ b/tests/e2e-pw/specs/subscriptions/merchant/merchant-subscriptions-settings.spec.ts @@ -2,9 +2,9 @@ * External dependencies */ import test, { expect } from 'playwright/test'; -import { describeif, useMerchant } from '../../utils/helpers'; -import { shouldRunSubscriptionsTests } from '../../utils/constants'; -import { goToWooCommerceSettings } from '../../utils/merchant-navigation'; +import { describeif, useMerchant } from '../../../utils/helpers'; +import { shouldRunSubscriptionsTests } from '../../../utils/constants'; +import { goToWooCommerceSettings } from '../../../utils/merchant-navigation'; describeif( shouldRunSubscriptionsTests )( 'WooCommerce > Settings > Subscriptions', @@ -21,9 +21,11 @@ describeif( shouldRunSubscriptionsTests )( await expect( menuItem ).toBeVisible(); // An alternative way to verify the subscriptions menu page is active, avoiding the active tab classname. - const heading = await page.getByRole( 'heading', { - name: 'Subscriptions', - } ); + const heading = await page + .getByRole( 'heading', { + name: 'Subscriptions', + } ) + .first(); await expect( heading ).toBeVisible(); } ); } diff --git a/tests/e2e-pw/specs/shopper/shopper-subscriptions-manage-payments.spec.ts b/tests/e2e-pw/specs/subscriptions/shopper/shopper-subscriptions-manage-payments.spec.ts similarity index 87% rename from tests/e2e-pw/specs/shopper/shopper-subscriptions-manage-payments.spec.ts rename to tests/e2e-pw/specs/subscriptions/shopper/shopper-subscriptions-manage-payments.spec.ts index 53bffb11da0..4da007cb456 100644 --- a/tests/e2e-pw/specs/shopper/shopper-subscriptions-manage-payments.spec.ts +++ b/tests/e2e-pw/specs/subscriptions/shopper/shopper-subscriptions-manage-payments.spec.ts @@ -6,11 +6,14 @@ import test, { expect, Page } from '@playwright/test'; /** * Internal dependencies */ -import { config } from '../../config/default'; -import { products, shouldRunSubscriptionsTests } from '../../utils/constants'; -import { describeif, getShopper } from '../../utils/helpers'; -import * as shopper from '../../utils/shopper'; -import * as navigation from '../../utils/shopper-navigation'; +import { config } from '../../../config/default'; +import { + products, + shouldRunSubscriptionsTests, +} from '../../../utils/constants'; +import { describeif, getShopper } from '../../../utils/helpers'; +import * as shopper from '../../../utils/shopper'; +import * as navigation from '../../../utils/shopper-navigation'; const navigateToSubscriptionDetails = async ( page: Page, diff --git a/tests/e2e-pw/specs/shopper/shopper-subscriptions-purchase-free-trial.spec.ts b/tests/e2e-pw/specs/subscriptions/shopper/shopper-subscriptions-purchase-free-trial.spec.ts similarity index 92% rename from tests/e2e-pw/specs/shopper/shopper-subscriptions-purchase-free-trial.spec.ts rename to tests/e2e-pw/specs/subscriptions/shopper/shopper-subscriptions-purchase-free-trial.spec.ts index 275a99752cc..a9e22e79a70 100644 --- a/tests/e2e-pw/specs/shopper/shopper-subscriptions-purchase-free-trial.spec.ts +++ b/tests/e2e-pw/specs/subscriptions/shopper/shopper-subscriptions-purchase-free-trial.spec.ts @@ -6,25 +6,28 @@ import test, { Page, expect } from '@playwright/test'; /** * Internal dependencies */ -import { shouldRunSubscriptionsTests } from '../../utils/constants'; -import { describeif, getMerchant, getShopper } from '../../utils/helpers'; -import { config } from '../../config/default'; +import { shouldRunSubscriptionsTests } from '../../../utils/constants'; +import { describeif, getMerchant, getShopper } from '../../../utils/helpers'; +import { config } from '../../../config/default'; import { confirmCardAuthentication, emptyCart, fillCardDetails, setupCheckout, -} from '../../utils/shopper'; +} from '../../../utils/shopper'; import { goToCart, goToProductPageBySlug, -} from '../../utils/shopper-navigation'; -import { goToOrder, goToSubscriptions } from '../../utils/merchant-navigation'; +} from '../../../utils/shopper-navigation'; +import { + goToOrder, + goToSubscriptions, +} from '../../../utils/merchant-navigation'; import { activateMulticurrency, deactivateMulticurrency, isMulticurrencyEnabled, -} from '../../utils/merchant'; +} from '../../../utils/merchant'; const nowLocal = new Date(); const nowUTC = new Date( diff --git a/tests/e2e-pw/specs/shopper/shopper-subscriptions-purchase-multiple-subscriptions.spec.ts b/tests/e2e-pw/specs/subscriptions/shopper/shopper-subscriptions-purchase-multiple-subscriptions.spec.ts similarity index 91% rename from tests/e2e-pw/specs/shopper/shopper-subscriptions-purchase-multiple-subscriptions.spec.ts rename to tests/e2e-pw/specs/subscriptions/shopper/shopper-subscriptions-purchase-multiple-subscriptions.spec.ts index 04fe7227f86..b4b2fd015a1 100644 --- a/tests/e2e-pw/specs/shopper/shopper-subscriptions-purchase-multiple-subscriptions.spec.ts +++ b/tests/e2e-pw/specs/subscriptions/shopper/shopper-subscriptions-purchase-multiple-subscriptions.spec.ts @@ -6,25 +6,25 @@ import test, { Page, expect } from '@playwright/test'; /** * Internal dependencies */ -import { shouldRunSubscriptionsTests } from '../../utils/constants'; -import { describeif, getMerchant, getShopper } from '../../utils/helpers'; -import { config } from '../../config/default'; +import { shouldRunSubscriptionsTests } from '../../../utils/constants'; +import { describeif, getMerchant, getShopper } from '../../../utils/helpers'; +import { config } from '../../../config/default'; import { emptyCart, fillCardDetails, placeOrder, setupProductCheckout, -} from '../../utils/shopper'; +} from '../../../utils/shopper'; import { goToShop, goToShopWithCurrency, goToSubscriptions, -} from '../../utils/shopper-navigation'; +} from '../../../utils/shopper-navigation'; import { activateMulticurrency, deactivateMulticurrency, restoreCurrencies, -} from '../../utils/merchant'; +} from '../../../utils/merchant'; const products = { 'Subscription no signup fee product': 'subscription-no-signup-fee-product', diff --git a/tests/e2e-pw/specs/shopper/shopper-subscriptions-purchase-no-signup-fee.spec.ts b/tests/e2e-pw/specs/subscriptions/shopper/shopper-subscriptions-purchase-no-signup-fee.spec.ts similarity index 68% rename from tests/e2e-pw/specs/shopper/shopper-subscriptions-purchase-no-signup-fee.spec.ts rename to tests/e2e-pw/specs/subscriptions/shopper/shopper-subscriptions-purchase-no-signup-fee.spec.ts index 626c42771d5..d6b1948961d 100644 --- a/tests/e2e-pw/specs/shopper/shopper-subscriptions-purchase-no-signup-fee.spec.ts +++ b/tests/e2e-pw/specs/subscriptions/shopper/shopper-subscriptions-purchase-no-signup-fee.spec.ts @@ -6,16 +6,24 @@ import test, { expect } from '@playwright/test'; /** * Internal dependencies */ -import { shouldRunSubscriptionsTests } from '../../utils/constants'; -import { describeif, getMerchant, getShopper } from '../../utils/helpers'; -import { config } from '../../config/default'; -import { goToSubscriptions, goToOrder } from '../../utils/merchant-navigation'; +import { shouldRunSubscriptionsTests } from '../../../utils/constants'; +import { describeif, getMerchant, getShopper } from '../../../utils/helpers'; +import { config } from '../../../config/default'; +import { + goToSubscriptions, + goToOrder, +} from '../../../utils/merchant-navigation'; import { fillCardDetails, placeOrder, setupCheckout, -} from '../../utils/shopper'; -import { goToProductPageBySlug } from '../../utils/shopper-navigation'; +} from '../../../utils/shopper'; +import { goToProductPageBySlug } from '../../../utils/shopper-navigation'; +import { + activateMulticurrency, + deactivateMulticurrency, + isMulticurrencyEnabled, +} from '../../../utils/merchant'; const productName = 'Subscription no signup fee product'; const productSlug = 'subscription-no-signup-fee-product'; @@ -55,10 +63,21 @@ describeif( shouldRunSubscriptionsTests )( ); orderId = await orderIdField.textContent(); } ); + test( 'It should have a charge for subscription cost without fee & an active subscription', async ( { browser, } ) => { const { merchantPage } = await getMerchant( browser ); + + // Disable multi-currency in the merchant settings. + // This step is important because local environment setups might have multi-currency enabled. + const wasMultiCurrencyEnabled = await isMulticurrencyEnabled( + merchantPage + ); + if ( wasMultiCurrencyEnabled ) { + await deactivateMulticurrency( merchantPage ); + } + await goToOrder( merchantPage, orderId ); // Verify we have an active subscription @@ -87,10 +106,17 @@ describeif( shouldRunSubscriptionsTests )( await goToSubscriptions( merchantPage ); - const subscriptionsRow = merchantPage.locator( + let subscriptionsRow = merchantPage.locator( '#order-' + relatedSubscriptionId ); + // Fallback for WC 7.7.0. + if ( ( await subscriptionsRow.count() ) === 0 ) { + subscriptionsRow = merchantPage.locator( + '#post-' + relatedSubscriptionId + ); + } + await expect( subscriptionsRow.locator( '.subscription-status' ) ).toHaveText( 'Active' ); @@ -102,6 +128,11 @@ describeif( shouldRunSubscriptionsTests )( await expect( subscriptionsRow.locator( '.recurring_total' ) ).toHaveText( /\$9\.99 \/ month/i ); + + // Enable multicurrency if it was enabled before. + if ( wasMultiCurrencyEnabled ) { + await activateMulticurrency( merchantPage ); + } } ); } ); diff --git a/tests/e2e-pw/specs/shopper/shopper-subscriptions-purchase-sign-up-fee.spec.ts b/tests/e2e-pw/specs/subscriptions/shopper/shopper-subscriptions-purchase-sign-up-fee.spec.ts similarity index 82% rename from tests/e2e-pw/specs/shopper/shopper-subscriptions-purchase-sign-up-fee.spec.ts rename to tests/e2e-pw/specs/subscriptions/shopper/shopper-subscriptions-purchase-sign-up-fee.spec.ts index 2728a404530..24445e63d17 100644 --- a/tests/e2e-pw/specs/shopper/shopper-subscriptions-purchase-sign-up-fee.spec.ts +++ b/tests/e2e-pw/specs/subscriptions/shopper/shopper-subscriptions-purchase-sign-up-fee.spec.ts @@ -6,11 +6,14 @@ import { test, expect, Page } from '@playwright/test'; /** * Internal dependencies */ -import { config } from '../../config/default'; -import { describeif, getMerchant, getShopper } from '../../utils/helpers'; -import * as shopper from '../../utils/shopper'; -import * as navigation from '../../utils/merchant-navigation'; -import { shouldRunSubscriptionsTests, products } from '../../utils/constants'; +import { config } from '../../../config/default'; +import { describeif, getMerchant, getShopper } from '../../../utils/helpers'; +import * as shopper from '../../../utils/shopper'; +import * as navigation from '../../../utils/merchant-navigation'; +import { + shouldRunSubscriptionsTests, + products, +} from '../../../utils/constants'; describeif( shouldRunSubscriptionsTests )( 'Subscriptions > Purchase subscription with signup fee', diff --git a/tests/e2e-pw/specs/merchant/merchant-admin-account-balance.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-admin-account-balance.spec.ts similarity index 98% rename from tests/e2e-pw/specs/merchant/merchant-admin-account-balance.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-admin-account-balance.spec.ts index bed2efcb90d..2b60efe22d6 100644 --- a/tests/e2e-pw/specs/merchant/merchant-admin-account-balance.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-admin-account-balance.spec.ts @@ -6,7 +6,7 @@ import { test, expect } from '@playwright/test'; /** * Internal dependencies */ -import { useMerchant } from '../../utils/helpers'; +import { useMerchant } from '../../../utils/helpers'; // Optional currency symbol, followed by one or more digits, decimal separator, or comma. const formattedCurrencyRegex = /[^\d.,]*[\d.,]+/; diff --git a/tests/e2e-pw/specs/merchant/merchant-admin-analytics.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-admin-analytics.spec.ts similarity index 90% rename from tests/e2e-pw/specs/merchant/merchant-admin-analytics.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-admin-analytics.spec.ts index c8a1847297d..c9e4333e642 100644 --- a/tests/e2e-pw/specs/merchant/merchant-admin-analytics.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-admin-analytics.spec.ts @@ -6,16 +6,16 @@ import { test, expect } from '@playwright/test'; /** * Internal dependencies */ -import * as shopper from '../../utils/shopper'; -import { getMerchant, getShopper, useMerchant } from '../../utils/helpers'; +import * as shopper from '../../../utils/shopper'; +import { getMerchant, getShopper, useMerchant } from '../../../utils/helpers'; import { activateMulticurrency, ensureOrderIsProcessed, isMulticurrencyEnabled, tableDataHasLoaded, waitAndSkipTourComponent, -} from '../../utils/merchant'; -import { goToOrderAnalytics } from '../../utils/merchant-navigation'; +} from '../../../utils/merchant'; +import { goToOrderAnalytics } from '../../../utils/merchant-navigation'; test.describe( 'Admin order analytics', () => { let orderId: string; diff --git a/tests/e2e-pw/specs/merchant/merchant-admin-deposits.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-admin-deposits.spec.ts similarity index 96% rename from tests/e2e-pw/specs/merchant/merchant-admin-deposits.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-admin-deposits.spec.ts index 96008887630..1363dc7b175 100644 --- a/tests/e2e-pw/specs/merchant/merchant-admin-deposits.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-admin-deposits.spec.ts @@ -2,7 +2,7 @@ * External dependencies */ import { test, expect } from '@playwright/test'; -import { useMerchant } from '../../utils/helpers'; +import { useMerchant } from '../../../utils/helpers'; test.describe( 'Merchant deposits', () => { // Use the merchant user for this test suite. diff --git a/tests/e2e-pw/specs/merchant/merchant-admin-disputes.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-admin-disputes.spec.ts similarity index 92% rename from tests/e2e-pw/specs/merchant/merchant-admin-disputes.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-admin-disputes.spec.ts index d2fed057b5d..f6a3d52d893 100644 --- a/tests/e2e-pw/specs/merchant/merchant-admin-disputes.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-admin-disputes.spec.ts @@ -6,7 +6,7 @@ import { test, expect } from '@playwright/test'; /** * Internal dependencies */ -import { useMerchant } from '../../utils/helpers'; +import { useMerchant } from '../../../utils/helpers'; test.describe( 'Merchant disputes', () => { // Use the merchant user for this test suite. diff --git a/tests/e2e-pw/specs/merchant/merchant-admin-transactions.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-admin-transactions.spec.ts similarity index 78% rename from tests/e2e-pw/specs/merchant/merchant-admin-transactions.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-admin-transactions.spec.ts index 59547ed98a6..8709909934c 100644 --- a/tests/e2e-pw/specs/merchant/merchant-admin-transactions.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-admin-transactions.spec.ts @@ -6,9 +6,9 @@ import test, { expect } from '@playwright/test'; /** * Internal dependencies */ -import { shouldRunSubscriptionsTests } from '../../utils/constants'; -import { getMerchant } from '../../utils/helpers'; -import { goToTransactions } from '../../utils/merchant-navigation'; +import { shouldRunSubscriptionsTests } from '../../../utils/constants'; +import { getMerchant } from '../../../utils/helpers'; +import { goToTransactions } from '../../../utils/merchant-navigation'; test.describe( 'Admin transactions', () => { test( 'page should load without errors', async ( { browser } ) => { diff --git a/tests/e2e-pw/specs/merchant/merchant-disputes-respond.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-disputes-respond.spec.ts similarity index 97% rename from tests/e2e-pw/specs/merchant/merchant-disputes-respond.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-disputes-respond.spec.ts index e80bd0bb372..ed43e9411a7 100644 --- a/tests/e2e-pw/specs/merchant/merchant-disputes-respond.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-disputes-respond.spec.ts @@ -6,10 +6,13 @@ import { test, expect, Page, Browser } from '@playwright/test'; /** * Internal dependencies */ -import * as shopper from '../../utils/shopper'; -import { config } from '../../config/default'; -import { getAnonymousShopper, getMerchant } from '../../utils/helpers'; -import { goToOrder, goToPaymentDetails } from '../../utils/merchant-navigation'; +import * as shopper from '../../../utils/shopper'; +import { config } from '../../../config/default'; +import { getAnonymousShopper, getMerchant } from '../../../utils/helpers'; +import { + goToOrder, + goToPaymentDetails, +} from '../../../utils/merchant-navigation'; /** * Navigates to the payment details page for a given disputed order. diff --git a/tests/e2e-pw/specs/merchant/merchant-disputes-view-details-via-order-notice.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-disputes-view-details-via-order-notice.spec.ts similarity index 90% rename from tests/e2e-pw/specs/merchant/merchant-disputes-view-details-via-order-notice.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-disputes-view-details-via-order-notice.spec.ts index b7da795ce06..510d79b26b8 100644 --- a/tests/e2e-pw/specs/merchant/merchant-disputes-view-details-via-order-notice.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-disputes-view-details-via-order-notice.spec.ts @@ -6,10 +6,10 @@ import { test, expect } from '@playwright/test'; /** * Internal dependencies */ -import * as shopper from '../../utils/shopper'; -import { config } from '../../config/default'; -import { getMerchant, getShopper } from '../../utils/helpers'; -import { goToOrder } from '../../utils/merchant-navigation'; +import * as shopper from '../../../utils/shopper'; +import { config } from '../../../config/default'; +import { getMerchant, getShopper } from '../../../utils/helpers'; +import { goToOrder } from '../../../utils/merchant-navigation'; test.describe( 'Disputes > View dispute details via disputed order notice', diff --git a/tests/e2e-pw/specs/merchant/merchant-multi-currency-widget.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-multi-currency-widget.spec.ts similarity index 97% rename from tests/e2e-pw/specs/merchant/merchant-multi-currency-widget.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-multi-currency-widget.spec.ts index f326812ca24..770cc7e10a3 100644 --- a/tests/e2e-pw/specs/merchant/merchant-multi-currency-widget.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-multi-currency-widget.spec.ts @@ -6,15 +6,15 @@ import { test, expect, Page } from '@playwright/test'; /** * Internal dependencies */ -import { getMerchant, getShopper } from '../../utils/helpers'; +import { getMerchant, getShopper } from '../../../utils/helpers'; import { activateMulticurrency, addMulticurrencyWidget, deactivateMulticurrency, removeMultiCurrencyWidgets, restoreCurrencies, -} from '../../utils/merchant'; -import * as navigation from '../../utils/shopper-navigation'; +} from '../../../utils/merchant'; +import * as navigation from '../../../utils/shopper-navigation'; test.describe( 'Multi-currency widget setup', () => { let merchantPage: Page; diff --git a/tests/e2e-pw/specs/merchant/merchant-orders-full-refund.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-orders-full-refund.spec.ts similarity index 93% rename from tests/e2e-pw/specs/merchant/merchant-orders-full-refund.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-orders-full-refund.spec.ts index 8ea26d1dd3f..be69815098f 100644 --- a/tests/e2e-pw/specs/merchant/merchant-orders-full-refund.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-orders-full-refund.spec.ts @@ -6,13 +6,16 @@ import { test, expect, Page } from '@playwright/test'; /** * Internal dependencies */ -import { getMerchant, getShopper } from '../../utils/helpers'; +import { getMerchant, getShopper } from '../../../utils/helpers'; import { deactivateMulticurrency, isMulticurrencyEnabled, -} from '../../utils/merchant'; -import * as shopper from '../../utils/shopper'; -import { goToOrder, goToPaymentDetails } from '../../utils/merchant-navigation'; +} from '../../../utils/merchant'; +import * as shopper from '../../../utils/shopper'; +import { + goToOrder, + goToPaymentDetails, +} from '../../../utils/merchant-navigation'; test.describe( 'WooCommerce Payments - Full Refund', () => { let merchantPage: Page; diff --git a/tests/e2e-pw/specs/merchant/merchant-orders-manual-capture.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-orders-manual-capture.spec.ts similarity index 73% rename from tests/e2e-pw/specs/merchant/merchant-orders-manual-capture.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-orders-manual-capture.spec.ts index a23d9a35c09..366b34c5f7e 100644 --- a/tests/e2e-pw/specs/merchant/merchant-orders-manual-capture.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-orders-manual-capture.spec.ts @@ -1,24 +1,24 @@ /** * External dependencies */ -import { test, expect } from '@playwright/test'; +import { test, expect, Page } from '@playwright/test'; /** * Internal dependencies */ -import { getShopper, getMerchant } from '../../utils/helpers'; -import { goToOrder } from '../../utils/merchant-navigation'; +import { getShopper, getMerchant } from '../../../utils/helpers'; +import { goToOrder } from '../../../utils/merchant-navigation'; import { activateCaptureLater, deactivateCaptureLater, -} from '../../utils/merchant'; -import { placeOrderWithOptions } from '../../utils/shopper'; +} from '../../../utils/merchant'; +import { placeOrderWithOptions } from '../../../utils/shopper'; /** * Local variables. */ -let orderId; -let merchantPage; +let orderId: string; +let merchantPage: Page; test.describe( 'Order > Manual Capture', () => { test.beforeAll( async ( { browser } ) => { @@ -40,11 +40,16 @@ test.describe( 'Order > Manual Capture', () => { // Merchant go to the order. await goToOrder( merchantPage, orderId ); + const orderTotal = await merchantPage + .getByRole( 'row', { name: 'Order Total: $' } ) + .locator( 'bdi' ) + .textContent(); + // Confirm order status is 'On hold', and that there's an 'authorized' note. await expect( merchantPage.getByTitle( 'On hold' ) ).toBeVisible(); await expect( merchantPage.getByText( - 'A payment of $18.00 was authorized using WooPayments' + `A payment of ${ orderTotal } was authorized using WooPayments` ) ).toBeVisible(); @@ -60,7 +65,7 @@ test.describe( 'Order > Manual Capture', () => { await expect( merchantPage.getByTitle( 'Processing' ) ).toBeVisible(); await expect( merchantPage.getByText( - 'A payment of $18.00 was successfully captured using WooPayments' + `A payment of ${ orderTotal } was successfully captured using WooPayments` ) ).toBeVisible(); } ); diff --git a/tests/e2e-pw/specs/merchant/merchant-orders-partial-refund.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-orders-partial-refund.spec.ts similarity index 94% rename from tests/e2e-pw/specs/merchant/merchant-orders-partial-refund.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-orders-partial-refund.spec.ts index 4bc0c0cec9c..2454f74d474 100644 --- a/tests/e2e-pw/specs/merchant/merchant-orders-partial-refund.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-orders-partial-refund.spec.ts @@ -6,20 +6,20 @@ import { test, expect, Page } from '@playwright/test'; /** * Internal dependencies */ -import { config } from '../../config/default'; -import { getMerchant, getShopper } from '../../utils/helpers'; +import { config } from '../../../config/default'; +import { getMerchant, getShopper } from '../../../utils/helpers'; import { fillCardDetails, placeOrder, setupProductCheckout, -} from '../../utils/shopper'; -import { goToShop } from '../../utils/shopper-navigation'; -import { goToOrder } from '../../utils/merchant-navigation'; +} from '../../../utils/shopper'; +import { goToShop } from '../../../utils/shopper-navigation'; +import { goToOrder } from '../../../utils/merchant-navigation'; import { activateMulticurrency, deactivateMulticurrency, restoreCurrencies, -} from '../../utils/merchant'; +} from '../../../utils/merchant'; // Needs to be finished. test.describe( 'Order > Partial refund', () => { diff --git a/tests/e2e-pw/specs/merchant/merchant-orders-refund-failures.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-orders-refund-failures.spec.ts similarity index 93% rename from tests/e2e-pw/specs/merchant/merchant-orders-refund-failures.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-orders-refund-failures.spec.ts index 6f5dce44ac8..47e88a7a4c7 100644 --- a/tests/e2e-pw/specs/merchant/merchant-orders-refund-failures.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-orders-refund-failures.spec.ts @@ -6,10 +6,10 @@ import test, { Dialog, Page, expect } from '@playwright/test'; /** * Internal dependencies */ -import { emptyCart, placeOrderWithCurrency } from '../../utils/shopper'; -import { getMerchant, getShopper } from '../../utils/helpers'; -import { goToOrder } from '../../utils/merchant-navigation'; -import { ensureOrderIsProcessed } from '../../utils/merchant'; +import { emptyCart, placeOrderWithCurrency } from '../../../utils/shopper'; +import { getMerchant, getShopper } from '../../../utils/helpers'; +import { goToOrder } from '../../../utils/merchant-navigation'; +import { ensureOrderIsProcessed } from '../../../utils/merchant'; const selectorQty = '.refund_order_item_qty'; const selectorLineAmount = '.refund_line_total'; diff --git a/tests/e2e-pw/specs/merchant/merchant-orders-status-change.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-orders-status-change.spec.ts similarity index 96% rename from tests/e2e-pw/specs/merchant/merchant-orders-status-change.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-orders-status-change.spec.ts index a1f2da82ccb..b62c72bc1c7 100644 --- a/tests/e2e-pw/specs/merchant/merchant-orders-status-change.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-orders-status-change.spec.ts @@ -6,9 +6,9 @@ import { test, expect, Page } from '@playwright/test'; /** * Internal dependencies */ -import { getMerchant, getShopper, isUIUnblocked } from '../../utils/helpers'; -import { placeOrderWithOptions } from '../../utils/shopper'; -import * as navigation from '../../utils/merchant-navigation'; +import { getMerchant, getShopper, isUIUnblocked } from '../../../utils/helpers'; +import { placeOrderWithOptions } from '../../../utils/shopper'; +import * as navigation from '../../../utils/merchant-navigation'; const orderStatusDropdownSelector = 'select[name="order_status"]'; const cancelModalSelector = 'div.wcpay-confirmation-modal'; diff --git a/tests/e2e-pw/specs/merchant/merchant-payment-gateways-confirmation.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-payment-gateways-confirmation.spec.ts similarity index 98% rename from tests/e2e-pw/specs/merchant/merchant-payment-gateways-confirmation.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-payment-gateways-confirmation.spec.ts index 7e089ba858a..dda3adfc63e 100644 --- a/tests/e2e-pw/specs/merchant/merchant-payment-gateways-confirmation.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-payment-gateways-confirmation.spec.ts @@ -6,7 +6,7 @@ import { test, expect, Page } from '@playwright/test'; /** * Internal dependencies */ -import { useMerchant } from '../../utils/helpers'; +import { useMerchant } from '../../../utils/helpers'; test.describe( 'payment gateways disable confirmation', () => { useMerchant(); diff --git a/tests/e2e-pw/specs/merchant/merchant-payment-settings-manual-capture.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-payment-settings-manual-capture.spec.ts similarity index 92% rename from tests/e2e-pw/specs/merchant/merchant-payment-settings-manual-capture.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-payment-settings-manual-capture.spec.ts index 54456e23e34..ab6c5c39928 100644 --- a/tests/e2e-pw/specs/merchant/merchant-payment-settings-manual-capture.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-payment-settings-manual-capture.spec.ts @@ -5,8 +5,8 @@ import { test, expect } from '@playwright/test'; /** * Internal dependencies */ -import { useMerchant } from '../../utils/helpers'; -import { goToWooPaymentsSettings } from '../../utils/merchant-navigation'; +import { useMerchant } from '../../../utils/helpers'; +import { goToWooPaymentsSettings } from '../../../utils/merchant-navigation'; test.describe( 'As a merchant, I should be prompted a confirmation modal when I try to activate the manual capture', diff --git a/tests/e2e-pw/specs/merchant/merchant-progressive-onboarding.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/merchant-progressive-onboarding.spec.ts similarity index 91% rename from tests/e2e-pw/specs/merchant/merchant-progressive-onboarding.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/merchant-progressive-onboarding.spec.ts index 10c1e22e64b..4b294b2fbd3 100644 --- a/tests/e2e-pw/specs/merchant/merchant-progressive-onboarding.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/merchant-progressive-onboarding.spec.ts @@ -6,9 +6,9 @@ import { test, expect } from '@playwright/test'; /** * Internal dependencies */ -import { useMerchant } from '../../utils/helpers'; -import * as devtools from '../../utils/devtools'; -import { goToConnect } from '../../utils/merchant-navigation'; +import { useMerchant } from '../../../utils/helpers'; +import * as devtools from '../../../utils/devtools'; +import { goToConnect } from '../../../utils/merchant-navigation'; test.describe( 'Admin merchant progressive onboarding', () => { useMerchant(); diff --git a/tests/e2e-pw/specs/merchant/multi-currency-on-boarding.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/multi-currency-on-boarding.spec.ts similarity index 97% rename from tests/e2e-pw/specs/merchant/multi-currency-on-boarding.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/multi-currency-on-boarding.spec.ts index 59e81183582..ec8d6e3cfd7 100644 --- a/tests/e2e-pw/specs/merchant/multi-currency-on-boarding.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/multi-currency-on-boarding.spec.ts @@ -5,7 +5,7 @@ import { test, expect, Page } from '@playwright/test'; /** * Internal dependencies */ -import { useMerchant } from '../../utils/helpers'; +import { useMerchant } from '../../../utils/helpers'; import { activateMulticurrency, activateTheme, @@ -15,8 +15,8 @@ import { getActiveThemeSlug, removeCurrency, restoreCurrencies, -} from '../../utils/merchant'; -import * as navigation from '../../utils/merchant-navigation'; +} from '../../../utils/merchant'; +import * as navigation from '../../../utils/merchant-navigation'; test.describe( 'Multi-currency on-boarding', () => { let page: Page; diff --git a/tests/e2e-pw/specs/merchant/multi-currency-setup.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/multi-currency-setup.spec.ts similarity index 95% rename from tests/e2e-pw/specs/merchant/multi-currency-setup.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/multi-currency-setup.spec.ts index ad66065b39f..c347b29a8f8 100644 --- a/tests/e2e-pw/specs/merchant/multi-currency-setup.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/multi-currency-setup.spec.ts @@ -5,7 +5,7 @@ import { test, expect, Page } from '@playwright/test'; /** * Internal dependencies */ -import { getMerchant, getShopper } from '../../utils/helpers'; +import { getMerchant, getShopper } from '../../../utils/helpers'; import { activateMulticurrency, addCurrency, @@ -16,9 +16,9 @@ import { setCurrencyCharmPricing, setCurrencyPriceRounding, setCurrencyRate, -} from '../../utils/merchant'; -import * as navigation from '../../utils/shopper-navigation'; -import { getPriceFromProduct } from '../../utils/shopper'; +} from '../../../utils/merchant'; +import * as navigation from '../../../utils/shopper-navigation'; +import { getPriceFromProduct } from '../../../utils/shopper'; test.describe( 'Multi-currency setup', () => { let merchantPage: Page; diff --git a/tests/e2e-pw/specs/merchant/multi-currency.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/multi-currency.spec.ts similarity index 92% rename from tests/e2e-pw/specs/merchant/multi-currency.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/multi-currency.spec.ts index 92f42c3b97b..885410df350 100644 --- a/tests/e2e-pw/specs/merchant/multi-currency.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/multi-currency.spec.ts @@ -5,7 +5,7 @@ import { test, expect, Page } from '@playwright/test'; /** * Internal dependencies */ -import { useMerchant } from '../../utils/helpers'; +import { useMerchant } from '../../../utils/helpers'; import { activateMulticurrency, addMulticurrencyWidget, @@ -13,8 +13,8 @@ import { disableAllEnabledCurrencies, removeMultiCurrencyWidgets, restoreCurrencies, -} from '../../utils/merchant'; -import * as navigation from '../../utils/merchant-navigation'; +} from '../../../utils/merchant'; +import * as navigation from '../../../utils/merchant-navigation'; test.describe( 'Multi-currency', () => { let wasMulticurrencyEnabled: boolean; diff --git a/tests/e2e-pw/specs/merchant/woopay-setup.spec.ts b/tests/e2e-pw/specs/wcpay/merchant/woopay-setup.spec.ts similarity index 84% rename from tests/e2e-pw/specs/merchant/woopay-setup.spec.ts rename to tests/e2e-pw/specs/wcpay/merchant/woopay-setup.spec.ts index c36cdb135d0..4d26d56bed9 100644 --- a/tests/e2e-pw/specs/merchant/woopay-setup.spec.ts +++ b/tests/e2e-pw/specs/wcpay/merchant/woopay-setup.spec.ts @@ -5,8 +5,8 @@ import { test, Page } from '@playwright/test'; /** * Internal dependencies */ -import { getMerchant } from '../../utils/helpers'; -import { activateWooPay, deactivateWooPay } from '../../utils/merchant'; +import { getMerchant } from '../../../utils/helpers'; +import { activateWooPay, deactivateWooPay } from '../../../utils/merchant'; test.describe( 'WooPay setup', () => { let merchantPage: Page; diff --git a/tests/e2e-pw/specs/shopper/klarna-checkout-purchase.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/klarna-checkout-purchase.spec.ts similarity index 89% rename from tests/e2e-pw/specs/shopper/klarna-checkout-purchase.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/klarna-checkout-purchase.spec.ts index b810f32ecb0..165c41b73fd 100644 --- a/tests/e2e-pw/specs/shopper/klarna-checkout-purchase.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/klarna-checkout-purchase.spec.ts @@ -6,14 +6,14 @@ import { test, expect, Page } from '@playwright/test'; /** * Internal dependencies */ -import * as shopper from '../../utils/shopper'; -import { getMerchant, getShopper } from '../../utils/helpers'; -import * as merchant from '../../utils/merchant'; -import { config } from '../../config/default'; +import * as shopper from '../../../utils/shopper'; +import { getMerchant, getShopper } from '../../../utils/helpers'; +import * as merchant from '../../../utils/merchant'; +import { config } from '../../../config/default'; import { goToProductPageBySlug, goToShop, -} from '../../utils/shopper-navigation'; +} from '../../../utils/shopper-navigation'; test.describe( 'Klarna Checkout', () => { let merchantPage: Page; diff --git a/tests/e2e-pw/specs/shopper/multi-currency-checkout.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/multi-currency-checkout.spec.ts similarity index 91% rename from tests/e2e-pw/specs/shopper/multi-currency-checkout.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/multi-currency-checkout.spec.ts index a174ab1bcf7..8c832b03eb1 100644 --- a/tests/e2e-pw/specs/shopper/multi-currency-checkout.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/multi-currency-checkout.spec.ts @@ -5,15 +5,15 @@ import { test, expect, Page } from '@playwright/test'; /** * Internal dependencies */ -import { getMerchant, getShopper } from '../../utils/helpers'; +import { getMerchant, getShopper } from '../../../utils/helpers'; import { activateMulticurrency, addCurrency, deactivateMulticurrency, restoreCurrencies, -} from '../../utils/merchant'; -import { emptyCart, placeOrderWithCurrency } from '../../utils/shopper'; -import * as navigation from '../../utils/shopper-navigation'; +} from '../../../utils/merchant'; +import { emptyCart, placeOrderWithCurrency } from '../../../utils/shopper'; +import * as navigation from '../../../utils/shopper-navigation'; test.describe( 'Multi-currency checkout', () => { let merchantPage: Page; diff --git a/tests/e2e-pw/specs/shopper/shopper-bnpls-checkout.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/shopper-bnpls-checkout.spec.ts similarity index 90% rename from tests/e2e-pw/specs/shopper/shopper-bnpls-checkout.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/shopper-bnpls-checkout.spec.ts index 569093b959a..dfb2c8ffaab 100644 --- a/tests/e2e-pw/specs/shopper/shopper-bnpls-checkout.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/shopper-bnpls-checkout.spec.ts @@ -7,10 +7,10 @@ import { test, expect, Page } from '@playwright/test'; * Internal dependencies */ -import { getMerchant, getShopper } from '../../utils/helpers'; -import * as merchant from '../../utils/merchant'; -import * as shopper from '../../utils/shopper'; -import * as devtools from '../../utils/devtools'; +import { getMerchant, getShopper } from '../../../utils/helpers'; +import * as merchant from '../../../utils/merchant'; +import * as shopper from '../../../utils/shopper'; +import * as devtools from '../../../utils/devtools'; const cardTestingProtectionStates = [ false, true ]; const bnplProviders = [ 'Affirm', 'Afterpay' ]; diff --git a/tests/e2e-pw/specs/shopper/shopper-checkout-cart-coupon.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-cart-coupon.spec.ts similarity index 90% rename from tests/e2e-pw/specs/shopper/shopper-checkout-cart-coupon.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-cart-coupon.spec.ts index 2b0a94c33dd..353f997d996 100644 --- a/tests/e2e-pw/specs/shopper/shopper-checkout-cart-coupon.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-cart-coupon.spec.ts @@ -6,13 +6,13 @@ import test, { expect } from '@playwright/test'; /** * Internal dependencies */ -import { config } from '../../config/default'; +import { config } from '../../../config/default'; import { goToCart, goToCheckout, goToShop, -} from '../../utils/shopper-navigation'; -import { useShopper } from '../../utils/helpers'; +} from '../../../utils/shopper-navigation'; +import { useShopper } from '../../../utils/helpers'; import { addToCartFromShopPage, emptyCart, @@ -20,7 +20,7 @@ import { fillCardDetails, placeOrder, setupCheckout, -} from '../../utils/shopper'; +} from '../../../utils/shopper'; const productName = config.products.simple.name; diff --git a/tests/e2e-pw/specs/shopper/shopper-checkout-failures.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-failures.spec.ts similarity index 97% rename from tests/e2e-pw/specs/shopper/shopper-checkout-failures.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-failures.spec.ts index 5b21fc1570d..dbdebc71d73 100644 --- a/tests/e2e-pw/specs/shopper/shopper-checkout-failures.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-failures.spec.ts @@ -7,8 +7,8 @@ import { test, expect, Page } from '@playwright/test'; * Internal dependencies */ -import { config } from '../../config/default'; -import * as shopper from '../../utils/shopper'; +import { config } from '../../../config/default'; +import * as shopper from '../../../utils/shopper'; test.describe( 'Shopper > Checkout > Failures with various cards', () => { const waitForBanner = async ( page: Page, errorText: string ) => { diff --git a/tests/e2e-pw/specs/shopper/shopper-checkout-purchase-site-editor.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-purchase-site-editor.spec.ts similarity index 89% rename from tests/e2e-pw/specs/shopper/shopper-checkout-purchase-site-editor.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-purchase-site-editor.spec.ts index 23a55fbd7b8..63635773496 100644 --- a/tests/e2e-pw/specs/shopper/shopper-checkout-purchase-site-editor.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-purchase-site-editor.spec.ts @@ -9,10 +9,10 @@ import test, { Page, expect } from '@playwright/test'; import { disableCardTestingProtection, enableCardTestingProtection, -} from '../../utils/devtools'; -import { getMerchant, getShopper } from '../../utils/helpers'; -import { activateTheme } from '../../utils/merchant'; -import { config } from '../../config/default'; +} from '../../../utils/devtools'; +import { getMerchant, getShopper } from '../../../utils/helpers'; +import { activateTheme } from '../../../utils/merchant'; +import { config } from '../../../config/default'; import { addCartProduct, confirmCardAuthentication, @@ -21,8 +21,8 @@ import { fillCardDetails, placeOrder, setupCheckout, -} from '../../utils/shopper'; -import { goToShop } from '../../utils/shopper-navigation'; +} from '../../../utils/shopper'; +import { goToShop } from '../../../utils/shopper-navigation'; /** * Tests for successful purchases with both card testing prevention enabled diff --git a/tests/e2e-pw/specs/shopper/shopper-checkout-purchase-with-upe-methods.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-purchase-with-upe-methods.spec.ts similarity index 90% rename from tests/e2e-pw/specs/shopper/shopper-checkout-purchase-with-upe-methods.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-purchase-with-upe-methods.spec.ts index 6fdd21bf1fb..9c7427adc89 100644 --- a/tests/e2e-pw/specs/shopper/shopper-checkout-purchase-with-upe-methods.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-purchase-with-upe-methods.spec.ts @@ -13,12 +13,12 @@ import { disablePaymentMethods, enablePaymentMethods, restoreCurrencies, -} from '../../utils/merchant'; -import { getShopper, getMerchant } from '../../utils/helpers'; +} from '../../../utils/merchant'; +import { getShopper, getMerchant } from '../../../utils/helpers'; import { disableCardTestingProtection, enableCardTestingProtection, -} from '../../utils/devtools'; +} from '../../../utils/devtools'; import { addToCartFromShopPage, changeAccountCurrency, @@ -27,9 +27,9 @@ import { fillBillingAddress, focusPlaceOrderButton, placeOrder, -} from '../../utils/shopper'; -import { config } from '../../config/default'; -import { goToCheckout, goToShop } from '../../utils/shopper-navigation'; +} from '../../../utils/shopper'; +import { config } from '../../../config/default'; +import { goToCheckout, goToShop } from '../../../utils/shopper-navigation'; test.describe( 'Enable UPE with deferred intent creation', () => { let wasMultiCurrencyEnabled = false; diff --git a/tests/e2e-pw/specs/shopper/shopper-checkout-purchase.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-purchase.spec.ts similarity index 88% rename from tests/e2e-pw/specs/shopper/shopper-checkout-purchase.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-purchase.spec.ts index b2a0246d438..592591a379a 100644 --- a/tests/e2e-pw/specs/shopper/shopper-checkout-purchase.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-purchase.spec.ts @@ -7,10 +7,10 @@ import { test, expect, Page } from '@playwright/test'; * Internal dependencies */ -import { config } from '../../config/default'; -import * as shopper from '../../utils/shopper'; -import * as devtools from '../../utils/devtools'; -import { getMerchant, getShopper } from '../../utils/helpers'; +import { config } from '../../../config/default'; +import * as shopper from '../../../utils/shopper'; +import * as devtools from '../../../utils/devtools'; +import { getMerchant, getShopper } from '../../../utils/helpers'; test.describe( 'Successful purchase', () => { let merchantPage: Page; diff --git a/tests/e2e-pw/specs/shopper/shopper-checkout-save-card-and-purchase.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-save-card-and-purchase.spec.ts similarity index 92% rename from tests/e2e-pw/specs/shopper/shopper-checkout-save-card-and-purchase.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-save-card-and-purchase.spec.ts index 4b2ca024df7..a4375c2c3f0 100644 --- a/tests/e2e-pw/specs/shopper/shopper-checkout-save-card-and-purchase.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/shopper-checkout-save-card-and-purchase.spec.ts @@ -6,8 +6,8 @@ import test, { Page, expect } from '@playwright/test'; /** * Internal dependencies */ -import { config } from '../../config/default'; -import { getAnonymousShopper, getShopper } from '../../utils/helpers'; +import { config } from '../../../config/default'; +import { getAnonymousShopper, getShopper } from '../../../utils/helpers'; import { confirmCardAuthentication, deleteSavedCard, @@ -16,8 +16,8 @@ import { selectSavedCardOnCheckout, setSavePaymentMethod, setupProductCheckout, -} from '../../utils/shopper'; -import { goToMyAccount, goToShop } from '../../utils/shopper-navigation'; +} from '../../../utils/shopper'; +import { goToMyAccount, goToShop } from '../../../utils/shopper-navigation'; type CardType = [ string, typeof config.cards.basic ]; diff --git a/tests/e2e-pw/specs/shopper/shopper-multi-currency-widget.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/shopper-multi-currency-widget.spec.ts similarity index 81% rename from tests/e2e-pw/specs/shopper/shopper-multi-currency-widget.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/shopper-multi-currency-widget.spec.ts index cd2495bd6f0..ff278098068 100644 --- a/tests/e2e-pw/specs/shopper/shopper-multi-currency-widget.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/shopper-multi-currency-widget.spec.ts @@ -5,12 +5,12 @@ import { test, expect, Page } from '@playwright/test'; /** * Internal dependencies */ -import * as merchant from '../../utils/merchant'; -import * as shopper from '../../utils/shopper'; -import * as navigation from '../../utils/shopper-navigation'; -import { goToOrder } from '../../utils/merchant-navigation'; -import RestAPI from '../../utils/rest-api'; -import { getMerchant, getShopper } from '../../utils/helpers'; +import * as merchant from '../../../utils/merchant'; +import * as shopper from '../../../utils/shopper'; +import * as navigation from '../../../utils/shopper-navigation'; +import { goToOrder } from '../../../utils/merchant-navigation'; +import RestAPI from '../../../utils/rest-api'; +import { getMerchant, getShopper } from '../../../utils/helpers'; test.describe( 'Shopper Multi-Currency widget', () => { let merchantPage: Page; @@ -68,15 +68,11 @@ test.describe( 'Shopper Multi-Currency widget', () => { test.describe( 'Should not affect prices', () => { let orderId: string; + let orderPrice: string; test.afterEach( async () => { - await shopperPage.selectOption( - '.widget select[name=currency]', - 'EUR' - ); - await expect( - shopperPage.getByText( '$18.00 USD' ).first() + shopperPage.getByText( `${ orderPrice } USD` ).first() ).toBeVisible(); await navigation.goToShopWithCurrency( shopperPage, 'USD' ); @@ -87,12 +83,19 @@ test.describe( 'Shopper Multi-Currency widget', () => { shopperPage, 'USD' ); + orderPrice = await shopperPage + .getByRole( 'row', { name: 'Total: $' } ) + .locator( '.amount' ) + .nth( 1 ) + .textContent(); } ); test( 'at My account > Orders', async () => { await navigation.goToOrders( shopperPage ); await expect( - shopperPage.getByLabel( `View order number ${ orderId }` ) + shopperPage + .locator( '.woocommerce-orders-table__cell-order-number' ) + .getByRole( 'link', { name: orderId } ) ).toBeVisible(); } ); } ); diff --git a/tests/e2e-pw/specs/shopper/shopper-myaccount-payment-methods-add-fail.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/shopper-myaccount-payment-methods-add-fail.spec.ts similarity index 90% rename from tests/e2e-pw/specs/shopper/shopper-myaccount-payment-methods-add-fail.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/shopper-myaccount-payment-methods-add-fail.spec.ts index d20e2cdc34f..ce80f2497ee 100644 --- a/tests/e2e-pw/specs/shopper/shopper-myaccount-payment-methods-add-fail.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/shopper-myaccount-payment-methods-add-fail.spec.ts @@ -6,10 +6,13 @@ import test, { Page, expect } from '@playwright/test'; /** * Internal dependencies */ -import { config } from '../../config/default'; -import { goToMyAccount } from '../../utils/shopper-navigation'; -import { getShopper } from '../../utils/helpers'; -import { addSavedCard, confirmCardAuthentication } from '../../utils/shopper'; +import { config } from '../../../config/default'; +import { goToMyAccount } from '../../../utils/shopper-navigation'; +import { getShopper, isUIUnblocked } from '../../../utils/helpers'; +import { + addSavedCard, + confirmCardAuthentication, +} from '../../../utils/shopper'; type CardType = [ string, typeof config.cards.declined, string ]; @@ -62,6 +65,7 @@ test.describe( 'Payment Methods', () => { if ( 'declined-3ds' === cardType ) { await confirmCardAuthentication( shopperPage, false ); + await isUIUnblocked( shopperPage ); } // Verify that we get the expected error message. diff --git a/tests/e2e-pw/specs/shopper/shopper-myaccount-renew-subscription.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/shopper-myaccount-renew-subscription.spec.ts similarity index 85% rename from tests/e2e-pw/specs/shopper/shopper-myaccount-renew-subscription.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/shopper-myaccount-renew-subscription.spec.ts index 565c54e5863..c1d2197a977 100644 --- a/tests/e2e-pw/specs/shopper/shopper-myaccount-renew-subscription.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/shopper-myaccount-renew-subscription.spec.ts @@ -6,11 +6,14 @@ import { test, expect, Page } from '@playwright/test'; /** * Internal dependencies */ -import { config } from '../../config/default'; -import { describeif, getShopper } from '../../utils/helpers'; -import * as shopper from '../../utils/shopper'; -import * as navigation from '../../utils/shopper-navigation'; -import { products, shouldRunSubscriptionsTests } from '../../utils/constants'; +import { config } from '../../../config/default'; +import { describeif, getShopper } from '../../../utils/helpers'; +import * as shopper from '../../../utils/shopper'; +import * as navigation from '../../../utils/shopper-navigation'; +import { + products, + shouldRunSubscriptionsTests, +} from '../../../utils/constants'; describeif( shouldRunSubscriptionsTests )( 'Subscriptions > Renew a subscription in my account', diff --git a/tests/e2e-pw/specs/shopper/shopper-myaccount-saved-cards.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/shopper-myaccount-saved-cards.spec.ts similarity index 97% rename from tests/e2e-pw/specs/shopper/shopper-myaccount-saved-cards.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/shopper-myaccount-saved-cards.spec.ts index cdb4546afaf..0ab57aa8a7c 100644 --- a/tests/e2e-pw/specs/shopper/shopper-myaccount-saved-cards.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/shopper-myaccount-saved-cards.spec.ts @@ -6,9 +6,9 @@ import test, { Page, expect } from '@playwright/test'; /** * Internal dependencies */ -import { config } from '../../config/default'; -import { goToMyAccount, goToShop } from '../../utils/shopper-navigation'; -import { getShopper } from '../../utils/helpers'; +import { config } from '../../../config/default'; +import { goToMyAccount, goToShop } from '../../../utils/shopper-navigation'; +import { getShopper } from '../../../utils/helpers'; import { addSavedCard, confirmCardAuthentication, @@ -17,7 +17,7 @@ import { selectSavedCardOnCheckout, setDefaultPaymentMethod, setupProductCheckout, -} from '../../utils/shopper'; +} from '../../../utils/shopper'; type TestVariablesType = { [ key: string ]: { diff --git a/tests/e2e-pw/specs/shopper/shopper-pay-for-order.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/shopper-pay-for-order.spec.ts similarity index 89% rename from tests/e2e-pw/specs/shopper/shopper-pay-for-order.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/shopper-pay-for-order.spec.ts index ae5713568e7..576686bbb88 100644 --- a/tests/e2e-pw/specs/shopper/shopper-pay-for-order.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/shopper-pay-for-order.spec.ts @@ -6,11 +6,11 @@ import { test, expect } from '@playwright/test'; /** * Internal dependencies */ -import { config } from '../../config/default'; -import * as shopper from '../../utils/shopper'; -import * as shopperNavigation from '../../utils/shopper-navigation'; -import * as devtools from '../../utils/devtools'; -import { getMerchant, getShopper } from '../../utils/helpers'; +import { config } from '../../../config/default'; +import * as shopper from '../../../utils/shopper'; +import * as shopperNavigation from '../../../utils/shopper-navigation'; +import * as devtools from '../../../utils/devtools'; +import { getMerchant, getShopper } from '../../../utils/helpers'; const cardTestingPreventionStates = [ { cardTestingPreventionEnabled: false }, diff --git a/tests/e2e-pw/specs/shopper/shopper-wc-blocks-checkout-failures.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/shopper-wc-blocks-checkout-failures.spec.ts similarity index 84% rename from tests/e2e-pw/specs/shopper/shopper-wc-blocks-checkout-failures.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/shopper-wc-blocks-checkout-failures.spec.ts index ec8a15b3622..7e0522e70eb 100644 --- a/tests/e2e-pw/specs/shopper/shopper-wc-blocks-checkout-failures.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/shopper-wc-blocks-checkout-failures.spec.ts @@ -11,12 +11,12 @@ import { describeif, getMerchant, getShopper, -} from '../../utils/helpers'; -import * as navigation from '../../utils/shopper-navigation'; -import * as shopper from '../../utils/shopper'; -import { addWCBCheckoutPage } from '../../utils/merchant'; -import { shouldRunWCBlocksTests } from '../../utils/constants'; -import { config } from '../../config/default'; +} from '../../../utils/helpers'; +import * as navigation from '../../../utils/shopper-navigation'; +import * as shopper from '../../../utils/shopper'; +import { addWCBCheckoutPage } from '../../../utils/merchant'; +import { shouldRunWCBlocksTests } from '../../../utils/constants'; +import { config } from '../../../config/default'; const failures = [ { @@ -99,7 +99,9 @@ describeif( shouldRunWCBlocksTests )( await shopper.confirmCardAuthentication( shopperPage ); } await expect( - shopperPage.getByLabel( 'Checkout' ).getByText( error ) + shopperPage + .locator( '.wc-block-checkout__form' ) + .getByText( error ) ).toBeVisible(); } ); } diff --git a/tests/e2e-pw/specs/shopper/shopper-wc-blocks-checkout-purchase.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/shopper-wc-blocks-checkout-purchase.spec.ts similarity index 85% rename from tests/e2e-pw/specs/shopper/shopper-wc-blocks-checkout-purchase.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/shopper-wc-blocks-checkout-purchase.spec.ts index ef28ccc098e..7051366465d 100644 --- a/tests/e2e-pw/specs/shopper/shopper-wc-blocks-checkout-purchase.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/shopper-wc-blocks-checkout-purchase.spec.ts @@ -11,17 +11,17 @@ import { describeif, getMerchant, getShopper, -} from '../../utils/helpers'; -import { shouldRunWCBlocksTests } from '../../utils/constants'; -import { addWCBCheckoutPage } from '../../utils/merchant'; -import { goToCheckoutWCB } from '../../utils/shopper-navigation'; +} from '../../../utils/helpers'; +import { shouldRunWCBlocksTests } from '../../../utils/constants'; +import { addWCBCheckoutPage } from '../../../utils/merchant'; +import { goToCheckoutWCB } from '../../../utils/shopper-navigation'; import { addCartProduct, confirmCardAuthentication, fillBillingAddressWCB, fillCardDetailsWCB, -} from '../../utils/shopper'; -import { config } from '../../config/default'; +} from '../../../utils/shopper'; +import { config } from '../../../config/default'; describeif( shouldRunWCBlocksTests )( 'WooCommerce Blocks > Successful purchase', diff --git a/tests/e2e-pw/specs/shopper/shopper-wc-blocks-saved-card-checkout-and-usage.spec.ts b/tests/e2e-pw/specs/wcpay/shopper/shopper-wc-blocks-saved-card-checkout-and-usage.spec.ts similarity index 90% rename from tests/e2e-pw/specs/shopper/shopper-wc-blocks-saved-card-checkout-and-usage.spec.ts rename to tests/e2e-pw/specs/wcpay/shopper/shopper-wc-blocks-saved-card-checkout-and-usage.spec.ts index b212b94aea9..c82b7cb5b9a 100644 --- a/tests/e2e-pw/specs/shopper/shopper-wc-blocks-saved-card-checkout-and-usage.spec.ts +++ b/tests/e2e-pw/specs/wcpay/shopper/shopper-wc-blocks-saved-card-checkout-and-usage.spec.ts @@ -11,13 +11,13 @@ import { describeif, getMerchant, getShopper, -} from '../../utils/helpers'; -import { shouldRunWCBlocksTests } from '../../utils/constants'; +} from '../../../utils/helpers'; +import { shouldRunWCBlocksTests } from '../../../utils/constants'; import { goToMyAccount, goToShop, goToCheckoutWCB, -} from '../../utils/shopper-navigation'; +} from '../../../utils/shopper-navigation'; import { addCartProduct, deleteSavedCard, @@ -25,9 +25,9 @@ import { fillBillingAddressWCB, fillCardDetailsWCB, selectSavedCardOnCheckout, -} from '../../utils/shopper'; -import { addWCBCheckoutPage } from '../../utils/merchant'; -import { config } from '../../config/default'; +} from '../../../utils/shopper'; +import { addWCBCheckoutPage } from '../../../utils/merchant'; +import { config } from '../../../config/default'; describeif( shouldRunWCBlocksTests )( 'WooCommerce Blocks > Saved cards', diff --git a/tests/e2e-pw/utils/constants.ts b/tests/e2e-pw/utils/constants.ts index f223b1fd078..ec274824acb 100644 --- a/tests/e2e-pw/utils/constants.ts +++ b/tests/e2e-pw/utils/constants.ts @@ -10,3 +10,5 @@ export const products = { SUBSCRIPTION_SIGNUP_FEE: 70, SUBSCRIPTION_NO_SIGNUP_FEE: 88, }; + +export const wooCoreVersion = process.env.E2E_WC_VERSION; diff --git a/tests/e2e-pw/utils/helpers.ts b/tests/e2e-pw/utils/helpers.ts index 7f01beeb007..e470a9cfc53 100644 --- a/tests/e2e-pw/utils/helpers.ts +++ b/tests/e2e-pw/utils/helpers.ts @@ -96,12 +96,12 @@ export const getShopper = async ( shopperPage.locator( '.woocommerce-MyAccount-navigation-link--customer-logout' ) - ).toBeVisible( { timeout: 1000 } ); + ).toBeVisible(); await expect( shopperPage.locator( 'div.woocommerce-MyAccount-content > p >> nth=0' ) - ).toContainText( 'Hello', { timeout: 1000 } ); + ).toContainText( 'Hello' ); await shopperPage .context() .storageState( { path: customerStorageFile } ); diff --git a/tests/e2e-pw/utils/merchant-navigation.ts b/tests/e2e-pw/utils/merchant-navigation.ts index d258e5d09e4..b00fc1f2f78 100644 --- a/tests/e2e-pw/utils/merchant-navigation.ts +++ b/tests/e2e-pw/utils/merchant-navigation.ts @@ -4,6 +4,11 @@ import { Page } from 'playwright/test'; import { dataHasLoaded } from './merchant'; +/** + * Internal dependencies + */ +import { wooCoreVersion } from './constants'; + export const goToOrder = async ( page: Page, orderId: string ) => { await page.goto( `/wp-admin/admin.php?page=wc-orders&action=edit&id=${ orderId }`, @@ -114,19 +119,21 @@ export const goToConnect = async ( page: Page ) => { await dataHasLoaded( page ); }; -export const goToSubscriptions = async ( page: Page ) => - await page.goto( '/wp-admin/admin.php?page=wc-orders--shop_subscription', { +export const goToSubscriptions = async ( page: Page ) => { + const subscriptionsUrl = + wooCoreVersion === '7.7.0' + ? '/wp-admin/edit.php?post_type=shop_subscription' + : '/wp-admin/admin.php?page=wc-orders--shop_subscription'; + await page.goto( subscriptionsUrl, { waitUntil: 'load', } ); +}; export const goToSubscriptionPage = async ( page: Page, subscriptionId: number ) => { await goToSubscriptions( page ); - const orderRow = page.locator( - 'tr#order-' + subscriptionId + ' .order_title a:nth-child(1)' - ); - orderRow.evaluate( ( el: HTMLLinkElement ) => el.click() ); + await page.getByRole( 'link', { name: `#${ subscriptionId }` } ).click(); await dataHasLoaded( page ); }; diff --git a/tests/e2e-pw/utils/merchant.ts b/tests/e2e-pw/utils/merchant.ts index 9f18c1887e2..a98ae7eedaf 100644 --- a/tests/e2e-pw/utils/merchant.ts +++ b/tests/e2e-pw/utils/merchant.ts @@ -420,6 +420,17 @@ export const addWCBCheckoutPage = async ( page: Page ) => { await page.waitForTimeout( 500 ); await page.keyboard.press( 'Escape' ); // to dismiss a dialog if present + // Enable the "Company" field if it's not already enabled. + await page.getByLabel( 'Block: Shipping Address' ).click(); + + const companyCheckbox = page + .locator( '.components-toggle-control' ) + .getByLabel( 'Company' ); + + if ( ! ( await companyCheckbox.isChecked() ) ) { + await companyCheckbox.check(); + } + // Publish the page await page.locator( 'button.editor-post-publish-panel__toggle' ).click(); await page.waitForTimeout( 500 ); diff --git a/tests/e2e-pw/utils/shopper.ts b/tests/e2e-pw/utils/shopper.ts index d3105d83a11..17d5d07bb6f 100644 --- a/tests/e2e-pw/utils/shopper.ts +++ b/tests/e2e-pw/utils/shopper.ts @@ -68,9 +68,22 @@ export const fillBillingAddressWCB = async ( const billingAddressForm = page.getByRole( 'group', { name: 'Billing address', } ); - await billingAddressForm - .getByLabel( 'Country/Region' ) - .selectOption( billingAddress.country ); + + const countryField = billingAddressForm.getByLabel( 'Country/Region' ); + + try { + await countryField.selectOption( billingAddress.country ); + } catch ( error ) { + // Fallback for WC 7.7.0. + await countryField.focus(); + await countryField.fill( billingAddress.country ); + + await page + .locator( '.components-form-token-field__suggestion' ) + .first() + .click(); + } + await billingAddressForm .getByLabel( 'First Name' ) .fill( billingAddress.firstname ); @@ -93,10 +106,17 @@ export const fillBillingAddressWCB = async ( .getByLabel( 'Apartment, suite, etc. (optional)' ) .fill( billingAddress.addresssecondline ); await billingAddressForm.getByLabel( 'City' ).fill( billingAddress.city ); + + const stateInput = billingAddressForm.getByLabel( 'State', { + exact: true, + } ); if ( billingAddress.state ) { - await billingAddressForm - .getByLabel( 'State' ) - .selectOption( billingAddress.state ); + try { + await stateInput.selectOption( billingAddress.state ); + } catch ( error ) { + // Fallback for WC 7.7.0. + await stateInput.fill( billingAddress.state ); + } } await billingAddressForm .getByLabel( 'ZIP Code' ) @@ -206,7 +226,6 @@ export const fillCardDetailsWCB = async ( ); const stripeFrame = await frameHandle.contentFrame(); if ( ! stripeFrame ) return; - await stripeFrame.waitForLoadState( 'networkidle' ); await stripeFrame.getByPlaceholder( '1234 1234 1234' ).fill( card.number ); await stripeFrame .getByPlaceholder( 'MM / YY' ) @@ -280,9 +299,11 @@ export const addToCartFromShopPage = async ( page.locator( `${ addToCartSelector }.added` ) ).toBeVisible(); } else { + // This generic regex will match the aria-label for the "Add to cart" button for any product. + // It should work for WC 7.7.0 and later. // These unicode characters are the smart (or curly) quotes: “ ”. const addToCartRegex = new RegExp( - `Add to cart: \u201C${ product }\u201D` + `Add\\s+(?:to\\s+cart:\\s*)?\u201C${ product }\u201D(?:\\s+to\\s+your\\s+cart)?` ); await page.getByLabel( addToCartRegex ).click(); diff --git a/tests/e2e/env/setup.sh b/tests/e2e/env/setup.sh index d9e1bc5d7db..364d906f29e 100755 --- a/tests/e2e/env/setup.sh +++ b/tests/e2e/env/setup.sh @@ -219,9 +219,10 @@ cli wp option set woocommerce_checkout_company_field "optional" echo "Importing WooCommerce shop pages..." cli wp wc --user=admin tool run install_pages +INSTALLED_WC_VERSION=$(cli_debug wp plugin get woocommerce --field=version) + # Start - Workaround for > WC 8.3 compatibility by updating cart & checkout pages to use shortcode. # To be removed when WooPayments L-2 support is >= WC 8.3 -INSTALLED_WC_VERSION=$(cli_debug wp plugin get woocommerce --field=version) IS_WORKAROUND_REQUIRED=$(cli_debug wp eval "echo version_compare(\"$INSTALLED_WC_VERSION\", \"8.3\", \">=\");") if [[ "$IS_WORKAROUND_REQUIRED" = "1" ]]; then @@ -345,8 +346,16 @@ cli wp db query "DELETE p, m FROM wp_posts p LEFT JOIN wp_postmeta m ON p.ID = m echo "Setting up a coupon for E2E tests" cli wp wc --user=admin shop_coupon create --code=free --amount=100 --discount_type=percent --individual_use=true --free_shipping=true -echo "Syncing HPOS data" -cli wp wc hpos sync +# HPOS was officially released in WooCommerce 8.2.0, so we need to check if we should sync COT or HPOS data. +IS_HPOS_AVAILABLE=$(cli_debug wp eval "echo version_compare(\"$INSTALLED_WC_VERSION\", \"8.2\", \">=\");") + +if [[ ${IS_HPOS_AVAILABLE} ]]; then + echo "Syncing HPOS data" + cli wp wc hpos sync +else + echo "Syncing COT data" + cli wp wc cot sync +fi # Log test configuration for visibility echo