Commit 85c30d74 authored by Filipa Lacerda's avatar Filipa Lacerda

Updates the check for started in job header

The function that was checking if the job was started or not
was expecting a boolean, however it was receiving a null.
During the refactor the condition was changed, causing the function
to break with null

This commit fixes the check
parent fbec87b4
......@@ -30,7 +30,7 @@
'headerActions',
'headerTime',
'shouldRenderCalloutMessage',
'jobHasStarted',
'shouldRenderTriggeredLabel',
'hasEnvironment',
'isJobStuck',
'hasTrace',
......@@ -58,7 +58,7 @@
:user="job.user"
:actions="headerActions"
:has-sidebar-button="true"
:should-render-triggered-label="jobHasStarted"
:should-render-triggered-label="shouldRenderTriggeredLabel"
:item-name="__('Job')"
/>
</div>
......
......@@ -22,10 +22,10 @@ export const shouldRenderCalloutMessage = state =>
!_.isEmpty(state.job.status) && !_.isEmpty(state.job.callout_message);
/**
* When job has not started the key will be `false`
* When job has not started the key will be null
* When job started the key will be a string with a date.
*/
export const jobHasStarted = state => !(state.job.started === false);
export const shouldRenderTriggeredLabel = state => _.isString(state.job.started);
export const hasEnvironment = state => !_.isEmpty(state.job.deployment_status);
......
---
title: Fixes triggered/created labeled in job header
merge_request:
author:
type: fixed
......@@ -77,18 +77,18 @@ describe('Job Store Getters', () => {
});
});
describe('jobHasStarted', () => {
describe('when started equals false', () => {
describe('shouldRenderTriggeredLabel', () => {
describe('when started equals null', () => {
it('returns false', () => {
localState.job.started = false;
expect(getters.jobHasStarted(localState)).toEqual(false);
localState.job.started = null;
expect(getters.shouldRenderTriggeredLabel(localState)).toEqual(false);
});
});
describe('when started equals string', () => {
it('returns true', () => {
localState.job.started = '2018-08-31T16:20:49.023Z';
expect(getters.jobHasStarted(localState)).toEqual(true);
expect(getters.shouldRenderTriggeredLabel(localState)).toEqual(true);
});
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment