diff --git a/plugins/woocommerce/changelog/e2e-bulk-update-order-status b/plugins/woocommerce/changelog/e2e-bulk-update-order-status new file mode 100644 index 00000000000..be7672d0b57 --- /dev/null +++ b/plugins/woocommerce/changelog/e2e-bulk-update-order-status @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Add e2e test to bulk update order statuses diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-bulk-edit.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-bulk-edit.spec.js new file mode 100644 index 00000000000..1fdf2490280 --- /dev/null +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-bulk-edit.spec.js @@ -0,0 +1,92 @@ +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 for there to be 5 orders (plus a header and footer row) + await expect( page.getByRole( 'row' ) ).toHaveCount( 7 ); + + // 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(); + } ); + +} );