Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2a586727
Commit
2a586727
authored
Oct 26, 2021
by
Tom Quirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address reviewer feedback
Add more coverage for issue_field.
parent
e093779a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
21 deletions
+54
-21
ee/app/assets/javascripts/external_issues_show/components/sidebar/issue_field.vue
...s/external_issues_show/components/sidebar/issue_field.vue
+13
-3
ee/app/assets/javascripts/integrations/jira/issues_show/components/sidebar/jira_issues_sidebar_root.vue
...sues_show/components/sidebar/jira_issues_sidebar_root.vue
+1
-1
ee/spec/frontend/external_issues_show/components/sidebar/issue_field_spec.js
...ternal_issues_show/components/sidebar/issue_field_spec.js
+40
-17
No files found.
ee/app/assets/javascripts/external_issues_show/components/sidebar/issue_field.vue
View file @
2a586727
...
...
@@ -13,8 +13,18 @@ export default {
IssueFieldDropdown
,
SidebarEditableItem
,
},
inject
:
{
// In this context, `canUpdate` means: "can a user update any part of the sidebar?"
// `canUpdate` is also injected into `sidebar-editable-item`. Here, it's used, in
// conjunction with with its `canEdit` prop, to conditionally display the
// "edit" button.
canUpdate
:
{
default
:
false
,
},
},
props
:
{
canEdit
:
{
// In this context, `canEditField` means: "can a user edit this specific field?"
canEditField
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
...
...
@@ -99,7 +109,7 @@ export default {
ref=
"editableItem"
:loading=
"updating"
:title=
"title"
:can-edit=
"canEdit"
:can-edit=
"canEdit
Field
"
@
open=
"showDropdown"
>
<template
#collapsed
>
...
...
@@ -121,7 +131,7 @@ export default {
<
template
#default
>
<issue-field-dropdown
v-if=
"canEdit"
v-if=
"canEdit
Field && canUpdate
"
ref=
"dropdown"
:empty-text=
"dropdownEmpty"
:items=
"items"
...
...
ee/app/assets/javascripts/integrations/jira/issues_show/components/sidebar/jira_issues_sidebar_root.vue
View file @
2a586727
...
...
@@ -136,7 +136,7 @@ export default {
<issue-due-date
:due-date=
"issue.dueDate"
/>
<issue-field
icon=
"progress"
:can-edit=
"canUpdateStatus"
:can-edit
-field
=
"canUpdateStatus"
:dropdown-title=
"$options.i18n.statusDropdownTitle"
:dropdown-empty=
"$options.i18n.statusDropdownEmpty"
:items=
"statuses"
...
...
ee/spec/frontend/external_issues_show/components/sidebar/issue_field_spec.js
View file @
2a586727
...
...
@@ -15,7 +15,7 @@ describe('IssueField', () => {
title
:
'
Field Title
'
,
};
const
createComponent
=
({
props
=
{}
}
=
{})
=>
{
const
createComponent
=
({
props
=
{}
,
provide
=
{}
}
=
{})
=>
{
wrapper
=
shallowMountExtended
(
IssueField
,
{
directives
:
{
GlTooltip
:
createMockDirective
(),
...
...
@@ -26,6 +26,7 @@ describe('IssueField', () => {
},
provide
:
{
canUpdate
:
true
,
...
provide
,
},
});
};
...
...
@@ -40,6 +41,7 @@ describe('IssueField', () => {
const
findFieldCollapsedTooltip
=
()
=>
getBinding
(
findFieldCollapsed
().
element
,
'
gl-tooltip
'
);
const
findFieldValue
=
()
=>
wrapper
.
findByTestId
(
'
field-value
'
);
const
findGlIcon
=
()
=>
wrapper
.
findComponent
(
GlIcon
);
const
findEditableItemDropdown
=
()
=>
wrapper
.
findComponent
({
ref
:
'
dropdown
'
});
describe
(
'
template
'
,
()
=>
{
beforeEach
(()
=>
{
...
...
@@ -97,24 +99,45 @@ describe('IssueField', () => {
});
});
describe
(
'
with canEdit = true
'
,
()
=>
{
describe
.
each
`
canUpdate | canEditField | expectEditButton
${
false
}
|
${
false
}
|
${
false
}
${
false
}
|
${
true
}
|
${
false
}
${
true
}
|
${
false
}
|
${
false
}
${
true
}
|
${
true
}
|
${
true
}
`
(
'
when `canUpdate` is `$canUpdate` and `canEditField` is `$canEditField`
'
,
({
canUpdate
,
canEditField
,
expectEditButton
})
=>
{
beforeEach
(()
=>
{
createComponent
({
props
:
{
canEdit
:
true
},
props
:
{
canEditField
},
provide
:
{
canUpdate
,
},
});
});
it
(
'
renders "Edit" button
'
,
()
=>
{
expect
(
findEditButton
().
text
()).
toBe
(
'
Edit
'
);
it
(
'
renders "Edit" button correctly
'
,
()
=>
{
expect
(
findEditButton
().
exists
()).
toBe
(
expectEditButton
);
});
it
(
'
emits "issue-field-fetch" when dropdown is opened
'
,
()
=>
{
wrapper
.
vm
.
$refs
.
dropdown
.
showDropdown
=
jest
.
fn
();
it
(
'
renders dropdown in sidebar-editable-item
'
,
()
=>
{
expect
(
findEditableItemDropdown
().
exists
()).
toBe
(
expectEditButton
);
});
if
(
expectEditButton
)
{
describe
(
'
when sidebar-editable-item emits "open" event
'
,
()
=>
{
it
(
'
emits "issue-field-fetch" event
'
,
()
=>
{
const
dropdown
=
findEditableItemDropdown
();
dropdown
.
vm
.
showDropdown
=
jest
.
fn
();
findEditableItem
().
vm
.
$emit
(
'
open
'
);
expect
(
wrapper
.
vm
.
$refs
.
dropdown
.
showDropdown
).
toHaveBeenCalled
();
expect
(
dropdown
.
vm
.
showDropdown
).
toHaveBeenCalled
();
expect
(
wrapper
.
emitted
(
'
issue-field-fetch
'
)).
toHaveLength
(
1
);
});
});
}
},
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment