From 5446cb441320876feada2fea60447eeb35dd5a55 Mon Sep 17 00:00:00 2001 From: Marco Almeida Date: Tue, 29 Aug 2023 18:07:16 +0100 Subject: [PATCH 01/37] Do not remove "sale date from" when the sale is still active Do not remove "sale date from" when the sale is still active, as in some legislations it's mandatory to show the start and end date of sales, and developers can get it from this field. Closes #34696 --- plugins/woocommerce/includes/wc-product-functions.php | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/woocommerce/includes/wc-product-functions.php b/plugins/woocommerce/includes/wc-product-functions.php index da041dbb0ea..aa4825986d1 100644 --- a/plugins/woocommerce/includes/wc-product-functions.php +++ b/plugins/woocommerce/includes/wc-product-functions.php @@ -448,7 +448,6 @@ function wc_scheduled_sales() { if ( $sale_price ) { $product->set_price( $sale_price ); - $product->set_date_on_sale_from( '' ); } else { $product->set_date_on_sale_to( '' ); $product->set_date_on_sale_from( '' ); From b63fd9986d617d884eee8f3012f9576c3fb24f0c Mon Sep 17 00:00:00 2001 From: Jon Lane Date: Wed, 20 Sep 2023 14:23:07 -0700 Subject: [PATCH 02/37] Update order status to cancelled --- .../changelog/e2e-update-order-to-cancelled | 4 +++ .../e2e-pw/tests/merchant/order-edit.spec.js | 35 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 plugins/woocommerce/changelog/e2e-update-order-to-cancelled diff --git a/plugins/woocommerce/changelog/e2e-update-order-to-cancelled b/plugins/woocommerce/changelog/e2e-update-order-to-cancelled new file mode 100644 index 00000000000..d3fc2f1f67c --- /dev/null +++ b/plugins/woocommerce/changelog/e2e-update-order-to-cancelled @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Update order status to cancelled diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-edit.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-edit.spec.js index 270f93ba851..ed6c13e500b 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-edit.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-edit.spec.js @@ -5,7 +5,7 @@ const uuid = require( 'uuid' ); test.describe( 'Edit order', () => { test.use( { storageState: process.env.ADMINSTATE } ); - let orderId; + let orderId, orderToCancel; test.beforeAll( async ( { baseURL } ) => { const api = new wcApi( { @@ -21,6 +21,13 @@ test.describe( 'Edit order', () => { .then( ( response ) => { orderId = response.data.id; } ); + await api + .post( 'orders', { + status: 'processing', + } ) + .then( ( response ) => { + orderToCancel = response.data.id; + } ); } ); test.afterAll( async ( { baseURL } ) => { @@ -31,6 +38,7 @@ test.describe( 'Edit order', () => { version: 'wc/v3', } ); await api.delete( `orders/${ orderId }`, { force: true } ); + await api.delete( `orders/${ orderToCancel }`, { force: true } ); } ); test( 'can view single order', async ( { page } ) => { @@ -66,6 +74,31 @@ test.describe( 'Edit order', () => { await expect( page.locator( '#woocommerce-order-notes .note_content >> nth=0' ) ).toContainText( 'Order status changed from Processing to Completed.' ); + + // load the orders listing and confirm order is completed + await page.goto( 'wp-admin/admin.php?page=wc-orders' ); + + await expect( page.locator( `#order-${ orderId }` ).getByRole( 'cell', { name: 'Completed' }) ).toBeVisible(); + } ); + + test( 'can update order status to cancelled', async ( { page } ) => { + // open order we created + await page.goto( `wp-admin/post.php?post=${ orderToCancel }&action=edit` ); + + // update order status to Completed + await page.locator( '#order_status' ).selectOption( 'Cancelled' ); + await page.locator( 'button.save_order' ).click(); + + // verify order status changed and note added + await expect( page.locator( '#order_status' ) ).toHaveValue( + 'wc-cancelled' + ); + await expect( page.getByText( 'Order status changed from Processing to Cancelled.' ) ).toBeVisible(); + + // load the orders listing and confirm order is cancelled + await page.goto( 'wp-admin/admin.php?page=wc-orders' ); + + await expect( page.locator( `#order-${ orderToCancel }` ).getByRole( 'cell', { name: 'Cancelled' }) ).toBeVisible(); } ); test( 'can update order details', async ( { page } ) => { From 715c0d11705c0ba9a2ebddee9544bbf29aeaed82 Mon Sep 17 00:00:00 2001 From: Jon Lane Date: Wed, 20 Sep 2023 14:50:59 -0700 Subject: [PATCH 03/37] Add test to bulk update order status --- .../changelog/e2e-bulk-update-order-status | 4 + .../tests/merchant/order-bulk-edit.spec.js | 92 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 plugins/woocommerce/changelog/e2e-bulk-update-order-status create mode 100644 plugins/woocommerce/tests/e2e-pw/tests/merchant/order-bulk-edit.spec.js 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(); + } ); + +} ); From 3d451e75a69cd4accf7a8ebc9cbe0deaaba26601 Mon Sep 17 00:00:00 2001 From: Jon Lane Date: Thu, 21 Sep 2023 15:09:28 -0700 Subject: [PATCH 04/37] Remove count because other tests may have orders --- .../tests/e2e-pw/tests/merchant/order-bulk-edit.spec.js | 3 --- 1 file changed, 3 deletions(-) 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 index 1fdf2490280..0a0619827d9 100644 --- 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 @@ -67,9 +67,6 @@ test.describe( 'Bulk edit orders', () => { 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(); From 5b8336cc8a3cd61601538e027feabb8072cc20b3 Mon Sep 17 00:00:00 2001 From: Marco Almeida Date: Wed, 27 Sep 2023 10:01:56 +0100 Subject: [PATCH 05/37] Create changelog/39948-patch-4 --- changelog/39948-patch-4 | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/39948-patch-4 diff --git a/changelog/39948-patch-4 b/changelog/39948-patch-4 new file mode 100644 index 00000000000..2b48d2bf62e --- /dev/null +++ b/changelog/39948-patch-4 @@ -0,0 +1,4 @@ +Significance: minor +Type: update + +Do not remove sale date from when the sale is still active From 30d369adaa88ecb631e11bf5618028c1f6c35dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joni=20Erkkil=C3=A4?= Date: Sat, 30 Sep 2023 16:05:40 +0300 Subject: [PATCH 06/37] Added aria-label to wrapper element --- plugins/woocommerce/includes/wc-template-functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/wc-template-functions.php b/plugins/woocommerce/includes/wc-template-functions.php index 678cd1ac361..e2403851d0e 100644 --- a/plugins/woocommerce/includes/wc-template-functions.php +++ b/plugins/woocommerce/includes/wc-template-functions.php @@ -2338,7 +2338,7 @@ if ( ! function_exists( 'woocommerce_breadcrumb' ) ) { 'woocommerce_breadcrumb_defaults', array( 'delimiter' => ' / ', - 'wrap_before' => '