diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-11-22 18:17:43 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-11-22 18:17:43 +0000 |
commit | 48b65bb0ef5b7e70229491464bf69d910c27ed63 (patch) | |
tree | 397b9f5d18d6be5cc9b10c0bd201783a9f86c872 /spec | |
parent | 0c972f56b8193c173fffeccf1c9080c0682071e2 (diff) | |
parent | e67373007997ea61167a08d69008caed6e2d6c8e (diff) | |
download | gitlab-ce-48b65bb0ef5b7e70229491464bf69d910c27ed63.tar.gz |
Merge branch 'jivl-replace-vue-resource-prometheus-dashboard' into 'master'
Replace vue-resource for axios in the Prometheus Dashboard
See merge request gitlab-org/gitlab-ce!15547
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/monitoring/dashboard_spec.js | 12 | ||||
-rw-r--r-- | spec/javascripts/monitoring/mock_data.js | 15 |
2 files changed, 9 insertions, 18 deletions
diff --git a/spec/javascripts/monitoring/dashboard_spec.js b/spec/javascripts/monitoring/dashboard_spec.js index 752fdfb4614..9885b8a790f 100644 --- a/spec/javascripts/monitoring/dashboard_spec.js +++ b/spec/javascripts/monitoring/dashboard_spec.js @@ -1,6 +1,8 @@ import Vue from 'vue'; +import MockAdapter from 'axios-mock-adapter'; import Dashboard from '~/monitoring/components/dashboard.vue'; -import { MonitorMockInterceptor } from './mock_data'; +import axios from '~/lib/utils/axios_utils'; +import { metricsGroupsAPIResponse, mockApiEndpoint } from './mock_data'; describe('Dashboard', () => { const fixtureName = 'environments/metrics/metrics.html.raw'; @@ -26,13 +28,17 @@ describe('Dashboard', () => { }); describe('requests information to the server', () => { + let mock; beforeEach(() => { document.querySelector('#prometheus-graphs').setAttribute('data-has-metrics', 'true'); - Vue.http.interceptors.push(MonitorMockInterceptor); + mock = new MockAdapter(axios); + mock.onGet(mockApiEndpoint).reply(200, { + metricsGroupsAPIResponse, + }); }); afterEach(() => { - Vue.http.interceptors = _.without(Vue.http.interceptors, MonitorMockInterceptor); + mock.reset(); }); it('shows up a loading state', (done) => { diff --git a/spec/javascripts/monitoring/mock_data.js b/spec/javascripts/monitoring/mock_data.js index 7ceab657464..6b34855b8b2 100644 --- a/spec/javascripts/monitoring/mock_data.js +++ b/spec/javascripts/monitoring/mock_data.js @@ -2425,13 +2425,6 @@ const metricsGroupsAPIResponse = { export default metricsGroupsAPIResponse; -const responseMockData = { - 'GET': { - '/root/hello-prometheus/environments/30/additional_metrics.json': metricsGroupsAPIResponse, - 'http://test.host/frontend-fixtures/environments-project/environments/1/additional_metrics.json': metricsGroupsAPIResponse, // TODO: MAke sure this works in the monitoring_bundle_spec - }, -}; - export const deploymentData = [ { id: 111, @@ -8320,11 +8313,3 @@ export function convertDatesMultipleSeries(multipleSeries) { }); return convertedMultiple; } - -export function MonitorMockInterceptor(request, next) { - const body = responseMockData[request.method.toUpperCase()][request.url]; - - next(request.respondWith(JSON.stringify(body), { - status: 200, - })); -} |