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