2017-06-20 04:50:31 -04:00
|
|
|
import Vue from 'vue';
|
2017-11-22 11:33:53 -05:00
|
|
|
import MockAdapter from 'axios-mock-adapter';
|
2017-08-30 12:11:19 -04:00
|
|
|
import Dashboard from '~/monitoring/components/dashboard.vue';
|
2019-04-10 13:33:30 -04:00
|
|
|
import { timeWindows, timeWindowsKeyNames } from '~/monitoring/constants';
|
2019-05-27 18:30:36 -04:00
|
|
|
import * as types from '~/monitoring/stores/mutation_types';
|
|
|
|
import { createStore } from '~/monitoring/stores';
|
2017-11-22 11:33:53 -05:00
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2019-05-27 18:30:36 -04:00
|
|
|
import {
|
|
|
|
metricsGroupsAPIResponse,
|
|
|
|
mockApiEndpoint,
|
|
|
|
environmentData,
|
|
|
|
singleGroupResponse,
|
|
|
|
} from './mock_data';
|
2017-06-20 04:50:31 -04:00
|
|
|
|
2018-10-05 12:26:16 -04:00
|
|
|
const propsData = {
|
|
|
|
hasMetrics: false,
|
|
|
|
documentationPath: '/path/to/docs',
|
|
|
|
settingsPath: '/path/to/settings',
|
|
|
|
clustersPath: '/path/to/clusters',
|
|
|
|
tagsPath: '/path/to/tags',
|
|
|
|
projectPath: '/path/to/project',
|
|
|
|
metricsEndpoint: mockApiEndpoint,
|
|
|
|
deploymentEndpoint: null,
|
|
|
|
emptyGettingStartedSvgPath: '/path/to/getting-started.svg',
|
|
|
|
emptyLoadingSvgPath: '/path/to/loading.svg',
|
|
|
|
emptyNoDataSvgPath: '/path/to/no-data.svg',
|
|
|
|
emptyUnableToConnectSvgPath: '/path/to/unable-to-connect.svg',
|
|
|
|
environmentsEndpoint: '/root/hello-prometheus/environments/35',
|
|
|
|
currentEnvironmentName: 'production',
|
2019-05-07 13:46:33 -04:00
|
|
|
customMetricsAvailable: false,
|
|
|
|
customMetricsPath: '',
|
|
|
|
validateQueryPath: '',
|
2018-10-05 12:26:16 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
export default propsData;
|
|
|
|
|
2017-08-30 12:11:19 -04:00
|
|
|
describe('Dashboard', () => {
|
|
|
|
let DashboardComponent;
|
2019-02-03 18:50:04 -05:00
|
|
|
let mock;
|
2019-05-27 18:30:36 -04:00
|
|
|
let store;
|
2019-06-06 03:30:04 -04:00
|
|
|
let component;
|
2018-03-06 12:05:48 -05:00
|
|
|
|
2017-06-20 04:50:31 -04:00
|
|
|
beforeEach(() => {
|
2018-09-13 15:33:31 -04:00
|
|
|
setFixtures(`
|
|
|
|
<div class="prometheus-graphs"></div>
|
2019-01-23 18:06:40 -05:00
|
|
|
<div class="layout-page"></div>
|
2018-09-13 15:33:31 -04:00
|
|
|
`);
|
2019-02-03 18:50:04 -05:00
|
|
|
|
2019-03-25 23:41:17 -04:00
|
|
|
window.gon = {
|
|
|
|
...window.gon,
|
|
|
|
ee: false,
|
2019-05-07 10:47:09 -04:00
|
|
|
features: {
|
|
|
|
grafanaDashboardLink: true,
|
|
|
|
},
|
2019-03-25 23:41:17 -04:00
|
|
|
};
|
|
|
|
|
2019-05-27 18:30:36 -04:00
|
|
|
store = createStore();
|
2019-02-03 18:50:04 -05:00
|
|
|
mock = new MockAdapter(axios);
|
2017-08-30 12:11:19 -04:00
|
|
|
DashboardComponent = Vue.extend(Dashboard);
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|
|
|
|
|
2019-02-03 18:50:04 -05:00
|
|
|
afterEach(() => {
|
2019-06-06 03:30:04 -04:00
|
|
|
component.$destroy();
|
2019-02-03 18:50:04 -05:00
|
|
|
mock.restore();
|
|
|
|
});
|
|
|
|
|
2017-06-20 04:50:31 -04:00
|
|
|
describe('no metrics are available yet', () => {
|
|
|
|
it('shows a getting started empty state when no metrics are present', () => {
|
2019-06-06 03:30:04 -04:00
|
|
|
component = new DashboardComponent({
|
2018-03-06 12:09:16 -05:00
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
2019-04-02 16:02:29 -04:00
|
|
|
propsData: { ...propsData, showTimeWindowDropdown: false },
|
2019-05-27 18:30:36 -04:00
|
|
|
store,
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|
|
|
|
|
2018-03-06 12:09:16 -05:00
|
|
|
expect(component.$el.querySelector('.prometheus-graphs')).toBe(null);
|
2019-05-27 18:30:36 -04:00
|
|
|
expect(component.emptyState).toEqual('gettingStarted');
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('requests information to the server', () => {
|
|
|
|
beforeEach(() => {
|
2018-03-06 12:05:48 -05:00
|
|
|
mock.onGet(mockApiEndpoint).reply(200, metricsGroupsAPIResponse);
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|
|
|
|
|
2018-06-29 15:07:34 -04:00
|
|
|
it('shows up a loading state', done => {
|
2019-06-06 03:30:04 -04:00
|
|
|
component = new DashboardComponent({
|
2018-03-06 12:09:16 -05:00
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
2019-04-02 16:02:29 -04:00
|
|
|
propsData: { ...propsData, hasMetrics: true, showTimeWindowDropdown: false },
|
2019-05-27 18:30:36 -04:00
|
|
|
store,
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|
2018-03-06 12:05:48 -05:00
|
|
|
|
2017-06-20 04:50:31 -04:00
|
|
|
Vue.nextTick(() => {
|
2019-05-27 18:30:36 -04:00
|
|
|
expect(component.emptyState).toEqual('loading');
|
2017-06-20 04:50:31 -04:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2018-03-06 12:05:48 -05:00
|
|
|
|
2018-06-29 15:07:34 -04:00
|
|
|
it('hides the legend when showLegend is false', done => {
|
2019-06-06 03:30:04 -04:00
|
|
|
component = new DashboardComponent({
|
2018-03-06 12:09:16 -05:00
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
2019-04-02 16:02:29 -04:00
|
|
|
propsData: {
|
|
|
|
...propsData,
|
|
|
|
hasMetrics: true,
|
|
|
|
showLegend: false,
|
|
|
|
showTimeWindowDropdown: false,
|
|
|
|
},
|
2019-05-27 18:30:36 -04:00
|
|
|
store,
|
2018-03-06 12:05:48 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
expect(component.showEmptyState).toEqual(false);
|
2018-03-06 12:23:09 -05:00
|
|
|
expect(component.$el.querySelector('.legend-group')).toEqual(null);
|
2018-03-06 12:05:48 -05:00
|
|
|
expect(component.$el.querySelector('.prometheus-graph-group')).toBeTruthy();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-06-29 15:07:34 -04:00
|
|
|
it('hides the group panels when showPanels is false', done => {
|
2019-06-06 03:30:04 -04:00
|
|
|
component = new DashboardComponent({
|
2018-03-06 12:09:16 -05:00
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
2019-04-02 16:02:29 -04:00
|
|
|
propsData: {
|
|
|
|
...propsData,
|
|
|
|
hasMetrics: true,
|
|
|
|
showPanels: false,
|
|
|
|
showTimeWindowDropdown: false,
|
|
|
|
},
|
2019-05-27 18:30:36 -04:00
|
|
|
store,
|
2018-03-06 12:05:48 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
expect(component.showEmptyState).toEqual(false);
|
2018-03-06 12:23:09 -05:00
|
|
|
expect(component.$el.querySelector('.prometheus-panel')).toEqual(null);
|
2018-03-06 12:05:48 -05:00
|
|
|
expect(component.$el.querySelector('.prometheus-graph-group')).toBeTruthy();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2018-06-29 15:07:34 -04:00
|
|
|
|
2019-03-20 18:36:07 -04:00
|
|
|
it('renders the environments dropdown with a number of environments', done => {
|
2019-06-06 03:30:04 -04:00
|
|
|
component = new DashboardComponent({
|
2018-06-29 15:07:34 -04:00
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
2019-04-02 16:02:29 -04:00
|
|
|
propsData: {
|
|
|
|
...propsData,
|
|
|
|
hasMetrics: true,
|
|
|
|
showPanels: false,
|
|
|
|
showTimeWindowDropdown: false,
|
|
|
|
},
|
2019-05-27 18:30:36 -04:00
|
|
|
store,
|
2018-06-29 15:07:34 -04:00
|
|
|
});
|
|
|
|
|
2019-05-27 18:30:36 -04:00
|
|
|
component.$store.commit(
|
|
|
|
`monitoringDashboard/${types.RECEIVE_ENVIRONMENTS_DATA_SUCCESS}`,
|
|
|
|
environmentData,
|
|
|
|
);
|
|
|
|
component.$store.commit(
|
|
|
|
`monitoringDashboard/${types.RECEIVE_METRICS_DATA_SUCCESS}`,
|
|
|
|
singleGroupResponse,
|
|
|
|
);
|
2018-06-29 15:07:34 -04:00
|
|
|
|
|
|
|
setTimeout(() => {
|
2019-03-20 18:36:07 -04:00
|
|
|
const dropdownMenuEnvironments = component.$el.querySelectorAll(
|
|
|
|
'.js-environments-dropdown .dropdown-item',
|
|
|
|
);
|
2018-10-09 14:03:09 -04:00
|
|
|
|
2019-05-27 18:30:36 -04:00
|
|
|
expect(dropdownMenuEnvironments.length).toEqual(component.environments.length);
|
2018-06-29 15:07:34 -04:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-03-20 18:36:07 -04:00
|
|
|
it('hides the environments dropdown list when there is no environments', done => {
|
2019-06-06 03:30:04 -04:00
|
|
|
component = new DashboardComponent({
|
2018-10-26 11:31:04 -04:00
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
2019-04-02 16:02:29 -04:00
|
|
|
propsData: {
|
|
|
|
...propsData,
|
|
|
|
hasMetrics: true,
|
|
|
|
showPanels: false,
|
|
|
|
showTimeWindowDropdown: false,
|
|
|
|
},
|
2019-05-27 18:30:36 -04:00
|
|
|
store,
|
2018-10-26 11:31:04 -04:00
|
|
|
});
|
|
|
|
|
2019-05-27 18:30:36 -04:00
|
|
|
component.$store.commit(`monitoringDashboard/${types.RECEIVE_ENVIRONMENTS_DATA_SUCCESS}`, []);
|
|
|
|
component.$store.commit(
|
|
|
|
`monitoringDashboard/${types.RECEIVE_METRICS_DATA_SUCCESS}`,
|
|
|
|
singleGroupResponse,
|
|
|
|
);
|
2018-10-26 11:31:04 -04:00
|
|
|
|
2019-05-27 18:30:36 -04:00
|
|
|
Vue.nextTick()
|
|
|
|
.then(() => {
|
|
|
|
const dropdownMenuEnvironments = component.$el.querySelectorAll(
|
|
|
|
'.js-environments-dropdown .dropdown-item',
|
|
|
|
);
|
2018-10-26 11:31:04 -04:00
|
|
|
|
2019-05-27 18:30:36 -04:00
|
|
|
expect(dropdownMenuEnvironments.length).toEqual(0);
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done.fail);
|
2018-10-26 11:31:04 -04:00
|
|
|
});
|
|
|
|
|
2019-05-07 13:46:33 -04:00
|
|
|
it('renders the environments dropdown with a single active element', done => {
|
2019-06-06 03:30:04 -04:00
|
|
|
component = new DashboardComponent({
|
2018-06-29 15:07:34 -04:00
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
2019-04-02 16:02:29 -04:00
|
|
|
propsData: {
|
|
|
|
...propsData,
|
|
|
|
hasMetrics: true,
|
|
|
|
showPanels: false,
|
|
|
|
showTimeWindowDropdown: false,
|
|
|
|
},
|
2019-05-27 18:30:36 -04:00
|
|
|
store,
|
2018-06-29 15:07:34 -04:00
|
|
|
});
|
|
|
|
|
2019-05-27 18:30:36 -04:00
|
|
|
component.$store.commit(
|
|
|
|
`monitoringDashboard/${types.RECEIVE_ENVIRONMENTS_DATA_SUCCESS}`,
|
|
|
|
environmentData,
|
|
|
|
);
|
|
|
|
component.$store.commit(
|
|
|
|
`monitoringDashboard/${types.RECEIVE_METRICS_DATA_SUCCESS}`,
|
|
|
|
singleGroupResponse,
|
|
|
|
);
|
2018-06-29 15:07:34 -04:00
|
|
|
|
2019-05-27 18:30:36 -04:00
|
|
|
Vue.nextTick()
|
|
|
|
.then(() => {
|
|
|
|
const dropdownItems = component.$el.querySelectorAll(
|
|
|
|
'.js-environments-dropdown .dropdown-item[active="true"]',
|
|
|
|
);
|
2018-10-09 14:03:09 -04:00
|
|
|
|
2019-05-27 18:30:36 -04:00
|
|
|
expect(dropdownItems.length).toEqual(1);
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done.fail);
|
2019-03-25 23:41:17 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('hides the dropdown', done => {
|
2019-06-06 03:30:04 -04:00
|
|
|
component = new DashboardComponent({
|
2019-03-25 23:41:17 -04:00
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
|
|
|
propsData: {
|
|
|
|
...propsData,
|
|
|
|
hasMetrics: true,
|
|
|
|
showPanels: false,
|
|
|
|
environmentsEndpoint: '',
|
2019-04-02 16:02:29 -04:00
|
|
|
showTimeWindowDropdown: false,
|
2019-03-25 23:41:17 -04:00
|
|
|
},
|
2019-05-27 18:30:36 -04:00
|
|
|
store,
|
2019-03-25 23:41:17 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
const dropdownIsActiveElement = component.$el.querySelectorAll('.environments');
|
|
|
|
|
|
|
|
expect(dropdownIsActiveElement.length).toEqual(0);
|
2018-06-29 15:07:34 -04:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2019-03-12 14:55:43 -04:00
|
|
|
|
2019-04-02 16:02:29 -04:00
|
|
|
it('does not show the time window dropdown when the feature flag is not set', done => {
|
2019-06-06 03:30:04 -04:00
|
|
|
component = new DashboardComponent({
|
2019-04-01 14:38:26 -04:00
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
2019-04-02 16:02:29 -04:00
|
|
|
propsData: {
|
|
|
|
...propsData,
|
|
|
|
hasMetrics: true,
|
|
|
|
showPanels: false,
|
|
|
|
showTimeWindowDropdown: false,
|
|
|
|
},
|
2019-05-27 18:30:36 -04:00
|
|
|
store,
|
2019-04-01 14:38:26 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
const timeWindowDropdown = component.$el.querySelector('.js-time-window-dropdown');
|
|
|
|
|
|
|
|
expect(timeWindowDropdown).toBeNull();
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-04-03 18:10:39 -04:00
|
|
|
it('renders the time window dropdown with a set of options', done => {
|
2019-06-06 03:30:04 -04:00
|
|
|
component = new DashboardComponent({
|
2019-03-12 14:55:43 -04:00
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
2019-04-02 16:02:29 -04:00
|
|
|
propsData: {
|
|
|
|
...propsData,
|
|
|
|
hasMetrics: true,
|
|
|
|
showPanels: false,
|
|
|
|
showTimeWindowDropdown: true,
|
|
|
|
},
|
2019-05-27 18:30:36 -04:00
|
|
|
store,
|
2019-03-12 14:55:43 -04:00
|
|
|
});
|
|
|
|
const numberOfTimeWindows = Object.keys(timeWindows).length;
|
|
|
|
|
|
|
|
setTimeout(() => {
|
2019-03-20 15:52:24 -04:00
|
|
|
const timeWindowDropdown = component.$el.querySelector('.js-time-window-dropdown');
|
2019-03-12 14:55:43 -04:00
|
|
|
const timeWindowDropdownEls = component.$el.querySelectorAll(
|
2019-03-20 15:52:24 -04:00
|
|
|
'.js-time-window-dropdown .dropdown-item',
|
2019-03-12 14:55:43 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
expect(timeWindowDropdown).not.toBeNull();
|
|
|
|
expect(timeWindowDropdownEls.length).toEqual(numberOfTimeWindows);
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2019-04-10 13:33:30 -04:00
|
|
|
|
2019-06-06 03:30:04 -04:00
|
|
|
it('fetches the metrics data with proper time window', done => {
|
|
|
|
component = new DashboardComponent({
|
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
|
|
|
propsData: {
|
|
|
|
...propsData,
|
|
|
|
hasMetrics: true,
|
|
|
|
showPanels: false,
|
|
|
|
showTimeWindowDropdown: true,
|
|
|
|
},
|
|
|
|
store,
|
|
|
|
});
|
|
|
|
|
|
|
|
spyOn(component.$store, 'dispatch').and.stub();
|
|
|
|
const getTimeDiffSpy = spyOnDependency(Dashboard, 'getTimeDiff');
|
|
|
|
|
|
|
|
component.$store.commit(
|
|
|
|
`monitoringDashboard/${types.SET_ENVIRONMENTS_ENDPOINT}`,
|
|
|
|
'/environments',
|
|
|
|
);
|
|
|
|
component.$store.commit(
|
|
|
|
`monitoringDashboard/${types.RECEIVE_ENVIRONMENTS_DATA_SUCCESS}`,
|
|
|
|
environmentData,
|
|
|
|
);
|
|
|
|
|
|
|
|
component.$mount();
|
|
|
|
|
|
|
|
Vue.nextTick()
|
|
|
|
.then(() => {
|
|
|
|
expect(component.$store.dispatch).toHaveBeenCalled();
|
|
|
|
expect(getTimeDiffSpy).toHaveBeenCalledWith(component.selectedTimeWindow);
|
|
|
|
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done.fail);
|
|
|
|
});
|
|
|
|
|
2019-04-10 13:33:30 -04:00
|
|
|
it('shows a specific time window selected from the url params', done => {
|
|
|
|
spyOnDependency(Dashboard, 'getParameterValues').and.returnValue(['thirtyMinutes']);
|
|
|
|
|
2019-06-06 03:30:04 -04:00
|
|
|
component = new DashboardComponent({
|
2019-04-10 13:33:30 -04:00
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
|
|
|
propsData: { ...propsData, hasMetrics: true, showTimeWindowDropdown: true },
|
2019-05-27 18:30:36 -04:00
|
|
|
store,
|
2019-04-10 13:33:30 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
const selectedTimeWindow = component.$el.querySelector(
|
|
|
|
'.js-time-window-dropdown [active="true"]',
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(selectedTimeWindow.textContent.trim()).toEqual('30 minutes');
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('defaults to the eight hours time window for non valid url parameters', done => {
|
|
|
|
spyOnDependency(Dashboard, 'getParameterValues').and.returnValue([
|
|
|
|
'<script>alert("XSS")</script>',
|
|
|
|
]);
|
|
|
|
|
2019-06-06 03:30:04 -04:00
|
|
|
component = new DashboardComponent({
|
2019-04-10 13:33:30 -04:00
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
|
|
|
propsData: { ...propsData, hasMetrics: true, showTimeWindowDropdown: true },
|
2019-05-27 18:30:36 -04:00
|
|
|
store,
|
2019-04-10 13:33:30 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
expect(component.selectedTimeWindowKey).toEqual(timeWindowsKeyNames.eightHours);
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|
2018-09-13 15:33:31 -04:00
|
|
|
|
|
|
|
describe('when the window resizes', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
mock.onGet(mockApiEndpoint).reply(200, metricsGroupsAPIResponse);
|
|
|
|
jasmine.clock().install();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
jasmine.clock().uninstall();
|
|
|
|
});
|
|
|
|
|
2019-01-23 18:06:40 -05:00
|
|
|
it('sets elWidth to page width when the sidebar is resized', done => {
|
2019-06-06 03:30:04 -04:00
|
|
|
component = new DashboardComponent({
|
2018-09-13 15:33:31 -04:00
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
2019-04-02 16:02:29 -04:00
|
|
|
propsData: {
|
|
|
|
...propsData,
|
|
|
|
hasMetrics: true,
|
|
|
|
showPanels: false,
|
|
|
|
showTimeWindowDropdown: false,
|
|
|
|
},
|
2019-05-27 18:30:36 -04:00
|
|
|
store,
|
2018-09-13 15:33:31 -04:00
|
|
|
});
|
|
|
|
|
2019-01-23 18:06:40 -05:00
|
|
|
expect(component.elWidth).toEqual(0);
|
2018-09-13 15:33:31 -04:00
|
|
|
|
2019-01-23 18:06:40 -05:00
|
|
|
const pageLayoutEl = document.querySelector('.layout-page');
|
|
|
|
pageLayoutEl.classList.add('page-with-icon-sidebar');
|
2018-09-13 15:33:31 -04:00
|
|
|
|
|
|
|
Vue.nextTick()
|
|
|
|
.then(() => {
|
|
|
|
jasmine.clock().tick(1000);
|
|
|
|
return Vue.nextTick();
|
|
|
|
})
|
|
|
|
.then(() => {
|
2019-01-23 18:06:40 -05:00
|
|
|
expect(component.elWidth).toEqual(pageLayoutEl.clientWidth);
|
2018-09-13 15:33:31 -04:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done.fail);
|
|
|
|
});
|
|
|
|
});
|
2019-05-07 10:47:09 -04:00
|
|
|
|
|
|
|
describe('external dashboard link', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
mock.onGet(mockApiEndpoint).reply(200, metricsGroupsAPIResponse);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with feature flag enabled', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
component = new DashboardComponent({
|
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
|
|
|
propsData: {
|
|
|
|
...propsData,
|
|
|
|
hasMetrics: true,
|
|
|
|
showPanels: false,
|
|
|
|
showTimeWindowDropdown: false,
|
2019-06-04 13:55:52 -04:00
|
|
|
externalDashboardUrl: '/mockUrl',
|
2019-05-07 10:47:09 -04:00
|
|
|
},
|
2019-05-27 18:30:36 -04:00
|
|
|
store,
|
2019-05-07 10:47:09 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows the link', done => {
|
|
|
|
setTimeout(() => {
|
|
|
|
expect(component.$el.querySelector('.js-external-dashboard-link').innerText).toContain(
|
|
|
|
'View full dashboard',
|
|
|
|
);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('without feature flage enabled', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
window.gon.features.grafanaDashboardLink = false;
|
|
|
|
component = new DashboardComponent({
|
|
|
|
el: document.querySelector('.prometheus-graphs'),
|
|
|
|
propsData: {
|
|
|
|
...propsData,
|
|
|
|
hasMetrics: true,
|
|
|
|
showPanels: false,
|
|
|
|
showTimeWindowDropdown: false,
|
2019-06-04 13:55:52 -04:00
|
|
|
externalDashboardUrl: '',
|
2019-05-07 10:47:09 -04:00
|
|
|
},
|
2019-05-27 18:30:36 -04:00
|
|
|
store,
|
2019-05-07 10:47:09 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not show the link', done => {
|
|
|
|
setTimeout(() => {
|
|
|
|
expect(component.$el.querySelector('.js-external-dashboard-link')).toBe(null);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|