@@ -96,19 +96,21 @@ export const UnchangedPrompt: Story = {
9696
9797export const Submitting : Story = {
9898 beforeEach : async ( ) => {
99- // Mock all API calls that happen before updateTaskPrompt
100- spyOn ( API , "cancelWorkspaceBuild" ) . mockResolvedValue ( {
101- message : "Workspace build canceled" ,
102- } ) ;
10399 spyOn ( API , "getWorkspaceBuildByNumber" ) . mockResolvedValue ( {
104100 ...MockTaskWorkspace . latest_build ,
105101 status : "canceled" ,
102+ job : {
103+ ...MockTaskWorkspace . latest_build . job ,
104+ completed_at : undefined ,
105+ } ,
106+ } ) ;
107+ spyOn ( API , "cancelWorkspaceBuild" ) . mockResolvedValue ( {
108+ message : "Workspace build canceled" ,
106109 } ) ;
107110 spyOn ( API , "waitForBuild" ) . mockResolvedValue ( undefined ) ;
108111 spyOn ( API , "stopWorkspace" ) . mockResolvedValue (
109112 MockTaskWorkspace . latest_build ,
110113 ) ;
111- // Mock updateTaskPrompt to never resolve (keeps it in pending state)
112114 spyOn ( API , "updateTaskInput" ) . mockImplementation ( ( ) => {
113115 return new Promise ( ( ) => { } ) ;
114116 } ) ;
@@ -144,18 +146,22 @@ export const Submitting: Story = {
144146
145147export const Success : Story = {
146148 beforeEach : async ( ) => {
147- spyOn ( API , "updateTaskInput" ) . mockResolvedValue ( ) ;
148- spyOn ( API , "cancelWorkspaceBuild" ) . mockResolvedValue ( {
149- message : "Workspace build canceled" ,
150- } ) ;
151149 spyOn ( API , "getWorkspaceBuildByNumber" ) . mockResolvedValue ( {
152150 ...MockTaskWorkspace . latest_build ,
153151 status : "canceled" ,
152+ job : {
153+ ...MockTaskWorkspace . latest_build . job ,
154+ completed_at : undefined ,
155+ } ,
156+ } ) ;
157+ spyOn ( API , "cancelWorkspaceBuild" ) . mockResolvedValue ( {
158+ message : "Workspace build canceled" ,
154159 } ) ;
155160 spyOn ( API , "waitForBuild" ) . mockResolvedValue ( undefined ) ;
156161 spyOn ( API , "stopWorkspace" ) . mockResolvedValue (
157162 MockTaskWorkspace . latest_build ,
158163 ) ;
164+ spyOn ( API , "updateTaskInput" ) . mockResolvedValue ( ) ;
159165 spyOn ( API , "startWorkspace" ) . mockResolvedValue (
160166 MockTaskWorkspace . latest_build ,
161167 ) ;
@@ -205,26 +211,27 @@ export const Success: Story = {
205211
206212export const Failure : Story = {
207213 beforeEach : async ( ) => {
208- // Mock all API calls that happen before updateTaskPrompt
209- spyOn ( API , "cancelWorkspaceBuild" ) . mockResolvedValue ( {
210- message : "Workspace build canceled" ,
211- } ) ;
212214 spyOn ( API , "getWorkspaceBuildByNumber" ) . mockResolvedValue ( {
213215 ...MockTaskWorkspace . latest_build ,
214216 status : "canceled" ,
217+ job : {
218+ ...MockTaskWorkspace . latest_build . job ,
219+ completed_at : undefined ,
220+ } ,
221+ } ) ;
222+ spyOn ( API , "cancelWorkspaceBuild" ) . mockResolvedValue ( {
223+ message : "Workspace build canceled" ,
215224 } ) ;
216225 spyOn ( API , "waitForBuild" ) . mockResolvedValue ( undefined ) ;
217226 spyOn ( API , "stopWorkspace" ) . mockResolvedValue (
218227 MockTaskWorkspace . latest_build ,
219228 ) ;
220- // Mock updateTaskPrompt to reject with an error
221229 spyOn ( API , "updateTaskInput" ) . mockRejectedValue (
222230 mockApiError ( {
223231 message : "Failed to update task prompt" ,
224232 detail : "Build is not in a valid state for modification" ,
225233 } ) ,
226234 ) ;
227- // Don't need to mock startWorkspace since it won't be reached after the error
228235 } ,
229236 play : async ( { canvasElement, step } ) => {
230237 const body = within ( canvasElement . ownerDocument . body ) ;
0 commit comments