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
471c0e79
Commit
471c0e79
authored
10 months ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
reject with error
parent
0117588e
No related branches found
No related tags found
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/models/models.reducers.test.ts
+4
-3
4 additions, 3 deletions
src/redux/models/models.reducers.test.ts
src/redux/models/models.thunks.ts
+3
-5
3 additions, 5 deletions
src/redux/models/models.thunks.ts
with
7 additions
and
8 deletions
src/redux/models/models.reducers.test.ts
+
4
−
3
View file @
471c0e79
...
@@ -6,6 +6,7 @@ import {
...
@@ -6,6 +6,7 @@ import {
}
from
'
@/utils/createStoreInstanceUsingSliceReducer
'
;
}
from
'
@/utils/createStoreInstanceUsingSliceReducer
'
;
import
{
mockNetworkResponse
}
from
'
@/utils/mockNetworkResponse
'
;
import
{
mockNetworkResponse
}
from
'
@/utils/mockNetworkResponse
'
;
import
{
HttpStatusCode
}
from
'
axios
'
;
import
{
HttpStatusCode
}
from
'
axios
'
;
import
{
unwrapResult
}
from
'
@reduxjs/toolkit
'
;
import
modelsReducer
from
'
./models.slice
'
;
import
modelsReducer
from
'
./models.slice
'
;
import
{
getModels
}
from
'
./models.thunks
'
;
import
{
getModels
}
from
'
./models.thunks
'
;
import
{
ModelsState
}
from
'
./models.types
'
;
import
{
ModelsState
}
from
'
./models.types
'
;
...
@@ -44,11 +45,11 @@ describe('models reducer', () => {
...
@@ -44,11 +45,11 @@ describe('models reducer', () => {
it
(
'
should update store after failed getModels query
'
,
async
()
=>
{
it
(
'
should update store after failed getModels query
'
,
async
()
=>
{
mockedAxiosClient
.
onGet
(
apiPath
.
getModelsString
()).
reply
(
HttpStatusCode
.
NotFound
,
[]);
mockedAxiosClient
.
onGet
(
apiPath
.
getModelsString
()).
reply
(
HttpStatusCode
.
NotFound
,
[]);
const
{
type
,
payload
}
=
await
store
.
dispatch
(
getModels
());
const
action
=
await
store
.
dispatch
(
getModels
());
const
{
data
,
loading
,
error
}
=
store
.
getState
().
models
;
const
{
data
,
loading
,
error
}
=
store
.
getState
().
models
;
expect
(
type
).
toBe
(
'
project/getModels/rejected
'
);
expect
(
action
.
type
).
toBe
(
'
project/getModels/rejected
'
);
expect
(
payload
).
toBe
(
expect
(
()
=>
unwrapResult
(
action
)).
toThrow
(
"
Failed to fetch models: The page you're looking for doesn't exist. Please verify the URL and try again.
"
,
"
Failed to fetch models: The page you're looking for doesn't exist. Please verify the URL and try again.
"
,
);
);
expect
(
loading
).
toEqual
(
'
failed
'
);
expect
(
loading
).
toEqual
(
'
failed
'
);
...
...
This diff is collapsed.
Click to expand it.
src/redux/models/models.thunks.ts
+
3
−
5
View file @
471c0e79
...
@@ -2,16 +2,16 @@ import { mapModelSchema } from '@/models/modelSchema';
...
@@ -2,16 +2,16 @@ import { mapModelSchema } from '@/models/modelSchema';
import
{
apiPath
}
from
'
@/redux/apiPath
'
;
import
{
apiPath
}
from
'
@/redux/apiPath
'
;
import
{
axiosInstance
}
from
'
@/services/api/utils/axiosInstance
'
;
import
{
axiosInstance
}
from
'
@/services/api/utils/axiosInstance
'
;
import
{
MapModel
}
from
'
@/types/models
'
;
import
{
MapModel
}
from
'
@/types/models
'
;
import
{
getErrorMessage
}
from
'
@/utils/getErrorMessage
'
;
import
{
validateDataUsingZodSchema
}
from
'
@/utils/validateDataUsingZodSchema
'
;
import
{
validateDataUsingZodSchema
}
from
'
@/utils/validateDataUsingZodSchema
'
;
import
{
createAsyncThunk
}
from
'
@reduxjs/toolkit
'
;
import
{
createAsyncThunk
}
from
'
@reduxjs/toolkit
'
;
import
{
z
}
from
'
zod
'
;
import
{
z
}
from
'
zod
'
;
import
{
ThunkConfig
}
from
'
@/types/store
'
;
import
{
ThunkConfig
}
from
'
@/types/store
'
;
import
{
getError
}
from
'
@/utils/error-report/getError
'
;
import
{
MODELS_FETCHING_ERROR_PREFIX
}
from
'
./models.constants
'
;
import
{
MODELS_FETCHING_ERROR_PREFIX
}
from
'
./models.constants
'
;
export
const
getModels
=
createAsyncThunk
<
MapModel
[]
|
undefined
,
void
,
ThunkConfig
>
(
export
const
getModels
=
createAsyncThunk
<
MapModel
[]
|
undefined
,
void
,
ThunkConfig
>
(
'
project/getModels
'
,
'
project/getModels
'
,
async
(
_
,
{
rejectWithValue
}
)
=>
{
async
()
=>
{
try
{
try
{
const
response
=
await
axiosInstance
.
get
<
MapModel
[]
>
(
apiPath
.
getModelsString
());
const
response
=
await
axiosInstance
.
get
<
MapModel
[]
>
(
apiPath
.
getModelsString
());
...
@@ -19,9 +19,7 @@ export const getModels = createAsyncThunk<MapModel[] | undefined, void, ThunkCon
...
@@ -19,9 +19,7 @@ export const getModels = createAsyncThunk<MapModel[] | undefined, void, ThunkCon
return
isDataValid
?
response
.
data
:
undefined
;
return
isDataValid
?
response
.
data
:
undefined
;
}
catch
(
error
)
{
}
catch
(
error
)
{
const
errorMessage
=
getErrorMessage
({
error
,
prefix
:
MODELS_FETCHING_ERROR_PREFIX
});
return
Promise
.
reject
(
getError
({
error
,
prefix
:
MODELS_FETCHING_ERROR_PREFIX
}));
return
rejectWithValue
(
errorMessage
);
}
}
},
},
);
);
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