Fix recently failing "API on WP Latest" job in release testing workflow (#40453)
* Add changelog * Add dedicated PW config and global setup files * Add step to download chromium * Specify config and env var * Fix trivial whitespaces * Disable Slack notif for now * Re-enable Slack summary * Simplify getting major, minor version numbers * Use single line for response wait
This commit is contained in:
parent
773baea857
commit
c64ae36956
|
@ -1,6 +1,5 @@
|
||||||
name: Run API tests
|
name: Run API tests
|
||||||
description: Runs the WooCommerce Core API tests and generates Allure report.
|
description: Runs the WooCommerce Core API tests and generates Allure report.
|
||||||
permissions: {}
|
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
report-name:
|
report-name:
|
||||||
|
@ -8,6 +7,9 @@ inputs:
|
||||||
required: true
|
required: true
|
||||||
tests:
|
tests:
|
||||||
description: Specific tests to run, separated by single whitespace. See https://playwright.dev/docs/test-cli
|
description: Specific tests to run, separated by single whitespace. See https://playwright.dev/docs/test-cli
|
||||||
|
playwright-config:
|
||||||
|
description: Playwright config file to be used
|
||||||
|
default: playwright.config.js
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
result:
|
result:
|
||||||
|
@ -23,7 +25,7 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
pnpm exec playwright test \
|
pnpm exec playwright test \
|
||||||
--config=tests/api-core-tests/playwright.config.js \
|
--config=tests/api-core-tests/${{ inputs.playwright-config }} \
|
||||||
${{ inputs.tests }}
|
${{ inputs.tests }}
|
||||||
|
|
||||||
- name: Generate Test report.
|
- name: Generate Test report.
|
||||||
|
|
|
@ -155,16 +155,22 @@ jobs:
|
||||||
install-filters: woocommerce
|
install-filters: woocommerce
|
||||||
build: false
|
build: false
|
||||||
|
|
||||||
|
- name: Download and install Chromium browser.
|
||||||
|
working-directory: plugins/woocommerce
|
||||||
|
run: pnpm exec playwright install chromium
|
||||||
|
|
||||||
- name: Run API tests
|
- name: Run API tests
|
||||||
id: run-api-composite-action
|
id: run-api-composite-action
|
||||||
uses: ./.github/actions/tests/run-api-tests
|
uses: ./.github/actions/tests/run-api-tests
|
||||||
with:
|
with:
|
||||||
report-name: ${{ env.API_WP_LATEST_ARTIFACT }}
|
report-name: ${{ env.API_WP_LATEST_ARTIFACT }}
|
||||||
tests: hello
|
tests: hello
|
||||||
|
playwright-config: ci-release.playwright.config.js
|
||||||
env:
|
env:
|
||||||
API_BASE_URL: ${{ secrets.RELEASE_TEST_URL }}
|
API_BASE_URL: ${{ secrets.RELEASE_TEST_URL }}
|
||||||
USER_KEY: ${{ secrets.RELEASE_TEST_ADMIN_USER }}
|
USER_KEY: ${{ secrets.RELEASE_TEST_ADMIN_USER }}
|
||||||
USER_SECRET: ${{ secrets.RELEASE_TEST_ADMIN_PASSWORD }}
|
USER_SECRET: ${{ secrets.RELEASE_TEST_ADMIN_PASSWORD }}
|
||||||
|
UPDATE_WC: ${{ needs.get-tag.outputs.tag }}
|
||||||
|
|
||||||
- name: Upload Allure artifacts to bucket
|
- name: Upload Allure artifacts to bucket
|
||||||
if: success() || ( failure() && steps.run-api-composite-action.conclusion == 'failure' )
|
if: success() || ( failure() && steps.run-api-composite-action.conclusion == 'failure' )
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Fix "API on WP Latest" job in "Smoke test release" workflow.
|
|
@ -0,0 +1,107 @@
|
||||||
|
const { UPDATE_WC, USER_KEY, USER_SECRET } = process.env;
|
||||||
|
const { test, expect } = require( '@playwright/test' );
|
||||||
|
const path = require( 'path' );
|
||||||
|
const fs = require( 'fs' );
|
||||||
|
|
||||||
|
const zipPath = path.resolve( 'tmp', 'woocommerce.zip' );
|
||||||
|
const downloadURL = `https://github.com/woocommerce/woocommerce/releases/download/${ UPDATE_WC }/woocommerce.zip`;
|
||||||
|
|
||||||
|
test( `Setup remote test site`, async ( { page, request } ) => {
|
||||||
|
await test.step( `Download WooCommerce build zip`, async () => {
|
||||||
|
const response = await request.get( downloadURL );
|
||||||
|
expect( response.ok() ).toBeTruthy();
|
||||||
|
const body = await response.body();
|
||||||
|
fs.mkdirSync( 'tmp', { recursive: true } );
|
||||||
|
fs.writeFileSync( zipPath, body );
|
||||||
|
} );
|
||||||
|
|
||||||
|
await test.step( 'Login to wp-admin', async () => {
|
||||||
|
const Username = 'Username or Email Address';
|
||||||
|
const Password = 'Password';
|
||||||
|
const Log_In = 'Log In';
|
||||||
|
const Dashboard = 'Dashboard';
|
||||||
|
|
||||||
|
// Need to wait until network idle. Otherwise, Password field gets auto-cleared after typing password in.
|
||||||
|
await page.goto( '/wp-admin', { waitUntil: 'networkidle' } );
|
||||||
|
await page.getByLabel( Username ).fill( USER_KEY );
|
||||||
|
await page.getByLabel( Password, { exact: true } ).fill( USER_SECRET );
|
||||||
|
await page.getByRole( 'button', { name: Log_In } ).click();
|
||||||
|
await expect(
|
||||||
|
page
|
||||||
|
.locator( '#menu-dashboard' )
|
||||||
|
.getByRole( 'link', { name: Dashboard } )
|
||||||
|
).toBeVisible();
|
||||||
|
} );
|
||||||
|
|
||||||
|
await test.step( `Deactivate currently installed WooCommerce version`, async () => {
|
||||||
|
const response = await request.put(
|
||||||
|
'/wp-json/wp/v2/plugins/woocommerce/woocommerce',
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
status: 'inactive',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
expect( response.ok() ).toBeTruthy();
|
||||||
|
} );
|
||||||
|
|
||||||
|
await test.step( `Delete currently installed WooCommerce version`, async () => {
|
||||||
|
const response = await request.delete(
|
||||||
|
'/wp-json/wp/v2/plugins/woocommerce/woocommerce'
|
||||||
|
);
|
||||||
|
expect( response.ok() ).toBeTruthy();
|
||||||
|
} );
|
||||||
|
|
||||||
|
await test.step( `Install WooCommerce ${ UPDATE_WC }`, async () => {
|
||||||
|
const Upload_Plugin = 'Upload Plugin';
|
||||||
|
const Plugin_zip_file = 'Plugin zip file';
|
||||||
|
const Install_Now = 'Install Now';
|
||||||
|
const Activate_Plugin = 'Activate Plugin';
|
||||||
|
|
||||||
|
await page.goto( '/wp-admin/plugin-install.php' );
|
||||||
|
await page.getByRole( 'button', { name: Upload_Plugin } ).click();
|
||||||
|
await page.getByLabel( Plugin_zip_file ).setInputFiles( zipPath );
|
||||||
|
await page.getByRole( 'button', { name: Install_Now } ).click();
|
||||||
|
const uploadResponse = await page.waitForResponse(
|
||||||
|
'**/wp-admin/update.php?action=upload-plugin'
|
||||||
|
);;
|
||||||
|
expect( uploadResponse.ok() ).toBeTruthy();
|
||||||
|
await expect(
|
||||||
|
page.getByRole( 'link', { name: Activate_Plugin } )
|
||||||
|
).toBeVisible();
|
||||||
|
} );
|
||||||
|
|
||||||
|
await test.step( `Activate WooCommerce`, async () => {
|
||||||
|
const response = await request.put(
|
||||||
|
'/wp-json/wp/v2/plugins/woocommerce/woocommerce',
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
status: 'active',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
expect( response.ok() ).toBeTruthy();
|
||||||
|
} );
|
||||||
|
|
||||||
|
await test.step( `Verify WooCommerce version was installed`, async () => {
|
||||||
|
const response = await request.get(
|
||||||
|
'/wp-json/wp/v2/plugins/woocommerce/woocommerce'
|
||||||
|
);
|
||||||
|
const { status, version } = await response.json();
|
||||||
|
expect( status ).toEqual( 'active' );
|
||||||
|
expect( version ).toEqual( UPDATE_WC );
|
||||||
|
} );
|
||||||
|
|
||||||
|
await test.step( `Verify WooCommerce database version`, async () => {
|
||||||
|
const response = await request.get( '/wp-json/wc/v3/system_status' );
|
||||||
|
const { database } = await response.json();
|
||||||
|
const { wc_database_version } = database;
|
||||||
|
const [major, minor] = UPDATE_WC.split( '.' );
|
||||||
|
const pattern = new RegExp( `^${ major }\.${ minor }` );
|
||||||
|
expect( wc_database_version ).toMatch( pattern );
|
||||||
|
} );
|
||||||
|
|
||||||
|
await test.step( `Delete zip`, async () => {
|
||||||
|
fs.unlinkSync( zipPath );
|
||||||
|
} );
|
||||||
|
} );
|
|
@ -0,0 +1,24 @@
|
||||||
|
const defaultConfig = require( './playwright.config' );
|
||||||
|
|
||||||
|
// Global setup will be done through the 'Setup' project, not through the `globalSetup` property
|
||||||
|
delete defaultConfig[ 'globalSetup' ];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {import('@playwright/test').PlaywrightTestConfig}
|
||||||
|
*/
|
||||||
|
const config = {
|
||||||
|
...defaultConfig,
|
||||||
|
projects: [
|
||||||
|
{
|
||||||
|
name: 'Setup',
|
||||||
|
testDir: './',
|
||||||
|
testMatch: 'ci-release.global-setup.js',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'API tests',
|
||||||
|
dependencies: [ 'Setup' ],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = config;
|
Loading…
Reference in New Issue