Skip to content
This repository was archived by the owner on May 26, 2023. It is now read-only.

Commit

Permalink
Link to new executions for more event types (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnr authored Sep 8, 2021
1 parent b5f459a commit d71bd2e
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 22 deletions.
18 changes: 11 additions & 7 deletions client/routes/workflow/helpers/get-summary-workflow-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,26 @@ const getSummaryWorkflowStatus = ({
).toLowerCase();
}

if (workflowCompletedEvent.eventType === 'WorkflowExecutionContinuedAsNew') {
const text = workflowCompletedEvent.eventType
.replace('WorkflowExecution', '')
.toLowerCase()
.replace('continuedasnew', 'continued-as-new');

// Any of {Completed,Failed,TimedOut,ContinuedAsNew} can have this field:
if (workflowCompletedEvent.details && workflowCompletedEvent.details.newExecutionRunId) {
return {
to: {
text: text,
status: text,
next: {
name: 'workflow/summary',
params: {
runId: workflowCompletedEvent.details.newExecutionRunId,
},
},
text: 'Continued As New',
status: 'continued-as-new',
};
}

return workflowCompletedEvent.eventType
.replace('WorkflowExecution', '')
.toLowerCase();
return text;
};

export default getSummaryWorkflowStatus;
55 changes: 47 additions & 8 deletions client/routes/workflow/helpers/get-summary-workflow-status.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ describe('getSummaryWorkflowStatus', () => {
};
});

it('should return an object with to.name = "workflow/summary".', () => {
it('should return an object with next.name = "workflow/summary".', () => {
const output = getSummaryWorkflowStatus(event);

expect(output.to.name).toEqual('workflow/summary');
expect(output.next.name).toEqual('workflow/summary');
});

it('should return an object with to.params.runId.', () => {
it('should return an object with next.params.runId.', () => {
const output = getSummaryWorkflowStatus(event);

expect(output.to.params.runId).toEqual('newExecutionRunIdValue');
expect(output.next.params.runId).toEqual('newExecutionRunIdValue');
});

it('should return an object with text = "Continued As New".', () => {
it('should return an object with text = "continued-as-new".', () => {
const output = getSummaryWorkflowStatus(event);

expect(output.text).toEqual('Continued As New');
expect(output.text).toEqual('continued-as-new');
});

it('should return an object with status = "continued-as-new".', () => {
Expand All @@ -78,16 +78,55 @@ describe('getSummaryWorkflowStatus', () => {
});
});

describe('When passed an event with workflowCompletedEvent.eventType === "WorkflowExecutionCompleted" and workflowCompletedEvent.details.newExecutionRunId is defined', () => {
let event;

beforeEach(() => {
event = {
workflowCompletedEvent: {
eventType: 'WorkflowExecutionCompleted',
details: {
newExecutionRunId: 'newExecutionRunIdValue',
},
},
};
});

it('should return an object with next.name = "workflow/summary".', () => {
const output = getSummaryWorkflowStatus(event);

expect(output.next.name).toEqual('workflow/summary');
});

it('should return an object with next.params.runId.', () => {
const output = getSummaryWorkflowStatus(event);

expect(output.next.params.runId).toEqual('newExecutionRunIdValue');
});

it('should return an object with text = "completed".', () => {
const output = getSummaryWorkflowStatus(event);

expect(output.text).toEqual('completed');
});

it('should return an object with status = "completed".', () => {
const output = getSummaryWorkflowStatus(event);

expect(output.status).toEqual('completed');
});
});

describe('When passed an workflowCompletedEvent.eventType !== "WorkflowExecutionContinuedAsNew"', () => {
it('should return workflowCompletedEvent.eventType without WorkflowExecution and in lower case.', () => {
const event = {
workflowCompletedEvent: {
eventType: 'NotWorkflowExecutionContinuedAsNew',
eventType: 'WorkflowExecutionSomethingElse',
},
};
const output = getSummaryWorkflowStatus(event);

expect(output).toEqual('notcontinuedasnew');
expect(output).toEqual('somethingelse');
});
});
});
13 changes: 12 additions & 1 deletion client/routes/workflow/helpers/summarize-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,18 @@ const summaryExtractors = {

return summary;
},
WorkflowExecutionFailed: d => ({ message: d.failure?.message }),
WorkflowExecutionCompleted: d => ({
result: d.result,
newExecutionRunId: d.newExecutionRunId || undefined,
}),
WorkflowExecutionFailed: d => ({
message: d.failure?.message,
newExecutionRunId: d.newExecutionRunId || undefined,
}),
WorkflowExecutionTimedOut: d => ({
retryState: d.retryState,
newExecutionRunId: d.newExecutionRunId || undefined,
}),
WorkflowTaskFailed: d => ({ message: d.failure?.message }),
ChildWorkflowExecutionFailed: d => ({ message: d.failure?.message }),
};
Expand Down
10 changes: 5 additions & 5 deletions client/routes/workflow/summary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,10 @@
<dd>
<bar-loader v-if="wfStatus === 'running'" />
<span v-if="typeof wfStatus === 'string'">{{ wfStatus }}</span>
<router-link
v-if="wfStatus !== undefined && wfStatus.to"
:to="wfStatus.to"
>
<span v-if="wfStatus !== undefined && wfStatus.next">
{{ wfStatus.text }}
</router-link>
<router-link :to="wfStatus.next">(next)</router-link>
</span>
</dd>
</div>
<div class="workflow-id" data-cy="workflow-id">
Expand Down Expand Up @@ -286,6 +284,8 @@ section.workflow-summary
.workflow-status
dd
text-transform capitalize
a
text-transform none
&[data-status="completed"] dd
color uber-green
&[data-status="failed"] dd
Expand Down

0 comments on commit d71bd2e

Please sign in to comment.