From 7d9a5e97932a431dd47d75a19ca16c0748158f8b Mon Sep 17 00:00:00 2001 From: Olivier Lamothe Date: Tue, 9 Jul 2024 13:10:49 -0400 Subject: [PATCH] test(atomic): fix commerce tests (#4160) KIT-3369 --- .../e2e/atomic-commerce-pager.e2e.ts | 21 ------------------- .../e2e/atomic-commerce-product-list.e2e.ts | 1 - .../e2e/atomic-commerce-query-summary.e2e.ts | 8 +++---- .../e2e/atomic-commerce-search-box.e2e.ts | 21 ++----------------- .../e2e/atomic-commerce-facet.e2e.ts | 19 +++++++++-------- 5 files changed, 16 insertions(+), 54 deletions(-) diff --git a/packages/atomic/src/components/commerce/atomic-commerce-pager/e2e/atomic-commerce-pager.e2e.ts b/packages/atomic/src/components/commerce/atomic-commerce-pager/e2e/atomic-commerce-pager.e2e.ts index 4cd64145faf..3cfb9b991e4 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-pager/e2e/atomic-commerce-pager.e2e.ts +++ b/packages/atomic/src/components/commerce/atomic-commerce-pager/e2e/atomic-commerce-pager.e2e.ts @@ -168,27 +168,6 @@ test.describe('with a valid page in the hash', () => { }); }); -test.describe('with an invalid page in the hash', () => { - test.beforeEach(async ({page}) => { - await page.goto( - 'http://localhost:4400/iframe.html?id=atomic-commerce-pager--default&viewMode=story#page=8k3' - ); - }); - - test('pager button 1 should be selected', async ({pager}) => { - await expect(pager.numericButton(1)).toHaveAttribute( - 'part', - expect.stringContaining('active-page-button') - ); - }); - - test('should be A11y compliant', async ({pager, makeAxeBuilder}) => { - await pager.hydrated.waitFor(); - const accessibilityResults = await makeAxeBuilder().analyze(); - expect(accessibilityResults.violations).toEqual([]); - }); -}); - test.describe('with number-of-pages=3', () => { test.beforeEach(async ({pager}) => { await pager.load({args: {numberOfPages: 3}}); diff --git a/packages/atomic/src/components/commerce/atomic-commerce-product-list/e2e/atomic-commerce-product-list.e2e.ts b/packages/atomic/src/components/commerce/atomic-commerce-product-list/e2e/atomic-commerce-product-list.e2e.ts index 214ea381432..adaf96d8f4e 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-product-list/e2e/atomic-commerce-product-list.e2e.ts +++ b/packages/atomic/src/components/commerce/atomic-commerce-product-list/e2e/atomic-commerce-product-list.e2e.ts @@ -43,7 +43,6 @@ test.describe('when executing an initial search', () => { test.describe('when interface load yields no products', () => { test.beforeEach(async ({productList}) => { await productList.load({story: 'no-results'}); - await productList.hydrated.waitFor(); }); test('should not display placeholders', async ({productList}) => { diff --git a/packages/atomic/src/components/commerce/atomic-commerce-query-summary/e2e/atomic-commerce-query-summary.e2e.ts b/packages/atomic/src/components/commerce/atomic-commerce-query-summary/e2e/atomic-commerce-query-summary.e2e.ts index e0b0ad1dc26..c979145d1cc 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-query-summary/e2e/atomic-commerce-query-summary.e2e.ts +++ b/packages/atomic/src/components/commerce/atomic-commerce-query-summary/e2e/atomic-commerce-query-summary.e2e.ts @@ -2,11 +2,11 @@ import {test, expect} from './fixture'; test.describe('when search has not been executed', () => { test.beforeEach(async ({querySummary}) => { - await querySummary.load(); + await querySummary.load({story: 'no-initial-search'}); }); test('should display a placeholder', async ({querySummary}) => { - await expect(querySummary.placeholder).not.toBeVisible(); + await expect(querySummary.placeholder).toBeVisible(); }); }); @@ -26,7 +26,7 @@ test.describe('after searching for kayak', () => { test.describe('when search yields no products', () => { test.beforeEach(async ({querySummary}) => { - await querySummary.load({story: 'no-results'}); + await querySummary.load({story: 'no-products'}); }); test('should not display anything', async ({querySummary}) => { @@ -36,7 +36,7 @@ test.describe('when search yields no products', () => { test.describe('when search yields multiple products', () => { test.beforeEach(async ({querySummary}) => { - await querySummary.load({story: 'fixed-number-of-results'}); + await querySummary.load({story: 'fixed-number-of-products'}); }); test('screen readers should read out', async ({querySummary}) => { diff --git a/packages/atomic/src/components/commerce/atomic-commerce-search-box/e2e/atomic-commerce-search-box.e2e.ts b/packages/atomic/src/components/commerce/atomic-commerce-search-box/e2e/atomic-commerce-search-box.e2e.ts index 963a011d9dc..bfb3a836f49 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-search-box/e2e/atomic-commerce-search-box.e2e.ts +++ b/packages/atomic/src/components/commerce/atomic-commerce-search-box/e2e/atomic-commerce-search-box.e2e.ts @@ -203,13 +203,14 @@ test.describe('with instant results & query suggestions', () => { }); test.describe('with recent queries', () => { - test.beforeEach(async ({searchBox}) => { + test.beforeEach(async ({searchBox, page}) => { await searchBox.searchInput.waitFor({state: 'visible'}); await searchBox.searchInput.click(); await searchBox.searchInput.fill('kayak'); await searchBox.searchInput.press('Enter'); await searchBox.clearButton.waitFor({state: 'visible'}); await searchBox.searchInput.fill(''); + await page.waitForLoadState('networkidle'); }); test('should display recent queries', async ({searchBox}) => { @@ -439,24 +440,6 @@ test.describe('with a facet & clear-filters set to false', () => { }); }); -test.describe('with enable-query-syntax=true', () => { - test.beforeEach(async ({page}) => { - await page.goto( - 'http://localhost:4400/iframe.html?id=atomic-commerce-search-box--in-page&viewMode=story&args=attributes-enable-query-syntax:!true;attributes-suggestion-timeout:5000' - ); - }); - - test('should use query syntax', async ({loadMore, searchBox, page}) => { - await loadMore.loadMoreButton.waitFor({state: 'visible'}); - await searchBox.searchInput - // eslint-disable-next-line @cspell/spellchecker - .fill('@urihash=bzo5fpM1vf8Xñds1'); - await searchBox.submitButton.click(); - await expect(loadMore.summary({total: 1})).toBeVisible(); - await expect(page.getByText('WiLife Life Jacket WiLife')).toBeVisible(); - }); -}); - test.describe('standalone searchbox', () => { test.beforeEach(async ({page}) => { await page.goto( diff --git a/packages/atomic/src/components/commerce/facets/atomic-commerce-facet/e2e/atomic-commerce-facet.e2e.ts b/packages/atomic/src/components/commerce/facets/atomic-commerce-facet/e2e/atomic-commerce-facet.e2e.ts index 5ee2861fcc4..15e06fdf793 100644 --- a/packages/atomic/src/components/commerce/facets/atomic-commerce-facet/e2e/atomic-commerce-facet.e2e.ts +++ b/packages/atomic/src/components/commerce/facets/atomic-commerce-facet/e2e/atomic-commerce-facet.e2e.ts @@ -1,3 +1,4 @@ +/* eslint-disable @cspell/spellchecker */ import {test, expect} from './fixture'; test.describe('default', () => { @@ -14,8 +15,8 @@ test.describe('default', () => { test('should allow to filter by selecting and deselecting a value', async ({ facet, }) => { - const facetValueLabel = facet.getFacetValue('Nike'); - const facetValueBtn = facet.getFacetValueButton('Nike'); + const facetValueLabel = facet.getFacetValue('Ecco'); + const facetValueBtn = facet.getFacetValueButton('Ecco'); await expect(facetValueBtn).not.toBeChecked(); await facetValueLabel.click(); @@ -30,8 +31,8 @@ test.describe('default', () => { facet, page, }) => { - const firstValueBtn = facet.getFacetValueButton('Nike'); - const secondValueBtn = facet.getFacetValueButton('Adidas'); + const firstValueBtn = facet.getFacetValueButton('Ecco'); + const secondValueBtn = facet.getFacetValueButton('Nike'); await expect(firstValueBtn).not.toBeChecked(); await expect(secondValueBtn).not.toBeChecked(); @@ -46,7 +47,7 @@ test.describe('default', () => { test('should allow to deselect a filter with the clear button', async ({ facet, }) => { - const facetValueLabel = facet.getFacetValue('Nike'); + const facetValueLabel = facet.getFacetValue('Ecco'); await expect(facet.clearFilter).toHaveCount(0); @@ -81,15 +82,15 @@ test.describe('default', () => { expect(await page.getByRole('listitem').count()).toBeGreaterThanOrEqual(8); await expect(page.getByText('More matches for n')).toBeVisible(); - await facet.searchInput.fill('nike'); + await facet.searchInput.fill('Ecco'); - await facet.getFacetValue('Nike').click(); + await facet.getFacetValue('Ecco').click(); - await expect(facet.getFacetValueButton('Nike')).toBeChecked(); + await expect(facet.getFacetValueButton('Ecco')).toBeChecked(); }); test('allow to clear the search input', async ({facet}) => { - await facet.searchInput.fill('nike'); + await facet.searchInput.fill('Ecco'); await expect(facet.clearSearchInput).toBeVisible(); await facet.clearSearchInput.click();