From e74abeffe49cdfcedf36bff74e455ae6804a12e5 Mon Sep 17 00:00:00 2001 From: nigeljamesstevenson <105309450+nigeljamesstevenson@users.noreply.github.com> Date: Mon, 20 Mar 2023 20:24:36 +0000 Subject: [PATCH] update api-core-tests to handle extenstions that add shipping (#37239) --- .../update-api-core-tests-to-better-handle-shipping-types | 4 ++++ .../tests/payment-gateways/payment-gateways-crud.test.js | 4 ++-- .../api-core-tests/tests/shipping/shipping-method.test.js | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 plugins/woocommerce/changelog/update-api-core-tests-to-better-handle-shipping-types diff --git a/plugins/woocommerce/changelog/update-api-core-tests-to-better-handle-shipping-types b/plugins/woocommerce/changelog/update-api-core-tests-to-better-handle-shipping-types new file mode 100644 index 00000000000..bd3c4710274 --- /dev/null +++ b/plugins/woocommerce/changelog/update-api-core-tests-to-better-handle-shipping-types @@ -0,0 +1,4 @@ +Significance: patch +Type: update + +Update playwright api-core-tests to handle cases where extensions add to shipping methods diff --git a/plugins/woocommerce/tests/api-core-tests/tests/payment-gateways/payment-gateways-crud.test.js b/plugins/woocommerce/tests/api-core-tests/tests/payment-gateways/payment-gateways-crud.test.js index f1e83fe7dba..cdc7509c080 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/payment-gateways/payment-gateways-crud.test.js +++ b/plugins/woocommerce/tests/api-core-tests/tests/payment-gateways/payment-gateways-crud.test.js @@ -135,7 +135,7 @@ test.describe('Payment Gateways API tests', () => { "default": "", "tip": "If COD is only available for certain methods, set it up here. Leave blank to enable for all methods.", "placeholder": "", - "options": { + "options": expect.objectContaining({ "Flat rate": { "flat_rate": "Any "Flat rate" method" }, @@ -145,7 +145,7 @@ test.describe('Payment Gateways API tests', () => { "Local pickup": { "local_pickup": "Any "Local pickup" method" } - } + }) }, "enable_for_virtual": { "id": "enable_for_virtual", diff --git a/plugins/woocommerce/tests/api-core-tests/tests/shipping/shipping-method.test.js b/plugins/woocommerce/tests/api-core-tests/tests/shipping/shipping-method.test.js index 51f52e70144..72ac2b705f7 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/shipping/shipping-method.test.js +++ b/plugins/woocommerce/tests/api-core-tests/tests/shipping/shipping-method.test.js @@ -66,7 +66,7 @@ test.describe('Shipping methods API tests', () => { const responseJSON = await response.json(); expect(response.status()).toEqual(200); expect(Array.isArray(responseJSON)).toBe(true); - expect(responseJSON.length).toEqual(3); + expect(responseJSON.length).toBeGreaterThanOrEqual(3); expect(responseJSON[0].id).toEqual("flat_rate"); expect(responseJSON[1].id).toEqual("free_shipping"); expect(responseJSON[2].id).toEqual("local_pickup");