diff options
author | Fatih Acet <acetfatih@gmail.com> | 2019-05-03 21:54:05 +0000 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2019-05-03 21:54:05 +0000 |
commit | 08d1cc5c2a30868979a0d3ffc6327020d8e539e4 (patch) | |
tree | 01e37bc56fb50fa9ba5f22ce684029b1414b40b0 /spec/javascripts | |
parent | 96aa083854f8204a80851017ba547ea3b732e273 (diff) | |
parent | 3e3bead22bddc65963319e38926bae4c2c3a0eab (diff) | |
download | gitlab-ce-08d1cc5c2a30868979a0d3ffc6327020d8e539e4.tar.gz |
Merge branch '59365-include-time-window-parameters-in-the-url-query-string' into 'master'
Resolve "Include time window parameters in the URL query string"
Closes #59365
See merge request gitlab-org/gitlab-ce!27230
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/monitoring/dashboard_spec.js | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/spec/javascripts/monitoring/dashboard_spec.js b/spec/javascripts/monitoring/dashboard_spec.js index 16dc0084a10..5c28840d3a4 100644 --- a/spec/javascripts/monitoring/dashboard_spec.js +++ b/spec/javascripts/monitoring/dashboard_spec.js @@ -1,7 +1,7 @@ import Vue from 'vue'; import MockAdapter from 'axios-mock-adapter'; import Dashboard from '~/monitoring/components/dashboard.vue'; -import { timeWindows } from '~/monitoring/constants'; +import { timeWindows, timeWindowsKeyNames } from '~/monitoring/constants'; import axios from '~/lib/utils/axios_utils'; import { metricsGroupsAPIResponse, mockApiEndpoint, environmentData } from './mock_data'; @@ -248,6 +248,41 @@ describe('Dashboard', () => { done(); }); }); + + it('shows a specific time window selected from the url params', done => { + spyOnDependency(Dashboard, 'getParameterValues').and.returnValue(['thirtyMinutes']); + + const component = new DashboardComponent({ + el: document.querySelector('.prometheus-graphs'), + propsData: { ...propsData, hasMetrics: true, showTimeWindowDropdown: true }, + }); + + 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>', + ]); + + const component = new DashboardComponent({ + el: document.querySelector('.prometheus-graphs'), + propsData: { ...propsData, hasMetrics: true, showTimeWindowDropdown: true }, + }); + + Vue.nextTick(() => { + expect(component.selectedTimeWindowKey).toEqual(timeWindowsKeyNames.eightHours); + + done(); + }); + }); }); describe('when the window resizes', () => { |