Commit 7a7f95f0 authored by Florie Guibert's avatar Florie Guibert

Fix displaying weight of 0 for issues in epic tree

Changelog: fixed
EE: true
parent f79559cd
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
GlButton, GlButton,
GlTooltip, GlTooltip,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { isEmpty } from 'lodash'; import { isEmpty, isNumber } from 'lodash';
import { mapState, mapActions } from 'vuex'; import { mapState, mapActions } from 'vuex';
import ItemWeight from 'ee/boards/components/issue_card_weight.vue'; import ItemWeight from 'ee/boards/components/issue_card_weight.vue';
...@@ -75,6 +75,9 @@ export default { ...@@ -75,6 +75,9 @@ export default {
hasAssignees() { hasAssignees() {
return this.item.assignees && this.item.assignees.length > 0; return this.item.assignees && this.item.assignees.length > 0;
}, },
hasWeight() {
return isNumber(this.item.weight);
},
stateText() { stateText() {
return this.isOpen ? __('Opened') : __('Closed'); return this.isOpen ? __('Opened') : __('Closed');
}, },
...@@ -260,7 +263,7 @@ export default { ...@@ -260,7 +263,7 @@ export default {
/> />
<item-weight <item-weight
v-if="item.weight" v-if="hasWeight"
:weight="item.weight" :weight="item.weight"
class="item-weight gl-display-flex gl-align-items-center gl-mr-5!" class="item-weight gl-display-flex gl-align-items-center gl-mr-5!"
tag-name="span" tag-name="span"
......
import { GlButton, GlLink, GlIcon } from '@gitlab/ui'; import { GlButton, GlLink, GlIcon } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import ItemWeight from 'ee/boards/components/issue_card_weight.vue'; import ItemWeight from 'ee/boards/components/issue_card_weight.vue';
...@@ -28,8 +29,7 @@ import { ...@@ -28,8 +29,7 @@ import {
mockEpicMeta3, mockEpicMeta3,
} from '../mock_data'; } from '../mock_data';
const localVue = createLocalVue(); Vue.use(Vuex);
localVue.use(Vuex);
let mockItem; let mockItem;
...@@ -68,7 +68,6 @@ const createComponent = (parentItem = mockParentItem, item = mockItem) => { ...@@ -68,7 +68,6 @@ const createComponent = (parentItem = mockParentItem, item = mockItem) => {
}); });
return shallowMount(TreeItemBody, { return shallowMount(TreeItemBody, {
localVue,
store, store,
propsData: { propsData: {
parentItem, parentItem,
...@@ -337,7 +336,7 @@ describe('RelatedItemsTree', () => { ...@@ -337,7 +336,7 @@ describe('RelatedItemsTree', () => {
}); });
it('renders item link', () => { it('renders item link', () => {
const link = wrapper.find(GlLink); const link = wrapper.findComponent(GlLink);
expect(link.attributes('href')).toBe(mockItem.webPath); expect(link.attributes('href')).toBe(mockItem.webPath);
expect(link.text()).toBe(mockItem.title); expect(link.text()).toBe(mockItem.title);
...@@ -350,13 +349,13 @@ describe('RelatedItemsTree', () => { ...@@ -350,13 +349,13 @@ describe('RelatedItemsTree', () => {
}); });
it('renders item milestone when it has milestone', () => { it('renders item milestone when it has milestone', () => {
const milestone = wrapper.find(ItemMilestone); const milestone = wrapper.findComponent(ItemMilestone);
expect(milestone.isVisible()).toBe(true); expect(milestone.isVisible()).toBe(true);
}); });
it('renders item due date when it has due date', () => { it('renders item due date when it has due date', () => {
const dueDate = wrapper.find(ItemDueDate); const dueDate = wrapper.findComponent(ItemDueDate);
expect(dueDate.isVisible()).toBe(true); expect(dueDate.isVisible()).toBe(true);
}); });
...@@ -371,23 +370,39 @@ describe('RelatedItemsTree', () => { ...@@ -371,23 +370,39 @@ describe('RelatedItemsTree', () => {
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(wrapper.find(ItemDueDate).props('closed')).toBe(true); expect(wrapper.findComponent(ItemDueDate).props('closed')).toBe(true);
}); });
it('renders item weight when it has weight', () => { it('renders item weight when it has weight', () => {
const weight = wrapper.find(ItemWeight); const weight = wrapper.findComponent(ItemWeight);
expect(weight.isVisible()).toBe(true); expect(weight.isVisible()).toBe(true);
}); });
it('renders item weight when it has weight of 0', async () => {
wrapper.setProps({
item: {
...mockItem,
weight: 0,
},
});
await wrapper.vm.$nextTick();
const weight = wrapper.findComponent(ItemWeight);
expect(weight.isVisible()).toBe(true);
expect(weight.props('weight')).toBe(0);
});
it('renders item assignees when it has assignees', () => { it('renders item assignees when it has assignees', () => {
const assignees = wrapper.find(ItemAssignees); const assignees = wrapper.findComponent(ItemAssignees);
expect(assignees.isVisible()).toBe(true); expect(assignees.isVisible()).toBe(true);
}); });
it('renders item remove button when `item.userPermissions.adminEpic` is true', () => { it('renders item remove button when `item.userPermissions.adminEpic` is true', () => {
const removeButton = wrapper.find(GlButton); const removeButton = wrapper.findComponent(GlButton);
expect(removeButton.isVisible()).toBe(true); expect(removeButton.isVisible()).toBe(true);
expect(removeButton.attributes('title')).toBe('Remove'); expect(removeButton.attributes('title')).toBe('Remove');
......
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