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
46421574
Commit
46421574
authored
May 14, 2020
by
lauraMon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds a spec
parent
479c6eb8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
1 deletion
+52
-1
spec/frontend/alert_management/components/alert_management_detail_spec.js
...ert_management/components/alert_management_detail_spec.js
+52
-1
No files found.
spec/frontend/alert_management/components/alert_management_detail_spec.js
View file @
46421574
import
{
mount
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlAlert
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlAlert
,
GlLoadingIcon
,
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
AlertDetails
from
'
~/alert_management/components/alert_details.vue
'
;
import
updateAlertStatus
from
'
~/alert_management/graphql/mutations/update_alert_status.graphql
'
;
import
createFlash
from
'
~/flash
'
;
import
mockAlerts
from
'
../mocks/alerts.json
'
;
const
mockAlert
=
mockAlerts
[
0
];
jest
.
mock
(
'
~/flash
'
);
describe
(
'
AlertDetails
'
,
()
=>
{
let
wrapper
;
const
newIssuePath
=
'
root/alerts/-/issues/new
'
;
const
findStatusDropdownItem
=
()
=>
wrapper
.
find
(
GlDropdownItem
);
function
mountComponent
({
data
,
...
...
@@ -31,6 +35,7 @@ describe('AlertDetails', () => {
},
mocks
:
{
$apollo
:
{
mutate
:
jest
.
fn
(),
queries
:
{
alert
:
{
loading
,
...
...
@@ -188,4 +193,50 @@ describe('AlertDetails', () => {
});
});
});
describe
(
'
updating the alert status
'
,
()
=>
{
const
mockUpdatedMutationResult
=
{
data
:
{
updateAlertStatus
:
{
errors
:
[],
alert
:
{
status
:
'
acknowledged
'
,
},
},
},
};
beforeEach
(()
=>
{
mountComponent
({
props
:
{
alertManagementEnabled
:
true
,
userCanEnableAlertManagement
:
true
},
data
:
{
alert
:
mockAlert
},
loading
:
false
,
});
});
it
(
'
calls `$apollo.mutate` with `updateAlertStatus` mutation and variables containing `iid`, `status`, & `projectPath`
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
).
mockResolvedValue
(
mockUpdatedMutationResult
);
findStatusDropdownItem
().
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
vm
.
$apollo
.
mutate
).
toHaveBeenCalledWith
({
mutation
:
updateAlertStatus
,
variables
:
{
iid
:
'
alertId
'
,
status
:
'
TRIGGERED
'
,
projectPath
:
'
projectPath
'
,
},
});
});
it
(
'
calls `createFlash` when request fails
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
).
mockReturnValue
(
Promise
.
reject
(
new
Error
()));
findStatusDropdownItem
().
vm
.
$emit
(
'
click
'
);
setImmediate
(()
=>
{
expect
(
createFlash
).
toHaveBeenCalledWith
(
'
There was an error while updating the status of the alert. Please try again.
'
,
);
});
});
});
});
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