-
Notifications
You must be signed in to change notification settings - Fork 328
Apply Canvas decorator + assertion helper across stories #307
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,10 @@ | ||||||||||
| import type { Meta, StoryObj } from "storybook-solidjs-vite"; | ||||||||||
| import { expect, waitFor } from "storybook/test"; | ||||||||||
| import { ContextMenu } from "react-grab/src/components/context-menu.js"; | ||||||||||
| import type { Position } from "react-grab/src/types.js"; | ||||||||||
| import { assertMounted } from "./assertions.js"; | ||||||||||
| import { DEMO_BOUNDS } from "./demo-bounds.js"; | ||||||||||
| import { createMenuActions } from "./fixtures.js"; | ||||||||||
| import { Canvas, TargetBox } from "./target-box.js"; | ||||||||||
| import { TargetBox } from "./target-box.js"; | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||
| import { noop } from "./noop.js"; | ||||||||||
|
|
||||||||||
| interface ContextMenuSceneProps { | ||||||||||
|
|
@@ -21,7 +21,7 @@ const MENU_POSITION: Position = { | |||||||||
| const meta: Meta<ContextMenuSceneProps> = { | ||||||||||
| title: "Components/ContextMenu", | ||||||||||
| render: (args) => ( | ||||||||||
| <Canvas> | ||||||||||
| <> | ||||||||||
| <TargetBox /> | ||||||||||
| <ContextMenu | ||||||||||
| position={MENU_POSITION} | ||||||||||
|
|
@@ -33,13 +33,9 @@ const meta: Meta<ContextMenuSceneProps> = { | |||||||||
| onDismiss={noop} | ||||||||||
| onHide={noop} | ||||||||||
| /> | ||||||||||
| </Canvas> | ||||||||||
| </> | ||||||||||
| ), | ||||||||||
| play: async ({ canvasElement }) => { | ||||||||||
| await waitFor(() => { | ||||||||||
| expect(canvasElement.querySelector("[data-react-grab-context-menu]")).not.toBeNull(); | ||||||||||
| }); | ||||||||||
| }, | ||||||||||
| play: ({ canvasElement }) => assertMounted(canvasElement, "[data-react-grab-context-menu]"), | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The play function doesn't await the assertMounted promise, causing the test to complete before the assertion runs |
||||||||||
| args: { tagName: "button", componentName: "Button", hasFilePath: false }, | ||||||||||
| }; | ||||||||||
|
|
||||||||||
|
|
||||||||||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Play functions in story files don't await promise-returning assertion functions, causing tests to complete before assertions run