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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-31 21:07:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-31 21:07:42 +0300
commit580622bdb3c762a8e89facd8a3946881ee480442 (patch)
tree3ac9d759da23f78f95f50684bd238a9f76839538 /spec/javascripts
parentb211a4ea14d5e9ed9b0c248a4e8c5c1d85b542cb (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/boards/board_card_spec.js215
-rw-r--r--spec/javascripts/boards/board_list_spec.js262
-rw-r--r--spec/javascripts/boards/list_spec.js225
3 files changed, 0 insertions, 702 deletions
diff --git a/spec/javascripts/boards/board_card_spec.js b/spec/javascripts/boards/board_card_spec.js
deleted file mode 100644
index 2b0eee8b95d..00000000000
--- a/spec/javascripts/boards/board_card_spec.js
+++ /dev/null
@@ -1,215 +0,0 @@
-/* global List */
-/* global ListAssignee */
-/* global ListLabel */
-
-import Vue from 'vue';
-import MockAdapter from 'axios-mock-adapter';
-import axios from '~/lib/utils/axios_utils';
-
-import eventHub from '~/boards/eventhub';
-import '~/boards/models/label';
-import '~/boards/models/assignee';
-import '~/boards/models/list';
-import store from '~/boards/stores';
-import boardsStore from '~/boards/stores/boards_store';
-import boardCard from '~/boards/components/board_card.vue';
-import { listObj, boardsMockInterceptor, setMockEndpoints } from './mock_data';
-
-describe('Board card', () => {
- let vm;
- let mock;
-
- beforeEach(done => {
- mock = new MockAdapter(axios);
- mock.onAny().reply(boardsMockInterceptor);
- setMockEndpoints();
-
- boardsStore.create();
- boardsStore.detail.issue = {};
-
- const BoardCardComp = Vue.extend(boardCard);
- const list = new List(listObj);
- const label1 = new ListLabel({
- id: 3,
- title: 'testing 123',
- color: '#000cff',
- text_color: 'white',
- description: 'test',
- });
-
- setTimeout(() => {
- list.issues[0].labels.push(label1);
-
- vm = new BoardCardComp({
- store,
- propsData: {
- list,
- issue: list.issues[0],
- issueLinkBase: '/',
- disabled: false,
- index: 0,
- rootPath: '/',
- },
- }).$mount();
- done();
- }, 0);
- });
-
- afterEach(() => {
- mock.restore();
- });
-
- it('returns false when detailIssue is empty', () => {
- expect(vm.issueDetailVisible).toBe(false);
- });
-
- it('returns true when detailIssue is equal to card issue', () => {
- boardsStore.detail.issue = vm.issue;
-
- expect(vm.issueDetailVisible).toBe(true);
- });
-
- it("returns false when multiSelect doesn't contain issue", () => {
- expect(vm.multiSelectVisible).toBe(false);
- });
-
- it('returns true when multiSelect contains issue', () => {
- boardsStore.multiSelect.list = [vm.issue];
-
- expect(vm.multiSelectVisible).toBe(true);
- });
-
- it('adds user-can-drag class if not disabled', () => {
- expect(vm.$el.classList.contains('user-can-drag')).toBe(true);
- });
-
- it('does not add user-can-drag class disabled', done => {
- vm.disabled = true;
-
- setTimeout(() => {
- expect(vm.$el.classList.contains('user-can-drag')).toBe(false);
- done();
- }, 0);
- });
-
- it('does not add disabled class', () => {
- expect(vm.$el.classList.contains('is-disabled')).toBe(false);
- });
-
- it('adds disabled class is disabled is true', done => {
- vm.disabled = true;
-
- setTimeout(() => {
- expect(vm.$el.classList.contains('is-disabled')).toBe(true);
- done();
- }, 0);
- });
-
- describe('mouse events', () => {
- const triggerEvent = (eventName, el = vm.$el) => {
- const event = document.createEvent('MouseEvents');
- event.initMouseEvent(
- eventName,
- true,
- true,
- window,
- 1,
- 0,
- 0,
- 0,
- 0,
- false,
- false,
- false,
- false,
- 0,
- null,
- );
-
- el.dispatchEvent(event);
- };
-
- it('sets showDetail to true on mousedown', () => {
- triggerEvent('mousedown');
-
- expect(vm.showDetail).toBe(true);
- });
-
- it('sets showDetail to false on mousemove', () => {
- triggerEvent('mousedown');
-
- expect(vm.showDetail).toBe(true);
-
- triggerEvent('mousemove');
-
- expect(vm.showDetail).toBe(false);
- });
-
- it('does not set detail issue if showDetail is false', () => {
- expect(boardsStore.detail.issue).toEqual({});
- });
-
- it('does not set detail issue if link is clicked', () => {
- triggerEvent('mouseup', vm.$el.querySelector('a'));
-
- expect(boardsStore.detail.issue).toEqual({});
- });
-
- it('does not set detail issue if img is clicked', done => {
- vm.issue.assignees = [
- new ListAssignee({
- id: 1,
- name: 'testing 123',
- username: 'test',
- avatar: 'test_image',
- }),
- ];
-
- Vue.nextTick(() => {
- triggerEvent('mouseup', vm.$el.querySelector('img'));
-
- expect(boardsStore.detail.issue).toEqual({});
-
- done();
- });
- });
-
- it('does not set detail issue if showDetail is false after mouseup', () => {
- triggerEvent('mouseup');
-
- expect(boardsStore.detail.issue).toEqual({});
- });
-
- it('sets detail issue to card issue on mouse up', () => {
- spyOn(eventHub, '$emit');
-
- triggerEvent('mousedown');
- triggerEvent('mouseup');
-
- expect(eventHub.$emit).toHaveBeenCalledWith('newDetailIssue', vm.issue, undefined);
- expect(boardsStore.detail.list).toEqual(vm.list);
- });
-
- it('adds active class if detail issue is set', done => {
- vm.detailIssue.issue = vm.issue;
-
- Vue.nextTick()
- .then(() => {
- expect(vm.$el.classList.contains('is-active')).toBe(true);
- })
- .then(done)
- .catch(done.fail);
- });
-
- it('resets detail issue to empty if already set', () => {
- spyOn(eventHub, '$emit');
-
- boardsStore.detail.issue = vm.issue;
-
- triggerEvent('mousedown');
- triggerEvent('mouseup');
-
- expect(eventHub.$emit).toHaveBeenCalledWith('clearDetailIssue', undefined);
- });
- });
-});
diff --git a/spec/javascripts/boards/board_list_spec.js b/spec/javascripts/boards/board_list_spec.js
deleted file mode 100644
index b4e1d3b97b1..00000000000
--- a/spec/javascripts/boards/board_list_spec.js
+++ /dev/null
@@ -1,262 +0,0 @@
-/* global List */
-
-import Vue from 'vue';
-import eventHub from '~/boards/eventhub';
-import createComponent from './board_list_common_spec';
-import waitForPromises from '../helpers/wait_for_promises';
-
-import '~/boards/models/list';
-
-describe('Board list component', () => {
- let mock;
- let component;
- let getIssues;
- function generateIssues(compWrapper) {
- for (let i = 1; i < 20; i += 1) {
- const issue = Object.assign({}, compWrapper.list.issues[0]);
- issue.id += i;
- compWrapper.list.issues.push(issue);
- }
- }
-
- describe('When Expanded', () => {
- beforeEach(done => {
- getIssues = spyOn(List.prototype, 'getIssues').and.returnValue(new Promise(() => {}));
- ({ mock, component } = createComponent({ done }));
- });
-
- afterEach(() => {
- mock.restore();
- component.$destroy();
- });
-
- it('loads first page of issues', done => {
- waitForPromises()
- .then(() => {
- expect(getIssues).toHaveBeenCalled();
- })
- .then(done)
- .catch(done.fail);
- });
-
- it('renders component', () => {
- expect(component.$el.classList.contains('board-list-component')).toBe(true);
- });
-
- it('renders loading icon', done => {
- component.loading = true;
-
- Vue.nextTick(() => {
- expect(component.$el.querySelector('.board-list-loading')).not.toBeNull();
-
- done();
- });
- });
-
- it('renders issues', () => {
- expect(component.$el.querySelectorAll('.board-card').length).toBe(1);
- });
-
- it('sets data attribute with issue id', () => {
- expect(component.$el.querySelector('.board-card').getAttribute('data-issue-id')).toBe('1');
- });
-
- it('shows new issue form', done => {
- component.toggleForm();
-
- Vue.nextTick(() => {
- expect(component.$el.querySelector('.board-new-issue-form')).not.toBeNull();
-
- expect(component.$el.querySelector('.is-smaller')).not.toBeNull();
-
- done();
- });
- });
-
- it('shows new issue form after eventhub event', done => {
- eventHub.$emit(`hide-issue-form-${component.list.id}`);
-
- Vue.nextTick(() => {
- expect(component.$el.querySelector('.board-new-issue-form')).not.toBeNull();
-
- expect(component.$el.querySelector('.is-smaller')).not.toBeNull();
-
- done();
- });
- });
-
- it('does not show new issue form for closed list', done => {
- component.list.type = 'closed';
- component.toggleForm();
-
- Vue.nextTick(() => {
- expect(component.$el.querySelector('.board-new-issue-form')).toBeNull();
-
- done();
- });
- });
-
- it('shows count list item', done => {
- component.showCount = true;
-
- Vue.nextTick(() => {
- expect(component.$el.querySelector('.board-list-count')).not.toBeNull();
-
- expect(component.$el.querySelector('.board-list-count').textContent.trim()).toBe(
- 'Showing all issues',
- );
-
- done();
- });
- });
-
- it('sets data attribute with invalid id', done => {
- component.showCount = true;
-
- Vue.nextTick(() => {
- expect(component.$el.querySelector('.board-list-count').getAttribute('data-issue-id')).toBe(
- '-1',
- );
-
- done();
- });
- });
-
- it('shows how many more issues to load', done => {
- component.showCount = true;
- component.list.issuesSize = 20;
-
- Vue.nextTick(() => {
- expect(component.$el.querySelector('.board-list-count').textContent.trim()).toBe(
- 'Showing 1 of 20 issues',
- );
-
- done();
- });
- });
-
- it('loads more issues after scrolling', done => {
- spyOn(component.list, 'nextPage');
- component.$refs.list.style.height = '100px';
- component.$refs.list.style.overflow = 'scroll';
- generateIssues(component);
-
- Vue.nextTick(() => {
- component.$refs.list.scrollTop = 20000;
-
- waitForPromises()
- .then(() => {
- expect(component.list.nextPage).toHaveBeenCalled();
- })
- .then(done)
- .catch(done.fail);
- });
- });
-
- it('does not load issues if already loading', done => {
- component.list.nextPage = spyOn(component.list, 'nextPage').and.returnValue(
- new Promise(() => {}),
- );
-
- component.onScroll();
- component.onScroll();
-
- waitForPromises()
- .then(() => {
- expect(component.list.nextPage).toHaveBeenCalledTimes(1);
- })
- .then(done)
- .catch(done.fail);
- });
-
- it('shows loading more spinner', done => {
- component.showCount = true;
- component.list.loadingMore = true;
-
- Vue.nextTick(() => {
- expect(component.$el.querySelector('.board-list-count .gl-spinner')).not.toBeNull();
-
- done();
- });
- });
- });
-
- describe('When Collapsed', () => {
- beforeEach(done => {
- getIssues = spyOn(List.prototype, 'getIssues').and.returnValue(new Promise(() => {}));
- ({ mock, component } = createComponent({
- done,
- listProps: { type: 'closed', collapsed: true, issuesSize: 50 },
- }));
- generateIssues(component);
- component.scrollHeight = spyOn(component, 'scrollHeight').and.returnValue(0);
- });
-
- afterEach(() => {
- mock.restore();
- component.$destroy();
- });
-
- it('does not load all issues', done => {
- waitForPromises()
- .then(() => {
- // Initial getIssues from list constructor
- expect(getIssues).toHaveBeenCalledTimes(1);
- })
- .then(done)
- .catch(done.fail);
- });
- });
-
- describe('max issue count warning', () => {
- beforeEach(done => {
- ({ mock, component } = createComponent({
- done,
- listProps: { type: 'closed', collapsed: true, issuesSize: 50 },
- }));
- });
-
- afterEach(() => {
- mock.restore();
- component.$destroy();
- });
-
- describe('when issue count exceeds max issue count', () => {
- it('sets background to bg-danger-100', done => {
- component.list.issuesSize = 4;
- component.list.maxIssueCount = 3;
-
- Vue.nextTick(() => {
- expect(component.$el.querySelector('.bg-danger-100')).not.toBeNull();
-
- done();
- });
- });
- });
-
- describe('when list issue count does NOT exceed list max issue count', () => {
- it('does not sets background to bg-danger-100', done => {
- component.list.issuesSize = 2;
- component.list.maxIssueCount = 3;
-
- Vue.nextTick(() => {
- expect(component.$el.querySelector('.bg-danger-100')).toBeNull();
-
- done();
- });
- });
- });
-
- describe('when list max issue count is 0', () => {
- it('does not sets background to bg-danger-100', done => {
- component.list.maxIssueCount = 0;
-
- Vue.nextTick(() => {
- expect(component.$el.querySelector('.bg-danger-100')).toBeNull();
-
- done();
- });
- });
- });
- });
-});
diff --git a/spec/javascripts/boards/list_spec.js b/spec/javascripts/boards/list_spec.js
deleted file mode 100644
index 7385bfb0e5f..00000000000
--- a/spec/javascripts/boards/list_spec.js
+++ /dev/null
@@ -1,225 +0,0 @@
-/* global List */
-/* global ListAssignee */
-/* global ListIssue */
-/* global ListLabel */
-
-import MockAdapter from 'axios-mock-adapter';
-import axios from '~/lib/utils/axios_utils';
-import '~/boards/models/label';
-import '~/boards/models/assignee';
-import '~/boards/models/issue';
-import '~/boards/models/list';
-import boardsStore from '~/boards/stores/boards_store';
-import { listObj, listObjDuplicate, boardsMockInterceptor } from './mock_data';
-
-describe('List model', () => {
- let list;
- let mock;
-
- beforeEach(() => {
- mock = new MockAdapter(axios);
- mock.onAny().reply(boardsMockInterceptor);
- boardsStore.create();
-
- list = new List(listObj);
- });
-
- afterEach(() => {
- mock.restore();
- });
-
- it('gets issues when created', done => {
- setTimeout(() => {
- expect(list.issues.length).toBe(1);
- done();
- }, 0);
- });
-
- it('saves list and returns ID', done => {
- list = new List({
- title: 'test',
- label: {
- id: 1,
- title: 'test',
- color: 'red',
- text_color: 'white',
- },
- });
- list.save();
-
- setTimeout(() => {
- expect(list.id).toBe(listObj.id);
- expect(list.type).toBe('label');
- expect(list.position).toBe(0);
- expect(list.label.color).toBe('red');
- expect(list.label.textColor).toBe('white');
- done();
- }, 0);
- });
-
- it('destroys the list', done => {
- boardsStore.addList(listObj);
- list = boardsStore.findList('id', listObj.id);
-
- expect(boardsStore.state.lists.length).toBe(1);
- list.destroy();
-
- setTimeout(() => {
- expect(boardsStore.state.lists.length).toBe(0);
- done();
- }, 0);
- });
-
- it('gets issue from list', done => {
- setTimeout(() => {
- const issue = list.findIssue(1);
-
- expect(issue).toBeDefined();
- done();
- }, 0);
- });
-
- it('removes issue', done => {
- setTimeout(() => {
- const issue = list.findIssue(1);
-
- expect(list.issues.length).toBe(1);
- list.removeIssue(issue);
-
- expect(list.issues.length).toBe(0);
- done();
- }, 0);
- });
-
- it('sends service request to update issue label', () => {
- const listDup = new List(listObjDuplicate);
- const issue = new ListIssue({
- title: 'Testing',
- id: 1,
- iid: 1,
- confidential: false,
- labels: [list.label, listDup.label],
- assignees: [],
- });
-
- list.issues.push(issue);
- listDup.issues.push(issue);
-
- spyOn(boardsStore, 'moveIssue').and.callThrough();
-
- listDup.updateIssueLabel(issue, list);
-
- expect(boardsStore.moveIssue).toHaveBeenCalledWith(
- issue.id,
- list.id,
- listDup.id,
- undefined,
- undefined,
- );
- });
-
- describe('page number', () => {
- beforeEach(() => {
- spyOn(list, 'getIssues');
- });
-
- it('increase page number if current issue count is more than the page size', () => {
- for (let i = 0; i < 30; i += 1) {
- list.issues.push(
- new ListIssue({
- title: 'Testing',
- id: i,
- iid: i,
- confidential: false,
- labels: [list.label],
- assignees: [],
- }),
- );
- }
- list.issuesSize = 50;
-
- expect(list.issues.length).toBe(30);
-
- list.nextPage();
-
- expect(list.page).toBe(2);
- expect(list.getIssues).toHaveBeenCalled();
- });
-
- it('does not increase page number if issue count is less than the page size', () => {
- list.issues.push(
- new ListIssue({
- title: 'Testing',
- id: 1,
- confidential: false,
- labels: [list.label],
- assignees: [],
- }),
- );
- list.issuesSize = 2;
-
- list.nextPage();
-
- expect(list.page).toBe(1);
- expect(list.getIssues).toHaveBeenCalled();
- });
- });
-
- describe('newIssue', () => {
- beforeEach(() => {
- spyOn(boardsStore, 'newIssue').and.returnValue(
- Promise.resolve({
- data: {
- id: 42,
- subscribed: false,
- assignable_labels_endpoint: '/issue/42/labels',
- toggle_subscription_endpoint: '/issue/42/subscriptions',
- issue_sidebar_endpoint: '/issue/42/sidebar_info',
- },
- }),
- );
- });
-
- it('adds new issue to top of list', done => {
- const user = new ListAssignee({
- id: 1,
- name: 'testing 123',
- username: 'test',
- avatar: 'test_image',
- });
-
- list.issues.push(
- new ListIssue({
- title: 'Testing',
- id: 1,
- confidential: false,
- labels: [new ListLabel(list.label)],
- assignees: [],
- }),
- );
- const dummyIssue = new ListIssue({
- title: 'new issue',
- id: 2,
- confidential: false,
- labels: [new ListLabel(list.label)],
- assignees: [user],
- subscribed: false,
- });
-
- list
- .newIssue(dummyIssue)
- .then(() => {
- expect(list.issues.length).toBe(2);
- expect(list.issues[0]).toBe(dummyIssue);
- expect(list.issues[0].subscribed).toBe(false);
- expect(list.issues[0].assignableLabelsEndpoint).toBe('/issue/42/labels');
- expect(list.issues[0].toggleSubscriptionEndpoint).toBe('/issue/42/subscriptions');
- expect(list.issues[0].sidebarInfoEndpoint).toBe('/issue/42/sidebar_info');
- expect(list.issues[0].labels).toBe(dummyIssue.labels);
- expect(list.issues[0].assignees).toBe(dummyIssue.assignees);
- })
- .then(done)
- .catch(done.fail);
- });
- });
-});