Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/boards')
-rw-r--r--spec/frontend/boards/board_card_spec.js2
-rw-r--r--spec/frontend/boards/components/board_column_spec.js5
-rw-r--r--spec/frontend/boards/components/board_form_spec.js2
-rw-r--r--spec/frontend/boards/components/board_list_header_spec.js5
-rw-r--r--spec/frontend/boards/components/board_settings_sidebar_spec.js159
-rw-r--r--spec/frontend/boards/components/boards_selector_spec.js4
-rw-r--r--spec/frontend/boards/components/sidebar/remove_issue_spec.js28
-rw-r--r--spec/frontend/boards/issue_card_spec.js2
-rw-r--r--spec/frontend/boards/issue_spec.js25
-rw-r--r--spec/frontend/boards/list_spec.js2
-rw-r--r--spec/frontend/boards/mock_data.js23
-rw-r--r--spec/frontend/boards/stores/actions_spec.js32
-rw-r--r--spec/frontend/boards/stores/mutations_spec.js47
13 files changed, 291 insertions, 45 deletions
diff --git a/spec/frontend/boards/board_card_spec.js b/spec/frontend/boards/board_card_spec.js
index 959c71d05ca..d01b895f996 100644
--- a/spec/frontend/boards/board_card_spec.js
+++ b/spec/frontend/boards/board_card_spec.js
@@ -5,8 +5,8 @@
import { shallowMount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter';
-import axios from '~/lib/utils/axios_utils';
import waitForPromises from 'helpers/wait_for_promises';
+import axios from '~/lib/utils/axios_utils';
import eventHub from '~/boards/eventhub';
import sidebarEventHub from '~/sidebar/event_hub';
diff --git a/spec/frontend/boards/components/board_column_spec.js b/spec/frontend/boards/components/board_column_spec.js
index 6853fe2559d..c06b7aceaad 100644
--- a/spec/frontend/boards/components/board_column_spec.js
+++ b/spec/frontend/boards/components/board_column_spec.js
@@ -2,14 +2,13 @@ import Vue from 'vue';
import { shallowMount } from '@vue/test-utils';
import AxiosMockAdapter from 'axios-mock-adapter';
+import { TEST_HOST } from 'helpers/test_constants';
+import { listObj } from 'jest/boards/mock_data';
import Board from '~/boards/components/board_column.vue';
import List from '~/boards/models/list';
import { ListType } from '~/boards/constants';
import axios from '~/lib/utils/axios_utils';
-import { TEST_HOST } from 'helpers/test_constants';
-import { listObj } from 'jest/boards/mock_data';
-
describe('Board Column Component', () => {
let wrapper;
let axiosMock;
diff --git a/spec/frontend/boards/components/board_form_spec.js b/spec/frontend/boards/components/board_form_spec.js
index 94f607698d7..b1d277863e8 100644
--- a/spec/frontend/boards/components/board_form_spec.js
+++ b/spec/frontend/boards/components/board_form_spec.js
@@ -1,9 +1,9 @@
import { mount } from '@vue/test-utils';
+import { TEST_HOST } from 'jest/helpers/test_constants';
import boardsStore from '~/boards/stores/boards_store';
import boardForm from '~/boards/components/board_form.vue';
import DeprecatedModal from '~/vue_shared/components/deprecated_modal.vue';
-import { TEST_HOST } from 'jest/helpers/test_constants';
describe('board_form.vue', () => {
let wrapper;
diff --git a/spec/frontend/boards/components/board_list_header_spec.js b/spec/frontend/boards/components/board_list_header_spec.js
index 95673da1c56..76a3d5e71c8 100644
--- a/spec/frontend/boards/components/board_list_header_spec.js
+++ b/spec/frontend/boards/components/board_list_header_spec.js
@@ -2,14 +2,13 @@ import Vue from 'vue';
import { shallowMount } from '@vue/test-utils';
import AxiosMockAdapter from 'axios-mock-adapter';
+import { TEST_HOST } from 'helpers/test_constants';
+import { listObj } from 'jest/boards/mock_data';
import BoardListHeader from '~/boards/components/board_list_header.vue';
import List from '~/boards/models/list';
import { ListType } from '~/boards/constants';
import axios from '~/lib/utils/axios_utils';
-import { TEST_HOST } from 'helpers/test_constants';
-import { listObj } from 'jest/boards/mock_data';
-
describe('Board List Header Component', () => {
let wrapper;
let axiosMock;
diff --git a/spec/frontend/boards/components/board_settings_sidebar_spec.js b/spec/frontend/boards/components/board_settings_sidebar_spec.js
new file mode 100644
index 00000000000..f39adc0fc49
--- /dev/null
+++ b/spec/frontend/boards/components/board_settings_sidebar_spec.js
@@ -0,0 +1,159 @@
+import '~/boards/models/list';
+import MockAdapter from 'axios-mock-adapter';
+import axios from 'axios';
+import Vuex from 'vuex';
+import { shallowMount, createLocalVue } from '@vue/test-utils';
+import { GlDrawer, GlLabel } from '@gitlab/ui';
+import BoardSettingsSidebar from '~/boards/components/board_settings_sidebar.vue';
+import boardsStore from '~/boards/stores/boards_store';
+import sidebarEventHub from '~/sidebar/event_hub';
+import { inactiveId } from '~/boards/constants';
+
+const localVue = createLocalVue();
+
+localVue.use(Vuex);
+
+describe('BoardSettingsSidebar', () => {
+ let wrapper;
+ let mock;
+ let storeActions;
+ const labelTitle = 'test';
+ const labelColor = '#FFFF';
+ const listId = 1;
+
+ const createComponent = (state = { activeId: inactiveId }, actions = {}) => {
+ storeActions = actions;
+
+ const store = new Vuex.Store({
+ state,
+ actions: storeActions,
+ });
+
+ wrapper = shallowMount(BoardSettingsSidebar, {
+ store,
+ localVue,
+ });
+ };
+ const findLabel = () => wrapper.find(GlLabel);
+ const findDrawer = () => wrapper.find(GlDrawer);
+
+ beforeEach(() => {
+ boardsStore.create();
+ });
+
+ afterEach(() => {
+ jest.restoreAllMocks();
+ wrapper.destroy();
+ });
+
+ it('finds a GlDrawer component', () => {
+ createComponent();
+
+ expect(findDrawer().exists()).toBe(true);
+ });
+
+ describe('on close', () => {
+ it('calls closeSidebar', async () => {
+ const spy = jest.fn();
+ createComponent({ activeId: inactiveId }, { setActiveId: spy });
+
+ findDrawer().vm.$emit('close');
+
+ await wrapper.vm.$nextTick();
+
+ expect(storeActions.setActiveId).toHaveBeenCalledWith(
+ expect.anything(),
+ inactiveId,
+ undefined,
+ );
+ });
+
+ it('calls closeSidebar on sidebar.closeAll event', async () => {
+ createComponent({ activeId: inactiveId }, { setActiveId: jest.fn() });
+
+ sidebarEventHub.$emit('sidebar.closeAll');
+
+ await wrapper.vm.$nextTick();
+
+ expect(storeActions.setActiveId).toHaveBeenCalledWith(
+ expect.anything(),
+ inactiveId,
+ undefined,
+ );
+ });
+ });
+
+ describe('when activeId is zero', () => {
+ it('renders GlDrawer with open false', () => {
+ createComponent();
+
+ expect(findDrawer().props('open')).toBe(false);
+ });
+ });
+
+ describe('when activeId is greater than zero', () => {
+ beforeEach(() => {
+ mock = new MockAdapter(axios);
+
+ boardsStore.addList({
+ id: listId,
+ label: { title: labelTitle, color: labelColor },
+ list_type: 'label',
+ });
+ });
+
+ afterEach(() => {
+ boardsStore.removeList(listId);
+ });
+
+ it('renders GlDrawer with open false', () => {
+ createComponent({ activeId: 1 });
+
+ expect(findDrawer().props('open')).toBe(true);
+ });
+ });
+
+ describe('when activeId is in boardsStore', () => {
+ beforeEach(() => {
+ mock = new MockAdapter(axios);
+
+ boardsStore.addList({
+ id: listId,
+ label: { title: labelTitle, color: labelColor },
+ list_type: 'label',
+ });
+
+ createComponent({ activeId: listId });
+ });
+
+ afterEach(() => {
+ mock.restore();
+ });
+
+ it('renders label title', () => {
+ expect(findLabel().props('title')).toBe(labelTitle);
+ });
+
+ it('renders label background color', () => {
+ expect(findLabel().props('backgroundColor')).toBe(labelColor);
+ });
+ });
+
+ describe('when activeId is not in boardsStore', () => {
+ beforeEach(() => {
+ mock = new MockAdapter(axios);
+
+ boardsStore.addList({ id: listId, label: { title: labelTitle, color: labelColor } });
+
+ createComponent({ activeId: inactiveId });
+ });
+
+ afterEach(() => {
+ mock.restore();
+ });
+
+ it('does not render GlLabel', () => {
+ expect(findLabel().exists()).toBe(false);
+ });
+ });
+});
diff --git a/spec/frontend/boards/components/boards_selector_spec.js b/spec/frontend/boards/components/boards_selector_spec.js
index b1ae86c2d3f..f2d4de238d1 100644
--- a/spec/frontend/boards/components/boards_selector_spec.js
+++ b/spec/frontend/boards/components/boards_selector_spec.js
@@ -1,6 +1,6 @@
import { nextTick } from 'vue';
import { mount } from '@vue/test-utils';
-import { GlDropdown, GlLoadingIcon } from '@gitlab/ui';
+import { GlDeprecatedDropdown, GlLoadingIcon } from '@gitlab/ui';
import { TEST_HOST } from 'spec/test_constants';
import BoardsSelector from '~/boards/components/boards_selector.vue';
import boardsStore from '~/boards/stores/boards_store';
@@ -103,7 +103,7 @@ describe('BoardsSelector', () => {
});
// Emits gl-dropdown show event to simulate the dropdown is opened at initialization time
- wrapper.find(GlDropdown).vm.$emit('show');
+ wrapper.find(GlDeprecatedDropdown).vm.$emit('show');
});
afterEach(() => {
diff --git a/spec/frontend/boards/components/sidebar/remove_issue_spec.js b/spec/frontend/boards/components/sidebar/remove_issue_spec.js
new file mode 100644
index 00000000000..a33e4046724
--- /dev/null
+++ b/spec/frontend/boards/components/sidebar/remove_issue_spec.js
@@ -0,0 +1,28 @@
+import { shallowMount } from '@vue/test-utils';
+import { GlButton } from '@gitlab/ui';
+
+import RemoveIssue from '~/boards/components/sidebar/remove_issue.vue';
+
+describe('boards sidebar remove issue', () => {
+ let wrapper;
+
+ const findButton = () => wrapper.find(GlButton);
+
+ const createComponent = propsData => {
+ wrapper = shallowMount(RemoveIssue, {
+ propsData: {
+ issue: {},
+ list: {},
+ ...propsData,
+ },
+ });
+ };
+
+ beforeEach(() => {
+ createComponent();
+ });
+
+ it('renders remove button', () => {
+ expect(findButton().exists()).toBe(true);
+ });
+});
diff --git a/spec/frontend/boards/issue_card_spec.js b/spec/frontend/boards/issue_card_spec.js
index 15750a161ae..dee8cb7b6e5 100644
--- a/spec/frontend/boards/issue_card_spec.js
+++ b/spec/frontend/boards/issue_card_spec.js
@@ -5,10 +5,10 @@ import '~/boards/models/label';
import '~/boards/models/assignee';
import '~/boards/models/issue';
import '~/boards/models/list';
+import { GlLabel } from '@gitlab/ui';
import IssueCardInner from '~/boards/components/issue_card_inner.vue';
import { listObj } from './mock_data';
import store from '~/boards/stores';
-import { GlLabel } from '@gitlab/ui';
describe('Issue card component', () => {
const user = new ListAssignee({
diff --git a/spec/frontend/boards/issue_spec.js b/spec/frontend/boards/issue_spec.js
index 412f20684f5..d68e17c06a7 100644
--- a/spec/frontend/boards/issue_spec.js
+++ b/spec/frontend/boards/issue_spec.js
@@ -5,7 +5,7 @@ import '~/boards/models/assignee';
import '~/boards/models/issue';
import '~/boards/models/list';
import boardsStore from '~/boards/stores/boards_store';
-import { setMockEndpoints } from './mock_data';
+import { setMockEndpoints, mockIssue } from './mock_data';
describe('Issue model', () => {
let issue;
@@ -14,28 +14,7 @@ describe('Issue model', () => {
setMockEndpoints();
boardsStore.create();
- issue = new ListIssue({
- title: 'Testing',
- id: 1,
- iid: 1,
- confidential: false,
- labels: [
- {
- id: 1,
- title: 'test',
- color: 'red',
- description: 'testing',
- },
- ],
- assignees: [
- {
- id: 1,
- name: 'name',
- username: 'username',
- avatar_url: 'http://avatar_url',
- },
- ],
- });
+ issue = new ListIssue(mockIssue);
});
it('has label', () => {
diff --git a/spec/frontend/boards/list_spec.js b/spec/frontend/boards/list_spec.js
index b30281f8df5..b731bb6e474 100644
--- a/spec/frontend/boards/list_spec.js
+++ b/spec/frontend/boards/list_spec.js
@@ -4,6 +4,7 @@
/* global ListLabel */
import MockAdapter from 'axios-mock-adapter';
+import waitForPromises from 'helpers/wait_for_promises';
import axios from '~/lib/utils/axios_utils';
import '~/boards/models/label';
import '~/boards/models/assignee';
@@ -11,7 +12,6 @@ import '~/boards/models/issue';
import '~/boards/models/list';
import { ListType } from '~/boards/constants';
import boardsStore from '~/boards/stores/boards_store';
-import waitForPromises from 'helpers/wait_for_promises';
import { listObj, listObjDuplicate, boardsMockInterceptor } from './mock_data';
describe('List model', () => {
diff --git a/spec/frontend/boards/mock_data.js b/spec/frontend/boards/mock_data.js
index 97d49de6f2e..8ef6efe23c7 100644
--- a/spec/frontend/boards/mock_data.js
+++ b/spec/frontend/boards/mock_data.js
@@ -92,6 +92,29 @@ export const mockMilestone = {
due_date: '2019-12-31',
};
+export const mockIssue = {
+ title: 'Testing',
+ id: 1,
+ iid: 1,
+ confidential: false,
+ labels: [
+ {
+ id: 1,
+ title: 'test',
+ color: 'red',
+ description: 'testing',
+ },
+ ],
+ assignees: [
+ {
+ id: 1,
+ name: 'name',
+ username: 'username',
+ avatar_url: 'http://avatar_url',
+ },
+ ],
+};
+
export const BoardsMockData = {
GET: {
'/test/-/boards/1/lists/300/issues?id=300&page=1': {
diff --git a/spec/frontend/boards/stores/actions_spec.js b/spec/frontend/boards/stores/actions_spec.js
index 0debca1310a..d539cba76ca 100644
--- a/spec/frontend/boards/stores/actions_spec.js
+++ b/spec/frontend/boards/stores/actions_spec.js
@@ -1,6 +1,7 @@
+import testAction from 'helpers/vuex_action_helper';
import actions from '~/boards/stores/actions';
import * as types from '~/boards/stores/mutation_types';
-import testAction from 'helpers/vuex_action_helper';
+import { inactiveId } from '~/boards/constants';
const expectNotImplemented = action => {
it('is not implemented', () => {
@@ -8,19 +9,36 @@ const expectNotImplemented = action => {
});
};
-describe('setEndpoints', () => {
- it('sets endpoints object', () => {
- const mockEndpoints = {
+describe('setInitialBoardData', () => {
+ it('sets data object', () => {
+ const mockData = {
foo: 'bar',
bar: 'baz',
};
return testAction(
- actions.setEndpoints,
- mockEndpoints,
+ actions.setInitialBoardData,
+ mockData,
{},
- [{ type: types.SET_ENDPOINTS, payload: mockEndpoints }],
+ [{ type: types.SET_INITIAL_BOARD_DATA, payload: mockData }],
+ [],
+ );
+ });
+});
+
+describe('setActiveId', () => {
+ it('should commit mutation SET_ACTIVE_ID', done => {
+ const state = {
+ activeId: inactiveId,
+ };
+
+ testAction(
+ actions.setActiveId,
+ 1,
+ state,
+ [{ type: types.SET_ACTIVE_ID, payload: 1 }],
[],
+ done,
);
});
});
diff --git a/spec/frontend/boards/stores/mutations_spec.js b/spec/frontend/boards/stores/mutations_spec.js
index bc57c30b354..c1f7f3dda6e 100644
--- a/spec/frontend/boards/stores/mutations_spec.js
+++ b/spec/frontend/boards/stores/mutations_spec.js
@@ -1,6 +1,6 @@
import mutations from '~/boards/stores/mutations';
-import * as types from '~/boards/stores/mutation_types';
import defaultState from '~/boards/stores/state';
+import { mockIssue } from '../mock_data';
const expectNotImplemented = action => {
it('is not implemented', () => {
@@ -15,7 +15,7 @@ describe('Board Store Mutations', () => {
state = defaultState();
});
- describe('SET_ENDPOINTS', () => {
+ describe('SET_INITIAL_BOARD_DATA', () => {
it('Should set initial Boards data to state', () => {
const endpoints = {
boardsEndpoint: '/boards/',
@@ -25,10 +25,22 @@ describe('Board Store Mutations', () => {
boardId: 1,
fullPath: 'gitlab-org',
};
+ const boardType = 'group';
- mutations[types.SET_ENDPOINTS](state, endpoints);
+ mutations.SET_INITIAL_BOARD_DATA(state, { ...endpoints, boardType });
expect(state.endpoints).toEqual(endpoints);
+ expect(state.boardType).toEqual(boardType);
+ });
+ });
+
+ describe('SET_ACTIVE_ID', () => {
+ it('updates activeListId to be the value that is passed', () => {
+ const expectedId = 1;
+
+ mutations.SET_ACTIVE_ID(state, expectedId);
+
+ expect(state.activeId).toBe(expectedId);
});
});
@@ -68,6 +80,35 @@ describe('Board Store Mutations', () => {
expectNotImplemented(mutations.RECEIVE_REMOVE_LIST_ERROR);
});
+ describe('REQUEST_ISSUES_FOR_ALL_LISTS', () => {
+ it('sets isLoadingIssues to true', () => {
+ expect(state.isLoadingIssues).toBe(false);
+
+ mutations.REQUEST_ISSUES_FOR_ALL_LISTS(state);
+
+ expect(state.isLoadingIssues).toBe(true);
+ });
+ });
+
+ describe('RECEIVE_ISSUES_FOR_ALL_LISTS_SUCCESS', () => {
+ it('sets isLoadingIssues to false and updates issuesByListId object', () => {
+ const listIssues = {
+ '1': [mockIssue],
+ };
+
+ state = {
+ ...state,
+ isLoadingIssues: true,
+ issuesByListId: {},
+ };
+
+ mutations.RECEIVE_ISSUES_FOR_ALL_LISTS_SUCCESS(state, listIssues);
+
+ expect(state.isLoadingIssues).toBe(false);
+ expect(state.issuesByListId).toEqual(listIssues);
+ });
+ });
+
describe('REQUEST_ADD_ISSUE', () => {
expectNotImplemented(mutations.REQUEST_ADD_ISSUE);
});