summaryrefslogtreecommitdiff
path: root/spec/frontend/operation_settings
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-12 03:08:22 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-12 03:08:22 +0000
commit1b5db0f4a6ee2fc490aec0b8bed7d78d4ecc7996 (patch)
tree07050be1d311b1ea1f17e252d516d3d805f3b3aa /spec/frontend/operation_settings
parentee936c190ec1f3e691650ce20ec89b076b3a6ca5 (diff)
downloadgitlab-ce-1b5db0f4a6ee2fc490aec0b8bed7d78d4ecc7996.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/operation_settings')
-rw-r--r--spec/frontend/operation_settings/components/metrics_settings_spec.js91
-rw-r--r--spec/frontend/operation_settings/store/mutations_spec.js10
2 files changed, 78 insertions, 23 deletions
diff --git a/spec/frontend/operation_settings/components/metrics_settings_spec.js b/spec/frontend/operation_settings/components/metrics_settings_spec.js
index 7b7cf841fb7..a8e5b927b15 100644
--- a/spec/frontend/operation_settings/components/metrics_settings_spec.js
+++ b/spec/frontend/operation_settings/components/metrics_settings_spec.js
@@ -1,8 +1,11 @@
import { mount, shallowMount } from '@vue/test-utils';
-import { GlDeprecatedButton, GlLink, GlFormGroup, GlFormInput } from '@gitlab/ui';
+import { GlDeprecatedButton, GlLink, GlFormGroup, GlFormInput, GlFormSelect } from '@gitlab/ui';
import { TEST_HOST } from 'helpers/test_constants';
import MetricsSettings from '~/operation_settings/components/metrics_settings.vue';
+
import ExternalDashboard from '~/operation_settings/components/form_group/external_dashboard.vue';
+import DashboardTimezone from '~/operation_settings/components/form_group/dashboard_timezone.vue';
+import { timezones } from '~/monitoring/format_date';
import store from '~/operation_settings/store';
import axios from '~/lib/utils/axios_utils';
import { refreshCurrentPage } from '~/lib/utils/url_utility';
@@ -18,6 +21,8 @@ describe('operation settings external dashboard component', () => {
const helpPage = `${TEST_HOST}/help/metrics/page/path`;
const externalDashboardUrl = `http://mock-external-domain.com/external/dashboard/url`;
const externalDashboardHelpPage = `${TEST_HOST}/help/external/page/path`;
+ const dashboardTimezoneSetting = timezones.LOCAL;
+ const dashboardTimezoneHelpPage = `${TEST_HOST}/help/timezone/page/path`;
const mountComponent = (shallow = true) => {
const config = [
@@ -28,9 +33,12 @@ describe('operation settings external dashboard component', () => {
helpPage,
externalDashboardUrl,
externalDashboardHelpPage,
+ dashboardTimezoneSetting,
+ dashboardTimezoneHelpPage,
}),
stubs: {
ExternalDashboard,
+ DashboardTimezone,
},
},
];
@@ -84,38 +92,74 @@ describe('operation settings external dashboard component', () => {
});
describe('form', () => {
- describe('input label', () => {
- let formGroup;
-
- beforeEach(() => {
- mountComponent(false);
- formGroup = wrapper.find(ExternalDashboard).find(GlFormGroup);
+ describe('dashboard timezone', () => {
+ describe('field label', () => {
+ let formGroup;
+
+ beforeEach(() => {
+ mountComponent(false);
+ formGroup = wrapper.find(DashboardTimezone).find(GlFormGroup);
+ });
+
+ it('uses label text', () => {
+ expect(formGroup.find('label').text()).toBe('Dashboard timezone');
+ });
+
+ it('uses description text', () => {
+ const description = formGroup.find('small');
+ expect(description.text()).not.toBeFalsy();
+ });
});
- it('uses label text', () => {
- expect(formGroup.find('label').text()).toBe('External dashboard URL');
- });
+ describe('select field', () => {
+ let select;
+
+ beforeEach(() => {
+ mountComponent();
+ select = wrapper.find(DashboardTimezone).find(GlFormSelect);
+ });
- it('uses description text', () => {
- const description = formGroup.find('small');
- expect(description.find('a').attributes('href')).toBe(externalDashboardHelpPage);
+ it('defaults to externalDashboardUrl', () => {
+ expect(select.attributes('value')).toBe(dashboardTimezoneSetting);
+ });
});
});
- describe('input field', () => {
- let input;
+ describe('external dashboard', () => {
+ describe('input label', () => {
+ let formGroup;
- beforeEach(() => {
- mountComponent();
- input = wrapper.find(GlFormInput);
- });
+ beforeEach(() => {
+ mountComponent(false);
+ formGroup = wrapper.find(ExternalDashboard).find(GlFormGroup);
+ });
+
+ it('uses label text', () => {
+ expect(formGroup.find('label').text()).toBe('External dashboard URL');
+ });
- it('defaults to externalDashboardUrl', () => {
- expect(input.attributes().value).toBe(externalDashboardUrl);
+ it('uses description text', () => {
+ const description = formGroup.find('small');
+ expect(description.find('a').attributes('href')).toBe(externalDashboardHelpPage);
+ });
});
- it('uses a placeholder', () => {
- expect(input.attributes().placeholder).toBe('https://my-org.gitlab.io/my-dashboards');
+ describe('input field', () => {
+ let input;
+
+ beforeEach(() => {
+ mountComponent();
+ input = wrapper.find(ExternalDashboard).find(GlFormInput);
+ });
+
+ it('defaults to externalDashboardUrl', () => {
+ expect(input.attributes().value).toBeTruthy();
+ expect(input.attributes().value).toBe(externalDashboardUrl);
+ });
+
+ it('uses a placeholder', () => {
+ expect(input.attributes().placeholder).toBe('https://my-org.gitlab.io/my-dashboards');
+ });
});
});
@@ -128,6 +172,7 @@ describe('operation settings external dashboard component', () => {
{
project: {
metrics_setting_attributes: {
+ dashboard_timezone: dashboardTimezoneSetting,
external_dashboard_url: externalDashboardUrl,
},
},
diff --git a/spec/frontend/operation_settings/store/mutations_spec.js b/spec/frontend/operation_settings/store/mutations_spec.js
index 670ba95ab03..88eb66095ad 100644
--- a/spec/frontend/operation_settings/store/mutations_spec.js
+++ b/spec/frontend/operation_settings/store/mutations_spec.js
@@ -1,5 +1,6 @@
import mutations from '~/operation_settings/store/mutations';
import createState from '~/operation_settings/store/state';
+import { timezones } from '~/monitoring/format_date';
describe('operation settings mutations', () => {
let localState;
@@ -16,4 +17,13 @@ describe('operation settings mutations', () => {
expect(localState.externalDashboard.url).toBe(mockUrl);
});
});
+
+ describe('SET_DASHBOARD_TIMEZONE', () => {
+ it('sets dashboardTimezoneSetting', () => {
+ mutations.SET_DASHBOARD_TIMEZONE(localState, timezones.LOCAL);
+
+ expect(localState.dashboardTimezone.selected).not.toBeUndefined();
+ expect(localState.dashboardTimezone.selected).toBe(timezones.LOCAL);
+ });
+ });
});