diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-10 18:09:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-10 18:09:50 +0300 |
commit | de2fb5b82c92c90f90ed67ced45143c04e934fb8 (patch) | |
tree | ff8e5e642580de7bb596d90dd0e7f739f44ca540 /spec/frontend | |
parent | c6a33b298229f9e04933be43d6176c476ef03012 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
3 files changed, 206 insertions, 0 deletions
diff --git a/spec/frontend/jira_import/components/jira_import_form_spec.js b/spec/frontend/jira_import/components/jira_import_form_spec.js new file mode 100644 index 00000000000..315ccccd991 --- /dev/null +++ b/spec/frontend/jira_import/components/jira_import_form_spec.js @@ -0,0 +1,62 @@ +import { GlAvatar, GlNewButton, GlFormSelect, GlLabel } from '@gitlab/ui'; +import { shallowMount } from '@vue/test-utils'; +import JiraImportForm from '~/jira_import/components/jira_import_form.vue'; + +describe('JiraImportForm', () => { + let wrapper; + + beforeEach(() => { + wrapper = shallowMount(JiraImportForm); + }); + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + it('shows a dropdown to choose the Jira project to import from', () => { + expect(wrapper.find(GlFormSelect).exists()).toBe(true); + }); + + it('shows a label which will be applied to imported Jira projects', () => { + expect(wrapper.find(GlLabel).attributes('title')).toBe('jira-import::KEY-1'); + }); + + it('shows information to the user', () => { + expect(wrapper.find('p').text()).toBe( + "For each Jira issue successfully imported, we'll create a new GitLab issue with the following data:", + ); + }); + + it('shows jira.issue.summary for the Title', () => { + expect(wrapper.find('[id="jira-project-title"]').text()).toBe('jira.issue.summary'); + }); + + it('shows an avatar for the Reporter', () => { + expect(wrapper.find(GlAvatar).exists()).toBe(true); + }); + + it('shows jira.issue.description.content for the Description', () => { + expect(wrapper.find('[id="jira-project-description"]').text()).toBe( + 'jira.issue.description.content', + ); + }); + + it('shows a Next button', () => { + const nextButton = wrapper + .findAll(GlNewButton) + .at(0) + .text(); + + expect(nextButton).toBe('Next'); + }); + + it('shows a Cancel button', () => { + const cancelButton = wrapper + .findAll(GlNewButton) + .at(1) + .text(); + + expect(cancelButton).toBe('Cancel'); + }); +}); diff --git a/spec/frontend/prometheus_metrics/custom_metrics_spec.js b/spec/frontend/prometheus_metrics/custom_metrics_spec.js new file mode 100644 index 00000000000..3396b3694c0 --- /dev/null +++ b/spec/frontend/prometheus_metrics/custom_metrics_spec.js @@ -0,0 +1,122 @@ +import MockAdapter from 'axios-mock-adapter'; +import PrometheusMetrics from '~/prometheus_metrics/custom_metrics'; +import axios from '~/lib/utils/axios_utils'; +import PANEL_STATE from '~/prometheus_metrics/constants'; +import metrics from './mock_data'; + +describe('PrometheusMetrics', () => { + const FIXTURE = 'services/prometheus/prometheus_service.html'; + const customMetricsEndpoint = + 'http://test.host/frontend-fixtures/services-project/prometheus/metrics'; + let mock; + preloadFixtures(FIXTURE); + + beforeEach(() => { + mock = new MockAdapter(axios); + mock.onGet(customMetricsEndpoint).reply(200, { + metrics, + }); + loadFixtures(FIXTURE); + }); + + afterEach(() => { + mock.restore(); + }); + + describe('Custom Metrics', () => { + let prometheusMetrics; + + beforeEach(() => { + prometheusMetrics = new PrometheusMetrics('.js-prometheus-metrics-monitoring'); + }); + + it('should initialize wrapper element refs on the class object', () => { + expect(prometheusMetrics.$wrapperCustomMetrics).not.toBeNull(); + expect(prometheusMetrics.$monitoredCustomMetricsPanel).not.toBeNull(); + expect(prometheusMetrics.$monitoredCustomMetricsCount).not.toBeNull(); + expect(prometheusMetrics.$monitoredCustomMetricsLoading).not.toBeNull(); + expect(prometheusMetrics.$monitoredCustomMetricsEmpty).not.toBeNull(); + expect(prometheusMetrics.$monitoredCustomMetricsList).not.toBeNull(); + expect(prometheusMetrics.$newCustomMetricButton).not.toBeNull(); + expect(prometheusMetrics.$flashCustomMetricsContainer).not.toBeNull(); + }); + + it('should contain api endpoints', () => { + expect(prometheusMetrics.activeCustomMetricsEndpoint).toEqual(customMetricsEndpoint); + }); + + it('should show loading state when called with `loading`', () => { + prometheusMetrics.showMonitoringCustomMetricsPanelState(PANEL_STATE.LOADING); + + expect(prometheusMetrics.$monitoredCustomMetricsLoading.hasClass('hidden')).toEqual(false); + expect(prometheusMetrics.$monitoredCustomMetricsEmpty.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredCustomMetricsList.hasClass('hidden')).toBeTruthy(); + expect( + prometheusMetrics.$monitoredCustomMetricsNoIntegrationText.hasClass('hidden'), + ).toBeTruthy(); + + expect(prometheusMetrics.$newCustomMetricButton.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$newCustomMetricText.hasClass('hidden')).toBeTruthy(); + }); + + it('should show metrics list when called with `list`', () => { + prometheusMetrics.showMonitoringCustomMetricsPanelState(PANEL_STATE.LIST); + + expect(prometheusMetrics.$monitoredCustomMetricsLoading.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredCustomMetricsEmpty.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredCustomMetricsList.hasClass('hidden')).toEqual(false); + expect( + prometheusMetrics.$monitoredCustomMetricsNoIntegrationText.hasClass('hidden'), + ).toBeTruthy(); + + expect(prometheusMetrics.$newCustomMetricButton.hasClass('hidden')).toEqual(false); + expect(prometheusMetrics.$newCustomMetricText.hasClass('hidden')).toBeTruthy(); + }); + + it('should show empty state when called with `empty`', () => { + prometheusMetrics.showMonitoringCustomMetricsPanelState(PANEL_STATE.EMPTY); + + expect(prometheusMetrics.$monitoredCustomMetricsLoading.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredCustomMetricsEmpty.hasClass('hidden')).toEqual(false); + expect(prometheusMetrics.$monitoredCustomMetricsList.hasClass('hidden')).toBeTruthy(); + expect( + prometheusMetrics.$monitoredCustomMetricsNoIntegrationText.hasClass('hidden'), + ).toBeTruthy(); + + expect(prometheusMetrics.$newCustomMetricButton.hasClass('hidden')).toEqual(false); + expect(prometheusMetrics.$newCustomMetricText.hasClass('hidden')).toEqual(false); + }); + + it('should show monitored metrics list', () => { + prometheusMetrics.customMetrics = metrics; + prometheusMetrics.populateCustomMetrics(); + + const $metricsListLi = prometheusMetrics.$monitoredCustomMetricsList.find('li'); + + expect(prometheusMetrics.$monitoredCustomMetricsLoading.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredCustomMetricsList.hasClass('hidden')).toEqual(false); + expect( + prometheusMetrics.$monitoredCustomMetricsNoIntegrationText.hasClass('hidden'), + ).toBeTruthy(); + + expect(prometheusMetrics.$newCustomMetricButton.hasClass('hidden')).toEqual(false); + expect(prometheusMetrics.$newCustomMetricText.hasClass('hidden')).toBeTruthy(); + + expect($metricsListLi.length).toEqual(metrics.length); + }); + + it('should show the NO-INTEGRATION empty state', () => { + prometheusMetrics.setNoIntegrationActiveState(); + + expect(prometheusMetrics.$monitoredCustomMetricsEmpty.hasClass('hidden')).toEqual(false); + expect(prometheusMetrics.$monitoredCustomMetricsNoIntegrationText.hasClass('hidden')).toEqual( + false, + ); + + expect(prometheusMetrics.$monitoredCustomMetricsLoading.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredCustomMetricsList.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$newCustomMetricButton.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$newCustomMetricText.hasClass('hidden')).toBeTruthy(); + }); + }); +}); diff --git a/spec/frontend/prometheus_metrics/mock_data.js b/spec/frontend/prometheus_metrics/mock_data.js new file mode 100644 index 00000000000..d5532537302 --- /dev/null +++ b/spec/frontend/prometheus_metrics/mock_data.js @@ -0,0 +1,22 @@ +const metrics = [ + { + edit_path: '/root/prometheus-test/prometheus/metrics/3/edit', + id: 3, + title: 'Requests', + group: 'Business', + }, + { + edit_path: '/root/prometheus-test/prometheus/metrics/2/edit', + id: 2, + title: 'Sales by the hour', + group: 'Business', + }, + { + edit_path: '/root/prometheus-test/prometheus/metrics/1/edit', + id: 1, + title: 'Requests', + group: 'Business', + }, +]; + +export default metrics; |