Commit dc24e47d authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '217052-empty-time-value-on-alerts-list' into 'master'

Handle empty endDate case

See merge request gitlab-org/gitlab!31469
parents b9253058 c8995168
...@@ -197,11 +197,11 @@ export default { ...@@ -197,11 +197,11 @@ export default {
</template> </template>
<template #cell(startedAt)="{ item }"> <template #cell(startedAt)="{ item }">
<time-ago :time="item.startedAt" /> <time-ago v-if="item.startedAt" :time="item.startedAt" />
</template> </template>
<template #cell(endedAt)="{ item }"> <template #cell(endedAt)="{ item }">
<time-ago :time="item.endedAt" /> <time-ago v-if="item.endedAt" :time="item.endedAt" />
</template> </template>
<template #cell(title)="{ item }"> <template #cell(title)="{ item }">
......
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
GlIcon, GlIcon,
GlTab, GlTab,
} from '@gitlab/ui'; } from '@gitlab/ui';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
import AlertManagementList from '~/alert_management/components/alert_management_list.vue'; import AlertManagementList from '~/alert_management/components/alert_management_list.vue';
import { ALERTS_STATUS_TABS } from '../../../../app/assets/javascripts/alert_management/constants'; import { ALERTS_STATUS_TABS } from '../../../../app/assets/javascripts/alert_management/constants';
...@@ -24,6 +25,7 @@ describe('AlertManagementList', () => { ...@@ -24,6 +25,7 @@ describe('AlertManagementList', () => {
const findStatusDropdown = () => wrapper.find(GlNewDropdown); const findStatusDropdown = () => wrapper.find(GlNewDropdown);
const findStatusFilterTabs = () => wrapper.findAll(GlTab); const findStatusFilterTabs = () => wrapper.findAll(GlTab);
const findNumberOfAlertsBadge = () => wrapper.findAll(GlBadge); const findNumberOfAlertsBadge = () => wrapper.findAll(GlBadge);
const findDateFields = () => wrapper.findAll(TimeAgo);
function mountComponent({ function mountComponent({
props = { props = {
...@@ -198,5 +200,45 @@ describe('AlertManagementList', () => { ...@@ -198,5 +200,45 @@ describe('AlertManagementList', () => {
).toBe(true); ).toBe(true);
}); });
}); });
describe('handle date fields', () => {
it('should display time ago dates when values provided', () => {
mountComponent({
props: { alertManagementEnabled: true, userCanEnableAlertManagement: true },
data: {
alerts: [
{
iid: 1,
startedAt: '2020-03-17T23:18:14.996Z',
endedAt: '2020-04-17T23:18:14.996Z',
severity: 'high',
},
],
errored: false,
},
loading: false,
});
expect(findDateFields().length).toBe(2);
});
it('should not display time ago dates when values not provided', () => {
mountComponent({
props: { alertManagementEnabled: true, userCanEnableAlertManagement: true },
data: {
alerts: [
{
iid: 1,
startedAt: null,
endedAt: null,
severity: 'high',
},
],
errored: false,
},
loading: false,
});
expect(findDateFields().exists()).toBe(false);
});
});
}); });
}); });
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