diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-07 15:12:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-07 15:12:40 +0300 |
commit | ab15b68754fae11e160321fea4f018891a08b3b3 (patch) | |
tree | 8f6013ae793754c9b6df5ff6c27c30905cc88b78 /spec/frontend | |
parent | b9bc4d88ea6b998e2cede0da904f36daa2c18007 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
4 files changed, 75 insertions, 28 deletions
diff --git a/spec/frontend/boards/components/board_card_move_to_position_spec.js b/spec/frontend/boards/components/board_card_move_to_position_spec.js index 01bad53d9e1..7254b9486ef 100644 --- a/spec/frontend/boards/components/board_card_move_to_position_spec.js +++ b/spec/frontend/boards/components/board_card_move_to_position_spec.js @@ -1,8 +1,8 @@ +import { shallowMount } from '@vue/test-utils'; import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import { GlDropdown, GlDropdownItem } from '@gitlab/ui'; -import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import BoardCardMoveToPosition from '~/boards/components/board_card_move_to_position.vue'; import { mockList, mockIssue2, mockIssue, mockIssue3, mockIssue4 } from 'jest/boards/mock_data'; import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; @@ -19,6 +19,7 @@ describe('Board Card Move to position', () => { let trackingSpy; let store; let dispatch; + const itemIndex = 1; const createStoreOptions = () => { const state = { @@ -42,7 +43,7 @@ describe('Board Card Move to position', () => { }; const createComponent = (propsData) => { - wrapper = shallowMountExtended(BoardCardMoveToPosition, { + wrapper = shallowMount(BoardCardMoveToPosition, { store, propsData: { item: mockIssue2, @@ -66,7 +67,6 @@ describe('Board Card Move to position', () => { wrapper.destroy(); }); - const findEllipsesButton = () => wrapper.findByTestId('move-card-dropdown'); const findMoveToPositionDropdown = () => wrapper.findComponent(GlDropdown); const findDropdownItems = () => findMoveToPositionDropdown().findAllComponents(GlDropdownItem); const findDropdownItemAtIndex = (index) => findDropdownItems().at(index); @@ -74,7 +74,7 @@ describe('Board Card Move to position', () => { describe('Dropdown', () => { describe('Dropdown button', () => { it('has an icon with vertical ellipsis', () => { - expect(findEllipsesButton().exists()).toBe(true); + expect(findMoveToPositionDropdown().exists()).toBe(true); expect(findMoveToPositionDropdown().props('icon')).toBe('ellipsis_v'); }); @@ -82,24 +82,11 @@ describe('Board Card Move to position', () => { findMoveToPositionDropdown().vm.$emit('click'); expect(findDropdownItems()).toHaveLength(dropdownOptions.length); }); - - it('is opened on the click of vertical ellipsis and has 1 dropdown items when number of list items > 10', () => { - wrapper.destroy(); - - createComponent({ - list: { - ...mockList, - id: 'gid://gitlab/List/2', - }, - }); - findMoveToPositionDropdown().vm.$emit('click'); - expect(findDropdownItems()).toHaveLength(1); - }); }); describe('Dropdown options', () => { beforeEach(() => { - createComponent({ index: 1 }); + createComponent({ index: itemIndex }); trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn); dispatch = jest.spyOn(store, 'dispatch').mockImplementation(() => {}); }); @@ -109,13 +96,13 @@ describe('Board Card Move to position', () => { }); it.each` - dropdownIndex | dropdownLabel | trackLabel | moveAfterId | moveBeforeId - ${0} | ${BoardCardMoveToPosition.i18n.moveToStartText} | ${'move_to_start'} | ${mockIssue.id} | ${undefined} - ${1} | ${BoardCardMoveToPosition.i18n.moveToEndText} | ${'move_to_end'} | ${undefined} | ${mockIssue4.id} + dropdownIndex | dropdownLabel | trackLabel | positionInList + ${0} | ${BoardCardMoveToPosition.i18n.moveToStartText} | ${'move_to_start'} | ${0} + ${1} | ${BoardCardMoveToPosition.i18n.moveToEndText} | ${'move_to_end'} | ${-1} `( 'on click of dropdown index $dropdownIndex with label $dropdownLabel should call moveItem action with tracking label $trackLabel', - async ({ dropdownIndex, dropdownLabel, trackLabel, moveAfterId, moveBeforeId }) => { - await findEllipsesButton().vm.$emit('click'); + async ({ dropdownIndex, dropdownLabel, trackLabel, positionInList }) => { + await findMoveToPositionDropdown().vm.$emit('click'); expect(findDropdownItemAtIndex(dropdownIndex).text()).toBe(dropdownLabel); await findDropdownItemAtIndex(dropdownIndex).vm.$emit('click', { @@ -134,9 +121,10 @@ describe('Board Card Move to position', () => { itemId: mockIssue2.id, itemIid: mockIssue2.iid, itemPath: mockIssue2.referencePath, - moveBeforeId, - moveAfterId, + positionInList, toListId: mockList.id, + allItemsLoadedInList: true, + atIndex: itemIndex, }); }, ); diff --git a/spec/frontend/boards/stores/actions_spec.js b/spec/frontend/boards/stores/actions_spec.js index e48b946ff1b..e919300228a 100644 --- a/spec/frontend/boards/stores/actions_spec.js +++ b/spec/frontend/boards/stores/actions_spec.js @@ -1056,6 +1056,8 @@ describe('moveIssueCard and undoMoveIssueCard', () => { originalIndex = 0, moveBeforeId = undefined, moveAfterId = undefined, + allItemsLoadedInList = true, + listPosition = undefined, } = {}) => { state = { boardLists: { @@ -1065,12 +1067,28 @@ describe('moveIssueCard and undoMoveIssueCard', () => { boardItems: { [itemId]: originalIssue }, boardItemsByListId: { [fromListId]: [123] }, }; - params = { itemId, fromListId, toListId, moveBeforeId, moveAfterId }; + params = { + itemId, + fromListId, + toListId, + moveBeforeId, + moveAfterId, + listPosition, + allItemsLoadedInList, + }; moveMutations = [ { type: types.REMOVE_BOARD_ITEM_FROM_LIST, payload: { itemId, listId: fromListId } }, { type: types.ADD_BOARD_ITEM_TO_LIST, - payload: { itemId, listId: toListId, moveBeforeId, moveAfterId }, + payload: { + itemId, + listId: toListId, + moveBeforeId, + moveAfterId, + listPosition, + allItemsLoadedInList, + atIndex: originalIndex, + }, }, ]; undoMutations = [ @@ -1366,9 +1384,17 @@ describe('updateIssueOrder', () => { state, [ { + type: types.MUTATE_ISSUE_IN_PROGRESS, + payload: true, + }, + { type: types.MUTATE_ISSUE_SUCCESS, payload: { issue: rawIssue }, }, + { + type: types.MUTATE_ISSUE_IN_PROGRESS, + payload: false, + }, ], [], ); @@ -1390,6 +1416,14 @@ describe('updateIssueOrder', () => { state, [ { + type: types.MUTATE_ISSUE_IN_PROGRESS, + payload: true, + }, + { + type: types.MUTATE_ISSUE_IN_PROGRESS, + payload: false, + }, + { type: types.SET_ERROR, payload: 'An error occurred while moving the issue. Please try again.', }, diff --git a/spec/frontend/boards/stores/mutations_spec.js b/spec/frontend/boards/stores/mutations_spec.js index 1606ca09d8f..87a183c0441 100644 --- a/spec/frontend/boards/stores/mutations_spec.js +++ b/spec/frontend/boards/stores/mutations_spec.js @@ -513,6 +513,31 @@ describe('Board Store Mutations', () => { listState: [mockIssue2.id, mockIssue.id], }, ], + [ + 'to the top of the list', + { + payload: { + itemId: mockIssue2.id, + listId: mockList.id, + positionInList: 0, + atIndex: 1, + }, + listState: [mockIssue2.id, mockIssue.id], + }, + ], + [ + 'to the bottom of the list when the list is fully loaded', + { + payload: { + itemId: mockIssue2.id, + listId: mockList.id, + positionInList: -1, + atIndex: 0, + allItemsLoadedInList: true, + }, + listState: [mockIssue.id, mockIssue2.id], + }, + ], ])(`inserts an item into a list %s`, (_, { payload, listState }) => { mutations.ADD_BOARD_ITEM_TO_LIST(state, payload); diff --git a/spec/frontend/ide/stores/modules/commit/actions_spec.js b/spec/frontend/ide/stores/modules/commit/actions_spec.js index d65039e89cc..4e8467de759 100644 --- a/spec/frontend/ide/stores/modules/commit/actions_spec.js +++ b/spec/frontend/ide/stores/modules/commit/actions_spec.js @@ -210,7 +210,7 @@ describe('IDE commit module actions', () => { branch, }); store.state.openFiles.forEach((entry) => { - expect(entry.changed).toBeFalsy(); + expect(entry.changed).toBe(false); }); }); |