Commit 7d9d1058 authored by Ash McKenzie's avatar Ash McKenzie

Show Geo node details, regardless of HTTP status

This also effectively renders the edit, disable and remove buttons
parent f43f4197
<script> <script>
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import Flash from '~/flash'; import Flash from '~/flash';
import statusCodes from '~/lib/utils/http_status';
import loadingIcon from '~/vue_shared/components/loading_icon.vue'; import loadingIcon from '~/vue_shared/components/loading_icon.vue';
import DeprecatedModal from '~/vue_shared/components/deprecated_modal.vue'; import DeprecatedModal from '~/vue_shared/components/deprecated_modal.vue';
import SmartInterval from '~/smart_interval'; import SmartInterval from '~/smart_interval';
...@@ -116,7 +115,7 @@ export default { ...@@ -116,7 +115,7 @@ export default {
); );
}) })
.catch(err => { .catch(err => {
if (err.response && err.response.status === statusCodes.NOT_FOUND) { if (err.response && err.response.data) {
this.store.setNodeDetails(nodeId, { this.store.setNodeDetails(nodeId, {
geo_node_id: nodeId, geo_node_id: nodeId,
health: err.message, health: err.message,
......
---
title: Ability to edit, disable or remove Geo Nodes is now always available
merge_request:
author:
type: changed
...@@ -124,21 +124,25 @@ describe('AppComponent', () => { ...@@ -124,21 +124,25 @@ describe('AppComponent', () => {
}, 0); }, 0);
}); });
it('emits `nodeDetailsLoadFailed` event on failure', (done) => { it('emits `nodeDetailsLoaded` event with fake nodeDetails object on 404 failure', (done) => {
spyOn(eventHub, '$emit'); spyOn(eventHub, '$emit');
mock.onGet(mockNode.statusPath).reply(500, {}); mock.onGet(mockNode.statusPath).reply(404, {});
spyOn(vm.service, 'getGeoNodeDetails').and.callThrough(); spyOn(vm.service, 'getGeoNodeDetails').and.callThrough();
vm.fetchNodeDetails(mockNode); vm.fetchNodeDetails(mockNode);
setTimeout(() => { setTimeout(() => {
expect(eventHub.$emit).toHaveBeenCalledWith('nodeDetailsLoadFailed', mockNode.id, jasmine.any(Object)); expect(eventHub.$emit).toHaveBeenCalledWith('nodeDetailsLoaded', jasmine.any(Object));
const nodeDetails = vm.store.state.nodeDetails['1'];
expect(nodeDetails).toBeDefined();
expect(nodeDetails.syncStatusUnavailable).toBe(true);
expect(nodeDetails.health).toBe('Request failed with status code 404');
done(); done();
}, 0); }, 0);
}); });
it('emits `nodeDetailsLoaded` event with fake nodeDetails object on 404 failure', (done) => { it('emits `nodeDetailsLoaded` event with fake nodeDetails object on 500 failure', (done) => {
spyOn(eventHub, '$emit'); spyOn(eventHub, '$emit');
mock.onGet(mockNode.statusPath).reply(404, {}); mock.onGet(mockNode.statusPath).reply(500, {});
spyOn(vm.service, 'getGeoNodeDetails').and.callThrough(); spyOn(vm.service, 'getGeoNodeDetails').and.callThrough();
vm.fetchNodeDetails(mockNode); vm.fetchNodeDetails(mockNode);
...@@ -147,7 +151,19 @@ describe('AppComponent', () => { ...@@ -147,7 +151,19 @@ describe('AppComponent', () => {
const nodeDetails = vm.store.state.nodeDetails['1']; const nodeDetails = vm.store.state.nodeDetails['1'];
expect(nodeDetails).toBeDefined(); expect(nodeDetails).toBeDefined();
expect(nodeDetails.syncStatusUnavailable).toBe(true); expect(nodeDetails.syncStatusUnavailable).toBe(true);
expect(nodeDetails.health).toBe('Request failed with status code 404'); expect(nodeDetails.health).toBe('Request failed with status code 500');
done();
}, 0);
});
it('emits `nodeDetailsLoadFailed` event on failure when there is no response', (done) => {
spyOn(eventHub, '$emit');
mock.onGet(mockNode.statusPath).reply(500, null);
spyOn(vm.service, 'getGeoNodeDetails').and.callThrough();
vm.fetchNodeDetails(mockNode);
setTimeout(() => {
expect(eventHub.$emit).toHaveBeenCalledWith('nodeDetailsLoadFailed', mockNode.id, jasmine.any(Object));
done(); done();
}, 0); }, 0);
}); });
......
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