Skip to content

Commit 62bf40c

Browse files
authored
Change calculations for hasMissingEvents (#840)
* change calculations for hasMissingEvents * lint fix * fix hasMissingEvents for timeouts * better conditional reading
1 parent 967ddda commit 62bf40c

12 files changed

+319
-156
lines changed

Diff for: src/views/workflow-history/helpers/get-history-group-from-events/__tests__/get-activity-group-from-events.test.ts

+39-19
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,47 @@ describe('getActivityGroupFromEvents', () => {
4848
expect(timedoutActivitygroup.label).toBe('');
4949
});
5050

51-
it('should return a group with hasMissingEvents set to true when scheduled event is missing', () => {
52-
const completeEvents: ActivityHistoryEvent[] = [
53-
startActivityTaskEvent,
54-
completeActivityTaskEvent,
51+
it('should return a group with hasMissingEvents when any event is missing', () => {
52+
const assertions: Array<{
53+
name: string;
54+
events: ActivityHistoryEvent[];
55+
assertionValue: boolean;
56+
}> = [
57+
{
58+
name: 'missingCloseEvent',
59+
events: [scheduleActivityTaskEvent, startActivityTaskEvent],
60+
assertionValue: true,
61+
},
62+
{
63+
name: 'missingScheduleEvent',
64+
events: [startActivityTaskEvent, failedActivityTaskEvent],
65+
assertionValue: true,
66+
},
67+
{
68+
name: 'missingTimoutAndCloseEvent',
69+
events: [scheduleActivityTaskEvent],
70+
assertionValue: true,
71+
},
72+
{
73+
name: 'completeEvents',
74+
events: [
75+
scheduleActivityTaskEvent,
76+
startActivityTaskEvent,
77+
completeActivityTaskEvent,
78+
],
79+
assertionValue: false,
80+
},
81+
{
82+
name: 'timedoutEvents',
83+
events: [scheduleActivityTaskEvent, timeoutActivityTaskEvent],
84+
assertionValue: false,
85+
},
5586
];
56-
const completedActivitygroup = getActivityGroupFromEvents(completeEvents);
57-
expect(completedActivitygroup.hasMissingEvents).toBe(true);
5887

59-
const failureEvents: ActivityHistoryEvent[] = [
60-
startActivityTaskEvent,
61-
failedActivityTaskEvent,
62-
];
63-
const failedActivitygroup = getActivityGroupFromEvents(failureEvents);
64-
expect(failedActivitygroup.hasMissingEvents).toBe(true);
65-
66-
const timeoutEvents: ActivityHistoryEvent[] = [
67-
startActivityTaskEvent,
68-
timeoutActivityTaskEvent,
69-
];
70-
const timedoutActivitygroup = getActivityGroupFromEvents(timeoutEvents);
71-
expect(timedoutActivitygroup.hasMissingEvents).toBe(true);
88+
assertions.forEach(({ name, events, assertionValue }) => {
89+
const group = getActivityGroupFromEvents(events);
90+
expect([name, group.hasMissingEvents]).toEqual([name, assertionValue]);
91+
});
7292
});
7393

7494
it('should return a group with groupType equal to Activity', () => {

Diff for: src/views/workflow-history/helpers/get-history-group-from-events/__tests__/get-child-workflow-execution-group-from-events.test.ts

+37-39
Original file line numberDiff line numberDiff line change
@@ -26,45 +26,43 @@ describe('getChildWorkflowExecutionGroupFromEvents', () => {
2626
expect(group.label).toBe(expectedLabel);
2727
});
2828

29-
it('should return a group with hasMissingEvents set to true when initiate event is missing', () => {
30-
const intiateFailedEvents: ChildWorkflowExecutionHistoryEvent[] = [
31-
initiateFailureChildWorkflowEvent,
32-
];
33-
const intiateFailedChildWorkflowgroup =
34-
getChildWorkflowExecutionGroupFromEvents(intiateFailedEvents);
35-
expect(intiateFailedChildWorkflowgroup.hasMissingEvents).toBe(true);
36-
37-
const completeEvents: ChildWorkflowExecutionHistoryEvent[] = [
38-
startChildWorkflowEvent,
39-
completeChildWorkflowEvent,
40-
];
41-
const completedChildWorkflowgroup =
42-
getChildWorkflowExecutionGroupFromEvents(completeEvents);
43-
expect(completedChildWorkflowgroup.hasMissingEvents).toBe(true);
44-
45-
const failureEvents: ChildWorkflowExecutionHistoryEvent[] = [
46-
startChildWorkflowEvent,
47-
failChildWorkflowEvent,
48-
];
49-
const failedChildWorkflowgroup =
50-
getChildWorkflowExecutionGroupFromEvents(failureEvents);
51-
expect(failedChildWorkflowgroup.hasMissingEvents).toBe(true);
52-
53-
const timeoutEvents: ChildWorkflowExecutionHistoryEvent[] = [
54-
startChildWorkflowEvent,
55-
timeoutChildWorkflowEvent,
56-
];
57-
const timedoutChildWorkflowgroup =
58-
getChildWorkflowExecutionGroupFromEvents(timeoutEvents);
59-
expect(timedoutChildWorkflowgroup.hasMissingEvents).toBe(true);
60-
61-
const cancelEvents: ChildWorkflowExecutionHistoryEvent[] = [
62-
startChildWorkflowEvent,
63-
cancelChildWorkflowEvent,
64-
];
65-
const cancelChildWorkflowgroup =
66-
getChildWorkflowExecutionGroupFromEvents(cancelEvents);
67-
expect(cancelChildWorkflowgroup.hasMissingEvents).toBe(true);
29+
it('should return a group with hasMissingEvents set to true when any event is missing', () => {
30+
const assertions: Array<{
31+
name: string;
32+
events: ChildWorkflowExecutionHistoryEvent[];
33+
assertionValue: boolean;
34+
}> = [
35+
{
36+
name: 'missingInitiatedEvent',
37+
events: [initiateFailureChildWorkflowEvent],
38+
assertionValue: true,
39+
},
40+
{
41+
name: 'missingInitiationFailureAndCloseEvent',
42+
events: [initiateChildWorkflowEvent],
43+
assertionValue: true,
44+
},
45+
{
46+
name: 'missingCloseEvent',
47+
events: [initiateChildWorkflowEvent, startChildWorkflowEvent],
48+
assertionValue: true,
49+
},
50+
{
51+
name: 'missingStartEvent',
52+
events: [initiateChildWorkflowEvent, completeChildWorkflowEvent],
53+
assertionValue: true,
54+
},
55+
{
56+
name: 'completedFailedInitiationEvent',
57+
events: [initiateChildWorkflowEvent, initiateFailureChildWorkflowEvent],
58+
assertionValue: false,
59+
},
60+
];
61+
62+
assertions.forEach(({ name, events, assertionValue }) => {
63+
const group = getChildWorkflowExecutionGroupFromEvents(events);
64+
expect([name, group.hasMissingEvents]).toEqual([name, assertionValue]);
65+
});
6866
});
6967

7068
it('should return a group with groupType equal to ChildWorkflow', () => {

Diff for: src/views/workflow-history/helpers/get-history-group-from-events/__tests__/get-decision-group-from-events.test.ts

+44-19
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,52 @@ describe('getDecisionGroupFromEvents', () => {
2424
expect(group.label).toBe('Decision Task');
2525
});
2626

27-
it('should return a group with hasMissingEvents set to true when scheduled event is missing', () => {
28-
const completeEvents: ExtendedDecisionHistoryEvent[] = [
29-
startDecisionTaskEvent,
30-
completeDecisionTaskEvent,
31-
];
32-
const completedDecisiongroup = getDecisionGroupFromEvents(completeEvents);
33-
expect(completedDecisiongroup.hasMissingEvents).toBe(true);
34-
35-
const failureEvents: ExtendedDecisionHistoryEvent[] = [
36-
startDecisionTaskEvent,
37-
failedDecisionTaskEvent,
27+
it('should return a group with hasMissingEvents set to true when any event is missing', () => {
28+
const assertions: Array<{
29+
name: string;
30+
events: ExtendedDecisionHistoryEvent[];
31+
assertionValue: boolean;
32+
}> = [
33+
{
34+
name: 'missingScheduleEvent',
35+
events: [startDecisionTaskEvent, completeDecisionTaskEvent],
36+
assertionValue: true,
37+
},
38+
{
39+
name: 'missingTimoutAndCloseEvent',
40+
events: [scheduleDecisionTaskEvent],
41+
assertionValue: true,
42+
},
43+
{
44+
name: 'missingStartEvent',
45+
events: [scheduleDecisionTaskEvent, completeDecisionTaskEvent],
46+
assertionValue: true,
47+
},
48+
{
49+
name: 'missingCompleteEvent',
50+
events: [scheduleDecisionTaskEvent, startDecisionTaskEvent],
51+
assertionValue: true,
52+
},
53+
{
54+
name: 'completeEvents',
55+
events: [
56+
scheduleDecisionTaskEvent,
57+
startDecisionTaskEvent,
58+
completeDecisionTaskEvent,
59+
],
60+
assertionValue: false,
61+
},
62+
{
63+
name: 'timedoutEvents',
64+
events: [scheduleDecisionTaskEvent, timeoutDecisionTaskEvent],
65+
assertionValue: false,
66+
},
3867
];
39-
const failedDecisiongroup = getDecisionGroupFromEvents(failureEvents);
40-
expect(failedDecisiongroup.hasMissingEvents).toBe(true);
4168

42-
const timeoutEvents: ExtendedDecisionHistoryEvent[] = [
43-
startDecisionTaskEvent,
44-
timeoutDecisionTaskEvent,
45-
];
46-
const timedoutDecisiongroup = getDecisionGroupFromEvents(timeoutEvents);
47-
expect(timedoutDecisiongroup.hasMissingEvents).toBe(true);
69+
assertions.forEach(({ name, events, assertionValue }) => {
70+
const group = getDecisionGroupFromEvents(events);
71+
expect([name, group.hasMissingEvents]).toEqual([name, assertionValue]);
72+
});
4873
});
4974

5075
it('should return a group with groupType equal to Decision', () => {

Diff for: src/views/workflow-history/helpers/get-history-group-from-events/__tests__/get-request-cancel-external-workflow-execution-group-from-events.test.ts

+31-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,37 @@ describe('getRequestCancelExternalWorkflowExecutionGroupFromEvents', () => {
2222
expect(group.label).toBe(expectedLabel);
2323
});
2424

25-
it('should return a group with hasMissingEvents set to true when initiated event is missing', () => {
26-
const requestEvents: RequestCancelExternalWorkflowExecutionHistoryEvent[] =
27-
[requestCancelExternalWorkflowEvent];
28-
const requestGroup =
29-
getRequestCancelExternalWorkflowExecutionGroupFromEvents(requestEvents);
30-
expect(requestGroup.hasMissingEvents).toBe(true);
25+
it('should return a group with hasMissingEvents set to true when any event is missing', () => {
26+
const assertions: Array<{
27+
name: string;
28+
events: RequestCancelExternalWorkflowExecutionHistoryEvent[];
29+
assertionValue: boolean;
30+
}> = [
31+
{
32+
name: 'missingInitiatedEvent',
33+
events: [requestCancelExternalWorkflowEvent],
34+
assertionValue: true,
35+
},
36+
{
37+
name: 'missingCloseEvent',
38+
events: [initiateRequestCancelExternalWorkflowEvent],
39+
assertionValue: true,
40+
},
41+
{
42+
name: 'completedEvent',
43+
events: [
44+
initiateRequestCancelExternalWorkflowEvent,
45+
requestCancelExternalWorkflowEvent,
46+
],
47+
assertionValue: false,
48+
},
49+
];
50+
51+
assertions.forEach(({ name, events, assertionValue }) => {
52+
const group =
53+
getRequestCancelExternalWorkflowExecutionGroupFromEvents(events);
54+
expect([name, group.hasMissingEvents]).toEqual([name, assertionValue]);
55+
});
3156
});
3257

3358
it('should return a group with groupType equal to RequestCancelExternalWorkflowExecution', () => {

Diff for: src/views/workflow-history/helpers/get-history-group-from-events/__tests__/get-signal-external-workflow-execution-group-from-events.test.ts

+28-12
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,36 @@ describe('getSignalExternalWorkflowExecutionGroupFromEvents', () => {
2222
expect(group.label).toBe(expectedLabel);
2323
});
2424

25-
it('should return a group with hasMissingEvents set to true when initiate event is missing', () => {
26-
const signalEvents: SignalExternalWorkflowExecutionHistoryEvent[] = [
27-
signalExternalWorkflowEvent,
25+
it('should return a group with hasMissingEvents set to true when any event is missing', () => {
26+
const assertions: Array<{
27+
name: string;
28+
events: SignalExternalWorkflowExecutionHistoryEvent[];
29+
assertionValue: boolean;
30+
}> = [
31+
{
32+
name: 'missingInitiatedEvent',
33+
events: [signalExternalWorkflowEvent],
34+
assertionValue: true,
35+
},
36+
{
37+
name: 'missingCloseEvent',
38+
events: [initiateSignalExternalWorkflowEvent],
39+
assertionValue: true,
40+
},
41+
{
42+
name: 'completeEvents',
43+
events: [
44+
initiateSignalExternalWorkflowEvent,
45+
signalExternalWorkflowEvent,
46+
],
47+
assertionValue: false,
48+
},
2849
];
29-
const signalGroup =
30-
getSignalExternalWorkflowExecutionGroupFromEvents(signalEvents);
31-
expect(signalGroup.hasMissingEvents).toBe(true);
3250

33-
const failEvents: SignalExternalWorkflowExecutionHistoryEvent[] = [
34-
failSignalExternalWorkflowEvent,
35-
];
36-
const failedGroup =
37-
getSignalExternalWorkflowExecutionGroupFromEvents(failEvents);
38-
expect(failedGroup.hasMissingEvents).toBe(true);
51+
assertions.forEach(({ name, events, assertionValue }) => {
52+
const group = getSignalExternalWorkflowExecutionGroupFromEvents(events);
53+
expect([name, group.hasMissingEvents]).toEqual([name, assertionValue]);
54+
});
3955
});
4056

4157
it('should return a group with groupType equal to SignalExternalWorkflowExecution', () => {

Diff for: src/views/workflow-history/helpers/get-history-group-from-events/__tests__/get-timer-group-from-events.test.ts

+26-7
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,33 @@ describe('getTimerGroupFromEvents', () => {
2020
expect(group.label).toBe(expectedLabel);
2121
});
2222

23-
it('should return a group with hasMissingEvents set to true when start event is missing', () => {
24-
const fireEvents: TimerHistoryEvent[] = [fireTimerTaskEvent];
25-
const firedTimerGroup = getTimerGroupFromEvents(fireEvents);
26-
expect(firedTimerGroup.hasMissingEvents).toBe(true);
23+
it('should return a group with hasMissingEvents set to true when any event is missing', () => {
24+
const assertions: Array<{
25+
name: string;
26+
events: TimerHistoryEvent[];
27+
assertionValue: boolean;
28+
}> = [
29+
{
30+
name: 'missingStartEvent',
31+
events: [fireTimerTaskEvent],
32+
assertionValue: true,
33+
},
34+
{
35+
name: 'missingCloseEvent',
36+
events: [startTimerTaskEvent],
37+
assertionValue: true,
38+
},
39+
{
40+
name: 'completeEvents',
41+
events: [startTimerTaskEvent, fireTimerTaskEvent],
42+
assertionValue: false,
43+
},
44+
];
2745

28-
const cancelEvents: TimerHistoryEvent[] = [cancelTimerTaskEvent];
29-
const canceledTimerGroup = getTimerGroupFromEvents(cancelEvents);
30-
expect(canceledTimerGroup.hasMissingEvents).toBe(true);
46+
assertions.forEach(({ name, events, assertionValue }) => {
47+
const group = getTimerGroupFromEvents(events);
48+
expect([name, group.hasMissingEvents]).toEqual([name, assertionValue]);
49+
});
3150
});
3251

3352
it('should return a group with groupType equal to Timer', () => {

0 commit comments

Comments
 (0)