diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-11 06:07:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-11 06:07:33 +0300 |
commit | e2c044cf3f155cea010553ee5fe50145b7e9278d (patch) | |
tree | b57c8f6b98abff7fd180015c09d85aafb9a4cfa5 /spec/frontend | |
parent | feb7a8f326e530cfce4d12e3badb56cd86ee3f3e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
11 files changed, 33 insertions, 72 deletions
diff --git a/spec/frontend/boards/board_card_inner_spec.js b/spec/frontend/boards/board_card_inner_spec.js index 0df25604d5b..2c8e6306431 100644 --- a/spec/frontend/boards/board_card_inner_spec.js +++ b/spec/frontend/boards/board_card_inner_spec.js @@ -1,7 +1,7 @@ import { GlLabel, GlLoadingIcon, GlTooltip } from '@gitlab/ui'; import { range } from 'lodash'; +import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; -import { nextTick } from 'vue'; import setWindowLocation from 'helpers/set_window_location_helper'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { mountExtended } from 'helpers/vue_test_utils_helper'; @@ -17,6 +17,8 @@ import { mockLabelList, mockIssue, mockIssueFullPath } from './mock_data'; jest.mock('~/lib/utils/url_utility'); jest.mock('~/boards/eventhub'); +Vue.use(Vuex); + describe('Board card component', () => { const user = { id: 1, @@ -52,9 +54,8 @@ describe('Board card component', () => { const performSearchMock = jest.fn(); - const createStore = ({ isProjectBoard = false } = {}) => { + const createStore = () => { store = new Vuex.Store({ - ...defaultStore, actions: { performSearch: performSearchMock, }, @@ -62,14 +63,10 @@ describe('Board card component', () => { ...defaultStore.state, isShowingLabels: true, }, - getters: { - isGroupBoard: () => true, - isProjectBoard: () => isProjectBoard, - }, }); }; - const createWrapper = ({ props = {}, isEpicBoard = false } = {}) => { + const createWrapper = ({ props = {}, isEpicBoard = false, isGroupBoard = true } = {}) => { wrapper = mountExtended(BoardCardInner, { store, propsData: { @@ -97,6 +94,7 @@ describe('Board card component', () => { scopedLabelsAvailable: false, isEpicBoard, issuableType: issuableTypes.issue, + isGroupBoard, }, }); }; @@ -164,8 +162,8 @@ describe('Board card component', () => { }); it('does not render item reference path', () => { - createStore({ isProjectBoard: true }); - createWrapper(); + createStore(); + createWrapper({ isGroupBoard: false }); expect(wrapper.find('.board-card-number').text()).not.toContain(mockIssueFullPath); }); diff --git a/spec/frontend/boards/board_list_helper.js b/spec/frontend/boards/board_list_helper.js index c1d934cf274..af5509fd2e9 100644 --- a/spec/frontend/boards/board_list_helper.js +++ b/spec/frontend/boards/board_list_helper.js @@ -58,8 +58,6 @@ export default function createComponent({ ...state, }, getters: { - isGroupBoard: () => false, - isProjectBoard: () => true, isEpicBoard: () => false, ...getters, }, @@ -104,6 +102,8 @@ export default function createComponent({ canAdminList: true, isIssueBoard: true, isEpicBoard: false, + isGroupBoard: false, + isProjectBoard: true, ...provide, }, stubs, diff --git a/spec/frontend/boards/components/board_card_spec.js b/spec/frontend/boards/components/board_card_spec.js index 71a10fe7114..cd3882dc9ee 100644 --- a/spec/frontend/boards/components/board_card_spec.js +++ b/spec/frontend/boards/components/board_card_spec.js @@ -29,9 +29,6 @@ describe('Board card', () => { ...initialState, }, actions: mockActions, - getters: { - isProjectBoard: () => false, - }, }); }; @@ -62,6 +59,8 @@ describe('Board card', () => { scopedLabelsAvailable: false, isEpicBoard: false, issuableType: 'issue', + isProjectBoard: false, + isGroupBoard: true, ...provide, }, }); diff --git a/spec/frontend/boards/components/board_content_sidebar_spec.js b/spec/frontend/boards/components/board_content_sidebar_spec.js index cab00390901..51c42b48535 100644 --- a/spec/frontend/boards/components/board_content_sidebar_spec.js +++ b/spec/frontend/boards/components/board_content_sidebar_spec.js @@ -34,7 +34,6 @@ describe('BoardContentSidebar', () => { groupPathForActiveIssue: () => mockIssueGroupPath, projectPathForActiveIssue: () => mockIssueProjectPath, isSidebarOpen: () => true, - isGroupBoard: () => false, ...mockGetters, }, actions: mockActions, @@ -55,6 +54,7 @@ describe('BoardContentSidebar', () => { rootPath: '/', groupId: 1, issuableType: issuableTypes.issue, + isGroupBoard: false, }, store, stubs: { diff --git a/spec/frontend/boards/components/board_content_spec.js b/spec/frontend/boards/components/board_content_spec.js index 82e7ab48e7d..98f66ed804a 100644 --- a/spec/frontend/boards/components/board_content_spec.js +++ b/spec/frontend/boards/components/board_content_spec.js @@ -71,6 +71,7 @@ describe('BoardContent', () => { issuableType, isIssueBoard, isEpicBoard, + isGroupBoard: true, isApolloBoard, }, store, diff --git a/spec/frontend/boards/components/board_form_spec.js b/spec/frontend/boards/components/board_form_spec.js index fdc16b46167..f8154145d43 100644 --- a/spec/frontend/boards/components/board_form_spec.js +++ b/spec/frontend/boards/components/board_form_spec.js @@ -53,10 +53,6 @@ describe('BoardForm', () => { const setErrorMock = jest.fn(); const store = new Vuex.Store({ - getters: { - isGroupBoard: () => true, - isProjectBoard: () => false, - }, actions: { setBoard: setBoardMock, setError: setErrorMock, @@ -73,6 +69,8 @@ describe('BoardForm', () => { }, provide: { boardBaseUrl: 'root', + isGroupBoard: true, + isProjectBoard: false, }, mocks: { $apollo: { diff --git a/spec/frontend/boards/components/board_new_issue_spec.js b/spec/frontend/boards/components/board_new_issue_spec.js index 398caa4de62..c3e69ba0e40 100644 --- a/spec/frontend/boards/components/board_new_issue_spec.js +++ b/spec/frontend/boards/components/board_new_issue_spec.js @@ -16,7 +16,8 @@ const mockActions = { addListNewIssue: addListNewIssuesSpy }; const createComponent = ({ state = { selectedProject: mockGroupProjects[0] }, actions = mockActions, - getters = { isGroupBoard: () => true, getBoardItemsByList: () => () => [] }, + getters = { getBoardItemsByList: () => () => [] }, + isGroupBoard = true, } = {}) => shallowMount(BoardNewIssue, { store: new Vuex.Store({ @@ -32,6 +33,7 @@ const createComponent = ({ fullPath: mockGroupProjects[0].fullPath, weightFeatureAvailable: false, boardWeight: null, + isGroupBoard, }, stubs: { BoardNewItem, @@ -85,9 +87,9 @@ describe('Issue boards new issue form', () => { beforeEach(() => { wrapper = createComponent({ getters: { - isGroupBoard: () => true, getBoardItemsByList: () => () => [mockIssue, mockIssue2], }, + isGroupBoard: true, }); }); @@ -129,7 +131,7 @@ describe('Issue boards new issue form', () => { describe('when in project issue board', () => { beforeEach(() => { wrapper = createComponent({ - getters: { isGroupBoard: () => false }, + isGroupBoard: false, }); }); diff --git a/spec/frontend/boards/components/board_top_bar_spec.js b/spec/frontend/boards/components/board_top_bar_spec.js index 08b5042f70f..af492145eb0 100644 --- a/spec/frontend/boards/components/board_top_bar_spec.js +++ b/spec/frontend/boards/components/board_top_bar_spec.js @@ -33,6 +33,7 @@ describe('BoardTopBar', () => { boardType: 'group', releasesFetchPath: '/releases', isIssueBoard: true, + isGroupBoard: true, ...provide, }, stubs: { IssueBoardFilteredSearch }, diff --git a/spec/frontend/boards/components/boards_selector_spec.js b/spec/frontend/boards/components/boards_selector_spec.js index 9f7d36330b0..7b61ca5e6fd 100644 --- a/spec/frontend/boards/components/boards_selector_spec.js +++ b/spec/frontend/boards/components/boards_selector_spec.js @@ -10,7 +10,6 @@ import groupBoardsQuery from '~/boards/graphql/group_boards.query.graphql'; import projectBoardsQuery from '~/boards/graphql/project_boards.query.graphql'; import groupRecentBoardsQuery from '~/boards/graphql/group_recent_boards.query.graphql'; import projectRecentBoardsQuery from '~/boards/graphql/project_recent_boards.query.graphql'; -import defaultStore from '~/boards/stores'; import createMockApollo from 'helpers/mock_apollo_helper'; import { mountExtended } from 'helpers/vue_test_utils_helper'; import { @@ -28,23 +27,19 @@ import { const throttleDuration = 1; Vue.use(VueApollo); +Vue.use(Vuex); describe('BoardsSelector', () => { let wrapper; let fakeApollo; let store; - const createStore = ({ isGroupBoard = false, isProjectBoard = false } = {}) => { + const createStore = () => { store = new Vuex.Store({ - ...defaultStore, actions: { setError: jest.fn(), setBoardConfig: jest.fn(), }, - getters: { - isGroupBoard: () => isGroupBoard, - isProjectBoard: () => isProjectBoard, - }, state: { board: mockBoard, }, @@ -86,6 +81,7 @@ describe('BoardsSelector', () => { projectBoardsQueryHandler = projectBoardsQueryHandlerSuccess, projectRecentBoardsQueryHandler = projectRecentBoardsQueryHandlerSuccess, isGroupBoard = false, + isProjectBoard = false, } = {}) => { fakeApollo = createMockApollo([ [projectBoardsQuery, projectBoardsQueryHandler], @@ -110,6 +106,8 @@ describe('BoardsSelector', () => { scopedIssueBoardFeatureEnabled: true, weights: [], boardType: isGroupBoard ? 'group' : 'project', + isGroupBoard, + isProjectBoard, }, }); }; @@ -121,8 +119,8 @@ describe('BoardsSelector', () => { describe('template', () => { beforeEach(() => { - createStore({ isProjectBoard: true }); - createComponent(); + createStore(); + createComponent({ isProjectBoard: true }); }); describe('loading', () => { @@ -230,11 +228,11 @@ describe('BoardsSelector', () => { ${BoardType.group} | ${groupBoardsQueryHandlerSuccess} | ${projectBoardsQueryHandlerSuccess} ${BoardType.project} | ${projectBoardsQueryHandlerSuccess} | ${groupBoardsQueryHandlerSuccess} `('fetches $boardType boards', async ({ boardType, queryHandler, notCalledHandler }) => { - createStore({ - isProjectBoard: boardType === BoardType.project, + createStore(); + createComponent({ isGroupBoard: boardType === BoardType.group, + isProjectBoard: boardType === BoardType.project, }); - createComponent({ isGroupBoard: boardType === BoardType.group }); await nextTick(); diff --git a/spec/frontend/boards/components/issue_board_filtered_search_spec.js b/spec/frontend/boards/components/issue_board_filtered_search_spec.js index 513561307cd..57a30ddc512 100644 --- a/spec/frontend/boards/components/issue_board_filtered_search_spec.js +++ b/spec/frontend/boards/components/issue_board_filtered_search_spec.js @@ -18,7 +18,7 @@ describe('IssueBoardFilter', () => { isSignedIn, releasesFetchPath: '/releases', fullPath: 'gitlab-org', - boardType: 'group', + isGroupBoard: true, }, }); }; diff --git a/spec/frontend/boards/stores/getters_spec.js b/spec/frontend/boards/stores/getters_spec.js index 304f2aad98e..c86a256bd96 100644 --- a/spec/frontend/boards/stores/getters_spec.js +++ b/spec/frontend/boards/stores/getters_spec.js @@ -12,42 +12,6 @@ import { } from '../mock_data'; describe('Boards - Getters', () => { - describe('isGroupBoard', () => { - it('returns true when boardType on state is group', () => { - const state = { - boardType: 'group', - }; - - expect(getters.isGroupBoard(state)).toBe(true); - }); - - it('returns false when boardType on state is not group', () => { - const state = { - boardType: 'project', - }; - - expect(getters.isGroupBoard(state)).toBe(false); - }); - }); - - describe('isProjectBoard', () => { - it('returns true when boardType on state is project', () => { - const state = { - boardType: 'project', - }; - - expect(getters.isProjectBoard(state)).toBe(true); - }); - - it('returns false when boardType on state is not project', () => { - const state = { - boardType: 'group', - }; - - expect(getters.isProjectBoard(state)).toBe(false); - }); - }); - describe('isSidebarOpen', () => { it('returns true when activeId is not equal to 0', () => { const state = { |