diff --git a/tests/e2e/core-tests/specs/index.js b/tests/e2e/core-tests/specs/index.js index 256c87a4dba..b404e8bf19d 100644 --- a/tests/e2e/core-tests/specs/index.js +++ b/tests/e2e/core-tests/specs/index.js @@ -21,7 +21,7 @@ const { runAddSimpleProductTest, runAddVariableProductTest } = require( './merch const runUpdateGeneralSettingsTest = require( './merchant/wp-admin-settings-general.test' ); const runProductSettingsTest = require( './merchant/wp-admin-settings-product.test' ); const runTaxSettingsTest = require( './merchant/wp-admin-settings-tax.test' ); -const runOrderStatusFilterTest = require( './merchant/wp-admin-order-status-filter.test' ); +const runOrderStatusFiltersTest = require( './merchant/wp-admin-order-status-filters.test' ); const runSetupOnboardingTests = () => { runActivationTest(); @@ -45,7 +45,7 @@ const runMerchantTests = () => { runUpdateGeneralSettingsTest(); runProductSettingsTest(); runTaxSettingsTest(); - runOrderStatusFilterTest(); + runOrderStatusFiltersTest(); } module.exports = { @@ -66,6 +66,6 @@ module.exports = { runUpdateGeneralSettingsTest, runProductSettingsTest, runTaxSettingsTest, - runOrderStatusFilterTest, + runOrderStatusFiltersTest, runMerchantTests, }; diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-order-status-filter.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-order-status-filter.test.js deleted file mode 100644 index 4f69df2a236..00000000000 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-order-status-filter.test.js +++ /dev/null @@ -1,108 +0,0 @@ -/* eslint-disable jest/no-export, jest/no-disabled-tests */ -/** - * Internal dependencies - */ -const { - StoreOwnerFlow, - createSimpleOrder, - clickFilter, - moveAllItemsToTrash, -} = require( '@woocommerce/e2e-utils' ); - -let statusColumnTextSelector = 'mark.order-status > span'; - -const runOrderFiltersTest = () => { - describe('WooCommerce Orders > Filter Orders by Status', () => { - beforeAll(async () => { - // First, let's login - await StoreOwnerFlow.login(); - - // Next, let's create some orders we can filter against - await createSimpleOrder('Pending payment'); - await createSimpleOrder('Processing'); - await createSimpleOrder('Completed'); - await createSimpleOrder('Cancelled'); - await createSimpleOrder('Refunded'); - }); - - afterAll( async () => { - // Make sure we're on the all orders view and cleanup the orders we created - await StoreOwnerFlow.openAllOrdersView(); - await moveAllItemsToTrash(); - }); - - it('should filter by Pending payment', async () => { - await StoreOwnerFlow.openAllOrdersView(); - await clickFilter('.wc-pending'); - await expect(page).toMatchElement(statusColumnTextSelector, {text: 'Pending payment'}); - - // Verify other statuses don't show - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Processing'}); - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Completed'}); - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Cancelled'}); - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Refunded'}); - }); - - it('should filter by Processing', async () => { - await StoreOwnerFlow.openAllOrdersView(); - await clickFilter('.wc-processing'); - await expect(page).toMatchElement(statusColumnTextSelector, {text: 'Processing'}); - - // Verify other statuses don't show - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Pending payment'}); - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Completed'}); - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Cancelled'}); - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Refunded'}); - }); - - it('should filter by Completed', async () => { - await StoreOwnerFlow.openAllOrdersView(); - await clickFilter('.wc-completed'); - await expect(page).toMatchElement(statusColumnTextSelector, {text: 'Completed'}); - - // Verify other statuses don't show - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Pending payment'}); - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Processing'}); - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Cancelled'}); - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Refunded'}); - }); - - it('should filter by Cancelled', async () => { - await StoreOwnerFlow.openAllOrdersView(); - await clickFilter('.wc-cancelled'); - await expect(page).toMatchElement(statusColumnTextSelector, {text: 'Cancelled'}); - - // Verify other statuses don't show - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Pending payment'}); - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Processing'}); - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Completed'}); - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Refunded'}); - }); - - it('should filter by Refunded', async () => { - await StoreOwnerFlow.openAllOrdersView(); - await clickFilter('.wc-refunded'); - await expect(page).toMatchElement(statusColumnTextSelector, {text: 'Refunded'}); - - // Verify other statuses don't show - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Pending payment'}); - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Processing'}); - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Completed'}); - await expect(page).not.toMatchElement(statusColumnTextSelector, {text: 'Cancelled'}); - }); - - it('should filter by All', async () => { - await StoreOwnerFlow.openAllOrdersView(); - // Make sure all the order statuses that were created show in this list - await clickFilter('.all'); - await expect(page).toMatchElement(statusColumnTextSelector, {text: 'Pending payment'}); - await expect(page).toMatchElement(statusColumnTextSelector, {text: 'Processing'}); - await expect(page).toMatchElement(statusColumnTextSelector, {text: 'Completed'}); - await expect(page).toMatchElement(statusColumnTextSelector, {text: 'Cancelled'}); - await expect(page).toMatchElement(statusColumnTextSelector, {text: 'Refunded'}); - }); - - }); -}; - -module.exports = runOrderFiltersTest; diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-order-status-filters.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-order-status-filters.test.js new file mode 100644 index 00000000000..80f0099a3d9 --- /dev/null +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-order-status-filters.test.js @@ -0,0 +1,160 @@ +/* eslint-disable jest/no-export, jest/no-disabled-tests */ +/** + * Internal dependencies + */ +const { + StoreOwnerFlow, + createSimpleOrder, + clickFilter, + moveAllItemsToTrash, +} = require( '@woocommerce/e2e-utils' ); + +const statusColumnTextSelector = 'mark.order-status > span'; + +// Order Statuses to filter against +const config = require( 'config' ); +const pendingPayment = config.get( 'orderstatuses.pendingpayment' ); +const processing = config.get( 'orderstatuses.processing' ); +const onHold = config.get( 'orderstatuses.onhold' ); +const completed = config.get( 'orderstatuses.completed' ); +const cancelled = config.get( 'orderstatuses.cancelled' ); +const refunded = config.get( 'orderstatuses.refunded' ); +const failed = config.get( 'orderstatuses.failed' ); + +const runOrderStatusFiltersTest = () => { + describe('WooCommerce Orders > Filter Orders by Status', () => { + beforeAll(async () => { + // First, let's login + await StoreOwnerFlow.login(); + + // Next, let's create some orders we can filter against + await createSimpleOrder(pendingPayment); + await createSimpleOrder(processing); + await createSimpleOrder(onHold); + await createSimpleOrder(completed); + await createSimpleOrder(cancelled); + await createSimpleOrder(refunded); + await createSimpleOrder(failed); + }, 40000); + + afterAll( async () => { + // Make sure we're on the all orders view and cleanup the orders we created + await StoreOwnerFlow.openAllOrdersView(); + await moveAllItemsToTrash(); + }); + + it('should filter by Pending payment', async () => { + await StoreOwnerFlow.openAllOrdersView(); + await clickFilter('.wc-pending'); + await expect(page).toMatchElement(statusColumnTextSelector, { text: pendingPayment }); + + // Verify other statuses don't show + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: processing }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: completed }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: cancelled }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: refunded }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: onHold }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: failed }); + }); + + it('should filter by Processing', async () => { + await StoreOwnerFlow.openAllOrdersView(); + await clickFilter('.wc-processing'); + await expect(page).toMatchElement(statusColumnTextSelector, { text: processing }); + + // Verify other statuses don't show + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: pendingPayment }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: completed }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: cancelled }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: refunded }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: onHold }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: failed }); + }); + + it('should filter by On hold', async () => { + await StoreOwnerFlow.openAllOrdersView(); + await clickFilter('.wc-on-hold'); + await expect(page).toMatchElement(statusColumnTextSelector, { text: onHold }); + + // Verify other statuses don't show + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: pendingPayment }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: processing }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: completed }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: cancelled }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: refunded }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: failed }); + }); + + it('should filter by Completed', async () => { + await StoreOwnerFlow.openAllOrdersView(); + await clickFilter('.wc-completed'); + await expect(page).toMatchElement(statusColumnTextSelector, { text: completed }); + + // Verify other statuses don't show + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: pendingPayment }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: processing }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: cancelled }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: refunded }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: onHold }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: failed }); + }); + + it('should filter by Cancelled', async () => { + await StoreOwnerFlow.openAllOrdersView(); + await clickFilter('.wc-cancelled'); + await expect(page).toMatchElement(statusColumnTextSelector, { text: cancelled }); + + // Verify other statuses don't show + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: pendingPayment }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: processing }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: completed }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: refunded }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: onHold }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: failed }); + }); + + it('should filter by Refunded', async () => { + await StoreOwnerFlow.openAllOrdersView(); + await clickFilter('.wc-refunded'); + await expect(page).toMatchElement(statusColumnTextSelector, { text: refunded }); + + // Verify other statuses don't show + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: pendingPayment }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: processing }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: completed }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: cancelled }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: onHold }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: failed }); + }); + + it('should filter by Failed', async () => { + await StoreOwnerFlow.openAllOrdersView(); + await clickFilter('.wc-failed'); + await expect(page).toMatchElement(statusColumnTextSelector, { text: failed }); + + // Verify other statuses don't show + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: pendingPayment }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: processing }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: completed }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: cancelled }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: refunded }); + await expect(page).not.toMatchElement(statusColumnTextSelector, { text: onHold }); + }); + + it('should filter by All', async () => { + await StoreOwnerFlow.openAllOrdersView(); + // Make sure all the order statuses that were created show in this list + await clickFilter('.all'); + await expect(page).toMatchElement(statusColumnTextSelector, { text: pendingPayment }); + await expect(page).toMatchElement(statusColumnTextSelector, { text: processing }); + await expect(page).toMatchElement(statusColumnTextSelector, { text: completed }); + await expect(page).toMatchElement(statusColumnTextSelector, { text: cancelled }); + await expect(page).toMatchElement(statusColumnTextSelector, { text: refunded }); + await expect(page).toMatchElement(statusColumnTextSelector, { text: onHold }); + await expect(page).toMatchElement(statusColumnTextSelector, { text: failed }); + }); + + }); +}; + +module.exports = runOrderStatusFiltersTest; diff --git a/tests/e2e/env/config/default.json b/tests/e2e/env/config/default.json index 19693eece88..0f5fb666016 100644 --- a/tests/e2e/env/config/default.json +++ b/tests/e2e/env/config/default.json @@ -71,5 +71,14 @@ "zoneregions": "United States (US)", "shippingmethod": "Free shipping" } + }, + "orderstatuses": { + "pendingpayment": "Pending payment", + "processing": "Processing", + "onhold": "On hold", + "completed": "Completed", + "cancelled": "Cancelled", + "refunded": "Refunded", + "failed": "Failed" } } diff --git a/tests/e2e/specs/wp-admin/test-order-status-filters.js b/tests/e2e/specs/wp-admin/test-order-status-filters.js new file mode 100644 index 00000000000..5de9b3c2a50 --- /dev/null +++ b/tests/e2e/specs/wp-admin/test-order-status-filters.js @@ -0,0 +1,6 @@ +/* + * Internal dependencies + */ +const { runOrderStatusFiltersTest } = require( '@woocommerce/e2e-core-tests' ); + +runOrderStatusFiltersTest();