@@ -1221,6 +1221,42 @@ describe('POST /api/workflows/[id]/executions/[executionId]/cancel', () => {
12211221 expect ( mockCancelByExecution ) . not . toHaveBeenCalled ( )
12221222 } )
12231223
1224+ it ( 'finishes workflow-group reconciliation when abort arrives during its durable commit' , async ( ) => {
1225+ const controller = new AbortController ( )
1226+ dbChainMockFns . limit . mockResolvedValueOnce ( [
1227+ {
1228+ executionDeadlineAt : null ,
1229+ executionOrigin : 'workflow_group' ,
1230+ status : 'cancelled' ,
1231+ workspaceId : 'workspace-1' ,
1232+ } ,
1233+ ] )
1234+ mockCancelWorkflowGroupExecution . mockImplementationOnce ( async ( ) => {
1235+ controller . abort ( )
1236+ return {
1237+ kind : 'already_cancelled' ,
1238+ tableId : 'table-1' ,
1239+ rowId : 'row-1' ,
1240+ groupId : 'group-1' ,
1241+ }
1242+ } )
1243+ mockStagePausedCancellation . mockResolvedValue ( { kind : 'idle' } )
1244+ mockCompletePausedCancellation . mockResolvedValue ( true )
1245+
1246+ const response = await cancelWorkflowExecutionPostAuth ( {
1247+ workflowId : 'wf-1' ,
1248+ executionId : 'ex-1' ,
1249+ userId : 'user-1' ,
1250+ abortSignal : controller . signal ,
1251+ } )
1252+
1253+ expect ( response . status ) . toBe ( 200 )
1254+ await expect ( response . json ( ) ) . resolves . toMatchObject ( { success : true , pausedCancelled : true } )
1255+ expect ( mockClearPausedCancellationIntent ) . not . toHaveBeenCalled ( )
1256+ expect ( mockPublishWorkflowGroupCancellationEvent ) . toHaveBeenCalledOnce ( )
1257+ expect ( mockCompletePausedCancellation ) . toHaveBeenCalledWith ( 'ex-1' , 'wf-1' )
1258+ } )
1259+
12241260 it ( 'does not finalize an already-cancelled group retry until exact stop is accepted' , async ( ) => {
12251261 dbChainMockFns . limit . mockResolvedValueOnce ( [
12261262 {
0 commit comments