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
e70cc016
Commit
e70cc016
authored
Jan 28, 2021
by
Dave Pisek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec to cover opening of window
parent
e85d245c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
32 deletions
+32
-32
ee/app/assets/javascripts/security_dashboard/components/vulnerability_action_buttons.vue
...ity_dashboard/components/vulnerability_action_buttons.vue
+1
-1
ee/spec/frontend/security_dashboard/components/vulnerability_action_buttons_spec.js
...dashboard/components/vulnerability_action_buttons_spec.js
+31
-31
No files found.
ee/app/assets/javascripts/security_dashboard/components/vulnerability_action_buttons.vue
View file @
e70cc016
...
...
@@ -66,7 +66,7 @@ export default {
this
.
createIssue
({
vulnerability
,
flashError
:
true
});
}
},
openNewJiraIssueWindow
({
create_jira_issue_url
})
{
createNewJiraIssue
({
create_jira_issue_url
})
{
window
.
open
(
create_jira_issue_url
,
'
_blank
'
);
},
handleDismissVulnerability
()
{
...
...
ee/spec/frontend/security_dashboard/components/vulnerability_action_buttons_spec.js
View file @
e70cc016
...
...
@@ -17,6 +17,12 @@ describe('Security Dashboard Action Buttons', () => {
});
};
const
findAllButtons
=
()
=>
wrapper
.
findAll
(
'
.btn-group .btn
'
);
const
findMoreInfoButton
=
()
=>
wrapper
.
find
(
'
.js-more-info
'
);
const
findCreateIssueButton
=
()
=>
wrapper
.
find
(
'
.js-create-issue
'
);
const
findDismissVulnerabilityButton
=
()
=>
wrapper
.
find
(
'
.js-dismiss-vulnerability
'
);
const
findUndoDismissButton
=
()
=>
wrapper
.
find
(
'
.js-undo-dismiss
'
);
beforeEach
(()
=>
{
store
=
createStore
();
});
...
...
@@ -40,22 +46,16 @@ describe('Security Dashboard Action Buttons', () => {
});
it
(
'
should render three buttons in a button group
'
,
()
=>
{
expect
(
wrapper
.
findAll
(
'
.btn-group .btn
'
)).
toHaveLength
(
3
);
expect
(
findAllButtons
(
)).
toHaveLength
(
3
);
});
describe
(
'
More Info Button
'
,
()
=>
{
let
button
;
beforeEach
(()
=>
{
button
=
wrapper
.
find
(
'
.js-more-info
'
);
});
it
(
'
should render the More info button
'
,
()
=>
{
expect
(
button
.
exists
()).
toBe
(
true
);
expect
(
findMoreInfoButton
()
.
exists
()).
toBe
(
true
);
});
it
(
'
should emit an `setModalData` event and open the modal when clicked
'
,
()
=>
{
button
.
trigger
(
'
click
'
);
findMoreInfoButton
()
.
trigger
(
'
click
'
);
expect
(
wrapper
.
vm
.
$store
.
dispatch
).
toHaveBeenCalledWith
(
'
vulnerabilities/setModalData
'
,
{
vulnerability
:
mockDataVulnerabilities
[
0
],
...
...
@@ -67,18 +67,12 @@ describe('Security Dashboard Action Buttons', () => {
});
describe
(
'
Create Issue Button
'
,
()
=>
{
let
button
;
beforeEach
(()
=>
{
button
=
wrapper
.
find
(
'
.js-create-issue
'
);
});
it
(
'
should render the create issue button
'
,
()
=>
{
expect
(
button
.
exists
()).
toBe
(
true
);
expect
(
findCreateIssueButton
()
.
exists
()).
toBe
(
true
);
});
it
(
'
should emit an `createIssue` event when clicked
'
,
()
=>
{
button
.
trigger
(
'
click
'
);
findCreateIssueButton
()
.
trigger
(
'
click
'
);
expect
(
wrapper
.
vm
.
$store
.
dispatch
).
toHaveBeenCalledWith
(
'
vulnerabilities/createIssue
'
,
{
vulnerability
:
mockDataVulnerabilities
[
0
],
...
...
@@ -100,24 +94,30 @@ describe('Security Dashboard Action Buttons', () => {
});
it
(
'
should render the correct tooltip
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-create-issue
'
).
attributes
(
'
title
'
)).
toBe
(
'
Create Jira issue
'
);
expect
(
findCreateIssueButton
(
).
attributes
(
'
title
'
)).
toBe
(
'
Create Jira issue
'
);
});
});
});
describe
(
'
Dismiss Vulnerability Button
'
,
()
=>
{
let
button
;
it
(
'
should open a new window when the create-issue button is clicked
'
,
()
=>
{
jest
.
spyOn
(
window
,
'
open
'
).
mockReturnValueOnce
();
expect
(
window
.
open
).
not
.
toHaveBeenCalled
();
findCreateIssueButton
().
trigger
(
'
click
'
);
beforeEach
(()
=>
{
button
=
wrapper
.
find
(
'
.js-dismiss-vulnerability
'
);
expect
(
window
.
open
).
toHaveBeenCalledWith
(
mockDataVulnerabilities
[
8
].
create_jira_issue_url
,
'
_blank
'
,
);
});
});
});
describe
(
'
Dismiss Vulnerability Button
'
,
()
=>
{
it
(
'
should render the dismiss vulnerability button
'
,
()
=>
{
expect
(
button
.
exists
()).
toBe
(
true
);
expect
(
findDismissVulnerabilityButton
()
.
exists
()).
toBe
(
true
);
});
it
(
'
should emit an `dismissVulnerability` event when clicked
'
,
()
=>
{
button
.
trigger
(
'
click
'
);
findDismissVulnerabilityButton
()
.
trigger
(
'
click
'
);
expect
(
wrapper
.
vm
.
$store
.
dispatch
).
toHaveBeenCalledWith
(
'
vulnerabilities/dismissVulnerability
'
,
...
...
@@ -140,11 +140,11 @@ describe('Security Dashboard Action Buttons', () => {
});
it
(
'
should only render one button
'
,
()
=>
{
expect
(
wrapper
.
findAll
(
'
.btn
'
)).
toHaveLength
(
1
);
expect
(
findAllButtons
(
)).
toHaveLength
(
1
);
});
it
(
'
should not render the create issue button
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-create-issue
'
).
exists
()).
toBe
(
false
);
expect
(
findCreateIssueButton
(
).
exists
()).
toBe
(
false
);
});
});
...
...
@@ -160,15 +160,15 @@ describe('Security Dashboard Action Buttons', () => {
});
it
(
'
should render two buttons in a button group
'
,
()
=>
{
expect
(
wrapper
.
findAll
(
'
.btn-group .btn
'
)).
toHaveLength
(
2
);
expect
(
findAllButtons
(
)).
toHaveLength
(
2
);
});
it
(
'
should not render the dismiss vulnerability button
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-dismiss-vulnerability
'
).
exists
()).
toBe
(
false
);
expect
(
findDismissVulnerabilityButton
(
).
exists
()).
toBe
(
false
);
});
it
(
'
should render the undo dismiss button
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-undo-dismiss
'
).
exists
()).
toBe
(
true
);
expect
(
findUndoDismissButton
(
).
exists
()).
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