-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(product): integrate facet rating component in storybook (#724)
- Loading branch information
1 parent
997e19a
commit caef460
Showing
3 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
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,36 @@ | ||
import { resolve } from '@spryker-oryx/di'; | ||
import { MockRouterService } from '@spryker-oryx/experience/mocks'; | ||
import { RouterService } from '@spryker-oryx/router'; | ||
import { FacetListService } from '@spryker-oryx/search'; | ||
import { SearchFacetComponentAttributes } from '@spryker-oryx/search/facet'; | ||
import { Story } from '@storybook/web-components'; | ||
import { TemplateResult, html } from 'lit'; | ||
import { storybookPrefix } from '../../.constants'; | ||
|
||
export default { | ||
title: `${storybookPrefix}/Facet Rating`, | ||
args: { | ||
open: true, | ||
}, | ||
parameters: { | ||
chromatic: { | ||
disableSnapshot: true, | ||
}, | ||
}, | ||
}; | ||
|
||
const Template: Story<SearchFacetComponentAttributes> = ( | ||
attrs | ||
): TemplateResult => { | ||
resolve(FacetListService); | ||
|
||
const router = resolve(RouterService) as unknown as MockRouterService; | ||
router.params$.next({}); | ||
|
||
return html`<oryx-search-facet-rating | ||
name="Rating" | ||
?open=${attrs.open} | ||
></oryx-search-facet-rating>`; | ||
}; | ||
|
||
export const Demo = Template.bind({}); |
55 changes: 55 additions & 0 deletions
55
libs/domain/search/facet-rating/stories/static/static.stories.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,55 @@ | ||
import { resolve } from '@spryker-oryx/di'; | ||
import { MockRouterService } from '@spryker-oryx/experience/mocks'; | ||
import { RouterService } from '@spryker-oryx/router'; | ||
import { FacetListService } from '@spryker-oryx/search'; | ||
import { Story } from '@storybook/web-components'; | ||
import { TemplateResult, html } from 'lit'; | ||
import { storybookPrefix } from '../../../.constants'; | ||
|
||
export default { | ||
title: `${storybookPrefix}/Facet Rating`, | ||
}; | ||
|
||
const Template: Story = (): TemplateResult => { | ||
resolve(FacetListService); | ||
|
||
const router = resolve(RouterService) as unknown as MockRouterService; | ||
router.params$.next({}); | ||
|
||
return html`<oryx-search-facet-rating | ||
name="Rating" | ||
open | ||
></oryx-search-facet-rating> | ||
<script> | ||
document.addEventListener( | ||
'DOMContentLoaded', | ||
() => { | ||
const component = document.querySelector('oryx-search-facet-rating'); | ||
if (!component) { | ||
return; | ||
} | ||
const observer = new MutationObserver((mutation) => { | ||
mutation.forEach((mutation) => { | ||
if (mutation) { | ||
const inputs = document | ||
.querySelector('oryx-search-facet-rating') | ||
.shadowRoot?.querySelector( | ||
'oryx-search-facet-value-navigation' | ||
) | ||
.querySelectorAll('input'); | ||
inputs[1]?.setAttribute('checked', ''); | ||
} | ||
}); | ||
}); | ||
observer.observe(component, { | ||
childList: true, | ||
attributes: true, | ||
subtree: true, | ||
}); | ||
}, | ||
{ once: true } | ||
); | ||
</script> `; | ||
}; | ||
|
||
export const Static = Template.bind({}); |