Commit 0791f443 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '235922-boards-use-provide-inject-for-static-props' into 'master'

Boards - Use provide/inject for static props

See merge request gitlab-org/gitlab!42186
parents 47c0f61b 228dceec
<script> <script>
/* eslint-disable vue/require-default-prop */
import IssueCardInner from './issue_card_inner.vue'; import IssueCardInner from './issue_card_inner.vue';
import boardsStore from '../stores/boards_store'; import boardsStore from '../stores/boards_store';
...@@ -19,11 +18,6 @@ export default { ...@@ -19,11 +18,6 @@ export default {
default: () => ({}), default: () => ({}),
required: false, required: false,
}, },
issueLinkBase: {
type: String,
default: '',
required: false,
},
disabled: { disabled: {
type: Boolean, type: Boolean,
default: false, default: false,
...@@ -34,15 +28,6 @@ export default { ...@@ -34,15 +28,6 @@ export default {
default: 0, default: 0,
required: false, required: false,
}, },
rootPath: {
type: String,
default: '',
required: false,
},
groupId: {
type: Number,
required: false,
},
isActive: { isActive: {
type: Boolean, type: Boolean,
required: false, required: false,
...@@ -103,13 +88,6 @@ export default { ...@@ -103,13 +88,6 @@ export default {
@mousemove="mouseMove" @mousemove="mouseMove"
@mouseup="showIssue($event)" @mouseup="showIssue($event)"
> >
<issue-card-inner <issue-card-inner :list="list" :issue="issue" :update-filters="true" />
:list="list"
:issue="issue"
:issue-link-base="issueLinkBase"
:group-id="groupId"
:root-path="rootPath"
:update-filters="true"
/>
</li> </li>
</template> </template>
...@@ -34,27 +34,15 @@ export default { ...@@ -34,27 +34,15 @@ export default {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
issueLinkBase: {
type: String,
required: true,
},
rootPath: {
type: String,
required: true,
},
boardId: {
type: String,
required: true,
},
canAdminList: { canAdminList: {
type: Boolean, type: Boolean,
required: false, required: false,
default: false, default: false,
}, },
groupId: { },
type: Number, inject: {
required: false, boardId: {
default: null, type: String,
}, },
}, },
data() { data() {
...@@ -151,22 +139,14 @@ export default { ...@@ -151,22 +139,14 @@ export default {
<div <div
class="board-inner gl-display-flex gl-flex-direction-column gl-relative gl-h-full gl-rounded-base" class="board-inner gl-display-flex gl-flex-direction-column gl-relative gl-h-full gl-rounded-base"
> >
<board-list-header <board-list-header :can-admin-list="canAdminList" :list="list" :disabled="disabled" />
:can-admin-list="canAdminList"
:list="list"
:disabled="disabled"
:board-id="boardId"
/>
<board-list <board-list
v-if="showBoardListAndBoardInfo" v-if="showBoardListAndBoardInfo"
ref="board-list" ref="board-list"
:disabled="disabled" :disabled="disabled"
:group-id="groupId || null"
:issue-link-base="issueLinkBase"
:issues="listIssues" :issues="listIssues"
:list="list" :list="list"
:loading="list.loading" :loading="list.loading"
:root-path="rootPath"
/> />
<board-blank-state v-if="canAdminList && list.id === 'blank'" /> <board-blank-state v-if="canAdminList && list.id === 'blank'" />
......
...@@ -21,27 +21,10 @@ export default { ...@@ -21,27 +21,10 @@ export default {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
groupId: {
type: Number,
required: false,
default: null,
},
disabled: { disabled: {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
issueLinkBase: {
type: String,
required: true,
},
rootPath: {
type: String,
required: true,
},
boardId: {
type: String,
required: true,
},
}, },
computed: { computed: {
...mapState(['boardLists', 'error']), ...mapState(['boardLists', 'error']),
...@@ -77,12 +60,8 @@ export default { ...@@ -77,12 +60,8 @@ export default {
:key="list.id" :key="list.id"
ref="board" ref="board"
:can-admin-list="canAdminList" :can-admin-list="canAdminList"
:group-id="groupId"
:list="list" :list="list"
:disabled="disabled" :disabled="disabled"
:issue-link-base="issueLinkBase"
:root-path="rootPath"
:board-id="boardId"
/> />
</div> </div>
...@@ -92,9 +71,6 @@ export default { ...@@ -92,9 +71,6 @@ export default {
:lists="boardLists" :lists="boardLists"
:can-admin-list="canAdminList" :can-admin-list="canAdminList"
:disabled="disabled" :disabled="disabled"
:board-id="boardId"
:group-id="groupId"
:root-path="rootPath"
/> />
<board-content-sidebar /> <board-content-sidebar />
</template> </template>
......
...@@ -27,11 +27,6 @@ export default { ...@@ -27,11 +27,6 @@ export default {
}, },
mixins: [glFeatureFlagMixin()], mixins: [glFeatureFlagMixin()],
props: { props: {
groupId: {
type: Number,
required: false,
default: 0,
},
disabled: { disabled: {
type: Boolean, type: Boolean,
required: true, required: true,
...@@ -48,14 +43,6 @@ export default { ...@@ -48,14 +43,6 @@ export default {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
issueLinkBase: {
type: String,
required: true,
},
rootPath: {
type: String,
required: true,
},
}, },
data() { data() {
return { return {
...@@ -435,11 +422,7 @@ export default { ...@@ -435,11 +422,7 @@ export default {
<div v-if="loading" class="board-list-loading text-center" :aria-label="__('Loading issues')"> <div v-if="loading" class="board-list-loading text-center" :aria-label="__('Loading issues')">
<gl-loading-icon /> <gl-loading-icon />
</div> </div>
<board-new-issue <board-new-issue v-if="list.type !== 'closed' && showIssueForm" :list="list" />
v-if="list.type !== 'closed' && showIssueForm"
:group-id="groupId"
:list="list"
/>
<ul <ul
v-show="!loading" v-show="!loading"
ref="list" ref="list"
...@@ -455,9 +438,6 @@ export default { ...@@ -455,9 +438,6 @@ export default {
:index="index" :index="index"
:list="list" :list="list"
:issue="issue" :issue="issue"
:issue-link-base="issueLinkBase"
:group-id="groupId"
:root-path="rootPath"
:disabled="disabled" :disabled="disabled"
/> />
<li v-if="showCount" class="board-list-count text-center" data-issue-id="-1"> <li v-if="showCount" class="board-list-count text-center" data-issue-id="-1">
......
...@@ -45,10 +45,6 @@ export default { ...@@ -45,10 +45,6 @@ export default {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
boardId: {
type: String,
required: true,
},
canAdminList: { canAdminList: {
type: Boolean, type: Boolean,
required: false, required: false,
...@@ -60,6 +56,11 @@ export default { ...@@ -60,6 +56,11 @@ export default {
default: false, default: false,
}, },
}, },
inject: {
boardId: {
type: String,
},
},
data() { data() {
return { return {
weightFeatureAvailable: false, weightFeatureAvailable: false,
......
...@@ -17,16 +17,16 @@ export default { ...@@ -17,16 +17,16 @@ export default {
}, },
mixins: [glFeatureFlagMixin()], mixins: [glFeatureFlagMixin()],
props: { props: {
groupId: {
type: Number,
required: false,
default: 0,
},
list: { list: {
type: Object, type: Object,
required: true, required: true,
}, },
}, },
inject: {
groupId: {
type: Number,
},
},
data() { data() {
return { return {
title: '', title: '',
...@@ -139,7 +139,7 @@ export default { ...@@ -139,7 +139,7 @@ export default {
<project-select v-if="groupId" :group-id="groupId" :list="list" /> <project-select v-if="groupId" :group-id="groupId" :list="list" />
<div class="clearfix gl-mt-3"> <div class="clearfix gl-mt-3">
<gl-button <gl-button
ref="submit-button" ref="submitButton"
:disabled="disabled" :disabled="disabled"
class="float-left" class="float-left"
variant="success" variant="success"
...@@ -147,9 +147,14 @@ export default { ...@@ -147,9 +147,14 @@ export default {
type="submit" type="submit"
>{{ __('Submit issue') }}</gl-button >{{ __('Submit issue') }}</gl-button
> >
<gl-button class="float-right" type="button" variant="default" @click="cancel">{{ <gl-button
__('Cancel') ref="cancelButton"
}}</gl-button> class="float-right"
type="button"
variant="default"
@click="cancel"
>{{ __('Cancel') }}</gl-button
>
</div> </div>
</form> </form>
</div> </div>
......
...@@ -30,28 +30,23 @@ export default { ...@@ -30,28 +30,23 @@ export default {
type: Object, type: Object,
required: true, required: true,
}, },
issueLinkBase: {
type: String,
required: true,
},
list: { list: {
type: Object, type: Object,
required: false, required: false,
default: () => ({}), default: () => ({}),
}, },
rootPath: {
type: String,
required: true,
},
updateFilters: { updateFilters: {
type: Boolean, type: Boolean,
required: false, required: false,
default: false, default: false,
}, },
},
inject: {
groupId: { groupId: {
type: Number, type: Number,
required: false, },
default: null, rootPath: {
type: String,
}, },
}, },
data() { data() {
......
...@@ -26,14 +26,6 @@ export default { ...@@ -26,14 +26,6 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
issueLinkBase: {
type: String,
required: true,
},
rootPath: {
type: String,
required: true,
},
projectId: { projectId: {
type: Number, type: Number,
required: true, required: true,
...@@ -146,12 +138,7 @@ export default { ...@@ -146,12 +138,7 @@ export default {
> >
<div class="add-issues-container d-flex flex-column m-auto rounded"> <div class="add-issues-container d-flex flex-column m-auto rounded">
<modal-header :project-id="projectId" :label-path="labelPath" /> <modal-header :project-id="projectId" :label-path="labelPath" />
<modal-list <modal-list v-if="!loading && showList && !filterLoading" :empty-state-svg="emptyStateSvg" />
v-if="!loading && showList && !filterLoading"
:issue-link-base="issueLinkBase"
:root-path="rootPath"
:empty-state-svg="emptyStateSvg"
/>
<empty-state <empty-state
v-if="showEmptyState" v-if="showEmptyState"
:new-issue-path="newIssuePath" :new-issue-path="newIssuePath"
......
...@@ -10,14 +10,6 @@ export default { ...@@ -10,14 +10,6 @@ export default {
GlIcon, GlIcon,
}, },
props: { props: {
issueLinkBase: {
type: String,
required: true,
},
rootPath: {
type: String,
required: true,
},
emptyStateSvg: { emptyStateSvg: {
type: String, type: String,
required: true, required: true,
...@@ -134,7 +126,7 @@ export default { ...@@ -134,7 +126,7 @@ export default {
class="board-card position-relative p-3 rounded" class="board-card position-relative p-3 rounded"
@click="toggleIssue($event, issue)" @click="toggleIssue($event, issue)"
> >
<issue-card-inner :issue="issue" :issue-link-base="issueLinkBase" :root-path="rootPath" /> <issue-card-inner :issue="issue" />
<gl-icon <gl-icon
v-if="issue.selected" v-if="issue.selected"
:aria-label="'Issue #' + issue.id + ' selected'" :aria-label="'Issue #' + issue.id + ' selected'"
......
...@@ -15,16 +15,16 @@ export default { ...@@ -15,16 +15,16 @@ export default {
GlLoadingIcon, GlLoadingIcon,
}, },
props: { props: {
groupId: {
type: Number,
required: true,
default: 0,
},
list: { list: {
type: Object, type: Object,
required: true, required: true,
}, },
}, },
inject: {
groupId: {
type: Number,
},
},
data() { data() {
return { return {
loading: true, loading: true,
......
...@@ -82,12 +82,13 @@ export default () => { ...@@ -82,12 +82,13 @@ export default () => {
BoardAddIssuesModal, BoardAddIssuesModal,
BoardSettingsSidebar: () => import('~/boards/components/board_settings_sidebar.vue'), BoardSettingsSidebar: () => import('~/boards/components/board_settings_sidebar.vue'),
}, },
store,
apolloProvider,
provide: { provide: {
// TODO: Mv all non-reactive props from data/props to here. boardId: $boardApp.dataset.boardId,
groupId: Number($boardApp.dataset.groupId) || null,
rootPath: $boardApp.dataset.rootPath, rootPath: $boardApp.dataset.rootPath,
}, },
store,
apolloProvider,
data() { data() {
return { return {
state: boardsStore.state, state: boardsStore.state,
...@@ -95,10 +96,7 @@ export default () => { ...@@ -95,10 +96,7 @@ export default () => {
boardsEndpoint: $boardApp.dataset.boardsEndpoint, boardsEndpoint: $boardApp.dataset.boardsEndpoint,
recentBoardsEndpoint: $boardApp.dataset.recentBoardsEndpoint, recentBoardsEndpoint: $boardApp.dataset.recentBoardsEndpoint,
listsEndpoint: $boardApp.dataset.listsEndpoint, listsEndpoint: $boardApp.dataset.listsEndpoint,
boardId: $boardApp.dataset.boardId,
disabled: parseBoolean($boardApp.dataset.disabled), disabled: parseBoolean($boardApp.dataset.disabled),
issueLinkBase: $boardApp.dataset.issueLinkBase,
rootPath: $boardApp.dataset.rootPath,
bulkUpdatePath: $boardApp.dataset.bulkUpdatePath, bulkUpdatePath: $boardApp.dataset.bulkUpdatePath,
detailIssue: boardsStore.detail, detailIssue: boardsStore.detail,
parent: $boardApp.dataset.parent, parent: $boardApp.dataset.parent,
...@@ -116,7 +114,7 @@ export default () => { ...@@ -116,7 +114,7 @@ export default () => {
recentBoardsEndpoint: this.recentBoardsEndpoint, recentBoardsEndpoint: this.recentBoardsEndpoint,
listsEndpoint: this.listsEndpoint, listsEndpoint: this.listsEndpoint,
bulkUpdatePath: this.bulkUpdatePath, bulkUpdatePath: this.bulkUpdatePath,
boardId: this.boardId, boardId: $boardApp.dataset.boardId,
fullPath: $boardApp.dataset.fullPath, fullPath: $boardApp.dataset.fullPath,
}; };
this.setInitialBoardData({ this.setInitialBoardData({
......
...@@ -11,13 +11,13 @@ module BoardsHelper ...@@ -11,13 +11,13 @@ module BoardsHelper
lists_endpoint: board_lists_path(board), lists_endpoint: board_lists_path(board),
board_id: board.id, board_id: board.id,
disabled: (!can?(current_user, :create_non_backlog_issues, board)).to_s, disabled: (!can?(current_user, :create_non_backlog_issues, board)).to_s,
issue_link_base: build_issue_link_base,
root_path: root_path, root_path: root_path,
full_path: full_path, full_path: full_path,
bulk_update_path: @bulk_issues_path, bulk_update_path: @bulk_issues_path,
time_tracking_limit_to_hours: Gitlab::CurrentSettings.time_tracking_limit_to_hours.to_s, time_tracking_limit_to_hours: Gitlab::CurrentSettings.time_tracking_limit_to_hours.to_s,
recent_boards_endpoint: recent_boards_path, recent_boards_endpoint: recent_boards_path,
parent: current_board_parent.model_name.param_key parent: current_board_parent.model_name.param_key,
group_id: @group&.id
} }
end end
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
- group = local_assigns.fetch(:group, false) - group = local_assigns.fetch(:group, false)
-# TODO: Move group_id and can_admin_list to the board store -# TODO: Move group_id and can_admin_list to the board store
See: https://gitlab.com/gitlab-org/gitlab/-/issues/213082 See: https://gitlab.com/gitlab-org/gitlab/-/issues/213082
- group_id = @group&.id || "null"
- can_admin_list = can?(current_user, :admin_list, current_board_parent) == true - can_admin_list = can?(current_user, :admin_list, current_board_parent) == true
- @no_breadcrumb_container = true - @no_breadcrumb_container = true
- @no_container = true - @no_container = true
...@@ -24,11 +23,7 @@ ...@@ -24,11 +23,7 @@
"ref" => "board_content", "ref" => "board_content",
":lists" => "state.lists", ":lists" => "state.lists",
":can-admin-list" => can_admin_list, ":can-admin-list" => can_admin_list,
":group-id" => group_id, ":disabled" => "disabled" }
":disabled" => "disabled",
":issue-link-base" => "issueLinkBase",
":root-path" => "rootPath",
":board-id" => "boardId" }
- else - else
.boards-list.w-100.py-3.px-2.text-nowrap{ data: { qa_selector: "boards_list" } } .boards-list.w-100.py-3.px-2.text-nowrap{ data: { qa_selector: "boards_list" } }
.boards-app-loading.w-100.text-center{ "v-if" => "loading" } .boards-app-loading.w-100.text-center{ "v-if" => "loading" }
...@@ -37,12 +32,8 @@ ...@@ -37,12 +32,8 @@
"v-for" => "list in state.lists", "v-for" => "list in state.lists",
"ref" => "board", "ref" => "board",
":can-admin-list" => can_admin_list, ":can-admin-list" => can_admin_list,
":group-id" => group_id,
":list" => "list", ":list" => "list",
":disabled" => "disabled", ":disabled" => "disabled",
":issue-link-base" => "issueLinkBase",
":root-path" => "rootPath",
":board-id" => "boardId",
":key" => "list.id" } ":key" => "list.id" }
= render "shared/boards/components/sidebar", group: group = render "shared/boards/components/sidebar", group: group
= render_if_exists 'shared/boards/components/board_settings_sidebar' = render_if_exists 'shared/boards/components/board_settings_sidebar'
...@@ -51,6 +42,4 @@ ...@@ -51,6 +42,4 @@
"milestone-path" => milestones_filter_dropdown_path, "milestone-path" => milestones_filter_dropdown_path,
"label-path" => labels_filter_path_with_defaults, "label-path" => labels_filter_path_with_defaults,
"empty-state-svg" => image_path('illustrations/issues.svg'), "empty-state-svg" => image_path('illustrations/issues.svg'),
":issue-link-base" => "issueLinkBase",
":root-path" => "rootPath",
":project-id" => @project.id } ":project-id" => @project.id }
...@@ -37,10 +37,6 @@ export default { ...@@ -37,10 +37,6 @@ export default {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
rootPath: {
type: String,
required: true,
},
canAdminList: { canAdminList: {
type: Boolean, type: Boolean,
required: false, required: false,
...@@ -157,7 +153,6 @@ export default { ...@@ -157,7 +153,6 @@ export default {
:issues="getIssuesByEpic(list.id, epic.id)" :issues="getIssuesByEpic(list.id, epic.id)"
:is-loading="isLoadingIssues" :is-loading="isLoadingIssues"
:disabled="disabled" :disabled="disabled"
:root-path="rootPath"
:epic-id="epic.id" :epic-id="epic.id"
:epic-is-confidential="epic.confidential" :epic-is-confidential="epic.confidential"
:can-admin-list="canAdminList" :can-admin-list="canAdminList"
......
...@@ -28,24 +28,11 @@ export default { ...@@ -28,24 +28,11 @@ export default {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
boardId: {
type: String,
required: true,
},
canAdminList: { canAdminList: {
type: Boolean, type: Boolean,
required: false, required: false,
default: false, default: false,
}, },
groupId: {
type: Number,
required: false,
default: 0,
},
rootPath: {
type: String,
required: true,
},
}, },
computed: { computed: {
...mapState(['epics', 'isLoadingIssues']), ...mapState(['epics', 'isLoadingIssues']),
...@@ -125,7 +112,6 @@ export default { ...@@ -125,7 +112,6 @@ export default {
:can-admin-list="canAdminList" :can-admin-list="canAdminList"
:list="list" :list="list"
:disabled="disabled" :disabled="disabled"
:board-id="boardId"
:is-swimlanes-header="true" :is-swimlanes-header="true"
/> />
</div> </div>
...@@ -138,7 +124,6 @@ export default { ...@@ -138,7 +124,6 @@ export default {
:lists="lists" :lists="lists"
:is-loading-issues="isLoadingIssues" :is-loading-issues="isLoadingIssues"
:disabled="disabled" :disabled="disabled"
:root-path="rootPath"
:can-admin-list="canAdminList" :can-admin-list="canAdminList"
/> />
<div class="board-lane-unassigned-issues-title gl-sticky gl-display-inline-block gl-left-0"> <div class="board-lane-unassigned-issues-title gl-sticky gl-display-inline-block gl-left-0">
...@@ -167,11 +152,9 @@ export default { ...@@ -167,11 +152,9 @@ export default {
:key="`${list.id}-issues`" :key="`${list.id}-issues`"
:list="list" :list="list"
:issues="unassignedIssues(list.id)" :issues="unassignedIssues(list.id)"
:group-id="groupId"
:is-unassigned-issues-lane="true" :is-unassigned-issues-lane="true"
:is-loading="isLoadingIssues" :is-loading="isLoadingIssues"
:disabled="disabled" :disabled="disabled"
:root-path="rootPath"
:can-admin-list="canAdminList" :can-admin-list="canAdminList"
/> />
</div> </div>
......
...@@ -28,11 +28,6 @@ export default { ...@@ -28,11 +28,6 @@ export default {
required: true, required: true,
default: () => [], default: () => [],
}, },
groupId: {
type: Number,
required: false,
default: 0,
},
isUnassignedIssuesLane: { isUnassignedIssuesLane: {
type: Boolean, type: Boolean,
required: false, required: false,
...@@ -43,10 +38,6 @@ export default { ...@@ -43,10 +38,6 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
rootPath: {
type: String,
required: true,
},
canAdminList: { canAdminList: {
type: Boolean, type: Boolean,
required: false, required: false,
...@@ -150,7 +141,6 @@ export default { ...@@ -150,7 +141,6 @@ export default {
<gl-loading-icon v-if="isLoading" class="gl-p-2" /> <gl-loading-icon v-if="isLoading" class="gl-p-2" />
<board-new-issue <board-new-issue
v-if="list.type !== 'closed' && showIssueForm && isUnassignedIssuesLane" v-if="list.type !== 'closed' && showIssueForm && isUnassignedIssuesLane"
:group-id="groupId"
:list="list" :list="list"
/> />
<component <component
...@@ -167,7 +157,6 @@ export default { ...@@ -167,7 +157,6 @@ export default {
:index="index" :index="index"
:list="list" :list="list"
:issue="issue" :issue="issue"
:root-path="rootPath"
:is-active="isActiveIssue(issue)" :is-active="isActiveIssue(issue)"
@show="showIssue(issue)" @show="showIssue(issue)"
/> />
......
...@@ -15,9 +15,6 @@ describe('ee/BoardContent', () => { ...@@ -15,9 +15,6 @@ describe('ee/BoardContent', () => {
lists: [], lists: [],
canAdminList: false, canAdminList: false,
disabled: false, disabled: false,
issueLinkBase: '',
rootPath: '',
boardId: '',
}, },
stubs: { stubs: {
'board-content-sidebar': BoardContentSidebar, 'board-content-sidebar': BoardContentSidebar,
......
...@@ -74,13 +74,13 @@ describe('Board List Header Component', () => { ...@@ -74,13 +74,13 @@ describe('Board List Header Component', () => {
store, store,
localVue, localVue,
propsData: { propsData: {
boardId,
disabled: false, disabled: false,
issueLinkBase: '/',
rootPath: '/',
list, list,
isSwimlanesHeader, isSwimlanesHeader,
}, },
provide: {
boardId,
},
}); });
}; };
......
...@@ -15,7 +15,6 @@ describe('BoardList Component', () => { ...@@ -15,7 +15,6 @@ describe('BoardList Component', () => {
const componentProps = { const componentProps = {
groupId: undefined, groupId: undefined,
issueLinkBase: '/test/:project_path/issues',
}; };
({ mock, component } = createComponent({ ({ mock, component } = createComponent({
......
...@@ -29,7 +29,6 @@ describe('EpicLane', () => { ...@@ -29,7 +29,6 @@ describe('EpicLane', () => {
epic: mockEpic, epic: mockEpic,
lists: mockListsWithModel, lists: mockListsWithModel,
disabled: false, disabled: false,
rootPath: '/',
}; };
wrapper = shallowMount(EpicLane, { wrapper = shallowMount(EpicLane, {
......
...@@ -34,9 +34,7 @@ describe('EpicsSwimlanes', () => { ...@@ -34,9 +34,7 @@ describe('EpicsSwimlanes', () => {
const store = createStore(); const store = createStore();
const defaultProps = { const defaultProps = {
lists: mockListsWithModel, lists: mockListsWithModel,
boardId: '1',
disabled: false, disabled: false,
rootPath: '/',
}; };
wrapper = shallowMount(EpicsSwimlanes, { wrapper = shallowMount(EpicsSwimlanes, {
......
...@@ -55,7 +55,6 @@ describe('IssuesLaneList', () => { ...@@ -55,7 +55,6 @@ describe('IssuesLaneList', () => {
list, list,
issues: mockIssues, issues: mockIssues,
disabled: false, disabled: false,
rootPath: '/',
}, },
}); });
}; };
......
...@@ -17,10 +17,11 @@ describe('Issue card component', () => { ...@@ -17,10 +17,11 @@ describe('Issue card component', () => {
propsData: { propsData: {
list, list,
issue, issue,
...props,
},
provide: {
groupId: null, groupId: null,
rootPath: '/', rootPath: '/',
issueLinkBase: '/test',
...props,
}, },
}); });
}; };
......
...@@ -52,10 +52,12 @@ export default function createComponent({ ...@@ -52,10 +52,12 @@ export default function createComponent({
list, list,
issues: list.issues, issues: list.issues,
loading: false, loading: false,
issueLinkBase: '/issues',
rootPath: '/',
...componentProps, ...componentProps,
}, },
provide: {
groupId: null,
rootPath: '/',
},
}).$mount(); }).$mount();
Vue.nextTick(() => { Vue.nextTick(() => {
......
...@@ -45,10 +45,12 @@ const createComponent = ({ done, listIssueProps = {}, componentProps = {}, listP ...@@ -45,10 +45,12 @@ const createComponent = ({ done, listIssueProps = {}, componentProps = {}, listP
list, list,
issues: list.issues, issues: list.issues,
loading: false, loading: false,
issueLinkBase: '/issues',
rootPath: '/',
...componentProps, ...componentProps,
}, },
provide: {
groupId: null,
rootPath: '/',
},
}).$mount(); }).$mount();
Vue.nextTick(() => { Vue.nextTick(() => {
......
/* global List */ /* global List */
import Vue from 'vue'; import Vue from 'vue';
import { mount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import boardNewIssue from '~/boards/components/board_new_issue.vue'; import boardNewIssue from '~/boards/components/board_new_issue.vue';
...@@ -10,6 +11,7 @@ import '~/boards/models/list'; ...@@ -10,6 +11,7 @@ import '~/boards/models/list';
import { listObj, boardsMockInterceptor } from './mock_data'; import { listObj, boardsMockInterceptor } from './mock_data';
describe('Issue boards new issue form', () => { describe('Issue boards new issue form', () => {
let wrapper;
let vm; let vm;
let list; let list;
let mock; let mock;
...@@ -24,13 +26,11 @@ describe('Issue boards new issue form', () => { ...@@ -24,13 +26,11 @@ describe('Issue boards new issue form', () => {
const dummySubmitEvent = { const dummySubmitEvent = {
preventDefault() {}, preventDefault() {},
}; };
vm.$refs.submitButton = vm.$el.querySelector('.btn-success'); wrapper.vm.$refs.submitButton = wrapper.find({ ref: 'submitButton' });
return vm.submit(dummySubmitEvent); return wrapper.vm.submit(dummySubmitEvent);
}; };
beforeEach(() => { beforeEach(() => {
setFixtures('<div class="test-container"></div>');
const BoardNewIssueComp = Vue.extend(boardNewIssue); const BoardNewIssueComp = Vue.extend(boardNewIssue);
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
...@@ -43,46 +43,52 @@ describe('Issue boards new issue form', () => { ...@@ -43,46 +43,52 @@ describe('Issue boards new issue form', () => {
newIssueMock = Promise.resolve(promiseReturn); newIssueMock = Promise.resolve(promiseReturn);
jest.spyOn(list, 'newIssue').mockImplementation(() => newIssueMock); jest.spyOn(list, 'newIssue').mockImplementation(() => newIssueMock);
vm = new BoardNewIssueComp({ wrapper = mount(BoardNewIssueComp, {
propsData: { propsData: {
disabled: false,
list, list,
}, },
}).$mount(document.querySelector('.test-container')); provide: {
groupId: null,
},
});
vm = wrapper.vm;
return Vue.nextTick(); return Vue.nextTick();
}); });
afterEach(() => { afterEach(() => {
vm.$destroy(); wrapper.destroy();
mock.restore(); mock.restore();
}); });
it('calls submit if submit button is clicked', () => { it('calls submit if submit button is clicked', () => {
jest.spyOn(vm, 'submit').mockImplementation(e => e.preventDefault()); jest.spyOn(wrapper.vm, 'submit').mockImplementation();
vm.title = 'Testing Title'; vm.title = 'Testing Title';
return Vue.nextTick().then(() => { return Vue.nextTick()
vm.$el.querySelector('.btn-success').click(); .then(submitIssue)
.then(() => {
expect(vm.submit.mock.calls.length).toBe(1); expect(wrapper.vm.submit).toHaveBeenCalled();
}); });
}); });
it('disables submit button if title is empty', () => { it('disables submit button if title is empty', () => {
expect(vm.$el.querySelector('.btn-success').disabled).toBe(true); expect(wrapper.find({ ref: 'submitButton' }).props().disabled).toBe(true);
}); });
it('enables submit button if title is not empty', () => { it('enables submit button if title is not empty', () => {
vm.title = 'Testing Title'; wrapper.setData({ title: 'Testing Title' });
return Vue.nextTick().then(() => { return Vue.nextTick().then(() => {
expect(vm.$el.querySelector('.form-control').value).toBe('Testing Title'); expect(wrapper.find({ ref: 'input' }).element.value).toBe('Testing Title');
expect(vm.$el.querySelector('.btn-success').disabled).not.toBe(true); expect(wrapper.find({ ref: 'submitButton' }).props().disabled).toBe(false);
}); });
}); });
it('clears title after clicking cancel', () => { it('clears title after clicking cancel', () => {
vm.$el.querySelector('.btn-default').click(); wrapper.find({ ref: 'cancelButton' }).trigger('click');
return Vue.nextTick().then(() => { return Vue.nextTick().then(() => {
expect(vm.title).toBe(''); expect(vm.title).toBe('');
...@@ -97,7 +103,7 @@ describe('Issue boards new issue form', () => { ...@@ -97,7 +103,7 @@ describe('Issue boards new issue form', () => {
describe('submit success', () => { describe('submit success', () => {
it('creates new issue', () => { it('creates new issue', () => {
vm.title = 'submit title'; wrapper.setData({ title: 'submit issue' });
return Vue.nextTick() return Vue.nextTick()
.then(submitIssue) .then(submitIssue)
...@@ -107,17 +113,18 @@ describe('Issue boards new issue form', () => { ...@@ -107,17 +113,18 @@ describe('Issue boards new issue form', () => {
}); });
it('enables button after submit', () => { it('enables button after submit', () => {
vm.title = 'submit issue'; jest.spyOn(wrapper.vm, 'submit').mockImplementation();
wrapper.setData({ title: 'submit issue' });
return Vue.nextTick() return Vue.nextTick()
.then(submitIssue) .then(submitIssue)
.then(() => { .then(() => {
expect(vm.$el.querySelector('.btn-success').disabled).toBe(false); expect(wrapper.vm.$refs.submitButton.props().disabled).toBe(false);
}); });
}); });
it('clears title after submit', () => { it('clears title after submit', () => {
vm.title = 'submit issue'; wrapper.setData({ title: 'submit issue' });
return Vue.nextTick() return Vue.nextTick()
.then(submitIssue) .then(submitIssue)
...@@ -128,7 +135,7 @@ describe('Issue boards new issue form', () => { ...@@ -128,7 +135,7 @@ describe('Issue boards new issue form', () => {
it('sets detail issue after submit', () => { it('sets detail issue after submit', () => {
expect(boardsStore.detail.issue.title).toBe(undefined); expect(boardsStore.detail.issue.title).toBe(undefined);
vm.title = 'submit issue'; wrapper.setData({ title: 'submit issue' });
return Vue.nextTick() return Vue.nextTick()
.then(submitIssue) .then(submitIssue)
...@@ -138,7 +145,7 @@ describe('Issue boards new issue form', () => { ...@@ -138,7 +145,7 @@ describe('Issue boards new issue form', () => {
}); });
it('sets detail list after submit', () => { it('sets detail list after submit', () => {
vm.title = 'submit issue'; wrapper.setData({ title: 'submit issue' });
return Vue.nextTick() return Vue.nextTick()
.then(submitIssue) .then(submitIssue)
...@@ -149,7 +156,7 @@ describe('Issue boards new issue form', () => { ...@@ -149,7 +156,7 @@ describe('Issue boards new issue form', () => {
it('sets detail weight after submit', () => { it('sets detail weight after submit', () => {
boardsStore.weightFeatureAvailable = true; boardsStore.weightFeatureAvailable = true;
vm.title = 'submit issue'; wrapper.setData({ title: 'submit issue' });
return Vue.nextTick() return Vue.nextTick()
.then(submitIssue) .then(submitIssue)
...@@ -160,7 +167,7 @@ describe('Issue boards new issue form', () => { ...@@ -160,7 +167,7 @@ describe('Issue boards new issue form', () => {
it('does not set detail weight after submit', () => { it('does not set detail weight after submit', () => {
boardsStore.weightFeatureAvailable = false; boardsStore.weightFeatureAvailable = false;
vm.title = 'submit issue'; wrapper.setData({ title: 'submit issue' });
return Vue.nextTick() return Vue.nextTick()
.then(submitIssue) .then(submitIssue)
......
...@@ -31,12 +31,14 @@ describe('Board card layout', () => { ...@@ -31,12 +31,14 @@ describe('Board card layout', () => {
propsData: { propsData: {
list, list,
issue: list.issues[0], issue: list.issues[0],
issueLinkBase: '/',
disabled: false, disabled: false,
index: 0, index: 0,
rootPath: '/',
...propsData, ...propsData,
}, },
provide: {
groupId: null,
rootPath: '/',
},
}); });
}; };
......
...@@ -38,12 +38,14 @@ describe('BoardCard', () => { ...@@ -38,12 +38,14 @@ describe('BoardCard', () => {
propsData: { propsData: {
list, list,
issue: list.issues[0], issue: list.issues[0],
issueLinkBase: '/',
disabled: false, disabled: false,
index: 0, index: 0,
rootPath: '/',
...propsData, ...propsData,
}, },
provide: {
groupId: null,
rootPath: '/',
},
}); });
}; };
......
...@@ -59,10 +59,11 @@ describe('Board Column Component', () => { ...@@ -59,10 +59,11 @@ describe('Board Column Component', () => {
propsData: { propsData: {
boardId, boardId,
disabled: false, disabled: false,
issueLinkBase: '/',
rootPath: '/',
list, list,
}, },
provide: {
boardId,
},
}); });
}; };
......
...@@ -39,11 +39,7 @@ describe('BoardContent', () => { ...@@ -39,11 +39,7 @@ describe('BoardContent', () => {
propsData: { propsData: {
lists: mockListsWithModel, lists: mockListsWithModel,
canAdminList: true, canAdminList: true,
groupId: 1,
disabled: false, disabled: false,
issueLinkBase: '/',
rootPath: '/',
boardId: '1',
}, },
store, store,
}); });
......
...@@ -57,12 +57,12 @@ describe('Board List Header Component', () => { ...@@ -57,12 +57,12 @@ describe('Board List Header Component', () => {
wrapper = shallowMount(BoardListHeader, { wrapper = shallowMount(BoardListHeader, {
propsData: { propsData: {
boardId,
disabled: false, disabled: false,
issueLinkBase: '/',
rootPath: '/',
list, list,
}, },
provide: {
boardId,
},
}); });
}; };
......
...@@ -47,13 +47,15 @@ describe('Issue card component', () => { ...@@ -47,13 +47,15 @@ describe('Issue card component', () => {
propsData: { propsData: {
list, list,
issue, issue,
issueLinkBase: '/test',
rootPath: '/',
}, },
store, store,
stubs: { stubs: {
GlLabel: true, GlLabel: true,
}, },
provide: {
groupId: null,
rootPath: '/',
},
}); });
}); });
......
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