Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
minerva
frontend
Commits
af40a282
Commit
af40a282
authored
3 months ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
mock endpoints used for obtaining backend stacktrace
parent
926252f8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!347
Merge 18.0.8
,
!346
Resolve "tests depend on lux1 being online"
,
!344
Resolve "removing overlay does not work"
Pipeline
#99252
passed
3 months ago
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/redux/middlewares/error.middleware.test.ts
+13
-2
13 additions, 2 deletions
src/redux/middlewares/error.middleware.test.ts
with
13 additions
and
2 deletions
src/redux/middlewares/error.middleware.test.ts
+
13
−
2
View file @
af40a282
import
{
store
}
from
'
@/redux/store
'
;
import
{
mockNetworkResponse
}
from
'
@/utils/mockNetworkResponse
'
;
import
{
apiPath
}
from
'
@/redux/apiPath
'
;
import
{
HttpStatusCode
}
from
'
axios
'
;
import
{
errorMiddlewareListener
}
from
'
./error.middleware
'
;
jest
.
mock
(
'
../../utils/showToast
'
);
const
mockedAxiosClient
=
mockNetworkResponse
();
describe
(
'
errorMiddlewareListener
'
,
()
=>
{
const
dispatchSpy
=
jest
.
spyOn
(
store
,
'
dispatch
'
);
...
...
@@ -12,6 +17,8 @@ describe('errorMiddlewareListener', () => {
});
it
(
'
should handle error with message when action is rejected
'
,
async
()
=>
{
mockedAxiosClient
.
onGet
(
apiPath
.
getStacktrace
(
'
Error-2
'
)).
reply
(
HttpStatusCode
.
Ok
,
{});
const
action
=
{
type
:
'
action/rejected
'
,
payload
:
'
Error message
'
,
...
...
@@ -21,7 +28,7 @@ describe('errorMiddlewareListener', () => {
requestStatus
:
'
rejected
'
,
},
error
:
{
code
:
'
Error
2
'
,
code
:
'
Error
-
2
'
,
},
};
const
{
getState
,
dispatch
}
=
store
;
...
...
@@ -37,6 +44,7 @@ describe('errorMiddlewareListener', () => {
});
it
(
'
should handle error without message when action is rejected
'
,
async
()
=>
{
mockedAxiosClient
.
onGet
(
apiPath
.
getStacktrace
(
'
Error-3
'
)).
reply
(
HttpStatusCode
.
Ok
,
{});
const
action
=
{
type
:
'
action/rejected
'
,
payload
:
null
,
...
...
@@ -46,7 +54,7 @@ describe('errorMiddlewareListener', () => {
requestStatus
:
'
rejected
'
,
},
error
:
{
code
:
'
Error
3
'
,
code
:
'
Error
-
3
'
,
},
};
const
{
getState
,
dispatch
}
=
store
;
...
...
@@ -78,6 +86,7 @@ describe('errorMiddlewareListener', () => {
});
it
(
'
should handle error with unknown error message when action payload is not a string
'
,
async
()
=>
{
mockedAxiosClient
.
onGet
(
apiPath
.
getStacktrace
(
'
ERROR
'
)).
reply
(
HttpStatusCode
.
Ok
,
{});
const
action
=
{
type
:
'
action/rejected
'
,
payload
:
{},
...
...
@@ -104,6 +113,7 @@ describe('errorMiddlewareListener', () => {
});
it
(
'
should handle error with custom message when action payload is a string
'
,
async
()
=>
{
mockedAxiosClient
.
onGet
(
apiPath
.
getStacktrace
(
'
ERROR
'
)).
reply
(
HttpStatusCode
.
Ok
,
{});
const
action
=
{
type
:
'
action/rejected
'
,
payload
:
'
Failed to fetch
'
,
...
...
@@ -133,6 +143,7 @@ describe('errorMiddlewareListener', () => {
});
it
(
'
should show modal on access denied
'
,
async
()
=>
{
mockedAxiosClient
.
onGet
(
apiPath
.
getStacktrace
(
'
403
'
)).
reply
(
HttpStatusCode
.
Ok
,
{});
const
action
=
{
type
:
'
action/rejected
'
,
payload
:
null
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment