Add test to bulk update order status (#40320)

This commit is contained in:
nigeljamesstevenson 2023-10-19 12:35:42 +01:00 committed by GitHub
commit 5653106e78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Add e2e test to bulk update order statuses

View File

@ -0,0 +1,89 @@
const { test, expect } = require( '@playwright/test' );
const wcApi = require( '@woocommerce/woocommerce-rest-api' ).default;
test.describe( 'Bulk edit orders', () => {
test.use( { storageState: process.env.ADMINSTATE } );
let orderId1, orderId2, orderId3, orderId4, orderId5;
test.beforeAll( async ( { baseURL } ) => {
const api = new wcApi( {
url: baseURL,
consumerKey: process.env.CONSUMER_KEY,
consumerSecret: process.env.CONSUMER_SECRET,
version: 'wc/v3',
} );
await api
.post( 'orders', {
status: 'processing',
} )
.then( ( response ) => {
orderId1 = response.data.id;
} );
await api
.post( 'orders', {
status: 'processing',
} )
.then( ( response ) => {
orderId2 = response.data.id;
} );
await api
.post( 'orders', {
status: 'processing',
} )
.then( ( response ) => {
orderId3 = response.data.id;
} );
await api
.post( 'orders', {
status: 'processing',
} )
.then( ( response ) => {
orderId4 = response.data.id;
} );
await api
.post( 'orders', {
status: 'processing',
} )
.then( ( response ) => {
orderId5 = response.data.id;
} );
} );
test.afterAll( async ( { baseURL } ) => {
const api = new wcApi( {
url: baseURL,
consumerKey: process.env.CONSUMER_KEY,
consumerSecret: process.env.CONSUMER_SECRET,
version: 'wc/v3',
} );
await api.delete( `orders/${ orderId1 }`, { force: true } );
await api.delete( `orders/${ orderId2 }`, { force: true } );
await api.delete( `orders/${ orderId3 }`, { force: true } );
await api.delete( `orders/${ orderId4 }`, { force: true } );
await api.delete( `orders/${ orderId5 }`, { force: true } );
} );
test( 'can bulk update order status', async ( { page } ) => {
await page.goto( 'wp-admin/admin.php?page=wc-orders' );
// expect order status 'processing' to show
await expect( page.locator( `#order-${ orderId1 }`).getByText( 'Processing') ).toBeVisible();
await expect( page.locator( `#order-${ orderId2 }`).getByText( 'Processing') ).toBeVisible();
await expect( page.locator( `#order-${ orderId3 }`).getByText( 'Processing') ).toBeVisible();
await expect( page.locator( `#order-${ orderId4 }`).getByText( 'Processing') ).toBeVisible();
await expect( page.locator( `#order-${ orderId5 }`).getByText( 'Processing') ).toBeVisible();
await page.locator( '#cb-select-all-1' ).click();
await page.locator( '#bulk-action-selector-top' ).selectOption( 'Change status to completed' );
await page.locator('#doaction').click();
// expect order status 'completed' to show
await expect( page.locator( `#order-${ orderId1 }`).getByText( 'Completed') ).toBeVisible();
await expect( page.locator( `#order-${ orderId2 }`).getByText( 'Completed') ).toBeVisible();
await expect( page.locator( `#order-${ orderId3 }`).getByText( 'Completed') ).toBeVisible();
await expect( page.locator( `#order-${ orderId4 }`).getByText( 'Completed') ).toBeVisible();
await expect( page.locator( `#order-${ orderId5 }`).getByText( 'Completed') ).toBeVisible();
} );
} );