|
| 1 | +import{chromatic}from"testHelpers/chromatic"; |
| 2 | +import{MockTask}from"testHelpers/entities"; |
| 3 | +importtype{Meta,StoryObj}from"@storybook/react-vite"; |
| 4 | +import{action}from"storybook/actions"; |
| 5 | +import{userEvent,within}from"storybook/test"; |
| 6 | +import{BatchDeleteConfirmation}from"./BatchDeleteConfirmation"; |
| 7 | + |
| 8 | +constmeta:Meta<typeofBatchDeleteConfirmation>={ |
| 9 | +title:"pages/TasksPage/BatchDeleteConfirmation", |
| 10 | +parameters:{ chromatic}, |
| 11 | +component:BatchDeleteConfirmation, |
| 12 | +args:{ |
| 13 | +onClose:action("onClose"), |
| 14 | +onConfirm:action("onConfirm"), |
| 15 | +open:true, |
| 16 | +isLoading:false, |
| 17 | +checkedTasks:[ |
| 18 | +MockTask, |
| 19 | +{ |
| 20 | +...MockTask, |
| 21 | +id:"task-2", |
| 22 | +name:"task-test-456", |
| 23 | +display_name:"Add API Tests", |
| 24 | +initial_prompt:"Add comprehensive tests for the API endpoints", |
| 25 | +// Different owner to test admin bulk delete of other users' tasks |
| 26 | +owner_name:"bob", |
| 27 | +created_at:newDate(Date.now()-24*60*60*1000).toISOString(), |
| 28 | +updated_at:newDate(Date.now()-1*60*60*1000).toISOString(), |
| 29 | +}, |
| 30 | +{ |
| 31 | +...MockTask, |
| 32 | +id:"task-3", |
| 33 | +name:"task-docs-789", |
| 34 | +display_name:"Update Documentation", |
| 35 | +initial_prompt:"Update documentation for the new features", |
| 36 | +// Intentionally null to test that only 2 workspaces are shown in review resources stage |
| 37 | +workspace_id:null, |
| 38 | +created_at:newDate( |
| 39 | +Date.now()-3*24*60*60*1000, |
| 40 | +).toISOString(), |
| 41 | +updated_at:newDate( |
| 42 | +Date.now()-2*24*60*60*1000, |
| 43 | +).toISOString(), |
| 44 | +}, |
| 45 | +], |
| 46 | +workspaceCount:2, |
| 47 | +}, |
| 48 | +}; |
| 49 | + |
| 50 | +exportdefaultmeta; |
| 51 | +typeStory=StoryObj<typeofBatchDeleteConfirmation>; |
| 52 | + |
| 53 | +exportconstConsequences:Story={}; |
| 54 | + |
| 55 | +exportconstReviewTasks:Story={ |
| 56 | +play:async({ canvasElement, step})=>{ |
| 57 | +constbody=within(canvasElement.ownerDocument.body); |
| 58 | + |
| 59 | +awaitstep("Advance to stage 2: Review tasks",async()=>{ |
| 60 | +constconfirmButton=awaitbody.findByRole("button",{ |
| 61 | +name:/reviewselectedtasks/i, |
| 62 | +}); |
| 63 | +awaituserEvent.click(confirmButton); |
| 64 | +}); |
| 65 | +}, |
| 66 | +}; |
| 67 | + |
| 68 | +exportconstReviewResources:Story={ |
| 69 | +play:async({ canvasElement, step})=>{ |
| 70 | +constbody=within(canvasElement.ownerDocument.body); |
| 71 | + |
| 72 | +awaitstep("Advance to stage 2: Review tasks",async()=>{ |
| 73 | +constconfirmButton=awaitbody.findByRole("button",{ |
| 74 | +name:/reviewselectedtasks/i, |
| 75 | +}); |
| 76 | +awaituserEvent.click(confirmButton); |
| 77 | +}); |
| 78 | + |
| 79 | +awaitstep("Advance to stage 3: Review resources",async()=>{ |
| 80 | +constconfirmButton=awaitbody.findByRole("button",{ |
| 81 | +name:/confirm.*tasks/i, |
| 82 | +}); |
| 83 | +awaituserEvent.click(confirmButton); |
| 84 | +}); |
| 85 | +}, |
| 86 | +}; |