Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(atomic): fix commerce tests #4160

Merged
merged 8 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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}});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

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();
});
});

Expand All @@ -20,13 +20,13 @@

test('should not display duration by default', async ({querySummary}) => {
const textRegex = /^Products 1-[\d,]+ of [\d,]+ for kayak$/;
await expect(querySummary.text(textRegex)).toBeVisible();

Check failure on line 23 in packages/atomic/src/components/commerce/atomic-commerce-query-summary/e2e/atomic-commerce-query-summary.e2e.ts

View workflow job for this annotation

GitHub Actions / Run Playwright tests for Atomic

[webkit] › components/commerce/atomic-commerce-query-summary/e2e/atomic-commerce-query-summary.e2e.ts:21:7 › after searching for kayak › should not display duration by default

2) [webkit] › components/commerce/atomic-commerce-query-summary/e2e/atomic-commerce-query-summary.e2e.ts:21:7 › after searching for kayak › should not display duration by default Error: expect.toBeVisible: Error: strict mode violation: getByText(/^Products 1-[\d,]+ of [\d,]+ for kayak$/) resolved to 2 elements: 1) <div role="status" aria-live="polite" id="aria-live-d…>Products 1-48 of 79 for kayak</div> aka locator('#aria-live-do9k6-query-summary') 2) <div part="container" class="text-on-background">…</div> aka locator('#code-root').getByText('Products 1-48 of 79 for kayak') Call log: - expect.toBeVisible with timeout 20000ms - waiting for getByText(/^Products 1-[\d,]+ of [\d,]+ for kayak$/) 21 | test('should not display duration by default', async ({querySummary}) => { 22 | const textRegex = /^Products 1-[\d,]+ of [\d,]+ for kayak$/; > 23 | await expect(querySummary.text(textRegex)).toBeVisible(); | ^ 24 | }); 25 | }); 26 | at /home/runner/work/ui-kit/ui-kit/packages/atomic/src/components/commerce/atomic-commerce-query-summary/e2e/atomic-commerce-query-summary.e2e.ts:23:48
});
});

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}) => {
Expand All @@ -36,7 +36,7 @@

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}) => {
Expand All @@ -55,7 +55,7 @@

test('should display message', async ({querySummary}) => {
const textRegex = /^Product 1 of 1 for @ec_product_id=SP03730_00007$/;
await expect(querySummary.text(textRegex)).toBeVisible();

Check failure on line 58 in packages/atomic/src/components/commerce/atomic-commerce-query-summary/e2e/atomic-commerce-query-summary.e2e.ts

View workflow job for this annotation

GitHub Actions / Run Playwright tests for Atomic

[webkit] › components/commerce/atomic-commerce-query-summary/e2e/atomic-commerce-query-summary.e2e.ts:56:7 › when a query yield a single product › should display message

3) [webkit] › components/commerce/atomic-commerce-query-summary/e2e/atomic-commerce-query-summary.e2e.ts:56:7 › when a query yield a single product › should display message Error: expect.toBeVisible: Error: strict mode violation: getByText(/^Product 1 of 1 for @ec_product_id=SP03730_00007$/) resolved to 2 elements: 1) <div role="status" aria-live="polite" id="aria-live-z…>Product 1 of 1 for @ec_product_id=SP03730_00007</div> aka locator('#aria-live-zze0p-query-summary') 2) <div part="container" class="text-on-background">…</div> aka locator('#code-root').getByText('Product 1 of 1 for @') Call log: - expect.toBeVisible with timeout 20000ms - waiting for getByText(/^Product 1 of 1 for @ec_product_id=SP03730_00007$/) 56 | test('should display message', async ({querySummary}) => { 57 | const textRegex = /^Product 1 of 1 for @ec_product_id=SP03730_00007$/; > 58 | await expect(querySummary.text(textRegex)).toBeVisible(); | ^ 59 | }); 60 | 61 | test('screen readers should read out', async ({querySummary}) => { at /home/runner/work/ui-kit/ui-kit/packages/atomic/src/components/commerce/atomic-commerce-query-summary/e2e/atomic-commerce-query-summary.e2e.ts:58:48
});

test('screen readers should read out', async ({querySummary}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,14 @@
});

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}) => {
Expand Down Expand Up @@ -270,7 +271,7 @@
await searchBox.searchInput.fill('Rec');
await searchBox.searchSuggestions({listSide: 'Left'}).first().hover();
await searchBox.searchInput.press('Enter');
await expect(searchBox.searchInput).toHaveValue('Rec');

Check failure on line 274 in packages/atomic/src/components/commerce/atomic-commerce-search-box/e2e/atomic-commerce-search-box.e2e.ts

View workflow job for this annotation

GitHub Actions / Run Playwright tests for Atomic

[webkit] › components/commerce/atomic-commerce-search-box/e2e/atomic-commerce-search-box.e2e.ts:268:11 › with instant results & query suggestions › after clicking the searchbox input › after focusing on suggestion with the mouse › should submit what is in the search box regardless of the mouse position

4) [webkit] › components/commerce/atomic-commerce-search-box/e2e/atomic-commerce-search-box.e2e.ts:268:11 › with instant results & query suggestions › after clicking the searchbox input › after focusing on suggestion with the mouse › should submit what is in the search box regardless of the mouse position Error: Timed out 20000ms waiting for expect(locator).toHaveValue(expected) Locator: getByRole('combobox', { name: 'Search' }) Expected string: "Rec" Received string: "repair" Call log: - expect.toHaveValue with timeout 20000ms - waiting for getByRole('combobox', { name: 'Search' }) - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" 272 | await searchBox.searchSuggestions({listSide: 'Left'}).first().hover(); 273 | await searchBox.searchInput.press('Enter'); > 274 | await expect(searchBox.searchInput).toHaveValue('Rec'); | ^

Check failure on line 274 in packages/atomic/src/components/commerce/atomic-commerce-search-box/e2e/atomic-commerce-search-box.e2e.ts

View workflow job for this annotation

GitHub Actions / Run Playwright tests for Atomic

[webkit] › components/commerce/atomic-commerce-search-box/e2e/atomic-commerce-search-box.e2e.ts:268:11 › with instant results & query suggestions › after clicking the searchbox input › after focusing on suggestion with the mouse › should submit what is in the search box regardless of the mouse position

4) [webkit] › components/commerce/atomic-commerce-search-box/e2e/atomic-commerce-search-box.e2e.ts:268:11 › with instant results & query suggestions › after clicking the searchbox input › after focusing on suggestion with the mouse › should submit what is in the search box regardless of the mouse position Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 20000ms waiting for expect(locator).toHaveValue(expected) Locator: getByRole('combobox', { name: 'Search' }) Expected string: "Rec" Received string: "repair" Call log: - expect.toHaveValue with timeout 20000ms - waiting for getByRole('combobox', { name: 'Search' }) - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" - locator resolved to <textarea rows="1" part="textarea" role="combobox" autocor…></textarea> - unexpected value "repair" 272 | await searchBox.searchSuggestions({listSide: 'Left'}).first().hover(); 273 | await searchBox.searchInput.press('Enter'); > 274 | await expect(sear
});
});
});
Expand Down Expand Up @@ -439,24 +440,6 @@
});
});

test.describe('with enable-query-syntax=true', () => {
olamothe marked this conversation as resolved.
Show resolved Hide resolved
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(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @cspell/spellchecker */
import {test, expect} from './fixture';

test.describe('default', () => {
Expand All @@ -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');
olamothe marked this conversation as resolved.
Show resolved Hide resolved

await expect(facetValueBtn).not.toBeChecked();
await facetValueLabel.click();
Expand All @@ -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();
Expand All @@ -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);

Expand Down Expand Up @@ -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();
Expand Down
Loading