Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
3c1346d8
Unverified
Commit
3c1346d8
authored
Jul 17, 2020
by
Torkel Ödegaard
Committed by
GitHub
Jul 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BackendSrv: Fix error alert logic (#26411)
parent
903c7641
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletions
+22
-1
public/app/core/services/backend_srv.ts
+1
-1
public/app/core/specs/backend_srv.test.ts
+21
-0
No files found.
public/app/core/services/backend_srv.ts
View file @
3c1346d8
...
...
@@ -219,7 +219,7 @@ export class BackendSrv implements BackendService {
}
// is showErrorAlert is undefined we only show alerts non data query and local api requests
if
(
config
.
showErrorAlert
===
undefined
||
isDataQuery
(
config
.
url
)
||
!
isLocalUrl
(
config
.
url
))
{
if
(
config
.
showErrorAlert
===
undefined
&&
(
isDataQuery
(
config
.
url
)
||
!
isLocalUrl
(
config
.
url
)
))
{
return
;
}
...
...
public/app/core/specs/backend_srv.test.ts
View file @
3c1346d8
...
...
@@ -7,6 +7,7 @@ import { BackendSrv } from '../services/backend_srv';
import
{
Emitter
}
from
'../utils/emitter'
;
import
{
ContextSrv
,
User
}
from
'../services/context_srv'
;
import
{
describe
,
expect
}
from
'../../../test/lib/common'
;
import
{
BackendSrvRequest
,
FetchError
}
from
'@grafana/runtime'
;
const
getTestContext
=
(
overides
?:
object
)
=>
{
const
defaults
=
{
...
...
@@ -217,6 +218,26 @@ describe('backendSrv', () => {
});
});
describe
(
'when showing error alert'
,
()
=>
{
describe
(
'when showErrorAlert is undefined and url is a normal api call'
,
()
=>
{
it
(
'It should emit alert event for normal api errors'
,
async
()
=>
{
const
{
backendSrv
,
appEventsMock
}
=
getTestContext
({});
backendSrv
.
showErrorAlert
(
{
url
:
'api/do/something'
,
}
as
BackendSrvRequest
,
{
data
:
{
message
:
'Something failed'
,
error
:
'Error'
,
},
}
as
FetchError
);
expect
(
appEventsMock
.
emit
).
toHaveBeenCalledWith
(
AppEvents
.
alertError
,
[
'Something failed'
,
''
]);
});
});
});
describe
(
'when making an unsuccessful 422 call'
,
()
=>
{
it
(
'then it should emit Validation failed message'
,
async
()
=>
{
jest
.
useFakeTimers
();
...
...
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