|
1 | 1 | import type { Meta, StoryObj } from "@storybook/react"
|
| 2 | +import { expect } from "@storybook/test" |
| 3 | +import { waitFor } from "@storybook/test" |
| 4 | +import { fireEvent } from "@storybook/test" |
| 5 | +import { within } from "@storybook/test" |
2 | 6 |
|
3 |
| -import { langViewportModes } from "../../../.storybook/modes" |
4 |
| -import { BaseLayout as BaseLayoutComponent } from "../../layouts/BaseLayout" |
5 |
| - |
6 |
| -import ListenToPlayer from "." |
| 7 | +import Component from "." |
7 | 8 |
|
8 | 9 | const meta = {
|
9 |
| - title: "Atoms / Media & Icons / ListenToPlayer / ListenToPlayer", |
10 |
| - component: BaseLayoutComponent, |
11 |
| - parameters: { |
12 |
| - layout: "fullscreen", |
13 |
| - chromatic: { |
14 |
| - modes: { |
15 |
| - ...langViewportModes, |
16 |
| - }, |
17 |
| - }, |
18 |
| - }, |
19 |
| - argTypes: { |
20 |
| - children: { |
21 |
| - table: { |
22 |
| - disable: true, |
23 |
| - }, |
24 |
| - }, |
25 |
| - lastDeployLocaleTimestamp: { |
26 |
| - table: { |
27 |
| - disable: true, |
28 |
| - }, |
29 |
| - }, |
| 10 | + title: "Atoms / Media & Icons / ListenToPlayer", |
| 11 | + component: Component, |
| 12 | + args: { |
| 13 | + slug: "/eth/", |
30 | 14 | },
|
31 |
| -} satisfies Meta<typeof BaseLayoutComponent> |
| 15 | +} satisfies Meta<typeof Component> |
32 | 16 |
|
33 | 17 | export default meta
|
34 | 18 |
|
35 |
| -export const BaseLayout: StoryObj<typeof meta> = { |
36 |
| - args: { |
37 |
| - children: ( |
38 |
| - <div className="flex w-full flex-col items-center gap-4 px-8 py-9 md:flex-row"> |
39 |
| - <ListenToPlayer slug="/eth" /> |
40 |
| - </div> |
41 |
| - ), |
42 |
| - // contentIsOutdated: false, |
43 |
| - // contentNotTranslated: false, |
44 |
| - lastDeployLocaleTimestamp: "May 14, 2021", |
| 19 | +type Story = StoryObj<typeof meta> |
| 20 | + |
| 21 | +export const PlayerButton: Story = {} |
| 22 | + |
| 23 | +export const PlayerWidget: Story = { |
| 24 | + play: async ({ canvasElement }) => { |
| 25 | + const canvas = within(canvasElement) |
| 26 | + const canvasParent = within(canvasElement.parentElement!) |
| 27 | + |
| 28 | + const playerButton = canvas.getByRole("button") |
| 29 | + await waitFor(() => { |
| 30 | + // TODO: hacky way to wait for the sound to be loaded |
| 31 | + expect(playerButton.textContent).not.toContain("0 min") |
| 32 | + }) |
| 33 | + |
| 34 | + fireEvent.click(playerButton) |
| 35 | + |
| 36 | + await waitFor(async () => { |
| 37 | + await expect( |
| 38 | + canvasParent.getByTestId("player-widget-modal") |
| 39 | + ).toBeVisible() |
| 40 | + }) |
45 | 41 | },
|
46 | 42 | }
|
0 commit comments