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
4a3f645f
Commit
4a3f645f
authored
10 months ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
provide error with stacktrace
parent
471c0e79
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!223
reset the pin numbers before search results are fetch (so the results will be...
,
!199
Resolve "[MIN-321] form for reporting errors in minerva"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/redux/export/export.reducers.test.ts
+6
-5
6 additions, 5 deletions
src/redux/export/export.reducers.test.ts
src/redux/export/export.thunks.ts
+5
-9
5 additions, 9 deletions
src/redux/export/export.thunks.ts
with
11 additions
and
14 deletions
src/redux/export/export.reducers.test.ts
+
6
−
5
View file @
4a3f645f
...
...
@@ -4,6 +4,7 @@ import {
createStoreInstanceUsingSliceReducer
,
}
from
'
@/utils/createStoreInstanceUsingSliceReducer
'
;
import
{
HttpStatusCode
}
from
'
axios
'
;
import
{
unwrapResult
}
from
'
@reduxjs/toolkit
'
;
import
{
ExportState
}
from
'
./export.types
'
;
import
exportReducer
from
'
./export.slice
'
;
import
{
apiPath
}
from
'
../apiPath
'
;
...
...
@@ -76,7 +77,7 @@ describe('export reducer', () => {
mockedAxiosClient
.
onPost
(
apiPath
.
downloadNetworkCsv
())
.
reply
(
HttpStatusCode
.
NotFound
,
undefined
);
const
{
payload
,
type
}
=
await
store
.
dispatch
(
const
action
=
await
store
.
dispatch
(
downloadNetwork
({
annotations
:
[],
columns
:
[],
...
...
@@ -85,8 +86,8 @@ describe('export reducer', () => {
submaps
:
[],
}),
);
expect
(
type
).
toBe
(
'
export/downloadNetwork/rejected
'
);
expect
(
payload
).
toBe
(
expect
(
action
.
type
).
toBe
(
'
export/downloadNetwork/rejected
'
);
expect
(
()
=>
unwrapResult
(
action
)).
toThrow
(
"
Failed to download network: The page you're looking for doesn't exist. Please verify the URL and try again.
"
,
);
const
{
loading
}
=
store
.
getState
().
export
.
downloadNetwork
;
...
...
@@ -135,7 +136,7 @@ describe('export reducer', () => {
mockedAxiosClient
.
onPost
(
apiPath
.
downloadElementsCsv
())
.
reply
(
HttpStatusCode
.
NotFound
,
undefined
);
const
{
payload
}
=
await
store
.
dispatch
(
const
action
=
await
store
.
dispatch
(
downloadElements
({
annotations
:
[],
columns
:
[],
...
...
@@ -147,7 +148,7 @@ describe('export reducer', () => {
const
{
loading
}
=
store
.
getState
().
export
.
downloadElements
;
expect
(
loading
).
toEqual
(
'
failed
'
);
expect
(
payload
).
toEqual
(
expect
(
()
=>
unwrapResult
(
action
)).
toThrow
(
"
Failed to download elements: The page you're looking for doesn't exist. Please verify the URL and try again.
"
,
);
});
...
...
This diff is collapsed.
Click to expand it.
src/redux/export/export.thunks.ts
+
5
−
9
View file @
4a3f645f
...
...
@@ -5,8 +5,8 @@ import { PROJECT_ID } from '@/constants';
import
{
ExportNetwork
,
ExportElements
}
from
'
@/types/models
'
;
import
{
validateDataUsingZodSchema
}
from
'
@/utils/validateDataUsingZodSchema
'
;
import
{
exportNetworkchema
,
exportElementsSchema
}
from
'
@/models/exportSchema
'
;
import
{
getErrorMessage
}
from
'
@/utils/getErrorMessage
'
;
import
{
ThunkConfig
}
from
'
@/types/store
'
;
import
{
getError
}
from
'
@/utils/error-report/getError
'
;
import
{
apiPath
}
from
'
../apiPath
'
;
import
{
downloadFileFromBlob
}
from
'
./export.utils
'
;
import
{
ELEMENTS_DOWNLOAD_ERROR_PREFIX
,
NETWORK_DOWNLOAD_ERROR_PREFIX
}
from
'
./export.constants
'
;
...
...
@@ -24,7 +24,7 @@ export const downloadElements = createAsyncThunk<
DownloadElementsBodyRequest
,
ThunkConfig
// eslint-disable-next-line consistent-return
>
(
'
export/downloadElements
'
,
async
(
data
,
{
rejectWithValue
})
=>
{
>
(
'
export/downloadElements
'
,
async
data
=>
{
try
{
const
response
=
await
axiosInstanceNewAPI
.
post
<
ExportElements
>
(
apiPath
.
downloadElementsCsv
(),
...
...
@@ -40,9 +40,7 @@ export const downloadElements = createAsyncThunk<
downloadFileFromBlob
(
response
.
data
,
`
${
PROJECT_ID
}
-elementExport.csv`
);
}
}
catch
(
error
)
{
const
errorMessage
=
getErrorMessage
({
error
,
prefix
:
ELEMENTS_DOWNLOAD_ERROR_PREFIX
});
return
rejectWithValue
(
errorMessage
);
return
Promise
.
reject
(
getError
({
error
,
prefix
:
ELEMENTS_DOWNLOAD_ERROR_PREFIX
}));
}
});
...
...
@@ -57,7 +55,7 @@ type DownloadNetworkBodyRequest = {
export
const
downloadNetwork
=
createAsyncThunk
<
undefined
,
DownloadNetworkBodyRequest
,
ThunkConfig
>
(
'
export/downloadNetwork
'
,
// eslint-disable-next-line consistent-return
async
(
data
,
{
rejectWithValue
})
=>
{
async
data
=>
{
try
{
const
response
=
await
axiosInstanceNewAPI
.
post
<
ExportNetwork
>
(
apiPath
.
downloadNetworkCsv
(),
...
...
@@ -73,9 +71,7 @@ export const downloadNetwork = createAsyncThunk<undefined, DownloadNetworkBodyRe
downloadFileFromBlob
(
response
.
data
,
`
${
PROJECT_ID
}
-networkExport.csv`
);
}
}
catch
(
error
)
{
const
errorMessage
=
getErrorMessage
({
error
,
prefix
:
NETWORK_DOWNLOAD_ERROR_PREFIX
});
return
rejectWithValue
(
errorMessage
);
return
Promise
.
reject
(
getError
({
error
,
prefix
:
NETWORK_DOWNLOAD_ERROR_PREFIX
}));
}
},
);
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