diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /spec/frontend/boards | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/frontend/boards')
-rw-r--r-- | spec/frontend/boards/components/board_card_spec.js | 126 | ||||
-rw-r--r-- | spec/frontend/boards/components/board_content_sidebar_spec.js | 4 | ||||
-rw-r--r-- | spec/frontend/boards/components/board_filtered_search_spec.js | 146 | ||||
-rw-r--r-- | spec/frontend/boards/components/sidebar/board_sidebar_labels_select_spec.js | 32 | ||||
-rw-r--r-- | spec/frontend/boards/mock_data.js | 6 | ||||
-rw-r--r-- | spec/frontend/boards/stores/actions_spec.js | 166 | ||||
-rw-r--r-- | spec/frontend/boards/stores/getters_spec.js | 9 | ||||
-rw-r--r-- | spec/frontend/boards/stores/mutations_spec.js | 46 |
8 files changed, 360 insertions, 175 deletions
diff --git a/spec/frontend/boards/components/board_card_spec.js b/spec/frontend/boards/components/board_card_spec.js index 022f8c05e1e..ceafa6ead94 100644 --- a/spec/frontend/boards/components/board_card_spec.js +++ b/spec/frontend/boards/components/board_card_spec.js @@ -1,4 +1,5 @@ -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { GlLabel } from '@gitlab/ui'; +import { createLocalVue, shallowMount, mount } from '@vue/test-utils'; import Vuex from 'vuex'; import BoardCard from '~/boards/components/board_card.vue'; @@ -14,10 +15,11 @@ describe('Board card', () => { const localVue = createLocalVue(); localVue.use(Vuex); - const createStore = ({ initialState = {}, isSwimlanesOn = false } = {}) => { + const createStore = ({ initialState = {} } = {}) => { mockActions = { toggleBoardItem: jest.fn(), toggleBoardItemMultiSelection: jest.fn(), + performSearch: jest.fn(), }; store = new Vuex.Store({ @@ -28,19 +30,21 @@ describe('Board card', () => { }, actions: mockActions, getters: { - isSwimlanesOn: () => isSwimlanesOn, isEpicBoard: () => false, }, }); }; // this particular mount component needs to be used after the root beforeEach because it depends on list being initialized - const mountComponent = ({ propsData = {}, provide = {} } = {}) => { - wrapper = shallowMount(BoardCard, { + const mountComponent = ({ + propsData = {}, + provide = {}, + mountFn = shallowMount, + stubs = { BoardCardInner }, + } = {}) => { + wrapper = mountFn(BoardCard, { localVue, - stubs: { - BoardCardInner, - }, + stubs, store, propsData: { list: mockLabelList, @@ -74,72 +78,76 @@ describe('Board card', () => { store = null; }); - describe.each` - isSwimlanesOn - ${true} | ${false} - `('when isSwimlanesOn is $isSwimlanesOn', ({ isSwimlanesOn }) => { - it('should not highlight the card by default', async () => { - createStore({ isSwimlanesOn }); - mountComponent(); + describe('when GlLabel is clicked in BoardCardInner', () => { + it('doesnt call toggleBoardItem', () => { + createStore({ initialState: { isShowingLabels: true } }); + mountComponent({ mountFn: mount, stubs: {} }); + + wrapper.find(GlLabel).trigger('mouseup'); - expect(wrapper.classes()).not.toContain('is-active'); - expect(wrapper.classes()).not.toContain('multi-select'); + expect(mockActions.toggleBoardItem).toHaveBeenCalledTimes(0); }); + }); - it('should highlight the card with a correct style when selected', async () => { - createStore({ - initialState: { - activeId: mockIssue.id, - }, - isSwimlanesOn, - }); - mountComponent(); + it('should not highlight the card by default', async () => { + createStore(); + mountComponent(); - expect(wrapper.classes()).toContain('is-active'); - expect(wrapper.classes()).not.toContain('multi-select'); + expect(wrapper.classes()).not.toContain('is-active'); + expect(wrapper.classes()).not.toContain('multi-select'); + }); + + it('should highlight the card with a correct style when selected', async () => { + createStore({ + initialState: { + activeId: mockIssue.id, + }, }); + mountComponent(); - it('should highlight the card with a correct style when multi-selected', async () => { - createStore({ - initialState: { - activeId: inactiveId, - selectedBoardItems: [mockIssue], - }, - isSwimlanesOn, - }); - mountComponent(); + expect(wrapper.classes()).toContain('is-active'); + expect(wrapper.classes()).not.toContain('multi-select'); + }); - expect(wrapper.classes()).toContain('multi-select'); - expect(wrapper.classes()).not.toContain('is-active'); + it('should highlight the card with a correct style when multi-selected', async () => { + createStore({ + initialState: { + activeId: inactiveId, + selectedBoardItems: [mockIssue], + }, }); + mountComponent(); - describe('when mouseup event is called on the card', () => { - beforeEach(() => { - createStore({ isSwimlanesOn }); - mountComponent(); - }); + expect(wrapper.classes()).toContain('multi-select'); + expect(wrapper.classes()).not.toContain('is-active'); + }); - describe('when not using multi-select', () => { - it('should call vuex action "toggleBoardItem" with correct parameters', async () => { - await selectCard(); + describe('when mouseup event is called on the card', () => { + beforeEach(() => { + createStore(); + mountComponent(); + }); + + describe('when not using multi-select', () => { + it('should call vuex action "toggleBoardItem" with correct parameters', async () => { + await selectCard(); - expect(mockActions.toggleBoardItem).toHaveBeenCalledTimes(1); - expect(mockActions.toggleBoardItem).toHaveBeenCalledWith(expect.any(Object), { - boardItem: mockIssue, - }); + expect(mockActions.toggleBoardItem).toHaveBeenCalledTimes(1); + expect(mockActions.toggleBoardItem).toHaveBeenCalledWith(expect.any(Object), { + boardItem: mockIssue, }); }); + }); - describe('when using multi-select', () => { - it('should call vuex action "multiSelectBoardItem" with correct parameters', async () => { - await multiSelectCard(); + describe('when using multi-select', () => { + it('should call vuex action "multiSelectBoardItem" with correct parameters', async () => { + await multiSelectCard(); - expect(mockActions.toggleBoardItemMultiSelection).toHaveBeenCalledTimes(1); - expect(mockActions.toggleBoardItemMultiSelection).toHaveBeenCalledWith( - expect.any(Object), - mockIssue, - ); - }); + expect(mockActions.toggleBoardItemMultiSelection).toHaveBeenCalledTimes(1); + expect(mockActions.toggleBoardItemMultiSelection).toHaveBeenCalledWith( + expect.any(Object), + mockIssue, + ); }); }); }); diff --git a/spec/frontend/boards/components/board_content_sidebar_spec.js b/spec/frontend/boards/components/board_content_sidebar_spec.js index 7f949739891..01c99a02db2 100644 --- a/spec/frontend/boards/components/board_content_sidebar_spec.js +++ b/spec/frontend/boards/components/board_content_sidebar_spec.js @@ -6,9 +6,9 @@ import BoardContentSidebar from '~/boards/components/board_content_sidebar.vue'; import BoardSidebarDueDate from '~/boards/components/sidebar/board_sidebar_due_date.vue'; import BoardSidebarLabelsSelect from '~/boards/components/sidebar/board_sidebar_labels_select.vue'; import BoardSidebarMilestoneSelect from '~/boards/components/sidebar/board_sidebar_milestone_select.vue'; -import BoardSidebarSubscription from '~/boards/components/sidebar/board_sidebar_subscription.vue'; import BoardSidebarTitle from '~/boards/components/sidebar/board_sidebar_title.vue'; import { ISSUABLE } from '~/boards/constants'; +import SidebarSubscriptionsWidget from '~/sidebar/components/subscriptions/sidebar_subscriptions_widget.vue'; import { mockIssue, mockIssueGroupPath, mockIssueProjectPath } from '../mock_data'; describe('BoardContentSidebar', () => { @@ -111,7 +111,7 @@ describe('BoardContentSidebar', () => { }); it('renders BoardSidebarSubscription', () => { - expect(wrapper.find(BoardSidebarSubscription).exists()).toBe(true); + expect(wrapper.find(SidebarSubscriptionsWidget).exists()).toBe(true); }); it('renders BoardSidebarMilestoneSelect', () => { diff --git a/spec/frontend/boards/components/board_filtered_search_spec.js b/spec/frontend/boards/components/board_filtered_search_spec.js new file mode 100644 index 00000000000..e27badca9de --- /dev/null +++ b/spec/frontend/boards/components/board_filtered_search_spec.js @@ -0,0 +1,146 @@ +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; +import Vuex from 'vuex'; +import BoardFilteredSearch from '~/boards/components/board_filtered_search.vue'; +import { createStore } from '~/boards/stores'; +import * as urlUtility from '~/lib/utils/url_utility'; +import { __ } from '~/locale'; +import FilteredSearchBarRoot from '~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue'; +import AuthorToken from '~/vue_shared/components/filtered_search_bar/tokens/author_token.vue'; +import LabelToken from '~/vue_shared/components/filtered_search_bar/tokens/label_token.vue'; + +Vue.use(Vuex); + +describe('BoardFilteredSearch', () => { + let wrapper; + let store; + const tokens = [ + { + icon: 'labels', + title: __('Label'), + type: 'label_name', + operators: [ + { value: '=', description: 'is' }, + { value: '!=', description: 'is not' }, + ], + token: LabelToken, + unique: false, + symbol: '~', + fetchLabels: () => new Promise(() => {}), + }, + { + icon: 'pencil', + title: __('Author'), + type: 'author_username', + operators: [ + { value: '=', description: 'is' }, + { value: '!=', description: 'is not' }, + ], + symbol: '@', + token: AuthorToken, + unique: true, + fetchAuthors: () => new Promise(() => {}), + }, + ]; + + const createComponent = ({ initialFilterParams = {} } = {}) => { + wrapper = shallowMount(BoardFilteredSearch, { + provide: { initialFilterParams, fullPath: '' }, + store, + propsData: { + tokens, + }, + }); + }; + + const findFilteredSearch = () => wrapper.findComponent(FilteredSearchBarRoot); + + beforeEach(() => { + // this needed for actions call for performSearch + window.gon = { features: {} }; + }); + + afterEach(() => { + wrapper.destroy(); + }); + + describe('default', () => { + beforeEach(() => { + store = createStore(); + + jest.spyOn(store, 'dispatch'); + + createComponent(); + }); + + it('renders FilteredSearch', () => { + expect(findFilteredSearch().exists()).toBe(true); + }); + + it('passes the correct tokens to FilteredSearch', () => { + expect(findFilteredSearch().props('tokens')).toEqual(tokens); + }); + + describe('when onFilter is emitted', () => { + it('calls performSearch', () => { + findFilteredSearch().vm.$emit('onFilter', [{ value: { data: '' } }]); + + expect(store.dispatch).toHaveBeenCalledWith('performSearch'); + }); + + it('calls historyPushState', () => { + jest.spyOn(urlUtility, 'updateHistory'); + findFilteredSearch().vm.$emit('onFilter', [{ value: { data: 'searchQuery' } }]); + + expect(urlUtility.updateHistory).toHaveBeenCalledWith({ + replace: true, + title: '', + url: 'http://test.host/', + }); + }); + }); + }); + + describe('when searching', () => { + beforeEach(() => { + store = createStore(); + + jest.spyOn(store, 'dispatch'); + + createComponent(); + }); + + it('sets the url params to the correct results', async () => { + const mockFilters = [ + { type: 'author_username', value: { data: 'root', operator: '=' } }, + { type: 'label_name', value: { data: 'label', operator: '=' } }, + { type: 'label_name', value: { data: 'label2', operator: '=' } }, + ]; + jest.spyOn(urlUtility, 'updateHistory'); + findFilteredSearch().vm.$emit('onFilter', mockFilters); + + expect(urlUtility.updateHistory).toHaveBeenCalledWith({ + title: '', + replace: true, + url: 'http://test.host/?author_username=root&label_name[]=label&label_name[]=label2', + }); + }); + }); + + describe('when url params are already set', () => { + beforeEach(() => { + store = createStore(); + + jest.spyOn(store, 'dispatch'); + + createComponent({ initialFilterParams: { authorUsername: 'root', labelName: ['label'] } }); + }); + + it('passes the correct props to FilterSearchBar', () => { + expect(findFilteredSearch().props('initialFilterValue')).toEqual([ + { type: 'author_username', value: { data: 'root', operator: '=' } }, + { type: 'label_name', value: { data: 'label', operator: '=' } }, + ]); + }); + }); +}); diff --git a/spec/frontend/boards/components/sidebar/board_sidebar_labels_select_spec.js b/spec/frontend/boards/components/sidebar/board_sidebar_labels_select_spec.js index 153d0640b23..ad682774ee6 100644 --- a/spec/frontend/boards/components/sidebar/board_sidebar_labels_select_spec.js +++ b/spec/frontend/boards/components/sidebar/board_sidebar_labels_select_spec.js @@ -1,7 +1,11 @@ import { GlLabel } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import { TEST_HOST } from 'helpers/test_constants'; -import { labels as TEST_LABELS, mockIssue as TEST_ISSUE } from 'jest/boards/mock_data'; +import { + labels as TEST_LABELS, + mockIssue as TEST_ISSUE, + mockIssueFullPath as TEST_ISSUE_FULLPATH, +} from 'jest/boards/mock_data'; import BoardEditableItem from '~/boards/components/sidebar/board_editable_item.vue'; import BoardSidebarLabelsSelect from '~/boards/components/sidebar/board_sidebar_labels_select.vue'; import { createStore } from '~/boards/stores'; @@ -23,7 +27,7 @@ describe('~/boards/components/sidebar/board_sidebar_labels_select.vue', () => { wrapper = null; }); - const createWrapper = ({ labels = [] } = {}) => { + const createWrapper = ({ labels = [], providedValues = {} } = {}) => { store = createStore(); store.state.boardItems = { [TEST_ISSUE.id]: { ...TEST_ISSUE, labels } }; store.state.activeId = TEST_ISSUE.id; @@ -32,9 +36,9 @@ describe('~/boards/components/sidebar/board_sidebar_labels_select.vue', () => { store, provide: { canUpdate: true, - labelsFetchPath: TEST_HOST, labelsManagePath: TEST_HOST, labelsFilterBasePath: TEST_HOST, + ...providedValues, }, stubs: { BoardEditableItem, @@ -48,6 +52,22 @@ describe('~/boards/components/sidebar/board_sidebar_labels_select.vue', () => { wrapper.findAll(GlLabel).wrappers.map((item) => item.props('title')); const findCollapsed = () => wrapper.find('[data-testid="collapsed-content"]'); + describe('when labelsFetchPath is provided', () => { + it('uses injected labels fetch path', () => { + createWrapper({ providedValues: { labelsFetchPath: 'foobar' } }); + + expect(findLabelsSelect().props('labelsFetchPath')).toEqual('foobar'); + }); + }); + + it('uses the default project label endpoint', () => { + createWrapper(); + + expect(findLabelsSelect().props('labelsFetchPath')).toEqual( + `/${TEST_ISSUE_FULLPATH}/-/labels?include_ancestor_groups=true`, + ); + }); + it('renders "None" when no labels are selected', () => { createWrapper(); @@ -78,7 +98,7 @@ describe('~/boards/components/sidebar/board_sidebar_labels_select.vue', () => { it('commits change to the server', () => { expect(wrapper.vm.setActiveBoardItemLabels).toHaveBeenCalledWith({ addLabelIds: TEST_LABELS.map((label) => label.id), - projectPath: 'gitlab-org/test-subgroup/gitlab-test', + projectPath: TEST_ISSUE_FULLPATH, removeLabelIds: [], }); }); @@ -103,7 +123,7 @@ describe('~/boards/components/sidebar/board_sidebar_labels_select.vue', () => { expect(wrapper.vm.setActiveBoardItemLabels).toHaveBeenCalledWith({ addLabelIds: [5, 7], removeLabelIds: [6], - projectPath: 'gitlab-org/test-subgroup/gitlab-test', + projectPath: TEST_ISSUE_FULLPATH, }); }); }); @@ -122,7 +142,7 @@ describe('~/boards/components/sidebar/board_sidebar_labels_select.vue', () => { expect(wrapper.vm.setActiveBoardItemLabels).toHaveBeenCalledWith({ removeLabelIds: [getIdFromGraphQLId(testLabel.id)], - projectPath: 'gitlab-org/test-subgroup/gitlab-test', + projectPath: TEST_ISSUE_FULLPATH, }); }); }); diff --git a/spec/frontend/boards/mock_data.js b/spec/frontend/boards/mock_data.js index 1c5b7cf8248..bcaca9522e4 100644 --- a/spec/frontend/boards/mock_data.js +++ b/spec/frontend/boards/mock_data.js @@ -151,6 +151,8 @@ export const rawIssue = { }, }; +export const mockIssueFullPath = 'gitlab-org/test-subgroup/gitlab-test'; + export const mockIssue = { id: 'gid://gitlab/Issue/436', iid: '27', @@ -159,8 +161,8 @@ export const mockIssue = { timeEstimate: 0, weight: null, confidential: false, - referencePath: 'gitlab-org/test-subgroup/gitlab-test#27', - path: '/gitlab-org/test-subgroup/gitlab-test/-/issues/27', + referencePath: `${mockIssueFullPath}#27`, + path: `/${mockIssueFullPath}/-/issues/27`, assignees, labels: [ { diff --git a/spec/frontend/boards/stores/actions_spec.js b/spec/frontend/boards/stores/actions_spec.js index 460e77a3f03..09343b5704f 100644 --- a/spec/frontend/boards/stores/actions_spec.js +++ b/spec/frontend/boards/stores/actions_spec.js @@ -1,15 +1,21 @@ import * as Sentry from '@sentry/browser'; +import { + inactiveId, + ISSUABLE, + ListType, + issuableTypes, + BoardType, + listsQuery, +} from 'ee_else_ce/boards/constants'; import issueMoveListMutation from 'ee_else_ce/boards/graphql/issue_move_list.mutation.graphql'; import testAction from 'helpers/vuex_action_helper'; import { - fullBoardId, formatListIssues, formatBoardLists, formatIssueInput, formatIssue, getMoveData, } from '~/boards/boards_util'; -import { inactiveId, ISSUABLE, ListType } from '~/boards/constants'; import destroyBoardListMutation from '~/boards/graphql/board_list_destroy.mutation.graphql'; import issueCreateMutation from '~/boards/graphql/issue_create.mutation.graphql'; import actions, { gqlClient } from '~/boards/stores/actions'; @@ -34,12 +40,6 @@ import { jest.mock('~/flash'); -const expectNotImplemented = (action) => { - it('is not implemented', () => { - expect(action).toThrow(new Error('Not implemented!')); - }); -}; - // We need this helper to make sure projectPath is including // subgroups when the movIssue action is called. const getProjectPath = (path) => path.split('#')[0]; @@ -66,20 +66,32 @@ describe('setInitialBoardData', () => { }); describe('setFilters', () => { - it('should commit mutation SET_FILTERS', (done) => { + it.each([ + [ + 'with correct filters as payload', + { + filters: { labelName: 'label' }, + updatedFilters: { labelName: 'label', not: {} }, + }, + ], + [ + 'and updates assigneeWildcardId', + { + filters: { assigneeId: 'None' }, + updatedFilters: { assigneeWildcardId: 'NONE', not: {} }, + }, + ], + ])('should commit mutation SET_FILTERS %s', (_, { filters, updatedFilters }) => { const state = { filters: {}, }; - const filters = { labelName: 'label' }; - testAction( actions.setFilters, filters, state, - [{ type: types.SET_FILTERS, payload: { ...filters, not: {} } }], + [{ type: types.SET_FILTERS, payload: updatedFilters }], [], - done, ); }); }); @@ -120,20 +132,12 @@ describe('setActiveId', () => { }); describe('fetchLists', () => { - it('should dispatch fetchIssueLists action', () => { - testAction({ - action: actions.fetchLists, - expectedActions: [{ type: 'fetchIssueLists' }], - }); - }); -}); - -describe('fetchIssueLists', () => { - const state = { + let state = { fullPath: 'gitlab-org', - boardId: '1', + fullBoardId: 'gid://gitlab/Board/1', filterParams: {}, boardType: 'group', + issuableType: 'issue', }; let queryResponse = { @@ -155,7 +159,7 @@ describe('fetchIssueLists', () => { jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse); testAction( - actions.fetchIssueLists, + actions.fetchLists, {}, state, [ @@ -173,7 +177,7 @@ describe('fetchIssueLists', () => { jest.spyOn(gqlClient, 'query').mockResolvedValue(Promise.reject()); testAction( - actions.fetchIssueLists, + actions.fetchLists, {}, state, [ @@ -202,7 +206,7 @@ describe('fetchIssueLists', () => { jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse); testAction( - actions.fetchIssueLists, + actions.fetchLists, {}, state, [ @@ -215,6 +219,43 @@ describe('fetchIssueLists', () => { done, ); }); + + it.each` + issuableType | boardType | fullBoardId | isGroup | isProject + ${issuableTypes.issue} | ${BoardType.group} | ${'gid://gitlab/Board/1'} | ${true} | ${false} + ${issuableTypes.issue} | ${BoardType.project} | ${'gid://gitlab/Board/1'} | ${false} | ${true} + `( + 'calls $issuableType query with correct variables', + async ({ issuableType, boardType, fullBoardId, isGroup, isProject }) => { + const commit = jest.fn(); + const dispatch = jest.fn(); + + state = { + fullPath: 'gitlab-org', + fullBoardId, + filterParams: {}, + boardType, + issuableType, + }; + + const variables = { + query: listsQuery[issuableType].query, + variables: { + fullPath: 'gitlab-org', + boardId: fullBoardId, + filters: {}, + isGroup, + isProject, + }, + }; + + jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse); + + await actions.fetchLists({ commit, state, dispatch }); + + expect(gqlClient.query).toHaveBeenCalledWith(variables); + }, + ); }); describe('createList', () => { @@ -236,7 +277,7 @@ describe('createIssueList', () => { beforeEach(() => { state = { fullPath: 'gitlab-org', - boardId: '1', + fullBoardId: 'gid://gitlab/Board/1', boardType: 'group', disabled: false, boardLists: [{ type: 'closed' }], @@ -366,7 +407,7 @@ describe('moveList', () => { const state = { fullPath: 'gitlab-org', - boardId: '1', + fullBoardId: 'gid://gitlab/Board/1', boardType: 'group', disabled: false, boardLists: initialBoardListsState, @@ -409,7 +450,7 @@ describe('moveList', () => { const state = { fullPath: 'gitlab-org', - boardId: '1', + fullBoardId: 'gid://gitlab/Board/1', boardType: 'group', disabled: false, boardLists: initialBoardListsState, @@ -443,10 +484,11 @@ describe('updateList', () => { const state = { fullPath: 'gitlab-org', - boardId: '1', + fullBoardId: 'gid://gitlab/Board/1', boardType: 'group', disabled: false, boardLists: [{ type: 'closed' }], + issuableType: issuableTypes.issue, }; testAction( @@ -490,6 +532,7 @@ describe('removeList', () => { beforeEach(() => { state = { boardLists: mockListsById, + issuableType: issuableTypes.issue, }; }); @@ -559,7 +602,7 @@ describe('fetchItemsForList', () => { const state = { fullPath: 'gitlab-org', - boardId: '1', + fullBoardId: 'gid://gitlab/Board/1', filterParams: {}, boardType: 'group', }; @@ -946,7 +989,7 @@ describe('updateIssueOrder', () => { const state = { boardItems: issues, - boardId: 'gid://gitlab/Board/1', + fullBoardId: 'gid://gitlab/Board/1', }; const moveData = { @@ -960,7 +1003,7 @@ describe('updateIssueOrder', () => { mutation: issueMoveListMutation, variables: { projectPath: getProjectPath(mockIssue.referencePath), - boardId: fullBoardId(state.boardId), + boardId: state.fullBoardId, iid: mockIssue.iid, fromListId: 1, toListId: 2, @@ -1362,7 +1405,7 @@ describe('setActiveItemSubscribed', () => { [mockActiveIssue.id]: mockActiveIssue, }, fullPath: 'gitlab-org', - issuableType: 'issue', + issuableType: issuableTypes.issue, }; const getters = { activeBoardItem: mockActiveIssue, isEpicBoard: false }; const subscribedState = true; @@ -1470,7 +1513,7 @@ describe('setActiveIssueMilestone', () => { describe('setActiveItemTitle', () => { const state = { boardItems: { [mockIssue.id]: mockIssue }, - issuableType: 'issue', + issuableType: issuableTypes.issue, fullPath: 'path/f', }; const getters = { activeBoardItem: mockIssue, isEpicBoard: false }; @@ -1522,6 +1565,33 @@ describe('setActiveItemTitle', () => { }); }); +describe('setActiveItemConfidential', () => { + const state = { boardItems: { [mockIssue.id]: mockIssue } }; + const getters = { activeBoardItem: mockIssue }; + + it('set confidential value on board item', (done) => { + const payload = { + itemId: getters.activeBoardItem.id, + prop: 'confidential', + value: true, + }; + + testAction( + actions.setActiveItemConfidential, + true, + { ...state, ...getters }, + [ + { + type: types.UPDATE_BOARD_ITEM_BY_ID, + payload, + }, + ], + [], + done, + ); + }); +}); + describe('fetchGroupProjects', () => { const state = { fullPath: 'gitlab-org', @@ -1749,27 +1819,3 @@ describe('unsetError', () => { }); }); }); - -describe('fetchBacklog', () => { - expectNotImplemented(actions.fetchBacklog); -}); - -describe('bulkUpdateIssues', () => { - expectNotImplemented(actions.bulkUpdateIssues); -}); - -describe('fetchIssue', () => { - expectNotImplemented(actions.fetchIssue); -}); - -describe('toggleIssueSubscription', () => { - expectNotImplemented(actions.toggleIssueSubscription); -}); - -describe('showPage', () => { - expectNotImplemented(actions.showPage); -}); - -describe('toggleEmptyState', () => { - expectNotImplemented(actions.toggleEmptyState); -}); diff --git a/spec/frontend/boards/stores/getters_spec.js b/spec/frontend/boards/stores/getters_spec.js index 6114ba0af5f..e7efb21bee5 100644 --- a/spec/frontend/boards/stores/getters_spec.js +++ b/spec/frontend/boards/stores/getters_spec.js @@ -110,6 +110,15 @@ describe('Boards - Getters', () => { ); }); + it('returns group path of last subgroup for the active issue', () => { + const mockActiveIssue = { + referencePath: 'gitlab-org/subgroup/subsubgroup/gitlab-test#1', + }; + expect(getters.groupPathForActiveIssue({}, { activeBoardItem: mockActiveIssue })).toEqual( + 'gitlab-org/subgroup/subsubgroup', + ); + }); + it('returns empty string as group path when active issue is an empty object', () => { const mockActiveIssue = {}; expect(getters.groupPathForActiveIssue({}, { activeBoardItem: mockActiveIssue })).toEqual(''); diff --git a/spec/frontend/boards/stores/mutations_spec.js b/spec/frontend/boards/stores/mutations_spec.js index af6d439e294..d89abcc79ae 100644 --- a/spec/frontend/boards/stores/mutations_spec.js +++ b/spec/frontend/boards/stores/mutations_spec.js @@ -13,12 +13,6 @@ import { mockList, } from '../mock_data'; -const expectNotImplemented = (action) => { - it('is not implemented', () => { - expect(action).toThrow(new Error('Not implemented!')); - }); -}; - describe('Board Store Mutations', () => { let state; @@ -158,10 +152,6 @@ describe('Board Store Mutations', () => { }); }); - describe('REQUEST_ADD_LIST', () => { - expectNotImplemented(mutations.REQUEST_ADD_LIST); - }); - describe('RECEIVE_ADD_LIST_SUCCESS', () => { it('adds list to boardLists state', () => { mutations.RECEIVE_ADD_LIST_SUCCESS(state, mockLists[0]); @@ -172,10 +162,6 @@ describe('Board Store Mutations', () => { }); }); - describe('RECEIVE_ADD_LIST_ERROR', () => { - expectNotImplemented(mutations.RECEIVE_ADD_LIST_ERROR); - }); - describe('MOVE_LIST', () => { it('updates boardLists state with reordered lists', () => { state = { @@ -341,10 +327,6 @@ describe('Board Store Mutations', () => { }); }); - describe('REQUEST_ADD_ISSUE', () => { - expectNotImplemented(mutations.REQUEST_ADD_ISSUE); - }); - describe('UPDATE_BOARD_ITEM_BY_ID', () => { const issueId = '1'; const prop = 'id'; @@ -386,14 +368,6 @@ describe('Board Store Mutations', () => { }); }); - describe('RECEIVE_ADD_ISSUE_SUCCESS', () => { - expectNotImplemented(mutations.RECEIVE_ADD_ISSUE_SUCCESS); - }); - - describe('RECEIVE_ADD_ISSUE_ERROR', () => { - expectNotImplemented(mutations.RECEIVE_ADD_ISSUE_ERROR); - }); - describe('MUTATE_ISSUE_SUCCESS', () => { it('updates issue in issues state', () => { const issues = { @@ -434,18 +408,6 @@ describe('Board Store Mutations', () => { }); }); - describe('REQUEST_UPDATE_ISSUE', () => { - expectNotImplemented(mutations.REQUEST_UPDATE_ISSUE); - }); - - describe('RECEIVE_UPDATE_ISSUE_SUCCESS', () => { - expectNotImplemented(mutations.RECEIVE_UPDATE_ISSUE_SUCCESS); - }); - - describe('RECEIVE_UPDATE_ISSUE_ERROR', () => { - expectNotImplemented(mutations.RECEIVE_UPDATE_ISSUE_ERROR); - }); - describe('ADD_BOARD_ITEM_TO_LIST', () => { beforeEach(() => { setBoardsListsState(); @@ -540,14 +502,6 @@ describe('Board Store Mutations', () => { }); }); - describe('SET_CURRENT_PAGE', () => { - expectNotImplemented(mutations.SET_CURRENT_PAGE); - }); - - describe('TOGGLE_EMPTY_STATE', () => { - expectNotImplemented(mutations.TOGGLE_EMPTY_STATE); - }); - describe('REQUEST_GROUP_PROJECTS', () => { it('Should set isLoading in groupProjectsFlags to true in state when fetchNext is false', () => { mutations[types.REQUEST_GROUP_PROJECTS](state, false); |