diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-14 15:09:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-14 15:09:26 +0300 |
commit | 2e4c4055181eec9186458dd5dd3219c937032ec7 (patch) | |
tree | eee59e7124ffcf093f1b53369436c69cfe4d9cc5 /spec/frontend | |
parent | 97f0ae7454597105a27df65ffb772949d9d4f3cb (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
6 files changed, 61 insertions, 12 deletions
diff --git a/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap b/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap index 88710b23bc9..d968b042ff1 100644 --- a/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap +++ b/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap @@ -92,7 +92,7 @@ exports[`Dashboard template matches the default snapshot 1`] = ` > <gl-deprecated-button-stub size="md" - title="Reload this page" + title="Refresh dashboard" variant="default" > <icon-stub diff --git a/spec/frontend/monitoring/store/actions_spec.js b/spec/frontend/monitoring/store/actions_spec.js index b37c10791bf..d6faec29b65 100644 --- a/spec/frontend/monitoring/store/actions_spec.js +++ b/spec/frontend/monitoring/store/actions_spec.js @@ -15,7 +15,7 @@ import { receiveMetricsDashboardSuccess, fetchDeploymentsData, fetchEnvironmentsData, - fetchPrometheusMetrics, + fetchDashboardData, fetchPrometheusMetric, setInitialState, filterEnvironments, @@ -375,7 +375,7 @@ describe('Monitoring store actions', () => { metricsDashboardResponse.dashboard, ); - expect(dispatch).toHaveBeenCalledWith('fetchPrometheusMetrics'); + expect(dispatch).toHaveBeenCalledWith('fetchDashboardData'); }); it('sets the dashboards loaded from the repository', () => { const params = {}; @@ -395,7 +395,7 @@ describe('Monitoring store actions', () => { expect(commit).toHaveBeenCalledWith(types.SET_ALL_DASHBOARDS, dashboardGitResponse); }); }); - describe('fetchPrometheusMetrics', () => { + describe('fetchDashboardData', () => { let commit; let dispatch; let state; @@ -413,7 +413,7 @@ describe('Monitoring store actions', () => { const getters = { metricsWithData: () => [], }; - fetchPrometheusMetrics({ state, commit, dispatch, getters }) + fetchDashboardData({ state, commit, dispatch, getters }) .then(() => { expect(Tracking.event).toHaveBeenCalledWith( document.body.dataset.page, @@ -442,7 +442,7 @@ describe('Monitoring store actions', () => { metricsWithData: () => [metric.id], }; - fetchPrometheusMetrics({ state, commit, dispatch, getters }) + fetchDashboardData({ state, commit, dispatch, getters }) .then(() => { expect(dispatch).toHaveBeenCalledWith('fetchPrometheusMetric', { metric, @@ -478,7 +478,7 @@ describe('Monitoring store actions', () => { dispatch.mockRejectedValueOnce(new Error('Error fetching this metric')); dispatch.mockResolvedValue(); - fetchPrometheusMetrics({ state, commit, dispatch }) + fetchDashboardData({ state, commit, dispatch }) .then(() => { expect(dispatch).toHaveBeenCalledTimes(10); // one per metric plus 1 for deployments expect(dispatch).toHaveBeenCalledWith('fetchDeploymentsData'); diff --git a/spec/frontend/monitoring/store/mutations_spec.js b/spec/frontend/monitoring/store/mutations_spec.js index 21a27a443af..34d224e13b0 100644 --- a/spec/frontend/monitoring/store/mutations_spec.js +++ b/spec/frontend/monitoring/store/mutations_spec.js @@ -202,15 +202,12 @@ describe('Monitoring mutations', () => { mutations[types.REQUEST_METRIC_RESULT](stateCopy, { metricId, - result, }); expect(stateCopy.showEmptyState).toBe(true); expect(getMetric()).toEqual( expect.objectContaining({ loading: true, - result: null, - state: metricStates.LOADING, }), ); }); @@ -232,7 +229,7 @@ describe('Monitoring mutations', () => { }); it('adds results to the store', () => { - expect(getMetric().result).toBe(undefined); + expect(getMetric().result).toBe(null); mutations[types.RECEIVE_METRIC_RESULT_SUCCESS](stateCopy, { metricId, diff --git a/spec/frontend/monitoring/store/utils_spec.js b/spec/frontend/monitoring/store/utils_spec.js index fcc5614850b..f46409e8e32 100644 --- a/spec/frontend/monitoring/store/utils_spec.js +++ b/spec/frontend/monitoring/store/utils_spec.js @@ -5,6 +5,7 @@ import { removeLeadingSlash, mapToDashboardViewModel, } from '~/monitoring/stores/utils'; +import { NOT_IN_DB_PREFIX } from '~/monitoring/constants'; const projectPath = 'gitlab-org/gitlab-test'; @@ -256,6 +257,9 @@ describe('mapToDashboardViewModel', () => { expect(getMappedMetric(dashboard)).toEqual({ label: expect.any(String), metricId: expect.any(String), + loading: false, + result: null, + state: null, }); }); @@ -307,7 +311,7 @@ describe('mapToDashboardViewModel', () => { describe('uniqMetricsId', () => { [ - { input: { id: 1 }, expected: 'NO_DB_1' }, + { input: { id: 1 }, expected: `${NOT_IN_DB_PREFIX}_1` }, { input: { metric_id: 2 }, expected: '2_undefined' }, { input: { metric_id: 2, id: 21 }, expected: '2_21' }, { input: { metric_id: 22, id: 1 }, expected: '22_1' }, diff --git a/spec/frontend/vue_shared/components/form/__snapshots__/form_footer_actions_spec.js.snap b/spec/frontend/vue_shared/components/form/__snapshots__/form_footer_actions_spec.js.snap new file mode 100644 index 00000000000..2189d6ac3cc --- /dev/null +++ b/spec/frontend/vue_shared/components/form/__snapshots__/form_footer_actions_spec.js.snap @@ -0,0 +1,19 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Form Footer Actions renders content properly 1`] = ` +<footer + class="form-actions d-flex justify-content-between" +> + <div> + Bar + </div> + + <div> + Foo + </div> + + <div> + Abrakadabra + </div> +</footer> +`; diff --git a/spec/frontend/vue_shared/components/form/form_footer_actions_spec.js b/spec/frontend/vue_shared/components/form/form_footer_actions_spec.js new file mode 100644 index 00000000000..30e16bd12da --- /dev/null +++ b/spec/frontend/vue_shared/components/form/form_footer_actions_spec.js @@ -0,0 +1,29 @@ +import FormFooterActions from '~/vue_shared/components/form/form_footer_actions.vue'; +import { shallowMount } from '@vue/test-utils'; + +describe('Form Footer Actions', () => { + let wrapper; + + function createComponent(slots = {}) { + wrapper = shallowMount(FormFooterActions, { + slots, + }); + } + + afterEach(() => { + wrapper.destroy(); + }); + + it('renders content properly', () => { + const defaultSlot = 'Foo'; + const prepend = 'Bar'; + const append = 'Abrakadabra'; + createComponent({ + default: defaultSlot, + prepend, + append, + }); + + expect(wrapper.element).toMatchSnapshot(); + }); +}); |