Commit eff1c121 authored by Simon Knox's avatar Simon Knox

backport boards specs

parent ff73a4ea
...@@ -145,7 +145,7 @@ describe('Api', () => { ...@@ -145,7 +145,7 @@ describe('Api', () => {
}); });
}); });
fdescribe('newLabel', () => { describe('newLabel', () => {
it('creates a new label', (done) => { it('creates a new label', (done) => {
const namespace = 'some namespace'; const namespace = 'some namespace';
const project = 'some project'; const project = 'some project';
......
/* global BoardService */ /* global BoardService */
/* global mockBoardService */
import Vue from 'vue'; import Vue from 'vue';
import '~/boards/stores/boards_store'; import '~/boards/stores/boards_store';
import boardBlankState from '~/boards/components/board_blank_state'; import boardBlankState from '~/boards/components/board_blank_state';
...@@ -12,7 +13,7 @@ describe('Boards blank state', () => { ...@@ -12,7 +13,7 @@ describe('Boards blank state', () => {
const Comp = Vue.extend(boardBlankState); const Comp = Vue.extend(boardBlankState);
gl.issueBoards.BoardsStore.create(); gl.issueBoards.BoardsStore.create();
gl.boardService = new BoardService('/test/issue-boards/board', '', '1'); gl.boardService = mockBoardService();
spyOn(gl.boardService, 'generateDefaultLists').and.callFake(() => new Promise((resolve, reject) => { spyOn(gl.boardService, 'generateDefaultLists').and.callFake(() => new Promise((resolve, reject) => {
if (fail) { if (fail) {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
/* global listObj */ /* global listObj */
/* global boardsMockInterceptor */ /* global boardsMockInterceptor */
/* global BoardService */ /* global BoardService */
/* global mockBoardService */
import Vue from 'vue'; import Vue from 'vue';
import '~/boards/models/assignee'; import '~/boards/models/assignee';
...@@ -14,13 +15,13 @@ import '~/boards/stores/boards_store'; ...@@ -14,13 +15,13 @@ import '~/boards/stores/boards_store';
import boardCard from '~/boards/components/board_card'; import boardCard from '~/boards/components/board_card';
import './mock_data'; import './mock_data';
describe('Issue card', () => { describe('Board card', () => {
let vm; let vm;
beforeEach((done) => { beforeEach((done) => {
Vue.http.interceptors.push(boardsMockInterceptor); Vue.http.interceptors.push(boardsMockInterceptor);
gl.boardService = new BoardService('/test/issue-boards/board', '', '1'); gl.boardService = mockBoardService();
gl.issueBoards.BoardsStore.create(); gl.issueBoards.BoardsStore.create();
gl.issueBoards.BoardsStore.detail.issue = {}; gl.issueBoards.BoardsStore.detail.issue = {};
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
/* global List */ /* global List */
/* global listObj */ /* global listObj */
/* global ListIssue */ /* global ListIssue */
/* global mockBoardService */
import Vue from 'vue'; import Vue from 'vue';
import _ from 'underscore'; import _ from 'underscore';
import Sortable from 'vendor/Sortable'; import Sortable from 'vendor/Sortable';
...@@ -24,7 +25,7 @@ describe('Board list component', () => { ...@@ -24,7 +25,7 @@ describe('Board list component', () => {
document.body.appendChild(el); document.body.appendChild(el);
Vue.http.interceptors.push(boardsMockInterceptor); Vue.http.interceptors.push(boardsMockInterceptor);
gl.boardService = new BoardService('/test/issue-boards/board', '', '1'); gl.boardService = mockBoardService();
gl.issueBoards.BoardsStore.create(); gl.issueBoards.BoardsStore.create();
gl.IssueBoardsApp = new Vue(); gl.IssueBoardsApp = new Vue();
...@@ -32,6 +33,7 @@ describe('Board list component', () => { ...@@ -32,6 +33,7 @@ describe('Board list component', () => {
const list = new List(listObj); const list = new List(listObj);
const issue = new ListIssue({ const issue = new ListIssue({
title: 'Testing', title: 'Testing',
id: 1,
iid: 1, iid: 1,
confidential: false, confidential: false,
labels: [], labels: [],
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
/* global BoardService */ /* global BoardService */
/* global List */ /* global List */
/* global listObj */ /* global listObj */
/* global mockBoardService */
import Vue from 'vue'; import Vue from 'vue';
import boardNewIssue from '~/boards/components/board_new_issue'; import boardNewIssue from '~/boards/components/board_new_issue';
...@@ -35,7 +36,7 @@ describe('Issue boards new issue form', () => { ...@@ -35,7 +36,7 @@ describe('Issue boards new issue form', () => {
const BoardNewIssueComp = Vue.extend(boardNewIssue); const BoardNewIssueComp = Vue.extend(boardNewIssue);
Vue.http.interceptors.push(boardsMockInterceptor); Vue.http.interceptors.push(boardsMockInterceptor);
gl.boardService = new BoardService('/test/issue-boards/board', '', '1'); gl.boardService = mockBoardService();
gl.issueBoards.BoardsStore.create(); gl.issueBoards.BoardsStore.create();
gl.IssueBoardsApp = new Vue(); gl.IssueBoardsApp = new Vue();
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
/* global listObj */ /* global listObj */
/* global listObjDuplicate */ /* global listObjDuplicate */
/* global ListIssue */ /* global ListIssue */
/* global mockBoardService */
import Vue from 'vue'; import Vue from 'vue';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
...@@ -20,7 +21,7 @@ import './mock_data'; ...@@ -20,7 +21,7 @@ import './mock_data';
describe('Store', () => { describe('Store', () => {
beforeEach(() => { beforeEach(() => {
Vue.http.interceptors.push(boardsMockInterceptor); Vue.http.interceptors.push(boardsMockInterceptor);
gl.boardService = new BoardService('/test/issue-boards/board', '', '1'); gl.boardService = mockBoardService();
gl.issueBoards.BoardsStore.create(); gl.issueBoards.BoardsStore.create();
spyOn(gl.boardService, 'moveIssue').and.callFake(() => new Promise((resolve) => { spyOn(gl.boardService, 'moveIssue').and.callFake(() => new Promise((resolve) => {
...@@ -78,7 +79,7 @@ describe('Store', () => { ...@@ -78,7 +79,7 @@ describe('Store', () => {
it('persists new list', (done) => { it('persists new list', (done) => {
gl.issueBoards.BoardsStore.new({ gl.issueBoards.BoardsStore.new({
title: 'Test', title: 'Test',
type: 'label', list_type: 'label',
label: { label: {
id: 1, id: 1,
title: 'Testing', title: 'Testing',
...@@ -210,6 +211,7 @@ describe('Store', () => { ...@@ -210,6 +211,7 @@ describe('Store', () => {
it('moves issue in list', (done) => { it('moves issue in list', (done) => {
const issue = new ListIssue({ const issue = new ListIssue({
title: 'Testing', title: 'Testing',
id: 2,
iid: 2, iid: 2,
confidential: false, confidential: false,
labels: [], labels: [],
......
/* global mockBoardService */
import Vue from 'vue'; import Vue from 'vue';
import '~/boards/services/board_service'; import '~/boards/services/board_service';
import '~/boards/components/board'; import '~/boards/components/board';
import '~/boards/models/list'; import '~/boards/models/list';
import '../mock_data';
describe('Board component', () => { describe('Board component', () => {
let vm; let vm;
...@@ -13,8 +15,12 @@ describe('Board component', () => { ...@@ -13,8 +15,12 @@ describe('Board component', () => {
el = document.createElement('div'); el = document.createElement('div');
document.body.appendChild(el); document.body.appendChild(el);
// eslint-disable-next-line no-undef gl.boardService = mockBoardService({
gl.boardService = new BoardService('/', '/', 1); boardsEndpoint: '/',
listsEndpoint: '/',
bulkUpdatePath: '/',
boardId: 1,
});
vm = new gl.issueBoards.Board({ vm = new gl.issueBoards.Board({
propsData: { propsData: {
......
...@@ -37,6 +37,7 @@ describe('Issue card component', () => { ...@@ -37,6 +37,7 @@ describe('Issue card component', () => {
list = listObj; list = listObj;
issue = new ListIssue({ issue = new ListIssue({
title: 'Testing', title: 'Testing',
id: 1,
iid: 1, iid: 1,
confidential: false, confidential: false,
labels: [list.label], labels: [list.label],
...@@ -238,65 +239,63 @@ describe('Issue card component', () => { ...@@ -238,65 +239,63 @@ describe('Issue card component', () => {
}); });
describe('labels', () => { describe('labels', () => {
describe('exists', () => { beforeEach((done) => {
beforeEach((done) => { component.issue.addLabel(label1);
component.issue.addLabel(label1);
Vue.nextTick(() => done()); Vue.nextTick(() => done());
}); });
it('renders list label', () => { it('renders list label', () => {
expect( expect(
component.$el.querySelectorAll('.label').length, component.$el.querySelectorAll('.label').length,
).toBe(2); ).toBe(2);
});
it('renders label', () => {
const nodes = [];
component.$el.querySelectorAll('.label').forEach((label) => {
nodes.push(label.title);
}); });
it('renders label', () => { expect(
const nodes = []; nodes.includes(label1.description),
component.$el.querySelectorAll('.label').forEach((label) => { ).toBe(true);
nodes.push(label.title); });
});
expect( it('sets label description as title', () => {
nodes.includes(label1.description), expect(
).toBe(true); component.$el.querySelector('.label').getAttribute('title'),
}); ).toContain(label1.description);
});
it('sets label description as title', () => { it('sets background color of button', () => {
expect( const nodes = [];
component.$el.querySelector('.label').getAttribute('title'), component.$el.querySelectorAll('.label').forEach((label) => {
).toContain(label1.description); nodes.push(label.style.backgroundColor);
}); });
it('sets background color of button', () => { expect(
const nodes = []; nodes.includes(label1.color),
component.$el.querySelectorAll('.label').forEach((label) => { ).toBe(true);
nodes.push(label.style.backgroundColor); });
});
expect( it('does not render label if label does not have an ID', (done) => {
nodes.includes(label1.color), component.issue.addLabel(new ListLabel({
).toBe(true); title: 'closed',
}); }));
it('does not render label if label does not have an ID', (done) => { Vue.nextTick()
component.issue.addLabel(new ListLabel({ .then(() => {
title: 'closed', expect(
})); component.$el.querySelectorAll('.label').length,
).toBe(2);
expect(
component.$el.textContent,
).not.toContain('closed');
Vue.nextTick() done();
.then(() => { })
expect( .catch(done.fail);
component.$el.querySelectorAll('.label').length,
).toBe(2);
expect(
component.$el.textContent,
).not.toContain('closed');
done();
})
.catch(done.fail);
});
}); });
}); });
}); });
/* eslint-disable comma-dangle */ /* eslint-disable comma-dangle */
/* global BoardService */ /* global BoardService */
/* global ListIssue */ /* global ListIssue */
/* global mockBoardService */
import Vue from 'vue'; import Vue from 'vue';
import '~/lib/utils/url_utility'; import '~/lib/utils/url_utility';
...@@ -16,11 +17,12 @@ describe('Issue model', () => { ...@@ -16,11 +17,12 @@ describe('Issue model', () => {
let issue; let issue;
beforeEach(() => { beforeEach(() => {
gl.boardService = new BoardService('/test/issue-boards/board', '', '1'); gl.boardService = mockBoardService();
gl.issueBoards.BoardsStore.create(); gl.issueBoards.BoardsStore.create();
issue = new ListIssue({ issue = new ListIssue({
title: 'Testing', title: 'Testing',
id: 1,
iid: 1, iid: 1,
confidential: false, confidential: false,
labels: [{ labels: [{
......
/* eslint-disable comma-dangle */ /* eslint-disable comma-dangle */
/* global boardsMockInterceptor */ /* global boardsMockInterceptor */
/* global BoardService */ /* global BoardService */
/* global mockBoardService */
/* global List */ /* global List */
/* global ListIssue */ /* global ListIssue */
/* global listObj */ /* global listObj */
...@@ -22,7 +23,9 @@ describe('List model', () => { ...@@ -22,7 +23,9 @@ describe('List model', () => {
beforeEach(() => { beforeEach(() => {
Vue.http.interceptors.push(boardsMockInterceptor); Vue.http.interceptors.push(boardsMockInterceptor);
gl.boardService = new BoardService('/test/issue-boards/board', '', '1'); gl.boardService = mockBoardService({
bulkUpdatePath: '/test/issue-boards/board/1/lists',
});
gl.issueBoards.BoardsStore.create(); gl.issueBoards.BoardsStore.create();
list = new List(listObj); list = new List(listObj);
...@@ -92,6 +95,7 @@ describe('List model', () => { ...@@ -92,6 +95,7 @@ describe('List model', () => {
const listDup = new List(listObjDuplicate); const listDup = new List(listObjDuplicate);
const issue = new ListIssue({ const issue = new ListIssue({
title: 'Testing', title: 'Testing',
id: _.random(10000),
iid: _.random(10000), iid: _.random(10000),
confidential: false, confidential: false,
labels: [list.label, listDup.label], labels: [list.label, listDup.label],
...@@ -118,6 +122,7 @@ describe('List model', () => { ...@@ -118,6 +122,7 @@ describe('List model', () => {
for (let i = 0; i < 30; i += 1) { for (let i = 0; i < 30; i += 1) {
list.issues.push(new ListIssue({ list.issues.push(new ListIssue({
title: 'Testing', title: 'Testing',
id: _.random(10000) + i,
iid: _.random(10000) + i, iid: _.random(10000) + i,
confidential: false, confidential: false,
labels: [list.label], labels: [list.label],
...@@ -137,7 +142,7 @@ describe('List model', () => { ...@@ -137,7 +142,7 @@ describe('List model', () => {
it('does not increase page number if issue count is less than the page size', () => { it('does not increase page number if issue count is less than the page size', () => {
list.issues.push(new ListIssue({ list.issues.push(new ListIssue({
title: 'Testing', title: 'Testing',
iid: _.random(10000), id: _.random(10000),
confidential: false, confidential: false,
labels: [list.label], labels: [list.label],
assignees: [], assignees: [],
...@@ -156,7 +161,7 @@ describe('List model', () => { ...@@ -156,7 +161,7 @@ describe('List model', () => {
spyOn(gl.boardService, 'newIssue').and.returnValue(Promise.resolve({ spyOn(gl.boardService, 'newIssue').and.returnValue(Promise.resolve({
json() { json() {
return { return {
iid: 42, id: 42,
}; };
}, },
})); }));
...@@ -165,14 +170,14 @@ describe('List model', () => { ...@@ -165,14 +170,14 @@ describe('List model', () => {
it('adds new issue to top of list', (done) => { it('adds new issue to top of list', (done) => {
list.issues.push(new ListIssue({ list.issues.push(new ListIssue({
title: 'Testing', title: 'Testing',
iid: _.random(10000), id: _.random(10000),
confidential: false, confidential: false,
labels: [list.label], labels: [list.label],
assignees: [], assignees: [],
})); }));
const dummyIssue = new ListIssue({ const dummyIssue = new ListIssue({
title: 'new issue', title: 'new issue',
iid: _.random(10000), id: _.random(10000),
confidential: false, confidential: false,
labels: [list.label], labels: [list.label],
assignees: [], assignees: [],
......
/* global BoardService */
/* eslint-disable comma-dangle, no-unused-vars, quote-props */ /* eslint-disable comma-dangle, no-unused-vars, quote-props */
const listObj = { const listObj = {
...@@ -28,19 +29,19 @@ const listObjDuplicate = { ...@@ -28,19 +29,19 @@ const listObjDuplicate = {
const BoardsMockData = { const BoardsMockData = {
'GET': { 'GET': {
'/test/issue-boards/board/1/lists{/id}/issues': { '/test/boards/1{/id}/issues': {
issues: [{ issues: [{
title: 'Testing', title: 'Testing',
id: 1,
iid: 1, iid: 1,
confidential: false, confidential: false,
labels: [], labels: [],
assignees: [], assignees: [],
}], }],
size: 1
} }
}, },
'POST': { 'POST': {
'/test/issue-boards/board/1/lists{/id}': listObj '/test/boards/1{/id}': listObj
}, },
'PUT': { 'PUT': {
'/test/issue-boards/board/1/lists{/id}': {} '/test/issue-boards/board/1/lists{/id}': {}
...@@ -58,7 +59,22 @@ const boardsMockInterceptor = (request, next) => { ...@@ -58,7 +59,22 @@ const boardsMockInterceptor = (request, next) => {
})); }));
}; };
const mockBoardService = (opts = {}) => {
const boardsEndpoint = opts.boardsEndpoint || '/test/issue-boards/board';
const listsEndpoint = opts.listsEndpoint || '/test/boards/1';
const bulkUpdatePath = opts.bulkUpdatePath || '';
const boardId = opts.boardId || '1';
return new BoardService({
boardsEndpoint,
listsEndpoint,
bulkUpdatePath,
boardId,
});
};
window.listObj = listObj; window.listObj = listObj;
window.listObjDuplicate = listObjDuplicate; window.listObjDuplicate = listObjDuplicate;
window.BoardsMockData = BoardsMockData; window.BoardsMockData = BoardsMockData;
window.boardsMockInterceptor = boardsMockInterceptor; window.boardsMockInterceptor = boardsMockInterceptor;
window.mockBoardService = mockBoardService;
...@@ -18,6 +18,7 @@ describe('Modal store', () => { ...@@ -18,6 +18,7 @@ describe('Modal store', () => {
issue = new ListIssue({ issue = new ListIssue({
title: 'Testing', title: 'Testing',
id: 1,
iid: 1, iid: 1,
confidential: false, confidential: false,
labels: [], labels: [],
...@@ -25,6 +26,7 @@ describe('Modal store', () => { ...@@ -25,6 +26,7 @@ describe('Modal store', () => {
}); });
issue2 = new ListIssue({ issue2 = new ListIssue({
title: 'Testing', title: 'Testing',
id: 1,
iid: 2, iid: 2,
confidential: false, confidential: false,
labels: [], labels: [],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment