Commit d2c573c3 authored by Scott Stern's avatar Scott Stern Committed by Illya Klymov

Move issuable title to component

parent ca0859c5
<script>
export default {
props: {
title: {
type: String,
required: true,
},
refPath: {
type: String,
required: true,
},
},
};
</script>
<template>
<div data-testid="issue-title">
<p class="gl-font-weight-bold">{{ title }}</p>
<p class="gl-mb-0">{{ refPath }}</p>
</div>
</template>
...@@ -4,12 +4,14 @@ import { GlDrawer } from '@gitlab/ui'; ...@@ -4,12 +4,14 @@ import { GlDrawer } from '@gitlab/ui';
import { ISSUABLE } from '~/boards/constants'; import { ISSUABLE } from '~/boards/constants';
import { contentTop } from '~/lib/utils/common_utils'; import { contentTop } from '~/lib/utils/common_utils';
import IssuableAssignees from '~/sidebar/components/assignees/issuable_assignees.vue'; import IssuableAssignees from '~/sidebar/components/assignees/issuable_assignees.vue';
import IssuableTitle from '~/boards/components/issuable_title.vue';
export default { export default {
headerHeight: `${contentTop()}px`, headerHeight: `${contentTop()}px`,
components: { components: {
IssuableAssignees, IssuableAssignees,
GlDrawer, GlDrawer,
IssuableTitle,
}, },
computed: { computed: {
...mapGetters(['isSidebarOpen', 'getActiveIssue']), ...mapGetters(['isSidebarOpen', 'getActiveIssue']),
...@@ -17,9 +19,6 @@ export default { ...@@ -17,9 +19,6 @@ export default {
showSidebar() { showSidebar() {
return this.sidebarType === ISSUABLE; return this.sidebarType === ISSUABLE;
}, },
issueTitle() {
return this.getActiveIssue.title;
},
}, },
methods: { methods: {
...mapActions(['unsetActiveId']), ...mapActions(['unsetActiveId']),
...@@ -35,10 +34,7 @@ export default { ...@@ -35,10 +34,7 @@ export default {
@close="unsetActiveId" @close="unsetActiveId"
> >
<template #header> <template #header>
<div data-testid="issue-title"> <issuable-title :ref-path="getActiveIssue.referencePath" :title="getActiveIssue.title" />
<p class="gl-font-weight-bold">{{ issueTitle }}</p>
<p class="gl-mb-0">{{ getActiveIssue.referencePath }}</p>
</div>
</template> </template>
<template> <template>
......
...@@ -3,6 +3,7 @@ import { GlDrawer } from '@gitlab/ui'; ...@@ -3,6 +3,7 @@ import { GlDrawer } from '@gitlab/ui';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import BoardContentSidebar from 'ee_component/boards/components/board_content_sidebar.vue'; import BoardContentSidebar from 'ee_component/boards/components/board_content_sidebar.vue';
import IssuableAssignees from '~/sidebar/components/assignees/issuable_assignees.vue'; import IssuableAssignees from '~/sidebar/components/assignees/issuable_assignees.vue';
import IssuableTitle from '~/boards/components/issuable_title.vue';
import { createStore } from '~/boards/stores'; import { createStore } from '~/boards/stores';
import { ISSUABLE } from '~/boards/constants'; import { ISSUABLE } from '~/boards/constants';
...@@ -22,7 +23,6 @@ describe('ee/BoardContentSidebar', () => { ...@@ -22,7 +23,6 @@ describe('ee/BoardContentSidebar', () => {
beforeEach(() => { beforeEach(() => {
store = createStore(); store = createStore();
store.state.sidebarType = ISSUABLE; store.state.sidebarType = ISSUABLE;
store.state.activeId = 1;
store.state.issues = { '1': { title: 'One', referencePath: 'path', assignees: [] } }; store.state.issues = { '1': { title: 'One', referencePath: 'path', assignees: [] } };
store.state.activeId = '1'; store.state.activeId = '1';
...@@ -31,6 +31,7 @@ describe('ee/BoardContentSidebar', () => { ...@@ -31,6 +31,7 @@ describe('ee/BoardContentSidebar', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
it('confirms we render GlDrawer', () => { it('confirms we render GlDrawer', () => {
...@@ -41,12 +42,8 @@ describe('ee/BoardContentSidebar', () => { ...@@ -41,12 +42,8 @@ describe('ee/BoardContentSidebar', () => {
expect(wrapper.find(GlDrawer).props('open')).toBe(true); expect(wrapper.find(GlDrawer).props('open')).toBe(true);
}); });
it('renders a title of an issue in the sidebar', () => { it('finds IssuableTitle', () => {
expect(wrapper.find('[data-testid="issue-title"]').text()).toContain('One'); expect(wrapper.find(IssuableTitle).text()).toContain('One');
});
it('renders a referencePath of an issue in the sidebar', () => {
expect(wrapper.find('[data-testid="issue-title"]').text()).toContain('path');
}); });
it('renders IssuableAssignees', () => { it('renders IssuableAssignees', () => {
......
import { shallowMount } from '@vue/test-utils';
import IssuableTitle from '~/boards/components/issuable_title.vue';
describe('IssuableTitle', () => {
let wrapper;
const defaultProps = {
title: 'One',
refPath: 'path',
};
const createComponent = () => {
wrapper = shallowMount(IssuableTitle, {
propsData: { ...defaultProps },
});
};
const findIssueContent = () => wrapper.find('[data-testid="issue-title"]');
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it('renders a title of an issue in the sidebar', () => {
expect(findIssueContent().text()).toContain('One');
});
it('renders a referencePath of an issue in the sidebar', () => {
expect(findIssueContent().text()).toContain('path');
});
});
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