@@ -4,6 +4,8 @@ import InboxScreen from "./InboxScreen";
4
4
5
5
import { Default as TaskListDefault } from "./components/TaskList.stories" ;
6
6
7
+ import { expect , userEvent , findByRole , within } from "@storybook/test" ;
8
+
7
9
export default {
8
10
component : InboxScreen ,
9
11
title : "InboxScreen" ,
@@ -35,3 +37,57 @@ export const Error = {
35
37
} ,
36
38
} ,
37
39
} ;
40
+
41
+ export const PinTask = {
42
+ parameters : {
43
+ ...Default . parameters ,
44
+ } ,
45
+ play : async ( { canvasElement } ) => {
46
+ const canvas = within ( canvasElement ) ;
47
+ const getTask = ( id ) => canvas . findByRole ( "listitem" , { name : id } ) ;
48
+
49
+ const itemToPin = await getTask ( "task-4" ) ;
50
+ // Find the pin button
51
+ const pinButton = await findByRole ( itemToPin , "button" , { name : "pin" } ) ;
52
+ // Click the pin button
53
+ await userEvent . click ( pinButton ) ;
54
+ // Check that the pin button is now a unpin button
55
+ const unpinButton = within ( itemToPin ) . getByRole ( "button" , {
56
+ name : "unpin" ,
57
+ } ) ;
58
+ await expect ( unpinButton ) . toBeInTheDocument ( ) ;
59
+ } ,
60
+ } ;
61
+
62
+ export const ArchiveTask = {
63
+ parameters : {
64
+ ...Default . parameters ,
65
+ } ,
66
+ play : async ( { canvasElement } ) => {
67
+ const canvas = within ( canvasElement ) ;
68
+ const getTask = ( id ) => canvas . findByRole ( "listitem" , { name : id } ) ;
69
+
70
+ const itemToArchive = await getTask ( "task-2" ) ;
71
+ const archiveButton = await findByRole ( itemToArchive , "button" , {
72
+ name : "archiveButton-2" ,
73
+ } ) ;
74
+ await userEvent . click ( archiveButton ) ;
75
+ } ,
76
+ } ;
77
+
78
+ export const EditTask = {
79
+ parameters : {
80
+ ...Default . parameters ,
81
+ } ,
82
+ play : async ( { canvasElement } ) => {
83
+ const canvas = within ( canvasElement ) ;
84
+ const getTask = ( id ) => canvas . findByRole ( "listitem" , { name : id } ) ;
85
+
86
+ const itemToEdit = await getTask ( "task-5" ) ;
87
+ const taskInput = await findByRole ( itemToEdit , "textbox" ) ;
88
+ await userEvent . type ( taskInput , " and disabled state" ) ;
89
+ await expect ( taskInput . value ) . toBe (
90
+ "Fix bug in input error state and disabled state"
91
+ ) ;
92
+ } ,
93
+ } ;
0 commit comments