diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-09 15:08:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-09 15:08:56 +0300 |
commit | fcda041fc06e7bad3e4f5b5cff921f91c7eba717 (patch) | |
tree | a7e935192b9f846fa9257daf85a1642fbaa0f01a /spec/frontend | |
parent | c3b45354d720654215eb0e7b8e718ba6ea2d7a96 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
10 files changed, 86 insertions, 103 deletions
diff --git a/spec/frontend/api_spec.js b/spec/frontend/api_spec.js index 95cc3806b8b..9536dd83afb 100644 --- a/spec/frontend/api_spec.js +++ b/spec/frontend/api_spec.js @@ -96,29 +96,6 @@ describe('Api', () => { }); }); - describe('groupMilestones', () => { - it('fetches group milestones', done => { - const groupId = 1; - const options = { state: 'active' }; - const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/groups/1/milestones`; - mock.onGet(expectedUrl).reply(200, [ - { - id: 1, - title: 'milestone1', - state: 'active', - }, - ]); - - Api.groupMilestones(groupId, options) - .then(({ data }) => { - expect(data.length).toBe(1); - expect(data[0].title).toBe('milestone1'); - }) - .then(done) - .catch(done.fail); - }); - }); - describe('namespaces', () => { it('fetches namespaces', done => { const query = 'dummy query'; @@ -319,29 +296,6 @@ describe('Api', () => { }); }); - describe('projectMilestones', () => { - it('fetches project milestones', done => { - const projectId = 1; - const options = { state: 'active' }; - const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects/1/milestones`; - mock.onGet(expectedUrl).reply(200, [ - { - id: 1, - title: 'milestone1', - state: 'active', - }, - ]); - - Api.projectMilestones(projectId, options) - .then(({ data }) => { - expect(data.length).toBe(1); - expect(data[0].title).toBe('milestone1'); - }) - .then(done) - .catch(done.fail); - }); - }); - describe('newLabel', () => { it('creates a new label', done => { const namespace = 'some namespace'; diff --git a/spec/frontend/boards/components/board_form_spec.js b/spec/frontend/boards/components/board_form_spec.js index a1b656876ed..ee427bc2154 100644 --- a/spec/frontend/boards/components/board_form_spec.js +++ b/spec/frontend/boards/components/board_form_spec.js @@ -10,6 +10,7 @@ describe('board_form.vue', () => { const propsData = { canAdminBoard: false, labelsPath: `${gl.TEST_HOST}/labels/path`, + milestonePath: `${gl.TEST_HOST}/milestone/path`, }; const findModal = () => wrapper.find(DeprecatedModal); diff --git a/spec/frontend/boards/components/boards_selector_spec.js b/spec/frontend/boards/components/boards_selector_spec.js index 347ffaf672e..b1ae86c2d3f 100644 --- a/spec/frontend/boards/components/boards_selector_spec.js +++ b/spec/frontend/boards/components/boards_selector_spec.js @@ -81,6 +81,7 @@ describe('BoardsSelector', () => { assignee_id: null, labels: [], }, + milestonePath: `${TEST_HOST}/milestone/path`, boardBaseUrl: `${TEST_HOST}/board/base/url`, hasMissingBoards: false, canAdminBoard: true, diff --git a/spec/frontend/ide/services/index_spec.js b/spec/frontend/ide/services/index_spec.js index 3cb6e064aa2..bc3f86702cf 100644 --- a/spec/frontend/ide/services/index_spec.js +++ b/spec/frontend/ide/services/index_spec.js @@ -2,7 +2,7 @@ import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import services from '~/ide/services'; import Api from '~/api'; -import gqClient from '~/ide/services/gql'; +import { query } from '~/ide/services/gql'; import { escapeFileUrl } from '~/lib/utils/url_utility'; import getUserPermissions from '~/ide/queries/getUserPermissions.query.graphql'; import { projectData } from '../mock_data'; @@ -207,12 +207,12 @@ describe('IDE services', () => { }, }; Api.project.mockReturnValue(Promise.resolve({ data: { ...projectData } })); - gqClient.query.mockReturnValue(Promise.resolve({ data: { project: gqlProjectData } })); + query.mockReturnValue(Promise.resolve({ data: { project: gqlProjectData } })); return services.getProjectData(TEST_NAMESPACE, TEST_PROJECT).then(response => { expect(response).toEqual({ data: { ...projectData, ...gqlProjectData } }); expect(Api.project).toHaveBeenCalledWith(TEST_PROJECT_ID); - expect(gqClient.query).toHaveBeenCalledWith({ + expect(query).toHaveBeenCalledWith({ query: getUserPermissions, variables: { projectPath: TEST_PROJECT_ID, diff --git a/spec/frontend/monitoring/components/__snapshots__/empty_state_spec.js.snap b/spec/frontend/monitoring/components/__snapshots__/empty_state_spec.js.snap index 31b3ad1bd76..611aa96fa0a 100644 --- a/spec/frontend/monitoring/components/__snapshots__/empty_state_spec.js.snap +++ b/spec/frontend/monitoring/components/__snapshots__/empty_state_spec.js.snap @@ -24,6 +24,18 @@ exports[`EmptyState shows loading state 1`] = ` /> `; +exports[`EmptyState shows noData state 1`] = ` +<gl-empty-state-stub + description="You are connected to the Prometheus server, but there is currently no data to display." + primarybuttonlink="/settingsPath" + primarybuttontext="Configure Prometheus" + secondarybuttonlink="" + secondarybuttontext="" + svgpath="/path/to/no-data.svg" + title="No data found" +/> +`; + exports[`EmptyState shows unableToConnect state 1`] = ` <gl-empty-state-stub description="Ensure connectivity is available from the GitLab server to the Prometheus server" diff --git a/spec/frontend/monitoring/components/dashboard_spec.js b/spec/frontend/monitoring/components/dashboard_spec.js index a4fbc0a981a..ba1118ef3b7 100644 --- a/spec/frontend/monitoring/components/dashboard_spec.js +++ b/spec/frontend/monitoring/components/dashboard_spec.js @@ -6,7 +6,7 @@ import { objectToQuery } from '~/lib/utils/url_utility'; import VueDraggable from 'vuedraggable'; import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; -import { metricStates } from '~/monitoring/constants'; +import { dashboardEmptyStates, metricStates } from '~/monitoring/constants'; import Dashboard from '~/monitoring/components/dashboard.vue'; import DashboardHeader from '~/monitoring/components/dashboard_header.vue'; @@ -126,13 +126,13 @@ describe('Dashboard', () => { }); it('shows up a loading state', () => { - store.state.monitoringDashboard.emptyState = 'loading'; + store.state.monitoringDashboard.emptyState = dashboardEmptyStates.LOADING; createShallowWrapper({ hasMetrics: true }); return wrapper.vm.$nextTick().then(() => { expect(wrapper.find(EmptyState).exists()).toBe(true); - expect(wrapper.find(EmptyState).props('selectedState')).toBe('loading'); + expect(wrapper.find(EmptyState).props('selectedState')).toBe(dashboardEmptyStates.LOADING); }); }); diff --git a/spec/frontend/monitoring/components/empty_state_spec.js b/spec/frontend/monitoring/components/empty_state_spec.js index e985e5fb443..3b03e16a446 100644 --- a/spec/frontend/monitoring/components/empty_state_spec.js +++ b/spec/frontend/monitoring/components/empty_state_spec.js @@ -1,4 +1,5 @@ import { shallowMount } from '@vue/test-utils'; +import { dashboardEmptyStates } from '~/monitoring/constants'; import EmptyState from '~/monitoring/components/empty_state.vue'; function createComponent(props) { @@ -20,7 +21,7 @@ function createComponent(props) { describe('EmptyState', () => { it('shows gettingStarted state', () => { const wrapper = createComponent({ - selectedState: 'gettingStarted', + selectedState: dashboardEmptyStates.GETTING_STARTED, }); expect(wrapper.element).toMatchSnapshot(); @@ -28,7 +29,7 @@ describe('EmptyState', () => { it('shows loading state', () => { const wrapper = createComponent({ - selectedState: 'loading', + selectedState: dashboardEmptyStates.LOADING, }); expect(wrapper.element).toMatchSnapshot(); @@ -36,7 +37,15 @@ describe('EmptyState', () => { it('shows unableToConnect state', () => { const wrapper = createComponent({ - selectedState: 'unableToConnect', + selectedState: dashboardEmptyStates.UNABLE_TO_CONNECT, + }); + + expect(wrapper.element).toMatchSnapshot(); + }); + + it('shows noData state', () => { + const wrapper = createComponent({ + selectedState: dashboardEmptyStates.NO_DATA, }); expect(wrapper.element).toMatchSnapshot(); diff --git a/spec/frontend/monitoring/store/mutations_spec.js b/spec/frontend/monitoring/store/mutations_spec.js index 86a8793c508..734a3597569 100644 --- a/spec/frontend/monitoring/store/mutations_spec.js +++ b/spec/frontend/monitoring/store/mutations_spec.js @@ -3,7 +3,7 @@ import httpStatusCodes from '~/lib/utils/http_status'; import mutations from '~/monitoring/stores/mutations'; import * as types from '~/monitoring/stores/mutation_types'; import state from '~/monitoring/stores/state'; -import { metricStates } from '~/monitoring/constants'; +import { dashboardEmptyStates, metricStates } from '~/monitoring/constants'; import { deploymentData, dashboardGitResponse, storeTextVariables } from '../mock_data'; import { metricsDashboardPayload } from '../fixture_data'; @@ -15,6 +15,15 @@ describe('Monitoring mutations', () => { stateCopy = state(); }); + describe('REQUEST_METRICS_DASHBOARD', () => { + it('sets an empty loading state', () => { + mutations[types.REQUEST_METRICS_DASHBOARD](stateCopy); + + expect(stateCopy.emptyState).toBe(dashboardEmptyStates.LOADING); + expect(stateCopy.showEmptyState).toBe(true); + }); + }); + describe('RECEIVE_METRICS_DASHBOARD_SUCCESS', () => { let payload; const getGroups = () => stateCopy.dashboard.panelGroups; @@ -23,6 +32,18 @@ describe('Monitoring mutations', () => { stateCopy.dashboard.panelGroups = []; payload = metricsDashboardPayload; }); + it('sets an empty noData state when the dashboard is empty', () => { + const emptyDashboardPayload = { + ...payload, + panel_groups: [], + }; + + mutations[types.RECEIVE_METRICS_DASHBOARD_SUCCESS](stateCopy, emptyDashboardPayload); + const groups = getGroups(); + + expect(groups).toEqual([]); + expect(stateCopy.emptyState).toBe(dashboardEmptyStates.NO_DATA); + }); it('adds a key to the group', () => { mutations[types.RECEIVE_METRICS_DASHBOARD_SUCCESS](stateCopy, payload); const groups = getGroups(); @@ -72,6 +93,22 @@ describe('Monitoring mutations', () => { }); }); + describe('RECEIVE_METRICS_DASHBOARD_FAILURE', () => { + it('sets an empty noData state when an empty error occurs', () => { + mutations[types.RECEIVE_METRICS_DASHBOARD_FAILURE](stateCopy); + + expect(stateCopy.emptyState).toBe(dashboardEmptyStates.NO_DATA); + expect(stateCopy.showEmptyState).toBe(true); + }); + + it('sets an empty unableToConnect state when an error occurs', () => { + mutations[types.RECEIVE_METRICS_DASHBOARD_FAILURE](stateCopy, 'myerror'); + + expect(stateCopy.emptyState).toBe(dashboardEmptyStates.UNABLE_TO_CONNECT); + expect(stateCopy.showEmptyState).toBe(true); + }); + }); + describe('Dashboard starring mutations', () => { it('REQUEST_DASHBOARD_STARRING', () => { stateCopy = { isUpdatingStarredValue: false }; @@ -283,6 +320,7 @@ describe('Monitoring mutations', () => { }); expect(stateCopy.showEmptyState).toBe(false); + expect(stateCopy.emptyState).toBe(null); }); it('adds results to the store', () => { diff --git a/spec/frontend/namespace_storage_limit_alert_spec.js b/spec/frontend/namespace_storage_limit_alert_spec.js deleted file mode 100644 index ef398b12e1f..00000000000 --- a/spec/frontend/namespace_storage_limit_alert_spec.js +++ /dev/null @@ -1,36 +0,0 @@ -import Cookies from 'js-cookie'; -import initNamespaceStorageLimitAlert from '~/namespace_storage_limit_alert'; - -describe('broadcast message on dismiss', () => { - const dismiss = () => { - const button = document.querySelector('.js-namespace-storage-alert-dismiss'); - button.click(); - }; - - beforeEach(() => { - setFixtures(` - <div class="js-namespace-storage-alert"> - <button class="js-namespace-storage-alert-dismiss" data-id="1" data-level="info"></button> - </div> - `); - - initNamespaceStorageLimitAlert(); - }); - - it('removes alert', () => { - expect(document.querySelector('.js-namespace-storage-alert')).toBeTruthy(); - - dismiss(); - - expect(document.querySelector('.js-namespace-storage-alert')).toBeNull(); - }); - - it('calls Cookies.set', () => { - jest.spyOn(Cookies, 'set'); - dismiss(); - - expect(Cookies.set).toHaveBeenCalledWith('hide_storage_limit_alert_1_info', true, { - expires: 365, - }); - }); -}); diff --git a/spec/frontend/registry/explorer/components/details_page/tags_list_spec.js b/spec/frontend/registry/explorer/components/details_page/tags_list_spec.js index 76154e11447..1f560753476 100644 --- a/spec/frontend/registry/explorer/components/details_page/tags_list_spec.js +++ b/spec/frontend/registry/explorer/components/details_page/tags_list_spec.js @@ -8,6 +8,7 @@ import { tagsListResponse } from '../../mock_data'; describe('Tags List', () => { let wrapper; const tags = [...tagsListResponse.data]; + const readOnlyTags = tags.map(t => ({ ...t, destroy_path: undefined })); const findTagsListRow = () => wrapper.findAll(TagsListRow); const findDeleteButton = () => wrapper.find(GlButton); @@ -39,17 +40,20 @@ describe('Tags List', () => { }); describe('delete button', () => { - it('is not shown on mobile view', () => { - mountComponent({ tags, isDesktop: false }); - - expect(findDeleteButton().exists()).toBe(false); - }); - - it('is shown on desktop view', () => { - mountComponent(); - - expect(findDeleteButton().exists()).toBe(true); - }); + it.each` + inputTags | isDesktop | isVisible + ${tags} | ${true} | ${true} + ${tags} | ${false} | ${false} + ${readOnlyTags} | ${true} | ${false} + ${readOnlyTags} | ${false} | ${false} + `( + 'is $isVisible that delete button exists when tags is $inputTags and isDesktop is $isDesktop', + ({ inputTags, isDesktop, isVisible }) => { + mountComponent({ tags: inputTags, isDesktop }); + + expect(findDeleteButton().exists()).toBe(isVisible); + }, + ); it('has the correct text', () => { mountComponent(); |