summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2018-03-06 11:05:48 -0600
committerMike Greiling <mike@pixelcog.com>2018-03-06 11:06:10 -0600
commitbae88da83c584046ed59e8c7ac4cb209cfd4b15f (patch)
treee33f33a420aa2107187729953eb3762bd660e9f0
parented993603de2535f144b37c637b50e8925db075ce (diff)
downloadgitlab-ce-bae88da83c584046ed59e8c7ac4cb209cfd4b15f.tar.gz
add new tests for metrics dashboard changes
-rw-r--r--spec/javascripts/monitoring/dashboard_spec.js43
1 files changed, 34 insertions, 9 deletions
diff --git a/spec/javascripts/monitoring/dashboard_spec.js b/spec/javascripts/monitoring/dashboard_spec.js
index c5733ef95cf..4c5a10393c6 100644
--- a/spec/javascripts/monitoring/dashboard_spec.js
+++ b/spec/javascripts/monitoring/dashboard_spec.js
@@ -7,7 +7,7 @@ import { metricsGroupsAPIResponse, mockApiEndpoint } from './mock_data';
describe('Dashboard', () => {
const fixtureName = 'environments/metrics/metrics.html.raw';
let DashboardComponent;
- let component;
+
const propsData = {
hasMetrics: false,
documentationPath: '/path/to/docs',
@@ -16,7 +16,7 @@ describe('Dashboard', () => {
tagsPath: '/path/to/tags',
projectPath: '/path/to/project',
metricsEndpoint: mockApiEndpoint,
- deploymentEndpoint: '/endpoint/deployments',
+ deploymentEndpoint: null,
emptyGettingStartedSvgPath: '/path/to/getting-started.svg',
emptyLoadingSvgPath: '/path/to/loading.svg',
emptyUnableToConnectSvgPath: '/path/to/unable-to-connect.svg',
@@ -31,12 +31,11 @@ describe('Dashboard', () => {
describe('no metrics are available yet', () => {
it('shows a getting started empty state when no metrics are present', () => {
- component = new DashboardComponent({
+ const component = new DashboardComponent({
el: document.querySelector('#prometheus-graphs'),
propsData,
});
- component.$mount();
expect(component.$el.querySelector('#prometheus-graphs')).toBe(null);
expect(component.state).toEqual('gettingStarted');
});
@@ -46,9 +45,7 @@ describe('Dashboard', () => {
let mock;
beforeEach(() => {
mock = new MockAdapter(axios);
- mock.onGet(mockApiEndpoint).reply(200, {
- metricsGroupsAPIResponse,
- });
+ mock.onGet(mockApiEndpoint).reply(200, metricsGroupsAPIResponse);
});
afterEach(() => {
@@ -56,15 +53,43 @@ describe('Dashboard', () => {
});
it('shows up a loading state', (done) => {
- component = new DashboardComponent({
+ const component = new DashboardComponent({
el: document.querySelector('#prometheus-graphs'),
propsData: { ...propsData, hasMetrics: true },
});
- component.$mount();
+
Vue.nextTick(() => {
expect(component.state).toEqual('loading');
done();
});
});
+
+ it('hides the legend when showLegend is false', (done) => {
+ const component = new DashboardComponent({
+ el: document.querySelector('#prometheus-graphs'),
+ propsData: { ...propsData, hasMetrics: true, showLegend: false },
+ });
+
+ setTimeout(() => {
+ expect(component.showEmptyState).toEqual(false);
+ expect(component.$el.querySelector('.legend-group')).toBeFalsy();
+ expect(component.$el.querySelector('.prometheus-graph-group')).toBeTruthy();
+ done();
+ });
+ });
+
+ it('hides the group panels when showPanels is false', (done) => {
+ const component = new DashboardComponent({
+ el: document.querySelector('#prometheus-graphs'),
+ propsData: { ...propsData, hasMetrics: true, showPanels: false },
+ });
+
+ setTimeout(() => {
+ expect(component.showEmptyState).toEqual(false);
+ expect(component.$el.querySelector('.prometheus-panel')).toBeFalsy();
+ expect(component.$el.querySelector('.prometheus-graph-group')).toBeTruthy();
+ done();
+ });
+ });
});
});