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
82cef990
Commit
82cef990
authored
10 months ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
return rejected error for error reporting
parent
6d34f98f
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/drugs/drugs.reducers.test.ts
+4
-3
4 additions, 3 deletions
src/redux/drugs/drugs.reducers.test.ts
src/redux/drugs/drugs.thunks.ts
+5
-8
5 additions, 8 deletions
src/redux/drugs/drugs.thunks.ts
with
9 additions
and
11 deletions
src/redux/drugs/drugs.reducers.test.ts
+
4
−
3
View file @
82cef990
...
@@ -7,6 +7,7 @@ import {
...
@@ -7,6 +7,7 @@ import {
}
from
'
@/utils/createStoreInstanceUsingSliceReducer
'
;
}
from
'
@/utils/createStoreInstanceUsingSliceReducer
'
;
import
{
mockNetworkNewAPIResponse
}
from
'
@/utils/mockNetworkResponse
'
;
import
{
mockNetworkNewAPIResponse
}
from
'
@/utils/mockNetworkResponse
'
;
import
{
HttpStatusCode
}
from
'
axios
'
;
import
{
HttpStatusCode
}
from
'
axios
'
;
import
{
unwrapResult
}
from
'
@reduxjs/toolkit
'
;
import
drugsReducer
from
'
./drugs.slice
'
;
import
drugsReducer
from
'
./drugs.slice
'
;
import
{
getDrugs
}
from
'
./drugs.thunks
'
;
import
{
getDrugs
}
from
'
./drugs.thunks
'
;
import
{
DrugsState
}
from
'
./drugs.types
'
;
import
{
DrugsState
}
from
'
./drugs.types
'
;
...
@@ -56,16 +57,16 @@ describe('drugs reducer', () => {
...
@@ -56,16 +57,16 @@ describe('drugs reducer', () => {
.
onGet
(
apiPath
.
getDrugsStringWithQuery
(
SEARCH_QUERY
))
.
onGet
(
apiPath
.
getDrugsStringWithQuery
(
SEARCH_QUERY
))
.
reply
(
HttpStatusCode
.
NotFound
,
[]);
.
reply
(
HttpStatusCode
.
NotFound
,
[]);
const
{
type
,
payload
}
=
await
store
.
dispatch
(
getDrugs
(
SEARCH_QUERY
));
const
action
=
await
store
.
dispatch
(
getDrugs
(
SEARCH_QUERY
));
const
{
data
}
=
store
.
getState
().
drugs
;
const
{
data
}
=
store
.
getState
().
drugs
;
const
drugsWithSearchElement
=
data
.
find
(
const
drugsWithSearchElement
=
data
.
find
(
bioEntity
=>
bioEntity
.
searchQueryElement
===
SEARCH_QUERY
,
bioEntity
=>
bioEntity
.
searchQueryElement
===
SEARCH_QUERY
,
);
);
expect
(
payload
).
toBe
(
expect
(
()
=>
unwrapResult
(
action
)).
toThrow
(
"
Failed to fetch drugs: The page you're looking for doesn't exist. Please verify the URL and try again.
"
,
"
Failed to fetch drugs: The page you're looking for doesn't exist. Please verify the URL and try again.
"
,
);
);
expect
(
type
).
toBe
(
'
project/getDrugs/rejected
'
);
expect
(
action
.
type
).
toBe
(
'
project/getDrugs/rejected
'
);
expect
(
drugsWithSearchElement
).
toEqual
({
expect
(
drugsWithSearchElement
).
toEqual
({
searchQueryElement
:
SEARCH_QUERY
,
searchQueryElement
:
SEARCH_QUERY
,
data
:
undefined
,
data
:
undefined
,
...
...
This diff is collapsed.
Click to expand it.
src/redux/drugs/drugs.thunks.ts
+
5
−
8
View file @
82cef990
...
@@ -3,16 +3,16 @@ import { apiPath } from '@/redux/apiPath';
...
@@ -3,16 +3,16 @@ import { apiPath } from '@/redux/apiPath';
import
{
axiosInstanceNewAPI
}
from
'
@/services/api/utils/axiosInstance
'
;
import
{
axiosInstanceNewAPI
}
from
'
@/services/api/utils/axiosInstance
'
;
import
{
Drug
}
from
'
@/types/models
'
;
import
{
Drug
}
from
'
@/types/models
'
;
import
{
ThunkConfig
}
from
'
@/types/store
'
;
import
{
ThunkConfig
}
from
'
@/types/store
'
;
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
{
getError
}
from
'
@/utils/error-report/getError
'
;
import
{
addNumbersToEntityNumberData
}
from
'
../entityNumber/entityNumber.slice
'
;
import
{
addNumbersToEntityNumberData
}
from
'
../entityNumber/entityNumber.slice
'
;
import
{
DRUGS_FETCHING_ERROR_PREFIX
,
MULTI_DRUGS_FETCHING_ERROR_PREFIX
}
from
'
./drugs.constants
'
;
import
{
DRUGS_FETCHING_ERROR_PREFIX
,
MULTI_DRUGS_FETCHING_ERROR_PREFIX
}
from
'
./drugs.constants
'
;
export
const
getDrugs
=
createAsyncThunk
<
Drug
[]
|
undefined
,
string
,
ThunkConfig
>
(
export
const
getDrugs
=
createAsyncThunk
<
Drug
[]
|
undefined
,
string
,
ThunkConfig
>
(
'
project/getDrugs
'
,
'
project/getDrugs
'
,
async
(
searchQuery
:
string
,
{
rejectWithValue
}
)
=>
{
async
(
searchQuery
:
string
)
=>
{
try
{
try
{
const
response
=
await
axiosInstanceNewAPI
.
get
<
Drug
[]
>
(
const
response
=
await
axiosInstanceNewAPI
.
get
<
Drug
[]
>
(
apiPath
.
getDrugsStringWithQuery
(
searchQuery
),
apiPath
.
getDrugsStringWithQuery
(
searchQuery
),
...
@@ -22,8 +22,7 @@ export const getDrugs = createAsyncThunk<Drug[] | undefined, string, ThunkConfig
...
@@ -22,8 +22,7 @@ export const getDrugs = createAsyncThunk<Drug[] | undefined, string, ThunkConfig
return
isDataValid
?
response
.
data
:
undefined
;
return
isDataValid
?
response
.
data
:
undefined
;
}
catch
(
error
)
{
}
catch
(
error
)
{
const
errorMessage
=
getErrorMessage
({
error
,
prefix
:
DRUGS_FETCHING_ERROR_PREFIX
});
return
Promise
.
reject
(
getError
({
error
,
prefix
:
DRUGS_FETCHING_ERROR_PREFIX
}));
return
rejectWithValue
(
errorMessage
);
}
}
},
},
);
);
...
@@ -31,7 +30,7 @@ export const getDrugs = createAsyncThunk<Drug[] | undefined, string, ThunkConfig
...
@@ -31,7 +30,7 @@ export const getDrugs = createAsyncThunk<Drug[] | undefined, string, ThunkConfig
export
const
getMultiDrugs
=
createAsyncThunk
<
void
,
string
[],
ThunkConfig
>
(
export
const
getMultiDrugs
=
createAsyncThunk
<
void
,
string
[],
ThunkConfig
>
(
'
project/getMultiDrugs
'
,
'
project/getMultiDrugs
'
,
// eslint-disable-next-line consistent-return
// eslint-disable-next-line consistent-return
async
(
searchQueries
,
{
dispatch
,
rejectWithValue
})
=>
{
async
(
searchQueries
,
{
dispatch
})
=>
{
try
{
try
{
const
asyncGetDrugsFunctions
=
searchQueries
.
map
(
searchQuery
=>
const
asyncGetDrugsFunctions
=
searchQueries
.
map
(
searchQuery
=>
dispatch
(
getDrugs
(
searchQuery
)),
dispatch
(
getDrugs
(
searchQuery
)),
...
@@ -52,9 +51,7 @@ export const getMultiDrugs = createAsyncThunk<void, string[], ThunkConfig>(
...
@@ -52,9 +51,7 @@ export const getMultiDrugs = createAsyncThunk<void, string[], ThunkConfig>(
const
drugsIds
=
drugsTargetsData
.
map
(
d
=>
d
.
elementId
);
const
drugsIds
=
drugsTargetsData
.
map
(
d
=>
d
.
elementId
);
dispatch
(
addNumbersToEntityNumberData
(
drugsIds
));
dispatch
(
addNumbersToEntityNumberData
(
drugsIds
));
}
catch
(
error
)
{
}
catch
(
error
)
{
const
errorMessage
=
getErrorMessage
({
error
,
prefix
:
MULTI_DRUGS_FETCHING_ERROR_PREFIX
});
return
Promise
.
reject
(
getError
({
error
,
prefix
:
MULTI_DRUGS_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