// noinspection DuplicatedCode import type { StoryObj } from '@storybook/web-components'; import {expect, within} from '@storybook/test'; import '../custom-element/custom-element.js'; import '../custom-element/http-request.js'; import '../custom-element/location-element.js'; type TProps = { title: string; body:string}; type Story = StoryObj; function sleep(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); } function render(args: TProps) { const {title, body} = args; return `
${ title } ${ body }
`; } const meta = { title: 'site' // , tags: ['autodocs'] , render }; export default meta; export const VersionsSelect:Story = { args : {title: 'Versions of custom-element', body:`

Select the version of custom-element StoryBook.

`} , play: async ({canvasElement}) => { const titleText = VersionsSelect.args!.title as string; const canvas = within(canvasElement) , code = async (id) => (await canvas.findByTestId(id)).textContent.trim(); window.location.hash = '#@epa-wg/custom-element-dist@0.0.24/storybook-static/index.html' await sleep(20) // expect( await code('p1') ).toEqual('default_P1' ); // expect( await code('p2') ).toEqual('always_p2' ); // expect( await code('p3') ).toEqual('def_P3' ); }, }; //#region unit tests /* istanbul ignore else -- @preserve */ if( 'test' === import.meta.env.MODE && !import.meta.url.includes('skiptest') ) { const mod = await import('./attributes.test.stories.ts?skiptest'); const { testStoryBook } = await import('./testStoryBook') const { describe } = await import('vitest') describe(meta.title, () => testStoryBook( mod, meta ) ); } //#endregion