Skip to content

Commit

Permalink
Fix e2e and api execution on daily runs (woocommerce#41113)
Browse files Browse the repository at this point in the history
* Increase a couple of timeouts

* Remove duplicate update to nightly

* Add changelog

* Install Playwright

* Handle Playwright setup

* Add in build name

* Add in check in e2e tests for daily run

* Reverse check

* Rookie mistake

* Use ternary operator instead

---------

Co-authored-by: Jon Lane <[email protected]>
  • Loading branch information
lanej0 and Jon Lane authored Nov 1, 2023
1 parent 4423117 commit 9572bf2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .github/actions/tests/run-api-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ outputs:
runs:
using: composite
steps:
- name: Download and install Chromium browser.
working-directory: plugins/woocommerce
shell: bash
run: pnpm exec playwright install chromium

- name: Run API tests.
id: run-api-tests
working-directory: plugins/woocommerce
Expand Down
11 changes: 2 additions & 9 deletions .github/workflows/smoke-test-daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ jobs:
install-filters: woocommerce
build: false

- name: Update site to nightly version
uses: ./.github/actions/tests/run-e2e-tests
with:
report-name: ${{ env.API_ARTIFACT }}
tests: update-woocommerce.spec.js
env:
GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }}
UPDATE_WC: nightly

- name: Run API tests
id: run-api-composite-action
uses: ./.github/actions/tests/run-api-tests
Expand All @@ -62,6 +53,8 @@ jobs:
env:
USER_KEY: ${{ secrets.SMOKE_TEST_ADMIN_USER }}
USER_SECRET: ${{ secrets.SMOKE_TEST_ADMIN_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }}
UPDATE_WC: nightly

e2e-tests:
name: E2E tests on nightly build
Expand Down
4 changes: 4 additions & 0 deletions plugins/woocommerce/changelog/fix-e2e-api-execution-on-daily
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fixes daily execution workflow for API and e2e tests
35 changes: 26 additions & 9 deletions plugins/woocommerce/tests/api-core-tests/global-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const axios = require( 'axios' ).default;
const playwrightConfig = require( './playwright.config' );
const { site } = require( './utils' );


/**
*
* @param {import('@playwright/test').FullConfig} config
Expand Down Expand Up @@ -155,9 +154,15 @@ module.exports = async ( config ) => {
await setupPage
.locator( '#install-plugin-submit' )
.click( { timeout: 60000 } );
await setupPage.waitForLoadState( 'networkidle' );
await setupPage.waitForLoadState( 'networkidle', {
timeout: 60000,
} );
await expect(
setupPage.getByRole( 'link', { name: 'Activate Plugin' } )
setupPage.getByRole(
'link',
{ name: 'Activate Plugin' },
{ timeout: 60000 }
)
).toBeVisible();
console.log( 'Activating Plugin...' );
await setupPage
Expand Down Expand Up @@ -206,18 +211,30 @@ module.exports = async ( config ) => {
}
} else {
// running on localhost using wp-env so ensure HPOS is set if ENABLE_HPOS env variable is passed
if (ENABLE_HPOS) {
if ( ENABLE_HPOS ) {
let hposConfigured = false;
const value = ENABLE_HPOS === '0' ? 'no' : 'yes';
try {
const auth = { username: playwrightConfig.userKey, password: playwrightConfig.userSecret };
const hposResponse = await axios.post( playwrightConfig.use.baseURL + '/wp-json/wc/v3/settings/advanced/woocommerce_custom_orders_table_enabled', { value }, { auth } );
const auth = {
username: playwrightConfig.userKey,
password: playwrightConfig.userSecret,
};
const hposResponse = await axios.post(
playwrightConfig.use.baseURL +
'/wp-json/wc/v3/settings/advanced/woocommerce_custom_orders_table_enabled',
{ value },
{ auth }
);
if ( hposResponse.data.value === value ) {
console.log( `HPOS Switched ${ value === 'yes' ? 'on' : 'off' } successfully` );
console.log(
`HPOS Switched ${
value === 'yes' ? 'on' : 'off'
} successfully`
);
hposConfigured = true;
}
} catch( error ) {
console.log( 'HPOS setup failed.');
} catch ( error ) {
console.log( 'HPOS setup failed.' );
console.log( error );
process.exit( 1 );
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/woocommerce/tests/e2e-pw/global-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ module.exports = async ( config ) => {
}
}

await site.useCartCheckoutShortcodes( baseURL, userAgent, admin );
!process.env.BASE_URL || process.env.BASE_URL === 'localhost' && await site.useCartCheckoutShortcodes( baseURL, userAgent, admin );

await adminContext.close();
await customerContext.close();
Expand Down

0 comments on commit 9572bf2

Please sign in to comment.