-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: atomic-commerce-searchbox (playwright demo) (#4033)
- Loading branch information
1 parent
20c0978
commit 7aa6094
Showing
15 changed files
with
621 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import AxeBuilder from '@axe-core/playwright'; | ||
import type {test as base} from '@playwright/test'; | ||
|
||
export type AxeFixture = { | ||
makeAxeBuilder: () => AxeBuilder; | ||
}; | ||
|
||
// Extend base test by providing "makeAxeBuilder" | ||
// | ||
// This new "test" can be used in multiple test files, and each of them will get | ||
// a consistently configured AxeBuilder instance. | ||
export const makeAxeBuilder: Parameters< | ||
typeof base.extend<AxeFixture> | ||
>[0]['makeAxeBuilder'] = async ({page}, use) => { | ||
const makeAxeBuilder = () => | ||
new AxeBuilder({page}) | ||
.withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']) | ||
.include('#code-root'); | ||
|
||
await use(makeAxeBuilder); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...ages/atomic/src/components/commerce/atomic-commerce-load-more-products/e2e/page-object.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type {Page} from '@playwright/test'; | ||
|
||
export class AtomicCommerceLoadMoreProductsLocators { | ||
private page: Page; | ||
constructor(page: Page) { | ||
this.page = page; | ||
} | ||
|
||
summary({index, total}: {index?: number; total?: number} = {}) { | ||
return this.page.getByText( | ||
new RegExp( | ||
`Showing ${index ?? '\\d'} of ${total ?? '\\d'} result${total === 1 ? '' : 's'}.` | ||
) | ||
); | ||
} | ||
|
||
get loadMoreButton() { | ||
return this.page.getByText('Load more results'); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.new.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { | ||
playExecuteFirstSearch, | ||
wrapInCommerceInterface, | ||
} from '@coveo/atomic/storybookUtils/commerce-interface-wrapper'; | ||
import {parameters} from '@coveo/atomic/storybookUtils/common-meta-parameters'; | ||
import {renderComponent} from '@coveo/atomic/storybookUtils/render-component'; | ||
import type {Meta, StoryObj as Story} from '@storybook/web-components'; | ||
import {html} from 'lit/static-html.js'; | ||
|
||
const {decorator, play} = wrapInCommerceInterface({skipFirstSearch: true}); | ||
|
||
const meta: Meta = { | ||
component: 'atomic-commerce-search-box', | ||
title: 'Atomic-Commerce/Searchbox', | ||
id: 'atomic-commerce-search-box', | ||
render: renderComponent, | ||
decorators: [decorator], | ||
parameters, | ||
play, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Default: Story = { | ||
name: 'atomic-commerce-search-box', | ||
}; | ||
|
||
export const RichSearchBox: Story = { | ||
name: 'With suggestions and recent queries', | ||
args: { | ||
default: ` <atomic-commerce-search-box-recent-queries></atomic-commerce-search-box-recent-queries> | ||
<atomic-commerce-search-box-query-suggestions></atomic-commerce-search-box-query-suggestions> | ||
<atomic-commerce-search-box-instant-products | ||
image-size="small" | ||
></atomic-commerce-search-box-instant-products>`, | ||
}, | ||
}; | ||
|
||
export const InPage: Story = { | ||
name: 'In a page', | ||
decorators: [ | ||
(story) => | ||
html` <atomic-commerce-layout> | ||
<atomic-layout-section section="search"> | ||
${story()} | ||
</atomic-layout-section> | ||
<atomic-layout-section section="facets" | ||
><atomic-commerce-facets></atomic-commerce-facets | ||
></atomic-layout-section> | ||
<atomic-layout-section section="main"> | ||
<atomic-layout-section section="status"> | ||
<atomic-commerce-query-summary></atomic-commerce-query-summary> | ||
<atomic-commerce-sort-dropdown></atomic-commerce-sort-dropdown> | ||
</atomic-layout-section> | ||
<atomic-layout-section section="products"> | ||
<atomic-commerce-product-list | ||
display="grid" | ||
density="compact" | ||
image-size="small" | ||
> | ||
</atomic-commerce-product-list> | ||
<atomic-commerce-query-error></atomic-commerce-query-error> | ||
</atomic-layout-section> | ||
<atomic-layout-section section="pagination"> | ||
<atomic-commerce-load-more-products></atomic-commerce-load-more-products> | ||
<!-- Alternative pagination | ||
<atomic-commerce-pager></atomic-commerce-pager> | ||
--> | ||
</atomic-layout-section> | ||
</atomic-layout-section> | ||
</atomic-commerce-layout>`, | ||
], | ||
play: async (context) => { | ||
await play(context); | ||
await playExecuteFirstSearch(context); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.