1
1
import type { Meta , StoryObj } from "@storybook/react-vite" ;
2
- import { expect , userEvent , waitFor , within } from "storybook/test" ;
2
+ import { expect , screen , userEvent , waitFor } from "storybook/test" ;
3
3
import { InfoTooltip } from "./InfoTooltip" ;
4
4
5
5
const meta = {
@@ -16,13 +16,13 @@ export default meta;
16
16
type Story = StoryObj < typeof InfoTooltip > ;
17
17
18
18
export const Example : Story = {
19
- play : async ( { canvasElement, step } ) => {
20
- const screen = within ( canvasElement ) ;
21
-
19
+ play : async ( { step } ) => {
22
20
await step ( "activate hover trigger" , async ( ) => {
23
21
await userEvent . hover ( screen . getByRole ( "button" ) ) ;
24
22
await waitFor ( ( ) =>
25
- expect ( screen . getByText ( meta . args . message ) ) . toBeInTheDocument ( ) ,
23
+ expect ( screen . getByRole ( "tooltip" ) ) . toHaveTextContent (
24
+ meta . args . message ,
25
+ ) ,
26
26
) ;
27
27
} ) ;
28
28
} ,
@@ -33,13 +33,13 @@ export const Notice = {
33
33
type : "notice" ,
34
34
message : "Unfortunately, there's a radio connected to my brain" ,
35
35
} ,
36
- play : async ( { canvasElement, step } ) => {
37
- const screen = within ( canvasElement ) ;
38
-
36
+ play : async ( { step } ) => {
39
37
await step ( "activate hover trigger" , async ( ) => {
40
38
await userEvent . hover ( screen . getByRole ( "button" ) ) ;
41
39
await waitFor ( ( ) =>
42
- expect ( screen . getByText ( Notice . args . message ) ) . toBeInTheDocument ( ) ,
40
+ expect ( screen . getByRole ( "tooltip" ) ) . toHaveTextContent (
41
+ Notice . args . message ,
42
+ ) ,
43
43
) ;
44
44
} ) ;
45
45
} ,
@@ -50,13 +50,13 @@ export const Warning = {
50
50
type : "warning" ,
51
51
message : "Unfortunately, there's a radio connected to my brain" ,
52
52
} ,
53
- play : async ( { canvasElement, step } ) => {
54
- const screen = within ( canvasElement ) ;
55
-
53
+ play : async ( { step } ) => {
56
54
await step ( "activate hover trigger" , async ( ) => {
57
55
await userEvent . hover ( screen . getByRole ( "button" ) ) ;
58
56
await waitFor ( ( ) =>
59
- expect ( screen . getByText ( Warning . args . message ) ) . toBeInTheDocument ( ) ,
57
+ expect ( screen . getByRole ( "tooltip" ) ) . toHaveTextContent (
58
+ Warning . args . message ,
59
+ ) ,
60
60
) ;
61
61
} ) ;
62
62
} ,
0 commit comments