4
4
type FormattedWorkflowExecutionFailedEvent ,
5
5
type FormattedWorkflowExecutionTerminatedEvent ,
6
6
type FormattedWorkflowExecutionTimedOutEvent ,
7
+ type FormattedWorkflowExecutionContinuedAsNewEvent ,
8
+ type FormattedTimerFiredEvent ,
7
9
} from '@/utils/data-formatters/schema/format-history-event-schema' ;
8
10
9
11
import getWorkflowResultJson from '../get-workflow-result-json' ;
@@ -20,7 +22,7 @@ describe('getWorkflowResultJson', () => {
20
22
expect ( getWorkflowResultJson ( formattedEvent ) ) . toBe ( 'canceled details' ) ;
21
23
} ) ;
22
24
23
- it ( 'should return details for WorkflowExecutionFailed event' , ( ) => {
25
+ it ( 'should return details and reason for WorkflowExecutionFailed event' , ( ) => {
24
26
const formattedEvent : FormattedWorkflowExecutionFailedEvent = {
25
27
eventType : 'WorkflowExecutionFailed' ,
26
28
reason : 'cadenceInternal:Generic' ,
@@ -29,7 +31,10 @@ describe('getWorkflowResultJson', () => {
29
31
timestamp : null ,
30
32
decisionTaskCompletedEventId : '1' ,
31
33
} ;
32
- expect ( getWorkflowResultJson ( formattedEvent ) ) . toBe ( 'failed details' ) ;
34
+ expect ( getWorkflowResultJson ( formattedEvent ) ) . toEqual ( {
35
+ reason : 'cadenceInternal:Generic' ,
36
+ details : 'failed details' ,
37
+ } ) ;
33
38
} ) ;
34
39
35
40
it ( 'should return details for WorkflowExecutionTerminated event' , ( ) => {
@@ -41,7 +46,11 @@ describe('getWorkflowResultJson', () => {
41
46
timestamp : null ,
42
47
identity : '1111' ,
43
48
} ;
44
- expect ( getWorkflowResultJson ( formattedEvent ) ) . toBe ( 'terminated details' ) ;
49
+ expect ( getWorkflowResultJson ( formattedEvent ) ) . toEqual ( {
50
+ reason : 'cadenceInternal:Generic' ,
51
+ details : 'terminated details' ,
52
+ identity : '1111' ,
53
+ } ) ;
45
54
} ) ;
46
55
47
56
it ( 'should return result for WorkflowExecutionCompleted event' , ( ) => {
@@ -55,13 +64,55 @@ describe('getWorkflowResultJson', () => {
55
64
expect ( getWorkflowResultJson ( formattedEvent ) ) . toBe ( 'completed result' ) ;
56
65
} ) ;
57
66
58
- it ( 'should return undefined for other eventType ' , ( ) => {
67
+ it ( 'should return timeoutType for WorkflowExecutionTimedOut event ' , ( ) => {
59
68
const formattedEvent : FormattedWorkflowExecutionTimedOutEvent = {
60
69
eventType : 'WorkflowExecutionTimedOut' ,
61
70
eventId : 1 ,
62
71
timeoutType : 'TIMEOUT_TYPE_HEARTBEAT' ,
63
72
timestamp : null ,
64
73
} ;
74
+ expect ( getWorkflowResultJson ( formattedEvent ) ) . toEqual ( {
75
+ timeoutType : 'TIMEOUT_TYPE_HEARTBEAT' ,
76
+ } ) ;
77
+ } ) ;
78
+
79
+ it ( 'should return correct fields for WorkflowExecutionContinuedAsNew event' , ( ) => {
80
+ const formattedEvent : FormattedWorkflowExecutionContinuedAsNewEvent = {
81
+ backoffStartIntervalInSeconds : 0 ,
82
+ decisionTaskCompletedEventId : '' ,
83
+ eventId : 1 ,
84
+ eventType : 'WorkflowExecutionContinuedAsNew' ,
85
+ executionStartToCloseTimeoutSeconds : 0 ,
86
+ workflowType : null ,
87
+ timestamp : null ,
88
+ header : { fields : { } } ,
89
+ input : [ ] ,
90
+ memo : { fields : { } } ,
91
+ searchAttributes : { indexedFields : '' } ,
92
+ taskList : { kind : 'NORMAL' , name : '' } ,
93
+ taskStartToCloseTimeoutSeconds : 0 ,
94
+ newExecutionRunId : '' ,
95
+ initiator : 'CRON_SCHEDULE' ,
96
+ failureDetails : 'Failure Details' ,
97
+ failureReason : 'Failure Reason' ,
98
+ lastCompletionResult : null ,
99
+ } ;
100
+ expect ( getWorkflowResultJson ( formattedEvent ) ) . toEqual ( {
101
+ initiator : 'CRON_SCHEDULE' ,
102
+ failureDetails : 'Failure Details' ,
103
+ failureReason : 'Failure Reason' ,
104
+ lastCompletionResult : null ,
105
+ } ) ;
106
+ } ) ;
107
+
108
+ it ( 'should return undefined for other eventType' , ( ) => {
109
+ const formattedEvent : FormattedTimerFiredEvent = {
110
+ eventType : 'TimerFired' ,
111
+ eventId : 3 ,
112
+ timestamp : null ,
113
+ startedEventId : 2 ,
114
+ timerId : '1' ,
115
+ } ;
65
116
expect ( getWorkflowResultJson ( formattedEvent ) ) . toBeUndefined ( ) ;
66
117
} ) ;
67
118
0 commit comments