From 118172f3c0aeb10de42f2ca4c21f4bfdf9644a5c Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 22 Mar 2022 15:39:30 +0000 Subject: [PATCH] Fix selectors in e2e tests --- .../best-selling-products.fixture.json | 5 +---- .../featured-category.fixture.json | 5 +---- .../hand-picked-products.fixture.json | 5 +---- .../__fixtures__/newest-products.fixture.json | 5 +---- .../product-categories-list.fixture.json | 5 +---- .../top-rated-products.fixture.json | 5 +---- tests/e2e/specs/backend/cart.test.js | 4 ++-- tests/utils/taxes.ts | 22 +++++++++---------- 8 files changed, 18 insertions(+), 38 deletions(-) diff --git a/tests/e2e/config/custom-matchers/__fixtures__/best-selling-products.fixture.json b/tests/e2e/config/custom-matchers/__fixtures__/best-selling-products.fixture.json index 592c5ded3ea..83be6820f4d 100644 --- a/tests/e2e/config/custom-matchers/__fixtures__/best-selling-products.fixture.json +++ b/tests/e2e/config/custom-matchers/__fixtures__/best-selling-products.fixture.json @@ -1,4 +1 @@ -{ - "title": "Best Selling Products Block", - "pageContent": "" -} +{"title":"Best Selling Products Block","pageContent":""} \ No newline at end of file diff --git a/tests/e2e/config/custom-matchers/__fixtures__/featured-category.fixture.json b/tests/e2e/config/custom-matchers/__fixtures__/featured-category.fixture.json index b6c77eb3381..60f0ae7b0d9 100644 --- a/tests/e2e/config/custom-matchers/__fixtures__/featured-category.fixture.json +++ b/tests/e2e/config/custom-matchers/__fixtures__/featured-category.fixture.json @@ -1,4 +1 @@ -{ - "title": "Featured Category Block", - "pageContent": "" -} +{"title":"Featured Category Block","pageContent":""} \ No newline at end of file diff --git a/tests/e2e/config/custom-matchers/__fixtures__/hand-picked-products.fixture.json b/tests/e2e/config/custom-matchers/__fixtures__/hand-picked-products.fixture.json index 4b2f1de3f43..907b84ea5ec 100644 --- a/tests/e2e/config/custom-matchers/__fixtures__/hand-picked-products.fixture.json +++ b/tests/e2e/config/custom-matchers/__fixtures__/hand-picked-products.fixture.json @@ -1,4 +1 @@ -{ - "title": "Hand-picked Products Block", - "pageContent": "" -} +{"title":"Hand-picked Products Block","pageContent":""} \ No newline at end of file diff --git a/tests/e2e/config/custom-matchers/__fixtures__/newest-products.fixture.json b/tests/e2e/config/custom-matchers/__fixtures__/newest-products.fixture.json index d3aa952f8b7..5ffe302fc75 100644 --- a/tests/e2e/config/custom-matchers/__fixtures__/newest-products.fixture.json +++ b/tests/e2e/config/custom-matchers/__fixtures__/newest-products.fixture.json @@ -1,4 +1 @@ -{ - "title": "Newest Products Block", - "pageContent": "" -} +{"title":"Newest Products Block","pageContent":""} \ No newline at end of file diff --git a/tests/e2e/config/custom-matchers/__fixtures__/product-categories-list.fixture.json b/tests/e2e/config/custom-matchers/__fixtures__/product-categories-list.fixture.json index 6f6baf27aef..7e6a4d9e3bb 100644 --- a/tests/e2e/config/custom-matchers/__fixtures__/product-categories-list.fixture.json +++ b/tests/e2e/config/custom-matchers/__fixtures__/product-categories-list.fixture.json @@ -1,4 +1 @@ -{ - "title": "Product Categories List Block", - "pageContent": "" -} +{"title":"Product Categories List Block","pageContent":""} \ No newline at end of file diff --git a/tests/e2e/config/custom-matchers/__fixtures__/top-rated-products.fixture.json b/tests/e2e/config/custom-matchers/__fixtures__/top-rated-products.fixture.json index a3190e493b4..4adb6788563 100644 --- a/tests/e2e/config/custom-matchers/__fixtures__/top-rated-products.fixture.json +++ b/tests/e2e/config/custom-matchers/__fixtures__/top-rated-products.fixture.json @@ -1,4 +1 @@ -{ - "title": "Top Rated Products Block", - "pageContent": "" -} +{"title":"Top Rated Products Block","pageContent":""} \ No newline at end of file diff --git a/tests/e2e/specs/backend/cart.test.js b/tests/e2e/specs/backend/cart.test.js index 492eb624d71..b2ede0e06d7 100644 --- a/tests/e2e/specs/backend/cart.test.js +++ b/tests/e2e/specs/backend/cart.test.js @@ -139,12 +139,12 @@ describe( `${ block.name } Block`, () => { beforeEach( async () => { await openDocumentSettingsSidebar(); await selectBlockByName( - 'woocommerce/cart-order-summary-block' + 'woocommerce/cart-order-summary-shipping-block' ); } ); it( 'can toggle Shipping calculator', async () => { - const selector = `${ block.class } .wc-block-components-totals-shipping__change-address-button`; + const selector = ` .wc-block-components-totals-shipping__change-address-button`; const toggleLabel = await findLabelWithText( 'Shipping calculator' ); diff --git a/tests/utils/taxes.ts b/tests/utils/taxes.ts index 2aadbaa7b3e..c3bf4a5e08f 100644 --- a/tests/utils/taxes.ts +++ b/tests/utils/taxes.ts @@ -44,18 +44,16 @@ export async function getTaxesFromCurrentPage(): Promise< value: string; } > > { - return await page.$$eval( - '.wc-block-components-totals-taxes .wc-block-components-totals-item', - ( nodes ) => - nodes.map( ( node ) => { - const label = node.querySelector( - '.wc-block-components-totals-item__label' - )?.innerHTML; - const value = node.querySelector( - '.wc-block-components-totals-item__value' - )?.innerHTML; - return { label, value }; - } ) + return await page.$$eval( '.wc-block-components-totals-taxes', ( nodes ) => + nodes.map( ( node ) => { + const label = node.querySelector( + '.wc-block-components-totals-item__label' + )?.innerHTML; + const value = node.querySelector( + '.wc-block-components-totals-item__value' + )?.innerHTML; + return { label, value }; + } ) ); }