2021-06-21 15:07:30 +00:00
|
|
|
import { GlLabel, GlLoadingIcon, GlTooltip } from '@gitlab/ui';
|
2020-01-22 00:08:47 +00:00
|
|
|
import { range } from 'lodash';
|
2021-03-16 06:09:57 +00:00
|
|
|
import Vuex from 'vuex';
|
2021-08-02 18:08:48 +00:00
|
|
|
import setWindowLocation from 'helpers/set_window_location_helper';
|
2021-09-13 15:10:34 +00:00
|
|
|
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
|
2021-06-21 15:07:30 +00:00
|
|
|
import { mountExtended } from 'helpers/vue_test_utils_helper';
|
2021-03-16 06:09:57 +00:00
|
|
|
import BoardBlockedIcon from '~/boards/components/board_blocked_icon.vue';
|
2021-02-25 06:10:51 +00:00
|
|
|
import BoardCardInner from '~/boards/components/board_card_inner.vue';
|
2021-03-16 06:09:57 +00:00
|
|
|
import { issuableTypes } from '~/boards/constants';
|
2020-12-22 12:10:09 +00:00
|
|
|
import eventHub from '~/boards/eventhub';
|
2021-02-14 18:09:20 +00:00
|
|
|
import defaultStore from '~/boards/stores';
|
2020-12-22 12:10:09 +00:00
|
|
|
import { updateHistory } from '~/lib/utils/url_utility';
|
2021-08-11 06:10:02 +00:00
|
|
|
import { mockLabelList, mockIssue, mockIssueFullPath } from './mock_data';
|
2020-12-22 12:10:09 +00:00
|
|
|
|
|
|
|
jest.mock('~/lib/utils/url_utility');
|
|
|
|
jest.mock('~/boards/eventhub');
|
2019-10-31 09:06:29 +00:00
|
|
|
|
2021-02-25 06:10:51 +00:00
|
|
|
describe('Board card component', () => {
|
2020-12-22 12:10:09 +00:00
|
|
|
const user = {
|
2019-10-31 09:06:29 +00:00
|
|
|
id: 1,
|
|
|
|
name: 'testing 123',
|
|
|
|
username: 'test',
|
2020-12-22 12:10:09 +00:00
|
|
|
avatarUrl: 'test_image',
|
|
|
|
};
|
2019-10-31 09:06:29 +00:00
|
|
|
|
2020-12-22 12:10:09 +00:00
|
|
|
const label1 = {
|
2019-10-31 09:06:29 +00:00
|
|
|
id: 3,
|
|
|
|
title: 'testing 123',
|
2020-03-09 09:07:45 +00:00
|
|
|
color: '#000CFF',
|
2020-12-22 12:10:09 +00:00
|
|
|
textColor: 'white',
|
2019-10-31 09:06:29 +00:00
|
|
|
description: 'test',
|
2020-12-22 12:10:09 +00:00
|
|
|
};
|
2019-10-31 09:06:29 +00:00
|
|
|
|
|
|
|
let wrapper;
|
|
|
|
let issue;
|
|
|
|
let list;
|
2021-03-16 06:09:57 +00:00
|
|
|
let store;
|
|
|
|
|
|
|
|
const findBoardBlockedIcon = () => wrapper.find(BoardBlockedIcon);
|
2021-06-21 15:07:30 +00:00
|
|
|
const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
|
|
|
|
const findEpicCountablesTotalTooltip = () => wrapper.findComponent(GlTooltip);
|
|
|
|
const findEpicCountables = () => wrapper.findByTestId('epic-countables');
|
|
|
|
const findEpicCountablesBadgeIssues = () => wrapper.findByTestId('epic-countables-counts-issues');
|
|
|
|
const findEpicCountablesBadgeWeight = () => wrapper.findByTestId('epic-countables-weight-issues');
|
2021-07-13 06:10:10 +00:00
|
|
|
const findEpicBadgeProgress = () => wrapper.findByTestId('epic-progress');
|
2021-06-21 15:07:30 +00:00
|
|
|
const findEpicCountablesTotalWeight = () => wrapper.findByTestId('epic-countables-total-weight');
|
2021-07-13 06:10:10 +00:00
|
|
|
const findEpicProgressTooltip = () => wrapper.findByTestId('epic-progress-tooltip-content');
|
2021-09-13 15:10:34 +00:00
|
|
|
const findHiddenIssueIcon = () => wrapper.findByTestId('hidden-icon');
|
2021-06-21 15:07:30 +00:00
|
|
|
|
2021-08-11 06:10:02 +00:00
|
|
|
const createStore = ({ isEpicBoard = false, isProjectBoard = false } = {}) => {
|
2021-03-16 06:09:57 +00:00
|
|
|
store = new Vuex.Store({
|
|
|
|
...defaultStore,
|
|
|
|
state: {
|
|
|
|
...defaultStore.state,
|
|
|
|
issuableType: issuableTypes.issue,
|
|
|
|
},
|
|
|
|
getters: {
|
|
|
|
isGroupBoard: () => true,
|
2021-06-21 15:07:30 +00:00
|
|
|
isEpicBoard: () => isEpicBoard,
|
2021-08-11 06:10:02 +00:00
|
|
|
isProjectBoard: () => isProjectBoard,
|
2021-03-16 06:09:57 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const createWrapper = (props = {}) => {
|
2021-06-21 15:07:30 +00:00
|
|
|
wrapper = mountExtended(BoardCardInner, {
|
2020-12-22 12:10:09 +00:00
|
|
|
store,
|
2019-10-31 09:06:29 +00:00
|
|
|
propsData: {
|
|
|
|
list,
|
2021-02-25 06:10:51 +00:00
|
|
|
item: issue,
|
2020-12-22 12:10:09 +00:00
|
|
|
...props,
|
2019-10-31 09:06:29 +00:00
|
|
|
},
|
2020-03-09 09:07:45 +00:00
|
|
|
stubs: {
|
|
|
|
GlLabel: true,
|
2021-05-21 06:11:06 +00:00
|
|
|
GlLoadingIcon: true,
|
2020-03-09 09:07:45 +00:00
|
|
|
},
|
2021-09-13 15:10:34 +00:00
|
|
|
directives: {
|
|
|
|
GlTooltip: createMockDirective(),
|
|
|
|
},
|
2021-03-16 06:09:57 +00:00
|
|
|
mocks: {
|
|
|
|
$apollo: {
|
|
|
|
queries: {
|
|
|
|
blockingIssuables: { loading: false },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-09-17 09:09:32 +00:00
|
|
|
provide: {
|
|
|
|
rootPath: '/',
|
2020-12-22 12:10:09 +00:00
|
|
|
scopedLabelsAvailable: false,
|
2020-09-17 09:09:32 +00:00
|
|
|
},
|
2019-10-31 09:06:29 +00:00
|
|
|
});
|
2020-12-22 12:10:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
list = mockLabelList;
|
|
|
|
issue = {
|
2021-03-16 06:09:57 +00:00
|
|
|
...mockIssue,
|
2020-12-22 12:10:09 +00:00
|
|
|
labels: [list.label],
|
|
|
|
assignees: [],
|
|
|
|
weight: 1,
|
|
|
|
};
|
|
|
|
|
2021-06-21 15:07:30 +00:00
|
|
|
createStore();
|
2021-02-25 06:10:51 +00:00
|
|
|
createWrapper({ item: issue, list });
|
2020-12-22 12:10:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
2021-03-16 06:09:57 +00:00
|
|
|
store = null;
|
2020-12-22 12:10:09 +00:00
|
|
|
jest.clearAllMocks();
|
2019-10-31 09:06:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders issue title', () => {
|
|
|
|
expect(wrapper.find('.board-card-title').text()).toContain(issue.title);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('includes issue base in link', () => {
|
|
|
|
expect(wrapper.find('.board-card-title a').attributes('href')).toContain('/test');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('includes issue title on link', () => {
|
|
|
|
expect(wrapper.find('.board-card-title a').attributes('title')).toBe(issue.title);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render confidential icon', () => {
|
2020-02-11 03:09:13 +00:00
|
|
|
expect(wrapper.find('.confidential-icon').exists()).toBe(false);
|
|
|
|
});
|
|
|
|
|
2021-09-13 15:10:34 +00:00
|
|
|
it('does not render hidden issue icon', () => {
|
|
|
|
expect(findHiddenIssueIcon().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
|
2019-10-31 09:06:29 +00:00
|
|
|
it('renders issue ID with #', () => {
|
2021-03-16 06:09:57 +00:00
|
|
|
expect(wrapper.find('.board-card-number').text()).toContain(`#${issue.iid}`);
|
2019-10-31 09:06:29 +00:00
|
|
|
});
|
|
|
|
|
2020-12-22 12:10:09 +00:00
|
|
|
it('does not render assignee', () => {
|
|
|
|
expect(wrapper.find('.board-card-assignee .avatar').exists()).toBe(false);
|
|
|
|
});
|
|
|
|
|
2021-05-21 06:11:06 +00:00
|
|
|
it('does not render loading icon', () => {
|
|
|
|
expect(wrapper.findComponent(GlLoadingIcon).exists()).toBe(false);
|
|
|
|
});
|
|
|
|
|
2021-08-11 06:10:02 +00:00
|
|
|
it('does not render item reference path', () => {
|
|
|
|
createStore({ isProjectBoard: true });
|
|
|
|
createWrapper();
|
|
|
|
|
|
|
|
expect(wrapper.find('.board-card-number').text()).not.toContain(mockIssueFullPath);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders item reference path', () => {
|
|
|
|
expect(wrapper.find('.board-card-number').text()).toContain(mockIssueFullPath);
|
|
|
|
});
|
|
|
|
|
2021-03-16 06:09:57 +00:00
|
|
|
describe('blocked', () => {
|
|
|
|
it('renders blocked icon if issue is blocked', async () => {
|
|
|
|
createWrapper({
|
|
|
|
item: {
|
|
|
|
...issue,
|
|
|
|
blocked: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(findBoardBlockedIcon().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not show blocked icon if issue is not blocked', () => {
|
|
|
|
createWrapper({
|
|
|
|
item: {
|
|
|
|
...issue,
|
|
|
|
blocked: false,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(findBoardBlockedIcon().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-12-22 12:10:09 +00:00
|
|
|
describe('confidential issue', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
wrapper.setProps({
|
2021-02-25 06:10:51 +00:00
|
|
|
item: {
|
|
|
|
...wrapper.props('item'),
|
2020-12-22 12:10:09 +00:00
|
|
|
confidential: true,
|
|
|
|
},
|
|
|
|
});
|
2019-10-31 09:06:29 +00:00
|
|
|
});
|
|
|
|
|
2020-12-22 12:10:09 +00:00
|
|
|
it('renders confidential icon', () => {
|
|
|
|
expect(wrapper.find('.confidential-icon').exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-13 15:10:34 +00:00
|
|
|
describe('hidden issue', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
wrapper.setProps({
|
|
|
|
item: {
|
|
|
|
...wrapper.props('item'),
|
|
|
|
hidden: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders hidden issue icon', () => {
|
|
|
|
expect(findHiddenIssueIcon().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('displays a tooltip which explains the meaning of the icon', () => {
|
|
|
|
const tooltip = getBinding(findHiddenIssueIcon().element, 'gl-tooltip');
|
|
|
|
|
|
|
|
expect(tooltip).toBeDefined();
|
|
|
|
expect(findHiddenIssueIcon().attributes('title')).toBe(
|
|
|
|
'This issue is hidden because its author has been banned',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-12-22 12:10:09 +00:00
|
|
|
describe('with assignee', () => {
|
|
|
|
describe('with avatar', () => {
|
|
|
|
beforeEach(() => {
|
2019-10-31 09:06:29 +00:00
|
|
|
wrapper.setProps({
|
2021-02-25 06:10:51 +00:00
|
|
|
item: {
|
|
|
|
...wrapper.props('item'),
|
2019-10-31 09:06:29 +00:00
|
|
|
assignees: [user],
|
2020-01-31 09:08:53 +00:00
|
|
|
updateData(newData) {
|
|
|
|
Object.assign(this, newData);
|
|
|
|
},
|
2019-10-31 09:06:29 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders assignee', () => {
|
|
|
|
expect(wrapper.find('.board-card-assignee .avatar').exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('sets title', () => {
|
|
|
|
expect(wrapper.find('.js-assignee-tooltip').text()).toContain(`${user.name}`);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('sets users path', () => {
|
|
|
|
expect(wrapper.find('.board-card-assignee a').attributes('href')).toBe('/test');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders avatar', () => {
|
|
|
|
expect(wrapper.find('.board-card-assignee img').exists()).toBe(true);
|
|
|
|
});
|
2020-01-31 09:08:53 +00:00
|
|
|
|
2020-12-22 12:10:09 +00:00
|
|
|
it('renders the avatar using avatarUrl property', async () => {
|
2021-02-25 06:10:51 +00:00
|
|
|
wrapper.props('item').updateData({
|
|
|
|
...wrapper.props('item'),
|
2020-01-31 09:08:53 +00:00
|
|
|
assignees: [
|
|
|
|
{
|
|
|
|
id: '1',
|
|
|
|
name: 'test',
|
|
|
|
state: 'active',
|
|
|
|
username: 'test_name',
|
2020-12-22 12:10:09 +00:00
|
|
|
avatarUrl: 'test_image_from_avatar_url',
|
2020-01-31 09:08:53 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
2020-12-22 12:10:09 +00:00
|
|
|
await wrapper.vm.$nextTick();
|
|
|
|
|
|
|
|
expect(wrapper.find('.board-card-assignee img').attributes('src')).toBe(
|
|
|
|
'test_image_from_avatar_url?width=24',
|
|
|
|
);
|
2020-01-31 09:08:53 +00:00
|
|
|
});
|
2019-10-31 09:06:29 +00:00
|
|
|
});
|
|
|
|
|
2020-12-22 12:10:09 +00:00
|
|
|
describe('with default avatar', () => {
|
|
|
|
beforeEach(() => {
|
2020-03-11 21:09:19 +00:00
|
|
|
global.gon.default_avatar_url = 'default_avatar';
|
|
|
|
|
2019-10-31 09:06:29 +00:00
|
|
|
wrapper.setProps({
|
2021-02-25 06:10:51 +00:00
|
|
|
item: {
|
|
|
|
...wrapper.props('item'),
|
2019-10-31 09:06:29 +00:00
|
|
|
assignees: [
|
2020-12-22 12:10:09 +00:00
|
|
|
{
|
2020-03-11 21:09:19 +00:00
|
|
|
id: 1,
|
|
|
|
name: 'testing 123',
|
|
|
|
username: 'test',
|
2020-12-22 12:10:09 +00:00
|
|
|
},
|
2019-10-31 09:06:29 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-03-11 21:09:19 +00:00
|
|
|
afterEach(() => {
|
|
|
|
global.gon.default_avatar_url = null;
|
|
|
|
});
|
|
|
|
|
2019-10-31 09:06:29 +00:00
|
|
|
it('displays defaults avatar if users avatar is null', () => {
|
|
|
|
expect(wrapper.find('.board-card-assignee img').exists()).toBe(true);
|
|
|
|
expect(wrapper.find('.board-card-assignee img').attributes('src')).toBe(
|
|
|
|
'default_avatar?width=24',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('multiple assignees', () => {
|
2020-12-22 12:10:09 +00:00
|
|
|
beforeEach(() => {
|
2019-10-31 09:06:29 +00:00
|
|
|
wrapper.setProps({
|
2021-02-25 06:10:51 +00:00
|
|
|
item: {
|
|
|
|
...wrapper.props('item'),
|
2019-10-31 09:06:29 +00:00
|
|
|
assignees: [
|
2020-12-22 12:10:09 +00:00
|
|
|
{
|
2019-10-31 09:06:29 +00:00
|
|
|
id: 2,
|
|
|
|
name: 'user2',
|
|
|
|
username: 'user2',
|
2020-12-22 12:10:09 +00:00
|
|
|
avatarUrl: 'test_image',
|
|
|
|
},
|
|
|
|
{
|
2019-10-31 09:06:29 +00:00
|
|
|
id: 3,
|
|
|
|
name: 'user3',
|
|
|
|
username: 'user3',
|
2020-12-22 12:10:09 +00:00
|
|
|
avatarUrl: 'test_image',
|
|
|
|
},
|
|
|
|
{
|
2019-10-31 09:06:29 +00:00
|
|
|
id: 4,
|
|
|
|
name: 'user4',
|
|
|
|
username: 'user4',
|
2020-12-22 12:10:09 +00:00
|
|
|
avatarUrl: 'test_image',
|
|
|
|
},
|
2019-10-31 09:06:29 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders all three assignees', () => {
|
|
|
|
expect(wrapper.findAll('.board-card-assignee .avatar').length).toEqual(3);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('more than three assignees', () => {
|
2020-12-22 12:10:09 +00:00
|
|
|
beforeEach(() => {
|
2021-02-25 06:10:51 +00:00
|
|
|
const { assignees } = wrapper.props('item');
|
2020-12-22 12:10:09 +00:00
|
|
|
assignees.push({
|
|
|
|
id: 5,
|
|
|
|
name: 'user5',
|
|
|
|
username: 'user5',
|
|
|
|
avatarUrl: 'test_image',
|
|
|
|
});
|
2019-10-31 09:06:29 +00:00
|
|
|
|
|
|
|
wrapper.setProps({
|
2021-02-25 06:10:51 +00:00
|
|
|
item: {
|
|
|
|
...wrapper.props('item'),
|
2019-10-31 09:06:29 +00:00
|
|
|
assignees,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders more avatar counter', () => {
|
2020-12-23 12:10:26 +00:00
|
|
|
expect(wrapper.find('.board-card-assignee .avatar-counter').text().trim()).toEqual('+2');
|
2019-10-31 09:06:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders two assignees', () => {
|
|
|
|
expect(wrapper.findAll('.board-card-assignee .avatar').length).toEqual(2);
|
|
|
|
});
|
|
|
|
|
2020-12-22 12:10:09 +00:00
|
|
|
it('renders 99+ avatar counter', async () => {
|
2019-10-31 09:06:29 +00:00
|
|
|
const assignees = [
|
2021-02-25 06:10:51 +00:00
|
|
|
...wrapper.props('item').assignees,
|
2020-12-23 21:10:24 +00:00
|
|
|
...range(5, 103).map((i) => ({
|
2020-12-22 12:10:09 +00:00
|
|
|
id: i,
|
|
|
|
name: 'name',
|
|
|
|
username: 'username',
|
|
|
|
avatarUrl: 'test_image',
|
|
|
|
})),
|
2019-10-31 09:06:29 +00:00
|
|
|
];
|
|
|
|
wrapper.setProps({
|
2021-02-25 06:10:51 +00:00
|
|
|
item: {
|
|
|
|
...wrapper.props('item'),
|
2019-10-31 09:06:29 +00:00
|
|
|
assignees,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2020-12-22 12:10:09 +00:00
|
|
|
await wrapper.vm.$nextTick();
|
|
|
|
|
2020-12-23 12:10:26 +00:00
|
|
|
expect(wrapper.find('.board-card-assignee .avatar-counter').text().trim()).toEqual('99+');
|
2019-10-31 09:06:29 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('labels', () => {
|
2020-12-22 12:10:09 +00:00
|
|
|
beforeEach(() => {
|
2021-02-25 06:10:51 +00:00
|
|
|
wrapper.setProps({ item: { ...issue, labels: [list.label, label1] } });
|
2019-10-31 09:06:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render list label but renders all other labels', () => {
|
2020-03-09 09:07:45 +00:00
|
|
|
expect(wrapper.findAll(GlLabel).length).toBe(1);
|
|
|
|
const label = wrapper.find(GlLabel);
|
|
|
|
expect(label.props('title')).toEqual(label1.title);
|
|
|
|
expect(label.props('description')).toEqual(label1.description);
|
|
|
|
expect(label.props('backgroundColor')).toEqual(label1.color);
|
2019-10-31 09:06:29 +00:00
|
|
|
});
|
|
|
|
|
2020-12-22 12:10:09 +00:00
|
|
|
it('does not render label if label does not have an ID', async () => {
|
2021-02-25 06:10:51 +00:00
|
|
|
wrapper.setProps({ item: { ...issue, labels: [label1, { title: 'closed' }] } });
|
2020-12-22 12:10:09 +00:00
|
|
|
|
|
|
|
await wrapper.vm.$nextTick();
|
|
|
|
|
|
|
|
expect(wrapper.findAll(GlLabel).length).toBe(1);
|
|
|
|
expect(wrapper.text()).not.toContain('closed');
|
2019-10-31 09:06:29 +00:00
|
|
|
});
|
|
|
|
});
|
2020-02-11 03:09:13 +00:00
|
|
|
|
2020-12-22 12:10:09 +00:00
|
|
|
describe('filterByLabel method', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
wrapper.setProps({
|
|
|
|
updateFilters: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when selected label is not in the filter', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
jest.spyOn(wrapper.vm, 'performSearch').mockImplementation(() => {});
|
2021-08-02 18:08:48 +00:00
|
|
|
setWindowLocation('?');
|
2020-12-22 12:10:09 +00:00
|
|
|
wrapper.vm.filterByLabel(label1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('calls updateHistory', () => {
|
|
|
|
expect(updateHistory).toHaveBeenCalledTimes(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('dispatches performSearch vuex action', () => {
|
|
|
|
expect(wrapper.vm.performSearch).toHaveBeenCalledTimes(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('emits updateTokens event', () => {
|
|
|
|
expect(eventHub.$emit).toHaveBeenCalledTimes(1);
|
|
|
|
expect(eventHub.$emit).toHaveBeenCalledWith('updateTokens');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when selected label is already in the filter', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
jest.spyOn(wrapper.vm, 'performSearch').mockImplementation(() => {});
|
2021-08-02 18:08:48 +00:00
|
|
|
setWindowLocation('?label_name[]=testing%20123');
|
2020-12-22 12:10:09 +00:00
|
|
|
wrapper.vm.filterByLabel(label1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not call updateHistory', () => {
|
|
|
|
expect(updateHistory).not.toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not dispatch performSearch vuex action', () => {
|
|
|
|
expect(wrapper.vm.performSearch).not.toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not emit updateTokens event', () => {
|
|
|
|
expect(eventHub.$emit).not.toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2021-05-21 06:11:06 +00:00
|
|
|
|
|
|
|
describe('loading', () => {
|
|
|
|
it('renders loading icon', async () => {
|
|
|
|
createWrapper({
|
|
|
|
item: {
|
|
|
|
...issue,
|
|
|
|
isLoading: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-06-21 15:07:30 +00:00
|
|
|
expect(findLoadingIcon().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('is an epic board', () => {
|
|
|
|
const descendantCounts = {
|
|
|
|
closedEpics: 0,
|
|
|
|
closedIssues: 0,
|
|
|
|
openedEpics: 0,
|
|
|
|
openedIssues: 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
const descendantWeightSum = {
|
|
|
|
closedIssues: 0,
|
|
|
|
openedIssues: 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
createStore({ isEpicBoard: true });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render if the item has issues', () => {
|
|
|
|
createWrapper({
|
|
|
|
item: {
|
|
|
|
...issue,
|
|
|
|
descendantCounts,
|
|
|
|
descendantWeightSum,
|
|
|
|
hasIssues: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(findEpicCountables().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not render if the item does not have issues', () => {
|
|
|
|
createWrapper({
|
|
|
|
item: {
|
|
|
|
...issue,
|
|
|
|
descendantCounts,
|
|
|
|
descendantWeightSum,
|
|
|
|
hasIssues: false,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(findEpicCountablesBadgeIssues().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
|
2021-07-13 06:10:10 +00:00
|
|
|
it('shows render item countBadge, weights, and progress correctly', () => {
|
2021-06-21 15:07:30 +00:00
|
|
|
createWrapper({
|
|
|
|
item: {
|
|
|
|
...issue,
|
|
|
|
descendantCounts: {
|
|
|
|
...descendantCounts,
|
|
|
|
openedIssues: 1,
|
|
|
|
},
|
|
|
|
descendantWeightSum: {
|
2021-07-13 06:10:10 +00:00
|
|
|
closedIssues: 10,
|
|
|
|
openedIssues: 5,
|
2021-06-21 15:07:30 +00:00
|
|
|
},
|
|
|
|
hasIssues: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(findEpicCountablesBadgeIssues().text()).toBe('1');
|
2021-07-13 06:10:10 +00:00
|
|
|
expect(findEpicCountablesBadgeWeight().text()).toBe('15');
|
|
|
|
expect(findEpicBadgeProgress().text()).toBe('67%');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render progress when weight is zero', () => {
|
|
|
|
createWrapper({
|
|
|
|
item: {
|
|
|
|
...issue,
|
|
|
|
descendantCounts: {
|
|
|
|
...descendantCounts,
|
|
|
|
openedIssues: 1,
|
|
|
|
},
|
|
|
|
descendantWeightSum,
|
|
|
|
hasIssues: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(findEpicBadgeProgress().exists()).toBe(false);
|
2021-06-21 15:07:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the tooltip with the correct data', () => {
|
|
|
|
createWrapper({
|
|
|
|
item: {
|
|
|
|
...issue,
|
|
|
|
descendantCounts,
|
|
|
|
descendantWeightSum: {
|
|
|
|
closedIssues: 10,
|
|
|
|
openedIssues: 5,
|
|
|
|
},
|
|
|
|
hasIssues: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const tooltip = findEpicCountablesTotalTooltip();
|
|
|
|
expect(tooltip).toBeDefined();
|
|
|
|
|
2021-07-13 06:10:10 +00:00
|
|
|
expect(findEpicCountablesTotalWeight().text()).toBe('15');
|
|
|
|
expect(findEpicProgressTooltip().text()).toBe('10 of 15 weight completed');
|
2021-05-21 06:11:06 +00:00
|
|
|
});
|
|
|
|
});
|
2019-10-31 09:06:29 +00:00
|
|
|
});
|