Commit c6978285 authored by Kushal Pandya's avatar Kushal Pandya Committed by Kushal Pandya

Show empty state when timestamp is not present

parent 238f2081
......@@ -35,16 +35,24 @@
<div
class="node-detail-value"
>
<strong>
{{ eventId }}
</strong>
<span
v-tooltip
class="event-status-timestamp"
data-placement="bottom"
:title="timeStampString"
<template v-if="eventTimeStamp">
<strong>
{{ eventId }}
</strong>
<span
v-tooltip
v-if="eventTimeStamp"
class="event-status-timestamp"
data-placement="bottom"
:title="timeStampString"
>
({{ timeFormated(timeStamp) }})
</span>
</template>
<strong
v-else
>
({{ timeFormated(timeStamp) }})
</span>
{{ __('Not available') }}
</strong>
</div>
</template>
......@@ -74,11 +74,11 @@ export default class GeoNodesStore {
failureCount: rawNodeDetails.attachments_failed_count || 0,
},
lastEvent: {
id: rawNodeDetails.last_event_id,
id: rawNodeDetails.last_event_id || 0,
timeStamp: rawNodeDetails.last_event_timestamp,
},
cursorLastEvent: {
id: rawNodeDetails.cursor_last_event_id,
id: rawNodeDetails.cursor_last_event_id || 0,
timeStamp: rawNodeDetails.cursor_last_event_timestamp,
},
namespaces: rawNodeDetails.namespaces,
......
......@@ -5,12 +5,15 @@ import { mockNodeDetails } from '../mock_data';
import mountComponent from '../../helpers/vue_mount_component_helper';
const createComponent = () => {
const createComponent = (
eventId = mockNodeDetails.lastEvent.id,
eventTimeStamp = mockNodeDetails.lastEvent.timeStamp,
) => {
const Component = Vue.extend(geoNodeEventStatusComponent);
return mountComponent(Component, {
eventId: mockNodeDetails.lastEvent.id,
eventTimeStamp: mockNodeDetails.lastEvent.timeStamp,
eventId,
eventTimeStamp,
});
};
......@@ -46,5 +49,13 @@ describe('GeoNodeEventStatus', () => {
expect(vm.$el.querySelector('strong').innerText.trim()).toBe(`${mockNodeDetails.lastEvent.id}`);
expect(vm.$el.querySelector('.event-status-timestamp').innerText).toContain('ago');
});
it('renders empty state when timestamp is not present', () => {
const vmWithoutTimestamp = createComponent(0, 0);
expect(vmWithoutTimestamp.$el.querySelectorAll('strong').length).not.toBe(0);
expect(vmWithoutTimestamp.$el.querySelectorAll('.event-status-timestamp').length).toBe(0);
expect(vmWithoutTimestamp.$el.querySelector('strong').innerText.trim()).toBe('Not available');
vmWithoutTimestamp.$destroy();
});
});
});
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