Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update e2e tests all and atomic workflows #10277

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ec0c743
Update run-log-tests action command
allie500 Jan 30, 2025
350e864
Revert 'ci' command change
allie500 Jan 30, 2025
9c4c590
Re-add 'ci' to command.
allie500 Jan 30, 2025
b089cc3
Temporarily add feature branch to action for testing
allie500 Jan 30, 2025
06d25db
Revert change to pull request workflow file
allie500 Jan 31, 2025
34a2469
Update run-log-tests action
allie500 Jan 31, 2025
595071f
Remove NODE_ENV flag
allie500 Jan 31, 2025
43c2d02
Add Playwright browser install step
allie500 Jan 31, 2025
657a7be
Update Playwright config
allie500 Jan 31, 2025
7e8ec50
Update run-log-tests action
allie500 Jan 31, 2025
5f628c2
Update E2E_RESULT_FILEPATH
allie500 Jan 31, 2025
78c2410
Update pull request workflow
allie500 Jan 31, 2025
8760dce
Update Playwright config
allie500 Jan 31, 2025
01dcc5d
Update results file config
allie500 Jan 31, 2025
67db114
Update failed test cound and retry failed tests command
allie500 Jan 31, 2025
aa2eb6b
Update Playwright config
allie500 Jan 31, 2025
afe1564
Update Playwright e2e tests directory structure
allie500 Jan 31, 2025
6df668c
Update e2e-test workflow to install Playwright chromium
allie500 Jan 31, 2025
ebd662f
Update projects to be a simple chromium setup
eduardoumpierre Jan 31, 2025
58a9fb9
Add Playwright test results to artifacts
eduardoumpierre Feb 1, 2025
a7b3650
Disable multi-currency before running price checks
eduardoumpierre Feb 1, 2025
2494c5f
Remove custom timeouts
eduardoumpierre Feb 1, 2025
f6bdc3c
Wait for UI to be unblocked to continue test
eduardoumpierre Feb 1, 2025
f129a1e
Fix snapshots folder location
eduardoumpierre Feb 1, 2025
b46ed4f
Ensure test report is always uploaded after execution
eduardoumpierre Feb 1, 2025
f3002da
Update E2E results file path for tests all workflow
eduardoumpierre Feb 1, 2025
b5028d6
Add step for installing Playwright
eduardoumpierre Feb 1, 2025
8299654
Remove wait for load state
eduardoumpierre Feb 1, 2025
db6633f
Check for HPOS availability before running the sync
eduardoumpierre Feb 1, 2025
270d80d
Fix strict mode violation for WC 7.7.0 test run
allie500 Feb 3, 2025
da2cd16
Enable the optional company field
eduardoumpierre Feb 3, 2025
4d78af5
Add fallback to WC 7.7.0
eduardoumpierre Feb 3, 2025
48ed1ef
Merge branch 'dev/10238-update-e2e-tests-all-workflow' of https://git…
eduardoumpierre Feb 3, 2025
352aebd
Add wooCoreVersion constant
allie500 Feb 3, 2025
9ec962f
Add WC version check to goToSubscriptions
allie500 Feb 3, 2025
4443a72
Update test to work with WC latest & 7.7.0
allie500 Feb 3, 2025
232ca49
Update locator selector to work on WC 7.7.0
eduardoumpierre Feb 3, 2025
55708e7
Merge branch 'dev/10238-update-e2e-tests-all-workflow' of https://git…
eduardoumpierre Feb 3, 2025
31de689
Update goToSubscriptionPage to work with WC latest and 7.7.0
allie500 Feb 3, 2025
5caa5c3
Fix test to work with WC latest & 7.7.0
allie500 Feb 3, 2025
9cb41aa
Update price assertions
eduardoumpierre Feb 3, 2025
0cbb0cb
Merge branch 'dev/10238-update-e2e-tests-all-workflow' of https://git…
eduardoumpierre Feb 3, 2025
9189fa6
Add fallback for WC 7.7.0
eduardoumpierre Feb 3, 2025
e5d366d
Update selectors to work with the latest WC version
eduardoumpierre Feb 3, 2025
6f5afaf
Increase maxDiffPixelRatio for WC 7.7.0
eduardoumpierre Feb 3, 2025
a6a9c96
Add changelog
allie500 Feb 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/actions/e2e/run-log-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -30,18 +30,19 @@ 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 }}
path: |
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
6 changes: 5 additions & 1 deletion .github/workflows/e2e-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
10 changes: 9 additions & 1 deletion .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions changelog/dev-10238-update-e2e-tests-all-workflow
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Update Github actions and workflows. Change e2e tests directory structure.
42 changes: 32 additions & 10 deletions tests/e2e-pw/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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' } ] ],
Expand All @@ -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: [
{
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 )(
Expand All @@ -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,
Expand All @@ -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 ( {
Expand Down Expand Up @@ -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();
} );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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();
} );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading
Loading