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
bc2a3899
Commit
bc2a3899
authored
Jul 22, 2021
by
Olena Horal-Koretska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide edit severity btn for users without permissions
Changelog: fixed
parent
2174e246
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
20 deletions
+44
-20
app/assets/javascripts/sidebar/components/severity/sidebar_severity.vue
...ascripts/sidebar/components/severity/sidebar_severity.vue
+2
-0
app/assets/javascripts/sidebar/mount_sidebar.js
app/assets/javascripts/sidebar/mount_sidebar.js
+4
-1
spec/frontend/sidebar/components/severity/sidebar_severity_spec.js
...tend/sidebar/components/severity/sidebar_severity_spec.js
+38
-19
No files found.
app/assets/javascripts/sidebar/components/severity/sidebar_severity.vue
View file @
bc2a3899
...
@@ -23,6 +23,7 @@ export default {
...
@@ -23,6 +23,7 @@ export default {
GlLink
,
GlLink
,
SeverityToken
,
SeverityToken
,
},
},
inject
:
[
'
canUpdate
'
],
props
:
{
props
:
{
projectPath
:
{
projectPath
:
{
type
:
String
,
type
:
String
,
...
@@ -153,6 +154,7 @@ export default {
...
@@ -153,6 +154,7 @@ export default {
>
>
{{ $options.i18n.SEVERITY }}
{{ $options.i18n.SEVERITY }}
<gl-link
<gl-link
v-if=
"canUpdate"
data-testid=
"editButton"
data-testid=
"editButton"
href=
"#"
href=
"#"
@
click=
"toggleFormDropdown"
@
click=
"toggleFormDropdown"
...
...
app/assets/javascripts/sidebar/mount_sidebar.js
View file @
bc2a3899
...
@@ -493,7 +493,7 @@ function mountSeverityComponent() {
...
@@ -493,7 +493,7 @@ function mountSeverityComponent() {
return
false
;
return
false
;
}
}
const
{
fullPath
,
iid
,
severity
}
=
getSidebarOptions
();
const
{
fullPath
,
iid
,
severity
,
editable
}
=
getSidebarOptions
();
return
new
Vue
({
return
new
Vue
({
el
:
severityContainerEl
,
el
:
severityContainerEl
,
...
@@ -501,6 +501,9 @@ function mountSeverityComponent() {
...
@@ -501,6 +501,9 @@ function mountSeverityComponent() {
components
:
{
components
:
{
SidebarSeverity
,
SidebarSeverity
,
},
},
provide
:
{
canUpdate
:
editable
,
},
render
:
(
createElement
)
=>
render
:
(
createElement
)
=>
createElement
(
'
sidebar-severity
'
,
{
createElement
(
'
sidebar-severity
'
,
{
props
:
{
props
:
{
...
...
spec/frontend/sidebar/components/severity/sidebar_severity_spec.js
View file @
bc2a3899
import
{
GlDropdown
,
GlDropdownItem
,
GlLoadingIcon
,
GlTooltip
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
GlDropdown
,
GlDropdownItem
,
GlLoadingIcon
,
GlTooltip
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
import
{
INCIDENT_SEVERITY
,
ISSUABLE_TYPES
}
from
'
~/sidebar/components/severity/constants
'
;
import
{
INCIDENT_SEVERITY
,
ISSUABLE_TYPES
}
from
'
~/sidebar/components/severity/constants
'
;
...
@@ -15,6 +16,7 @@ describe('SidebarSeverity', () => {
...
@@ -15,6 +16,7 @@ describe('SidebarSeverity', () => {
const
projectPath
=
'
gitlab-org/gitlab-test
'
;
const
projectPath
=
'
gitlab-org/gitlab-test
'
;
const
iid
=
'
1
'
;
const
iid
=
'
1
'
;
const
severity
=
'
CRITICAL
'
;
const
severity
=
'
CRITICAL
'
;
let
canUpdate
=
true
;
function
createComponent
(
props
=
{})
{
function
createComponent
(
props
=
{})
{
const
propsData
=
{
const
propsData
=
{
...
@@ -25,8 +27,11 @@ describe('SidebarSeverity', () => {
...
@@ -25,8 +27,11 @@ describe('SidebarSeverity', () => {
...
props
,
...
props
,
};
};
mutate
=
jest
.
fn
();
mutate
=
jest
.
fn
();
wrapper
=
shallowMount
(
SidebarSeverity
,
{
wrapper
=
shallowMount
Extended
(
SidebarSeverity
,
{
propsData
,
propsData
,
provide
:
{
canUpdate
,
},
mocks
:
{
mocks
:
{
$apollo
:
{
$apollo
:
{
mutate
,
mutate
,
...
@@ -45,22 +50,34 @@ describe('SidebarSeverity', () => {
...
@@ -45,22 +50,34 @@ describe('SidebarSeverity', () => {
afterEach
(()
=>
{
afterEach
(()
=>
{
if
(
wrapper
)
{
if
(
wrapper
)
{
wrapper
.
destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
}
}
});
});
const
findSeverityToken
=
()
=>
wrapper
.
findAll
(
SeverityToken
);
const
findSeverityToken
=
()
=>
wrapper
.
findAll
Components
(
SeverityToken
);
const
findEditBtn
=
()
=>
wrapper
.
find
(
'
[data-testid="editButton"]
'
);
const
findEditBtn
=
()
=>
wrapper
.
find
ByTestId
(
'
editButton
'
);
const
findDropdown
=
()
=>
wrapper
.
find
(
GlDropdown
);
const
findDropdown
=
()
=>
wrapper
.
find
Component
(
GlDropdown
);
const
findCriticalSeverityDropdownItem
=
()
=>
wrapper
.
find
(
GlDropdownItem
);
const
findCriticalSeverityDropdownItem
=
()
=>
wrapper
.
find
Component
(
GlDropdownItem
);
const
findLoadingIcon
=
()
=>
wrapper
.
find
(
GlLoadingIcon
);
const
findLoadingIcon
=
()
=>
wrapper
.
find
Component
(
GlLoadingIcon
);
const
findTooltip
=
()
=>
wrapper
.
find
(
GlTooltip
);
const
findTooltip
=
()
=>
wrapper
.
find
Component
(
GlTooltip
);
const
findCollapsedSeverity
=
()
=>
wrapper
.
find
({
ref
:
'
severity
'
});
const
findCollapsedSeverity
=
()
=>
wrapper
.
find
({
ref
:
'
severity
'
});
it
(
'
renders severity widget
'
,
()
=>
{
describe
(
'
Severity widget
'
,
()
=>
{
expect
(
findEditBtn
().
exists
()).
toBe
(
true
);
it
(
'
renders severity dropdown and token
'
,
()
=>
{
expect
(
findSeverityToken
().
exists
()).
toBe
(
true
);
expect
(
findSeverityToken
().
exists
()).
toBe
(
true
);
expect
(
findDropdown
().
exists
()).
toBe
(
true
);
expect
(
findDropdown
().
exists
()).
toBe
(
true
);
});
describe
(
'
edit button
'
,
()
=>
{
it
(
'
is rendered when `canUpdate` provided as `true`
'
,
()
=>
{
expect
(
findEditBtn
().
exists
()).
toBe
(
true
);
});
it
(
'
is NOT rendered when `canUpdate` provided as `false`
'
,
()
=>
{
canUpdate
=
false
;
createComponent
();
expect
(
findEditBtn
().
exists
()).
toBe
(
false
);
});
});
});
});
describe
(
'
Update severity
'
,
()
=>
{
describe
(
'
Update severity
'
,
()
=>
{
...
@@ -100,7 +117,7 @@ describe('SidebarSeverity', () => {
...
@@ -100,7 +117,7 @@ describe('SidebarSeverity', () => {
);
);
findCriticalSeverityDropdownItem
().
vm
.
$emit
(
'
click
'
);
findCriticalSeverityDropdownItem
().
vm
.
$emit
(
'
click
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findLoadingIcon
().
exists
()).
toBe
(
true
);
expect
(
findLoadingIcon
().
exists
()).
toBe
(
true
);
resolvePromise
();
resolvePromise
();
...
@@ -128,27 +145,29 @@ describe('SidebarSeverity', () => {
...
@@ -128,27 +145,29 @@ describe('SidebarSeverity', () => {
it
(
'
should expand the dropdown on collapsed icon click
'
,
async
()
=>
{
it
(
'
should expand the dropdown on collapsed icon click
'
,
async
()
=>
{
wrapper
.
vm
.
isDropdownShowing
=
false
;
wrapper
.
vm
.
isDropdownShowing
=
false
;
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findDropdown
().
classes
(
HIDDDEN_CLASS
)).
toBe
(
true
);
expect
(
findDropdown
().
classes
(
HIDDDEN_CLASS
)).
toBe
(
true
);
findCollapsedSeverity
().
trigger
(
'
click
'
);
findCollapsedSeverity
().
trigger
(
'
click
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findDropdown
().
classes
(
SHOWN_CLASS
)).
toBe
(
true
);
expect
(
findDropdown
().
classes
(
SHOWN_CLASS
)).
toBe
(
true
);
});
});
});
});
describe
(
'
expanded
'
,
()
=>
{
describe
(
'
expanded
'
,
()
=>
{
it
(
'
toggles dropdown with edit button
'
,
async
()
=>
{
it
(
'
toggles dropdown with edit button
'
,
async
()
=>
{
canUpdate
=
true
;
createComponent
();
wrapper
.
vm
.
isDropdownShowing
=
false
;
wrapper
.
vm
.
isDropdownShowing
=
false
;
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findDropdown
().
classes
(
HIDDDEN_CLASS
)).
toBe
(
true
);
expect
(
findDropdown
().
classes
(
HIDDDEN_CLASS
)).
toBe
(
true
);
findEditBtn
().
vm
.
$emit
(
'
click
'
);
findEditBtn
().
vm
.
$emit
(
'
click
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findDropdown
().
classes
(
SHOWN_CLASS
)).
toBe
(
true
);
expect
(
findDropdown
().
classes
(
SHOWN_CLASS
)).
toBe
(
true
);
findEditBtn
().
vm
.
$emit
(
'
click
'
);
findEditBtn
().
vm
.
$emit
(
'
click
'
);
await
wrapper
.
vm
.
$
nextTick
();
await
nextTick
();
expect
(
findDropdown
().
classes
(
HIDDDEN_CLASS
)).
toBe
(
true
);
expect
(
findDropdown
().
classes
(
HIDDDEN_CLASS
)).
toBe
(
true
);
});
});
});
});
...
...
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