diff --git a/src/models/bioEntityContentSchema.ts b/src/models/bioEntityContentSchema.ts new file mode 100644 index 0000000000000000000000000000000000000000..4ff85815794b73a621cf5909903b3de1f3443745 --- /dev/null +++ b/src/models/bioEntityContentSchema.ts @@ -0,0 +1,8 @@ +import { z } from 'zod'; +import { bioEntitySchema } from './bioEntitySchema'; + +export const bioEntityContentSchema = z.object({ + bioEntity: bioEntitySchema, + /** indicates if bioEntity matches perfect match even if not provided in query */ + perfect: z.boolean(), +}); diff --git a/src/models/bioEntityResponseSchema.ts b/src/models/bioEntityResponseSchema.ts index e025cab6912b951727fa6feec6578204d0e8e3d3..e4b4827bfb60345751424d36fb8d4f68be030b5e 100644 --- a/src/models/bioEntityResponseSchema.ts +++ b/src/models/bioEntityResponseSchema.ts @@ -1,12 +1,8 @@ import { z } from 'zod'; -import { bioEntitySchema } from './bioEntitySchema'; +import { bioEntityContentSchema } from './bioEntityContentSchema'; export const bioEntityResponseSchema = z.object({ - content: z.object({ - bioEntity: bioEntitySchema, - /** indicates if bioEntity matches perfect match even if not provided in query */ - perfect: z.boolean(), - }), + content: z.array(bioEntityContentSchema), totalPages: z.number(), totalElements: z.number(), numberOfElements: z.number(), diff --git a/src/models/bioEntitySchema.ts b/src/models/bioEntitySchema.ts index 178434e5a7dad5f2d018afa1d8a5942b767a2298..fc1e935aeec1d7408bf78e03aba7bb6a16905f64 100644 --- a/src/models/bioEntitySchema.ts +++ b/src/models/bioEntitySchema.ts @@ -7,6 +7,7 @@ import { colorSchema } from './colorSchema'; import { productsSchema } from './products'; import { lineSchema } from './lineSchema'; import { operatorSchema } from './operatorSchema'; +import { structuralStateSchema } from './structuralStateSchema'; export const bioEntitySchema = z.object({ id: z.number(), @@ -17,7 +18,7 @@ export const bioEntitySchema = z.object({ references: z.array(referenceSchema), z: z.number(), notes: z.string(), - symbol: z.string(), + symbol: z.union([z.string(), z.null()]), homodimer: z.number(), nameX: z.number(), nameY: z.number(), @@ -32,23 +33,23 @@ export const bioEntitySchema = z.object({ synonyms: z.array(z.string()), formerSymbols: z.array(z.string()), fullName: z.string(), - abbreviation: z.string(), - formula: z.string(), + abbreviation: z.union([z.string(), z.null()]), + formula: z.union([z.string(), z.null()]), glyph: z.union([glyphSchema, z.null()]), activity: z.boolean(), - structuralState: z.string(), - hypothetical: z.boolean(), + structuralState: z.union([structuralStateSchema, z.null()]), + hypothetical: z.union([z.boolean(), z.null()]), boundaryCondition: z.boolean(), constant: z.boolean(), - initialAmount: z.number(), - initialConcentration: z.number(), - charge: z.number(), - substanceUnits: z.string(), + initialAmount: z.union([z.number(), z.null()]), + initialConcentration: z.union([z.number(), z.null()]), + charge: z.union([z.number(), z.null()]), + substanceUnits: z.union([z.string(), z.null()]), onlySubstanceUnits: z.boolean(), - modificationResidues: modificationResiduesSchema, - complex: z.number(), - compartment: z.number(), - submodel: submodelSchema, + modificationResidues: z.optional(z.array(modificationResiduesSchema)), + complex: z.union([z.number(), z.null()]), + compartment: z.union([z.number(), z.null()]), + submodel: z.union([submodelSchema, z.null()]), x: z.number(), y: z.number(), lineWidth: z.number(), @@ -56,19 +57,19 @@ export const bioEntitySchema = z.object({ fontSize: z.number(), fillColor: colorSchema, borderColor: colorSchema, - smiles: z.string(), - inChI: z.string(), - inChIKey: z.string(), - thickness: z.number(), - outerWidth: z.number(), - innerWidth: z.number(), - idReaction: z.string(), - reversible: z.boolean(), - mechanicalConfidenceScore: z.boolean(), - lowerBound: z.boolean(), - upperBound: z.boolean(), - subsystem: z.string(), - geneProteinReaction: z.string(), + smiles: z.optional(z.string()), + inChI: z.optional(z.string()), + inChIKey: z.optional(z.string()), + thickness: z.optional(z.number()), + outerWidth: z.optional(z.number()), + innerWidth: z.optional(z.number()), + idReaction: z.optional(z.string()), + reversible: z.optional(z.boolean()), + mechanicalConfidenceScore: z.optional(z.boolean()), + lowerBound: z.optional(z.boolean()), + upperBound: z.optional(z.boolean()), + subsystem: z.optional(z.string()), + geneProteinReaction: z.optional(z.string()), kinetics: z.union([z.null(), z.undefined()]), products: z.union([z.array(productsSchema), z.undefined()]), reactants: z.union([z.array(productsSchema), z.undefined()]), diff --git a/src/models/fixtures/bioEntityContentsFixture.ts b/src/models/fixtures/bioEntityContentsFixture.ts index fec6a7137e8f820642686b4104f4450e15ac5b6d..09fc894b35b14f223d06ac99cb43e72f4ff174cb 100644 --- a/src/models/fixtures/bioEntityContentsFixture.ts +++ b/src/models/fixtures/bioEntityContentsFixture.ts @@ -1,12 +1,11 @@ import { ZOD_SEED } from '@/constants'; import { bioEntityContentSchema } from '@/models/bioEntityContentSchema'; -import { z } from 'zod'; // eslint-disable-next-line import/no-extraneous-dependencies import { createFixture } from 'zod-fixture'; +import { bioEntityResponseSchema } from '../bioEntityResponseSchema'; -export const bioEntityContentsFixture = createFixture(z.array(bioEntityContentSchema), { +export const bioEntityResponseFixture = createFixture(bioEntityResponseSchema, { seed: ZOD_SEED, - array: { min: 2, max: 2 }, }); export const bioEntityContentFixture = createFixture(bioEntityContentSchema, { diff --git a/src/models/referenceSchema.ts b/src/models/referenceSchema.ts index 30c2bd65da5d6107397d3e72280865ce2305b258..432f0eeceb6f7b1f3778e283ebbc7db050fd74be 100644 --- a/src/models/referenceSchema.ts +++ b/src/models/referenceSchema.ts @@ -2,7 +2,7 @@ import { z } from 'zod'; import { articleSchema } from './articleSchema'; export const referenceSchema = z.object({ - link: z.string(), + link: z.union([z.string(), z.null()]), article: articleSchema.optional(), type: z.string(), resource: z.string(), diff --git a/src/models/structuralStateSchema.ts b/src/models/structuralStateSchema.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ef0f149b4d4d0b3fa4e4158296ad6d8f789d949 --- /dev/null +++ b/src/models/structuralStateSchema.ts @@ -0,0 +1,16 @@ +import { z } from 'zod'; +import { positionSchema } from './positionSchema'; +import { colorSchema } from './colorSchema'; + +export const structuralStateSchema = z.object({ + value: z.string(), + position: positionSchema, + z: z.number(), + width: z.number(), + height: z.number(), + fontSize: z.number(), + size: z.number(), + center: positionSchema, + borderColor: colorSchema, + elementId: z.string(), +}); diff --git a/src/redux/apiPath.test.ts b/src/redux/apiPath.test.ts index e1337f97c6f7f73f141d5739313c1868ab357f30..d23bffc005c9cb4587b70e60f574aee2720198af 100644 --- a/src/redux/apiPath.test.ts +++ b/src/redux/apiPath.test.ts @@ -16,7 +16,7 @@ describe('api path', () => { it('should return url string for bio entity content', () => { expect(apiPath.getBioEntityContentsStringWithQuery('park7')).toBe( - `projects/${PROJECT_ID}/models/*/bioEntities:search?query=park7`, + `projects/${PROJECT_ID}/models/*/bioEntities/:search?query=park7&size=1000`, ); }); diff --git a/src/redux/apiPath.ts b/src/redux/apiPath.ts index 11ce6f11c1e59f6e8f6a4bf38037ac62e2e501a2..c9df159acff7b313a359a0bc6d6c107b0ec51759 100644 --- a/src/redux/apiPath.ts +++ b/src/redux/apiPath.ts @@ -2,7 +2,7 @@ import { PROJECT_ID } from '@/constants'; export const apiPath = { getBioEntityContentsStringWithQuery: (searchQuery: string): string => - `projects/${PROJECT_ID}/models/*/bioEntities:search?query=${searchQuery}`, + `projects/${PROJECT_ID}/models/*/bioEntities/:search?query=${searchQuery}&size=1000`, getDrugsStringWithQuery: (searchQuery: string): string => `projects/${PROJECT_ID}/drugs:search?query=${searchQuery}`, getMirnasStringWithQuery: (searchQuery: string): string => diff --git a/src/redux/bioEntityContents/bioEntityContents.reducers.test.ts b/src/redux/bioEntity/bioEntity.reducers.test.ts similarity index 51% rename from src/redux/bioEntityContents/bioEntityContents.reducers.test.ts rename to src/redux/bioEntity/bioEntity.reducers.test.ts index 12831d5c7b0c2bb05d54f2ca863fa9fd655ea1f0..e73215b52ef2b7465385dc0f59d64c34a991503e 100644 --- a/src/redux/bioEntityContents/bioEntityContents.reducers.test.ts +++ b/src/redux/bioEntity/bioEntity.reducers.test.ts @@ -1,16 +1,16 @@ -import { bioEntityContentsFixture } from '@/models/fixtures/bioEntityContentsFixture'; -import { mockNetworkResponse } from '@/utils/mockNetworkResponse'; +import { bioEntityResponseFixture } from '@/models/fixtures/bioEntityContentsFixture'; +import { mockNetworkExperimentalAPIResponse } from '@/utils/mockNetworkResponse'; import { ToolkitStoreWithSingleSlice, createStoreInstanceUsingSliceReducer, } from '@/utils/createStoreInstanceUsingSliceReducer'; import { HttpStatusCode } from 'axios'; import { apiPath } from '@/redux/apiPath'; -import { getBioEntityContents } from './bioEntityContents.thunks'; -import bioEntityContentsReducer from './bioEntityContents.slice'; -import { BioEntityContentsState } from './bioEntityContents.types'; +import { getBioEntity } from './bioEntity.thunks'; +import bioEntityContentsReducer from './bioEntity.slice'; +import { BioEntityContentsState } from './bioEntity.types'; -const mockedAxiosClient = mockNetworkResponse(); +const mockedAxiosClient = mockNetworkExperimentalAPIResponse(); const SEARCH_QUERY = 'park7'; const INITIAL_STATE: BioEntityContentsState = { @@ -19,10 +19,10 @@ const INITIAL_STATE: BioEntityContentsState = { error: { name: '', message: '' }, }; -describe('bioEntityContents reducer', () => { +describe('bioEntity reducer', () => { let store = {} as ToolkitStoreWithSingleSlice<BioEntityContentsState>; beforeEach(() => { - store = createStoreInstanceUsingSliceReducer('bioEntityContents', bioEntityContentsReducer); + store = createStoreInstanceUsingSliceReducer('bioEntity', bioEntityContentsReducer); }); it('should match initial state', () => { @@ -30,27 +30,27 @@ describe('bioEntityContents reducer', () => { expect(bioEntityContentsReducer(undefined, action)).toEqual(INITIAL_STATE); }); - it('should update store after succesfull getBioEntityContents query', async () => { + it('should update store after succesfull getBioEntity query', async () => { mockedAxiosClient .onGet(apiPath.getBioEntityContentsStringWithQuery(SEARCH_QUERY)) - .reply(HttpStatusCode.Ok, bioEntityContentsFixture); + .reply(HttpStatusCode.Ok, bioEntityResponseFixture); - const { type } = await store.dispatch(getBioEntityContents(SEARCH_QUERY)); - const { data, loading, error } = store.getState().bioEntityContents; + const { type } = await store.dispatch(getBioEntity(SEARCH_QUERY)); + const { data, loading, error } = store.getState().bioEntity; expect(type).toBe('project/getBioEntityContents/fulfilled'); expect(loading).toEqual('succeeded'); expect(error).toEqual({ message: '', name: '' }); - expect(data).toEqual(bioEntityContentsFixture); + expect(data).toEqual(bioEntityResponseFixture.content); }); - it('should update store after failed getBioEntityContents query', async () => { + it('should update store after failed getBioEntity query', async () => { mockedAxiosClient .onGet(apiPath.getBioEntityContentsStringWithQuery(SEARCH_QUERY)) - .reply(HttpStatusCode.NotFound, bioEntityContentsFixture); + .reply(HttpStatusCode.NotFound, bioEntityResponseFixture); - const { type } = await store.dispatch(getBioEntityContents(SEARCH_QUERY)); - const { data, loading, error } = store.getState().bioEntityContents; + const { type } = await store.dispatch(getBioEntity(SEARCH_QUERY)); + const { data, loading, error } = store.getState().bioEntity; expect(type).toBe('project/getBioEntityContents/rejected'); expect(loading).toEqual('failed'); @@ -58,22 +58,21 @@ describe('bioEntityContents reducer', () => { expect(data).toEqual([]); }); - it('should update store on loading getBioEntityContents query', async () => { + it('should update store on loading getBioEntity query', async () => { mockedAxiosClient .onGet(apiPath.getBioEntityContentsStringWithQuery(SEARCH_QUERY)) - .reply(HttpStatusCode.Ok, bioEntityContentsFixture); + .reply(HttpStatusCode.Ok, bioEntityResponseFixture); - const bioEntityContentsPromise = store.dispatch(getBioEntityContents(SEARCH_QUERY)); + const bioEntityContentsPromise = store.dispatch(getBioEntity(SEARCH_QUERY)); - const { data, loading } = store.getState().bioEntityContents; + const { data, loading } = store.getState().bioEntity; expect(data).toEqual([]); expect(loading).toEqual('pending'); bioEntityContentsPromise.then(() => { - const { data: dataPromiseFulfilled, loading: promiseFulfilled } = - store.getState().bioEntityContents; + const { data: dataPromiseFulfilled, loading: promiseFulfilled } = store.getState().bioEntity; - expect(dataPromiseFulfilled).toEqual(bioEntityContentsFixture); + expect(dataPromiseFulfilled).toEqual(bioEntityResponseFixture.content); expect(promiseFulfilled).toEqual('succeeded'); }); }); diff --git a/src/redux/bioEntityContents/bioEntityContents.reducers.ts b/src/redux/bioEntity/bioEntity.reducers.ts similarity index 54% rename from src/redux/bioEntityContents/bioEntityContents.reducers.ts rename to src/redux/bioEntity/bioEntity.reducers.ts index d8806feb7989dbfb6cf7a0d2876711c774feec4d..48ce02f4ce25e3b734ae97c905b767a03edbb101 100644 --- a/src/redux/bioEntityContents/bioEntityContents.reducers.ts +++ b/src/redux/bioEntity/bioEntity.reducers.ts @@ -1,18 +1,18 @@ import { ActionReducerMapBuilder } from '@reduxjs/toolkit'; -import { BioEntityContentsState } from './bioEntityContents.types'; -import { getBioEntityContents } from './bioEntityContents.thunks'; +import { BioEntityContentsState } from './bioEntity.types'; +import { getBioEntity } from './bioEntity.thunks'; export const getBioEntityContentsReducer = ( builder: ActionReducerMapBuilder<BioEntityContentsState>, ): void => { - builder.addCase(getBioEntityContents.pending, state => { + builder.addCase(getBioEntity.pending, state => { state.loading = 'pending'; }); - builder.addCase(getBioEntityContents.fulfilled, (state, action) => { + builder.addCase(getBioEntity.fulfilled, (state, action) => { state.data = action.payload; state.loading = 'succeeded'; }); - builder.addCase(getBioEntityContents.rejected, state => { + builder.addCase(getBioEntity.rejected, state => { state.loading = 'failed'; // TODO: error management to be discussed in the team }); diff --git a/src/redux/bioEntityContents/bioEntityContents.selectors.ts b/src/redux/bioEntity/bioEntity.selectors.ts similarity index 67% rename from src/redux/bioEntityContents/bioEntityContents.selectors.ts rename to src/redux/bioEntity/bioEntity.selectors.ts index 80a88cb0bec55d0ebf43ba8dd85827b44b429121..b29b13b78a665ebf7bc42a06c58d45312364abdc 100644 --- a/src/redux/bioEntityContents/bioEntityContents.selectors.ts +++ b/src/redux/bioEntity/bioEntity.selectors.ts @@ -1,10 +1,7 @@ import { rootSelector } from '@/redux/root/root.selectors'; import { createSelector } from '@reduxjs/toolkit'; -export const bioEntityContentsSelector = createSelector( - rootSelector, - state => state.bioEntityContents, -); +export const bioEntityContentsSelector = createSelector(rootSelector, state => state.bioEntity); export const loadingBioEntityStatusSelector = createSelector( bioEntityContentsSelector, diff --git a/src/redux/bioEntityContents/bioEntityContents.slice.ts b/src/redux/bioEntity/bioEntity.slice.ts similarity index 70% rename from src/redux/bioEntityContents/bioEntityContents.slice.ts rename to src/redux/bioEntity/bioEntity.slice.ts index 97e3b73cbb92836c41263f9cc4744bf9f756799f..1400797ae523cac389458436f9dfd5280aba24b4 100644 --- a/src/redux/bioEntityContents/bioEntityContents.slice.ts +++ b/src/redux/bioEntity/bioEntity.slice.ts @@ -1,6 +1,6 @@ import { createSlice } from '@reduxjs/toolkit'; -import { BioEntityContentsState } from '@/redux/bioEntityContents/bioEntityContents.types'; -import { getBioEntityContentsReducer } from './bioEntityContents.reducers'; +import { BioEntityContentsState } from '@/redux/bioEntity/bioEntity.types'; +import { getBioEntityContentsReducer } from './bioEntity.reducers'; const initialState: BioEntityContentsState = { data: [], diff --git a/src/redux/bioEntityContents/bioEntityContents.thunks.test.ts b/src/redux/bioEntity/bioEntity.thunks.test.ts similarity index 61% rename from src/redux/bioEntityContents/bioEntityContents.thunks.test.ts rename to src/redux/bioEntity/bioEntity.thunks.test.ts index 540e29ce5181233a2ce2667a19fcfcdb3e6e7135..f180cfe2a36400a5c62c30c527e0965b784b45bb 100644 --- a/src/redux/bioEntityContents/bioEntityContents.thunks.test.ts +++ b/src/redux/bioEntity/bioEntity.thunks.test.ts @@ -1,16 +1,16 @@ -import { bioEntityContentsFixture } from '@/models/fixtures/bioEntityContentsFixture'; -import { mockNetworkResponse } from '@/utils/mockNetworkResponse'; +import { bioEntityResponseFixture } from '@/models/fixtures/bioEntityContentsFixture'; +import { mockNetworkExperimentalAPIResponse } from '@/utils/mockNetworkResponse'; import { ToolkitStoreWithSingleSlice, createStoreInstanceUsingSliceReducer, } from '@/utils/createStoreInstanceUsingSliceReducer'; import { HttpStatusCode } from 'axios'; import { apiPath } from '@/redux/apiPath'; -import { getBioEntityContents } from './bioEntityContents.thunks'; -import contentsReducer from './bioEntityContents.slice'; -import { BioEntityContentsState } from './bioEntityContents.types'; +import { getBioEntity } from './bioEntity.thunks'; +import contentsReducer from './bioEntity.slice'; +import { BioEntityContentsState } from './bioEntity.types'; -const mockedAxiosClient = mockNetworkResponse(); +const mockedAxiosClient = mockNetworkExperimentalAPIResponse(); const SEARCH_QUERY = 'park7'; describe('bioEntityContents thunks', () => { @@ -22,17 +22,17 @@ describe('bioEntityContents thunks', () => { it('should return data when data response from API is valid', async () => { mockedAxiosClient .onGet(apiPath.getBioEntityContentsStringWithQuery(SEARCH_QUERY)) - .reply(HttpStatusCode.Ok, bioEntityContentsFixture); + .reply(HttpStatusCode.Ok, bioEntityResponseFixture); - const { payload } = await store.dispatch(getBioEntityContents(SEARCH_QUERY)); - expect(payload).toEqual(bioEntityContentsFixture); + const { payload } = await store.dispatch(getBioEntity(SEARCH_QUERY)); + expect(payload).toEqual(bioEntityResponseFixture.content); }); it('should return undefined when data response from API is not valid ', async () => { mockedAxiosClient .onGet(apiPath.getBioEntityContentsStringWithQuery(SEARCH_QUERY)) .reply(HttpStatusCode.Ok, { randomProperty: 'randomValue' }); - const { payload } = await store.dispatch(getBioEntityContents(SEARCH_QUERY)); + const { payload } = await store.dispatch(getBioEntity(SEARCH_QUERY)); expect(payload).toEqual(undefined); }); }); diff --git a/src/redux/bioEntity/bioEntity.thunks.ts b/src/redux/bioEntity/bioEntity.thunks.ts new file mode 100644 index 0000000000000000000000000000000000000000..fbc7c2e0622a9cef59f02c3b4e64129e522a56f6 --- /dev/null +++ b/src/redux/bioEntity/bioEntity.thunks.ts @@ -0,0 +1,19 @@ +import { createAsyncThunk } from '@reduxjs/toolkit'; +import { axiosInstanceExperimentalAPI } from '@/services/api/utils/axiosInstance'; +import { BioEntityContent, BioEntityResponse } from '@/types/models'; +import { validateDataUsingZodSchema } from '@/utils/validateDataUsingZodSchema'; +import { apiPath } from '@/redux/apiPath'; +import { bioEntityResponseSchema } from '@/models/bioEntityResponseSchema'; + +export const getBioEntity = createAsyncThunk( + 'project/getBioEntityContents', + async (searchQuery: string): Promise<BioEntityContent[] | undefined> => { + const response = await axiosInstanceExperimentalAPI.get<BioEntityResponse>( + apiPath.getBioEntityContentsStringWithQuery(searchQuery), + ); + + const isDataValid = validateDataUsingZodSchema(response.data, bioEntityResponseSchema); + + return isDataValid ? response.data.content : undefined; + }, +); diff --git a/src/redux/bioEntityContents/bioEntityContents.types.ts b/src/redux/bioEntity/bioEntity.types.ts similarity index 100% rename from src/redux/bioEntityContents/bioEntityContents.types.ts rename to src/redux/bioEntity/bioEntity.types.ts diff --git a/src/redux/bioEntityContents/bioEntityContents.thunks.ts b/src/redux/bioEntityContents/bioEntityContents.thunks.ts deleted file mode 100644 index 03f5977dc72a75c900624193fe3c7bff6a51331e..0000000000000000000000000000000000000000 --- a/src/redux/bioEntityContents/bioEntityContents.thunks.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { z } from 'zod'; -import { createAsyncThunk } from '@reduxjs/toolkit'; -import { axiosInstance } from '@/services/api/utils/axiosInstance'; -import { BioEntityContent } from '@/types/models'; -import { bioEntitySchema } from '@/models/bioEntitySchema'; -import { validateDataUsingZodSchema } from '@/utils/validateDataUsingZodSchema'; -import { apiPath } from '@/redux/apiPath'; - -export const getBioEntityContents = createAsyncThunk( - 'project/getBioEntityContents', - async (searchQuery: string): Promise<BioEntityContent[] | undefined> => { - const response = await axiosInstance.get<BioEntityContent[]>( - apiPath.getBioEntityContentsStringWithQuery(searchQuery), - ); - - const isDataValid = validateDataUsingZodSchema(response.data, z.array(bioEntitySchema)); - - return isDataValid ? response.data : undefined; - }, -); diff --git a/src/redux/search/search.thunks.ts b/src/redux/search/search.thunks.ts index 2724826c65aa793de889176cc3fe75764509ec1c..88dfc4f4dcc04fea7c30fd46241d27e72b8d478e 100644 --- a/src/redux/search/search.thunks.ts +++ b/src/redux/search/search.thunks.ts @@ -1,4 +1,4 @@ -import { getBioEntityContents } from '@/redux/bioEntityContents/bioEntityContents.thunks'; +import { getBioEntity } from '@/redux/bioEntity/bioEntity.thunks'; import { getChemicals } from '@/redux/chemicals/chemicals.thunks'; import { getDrugs } from '@/redux/drugs/drugs.thunks'; import { getMirnas } from '@/redux/mirnas/mirnas.thunks'; @@ -9,7 +9,7 @@ export const getSearchData = createAsyncThunk( async (searchQuery: string, { dispatch }): Promise<void> => { await Promise.all([ dispatch(getDrugs(searchQuery)), - dispatch(getBioEntityContents(searchQuery)), + dispatch(getBioEntity(searchQuery)), dispatch(getChemicals(searchQuery)), dispatch(getMirnas(searchQuery)), ]); diff --git a/src/redux/store.ts b/src/redux/store.ts index f3e2dc5e533fd38aa7f46cb1e86d3c4430d38572..cc60130e8db8dbfdf5e32608a934f4f200580e85 100644 --- a/src/redux/store.ts +++ b/src/redux/store.ts @@ -1,4 +1,4 @@ -import bioEntityContentsReducer from '@/redux/bioEntityContents/bioEntityContents.slice'; +import bioEntityReducer from '@/redux/bioEntity/bioEntity.slice'; import chemicalsReducer from '@/redux/chemicals/chemicals.slice'; import drawerReducer from '@/redux/drawer/drawer.slice'; import drugsReducer from '@/redux/drugs/drugs.slice'; @@ -15,7 +15,7 @@ export const store = configureStore({ drugs: drugsReducer, mirnas: mirnasReducer, chemicals: chemicalsReducer, - bioEntityContents: bioEntityContentsReducer, + bioEntity: bioEntityReducer, drawer: drawerReducer, models: modelsReducer, }, diff --git a/src/types/models.ts b/src/types/models.ts index 8902849349a999a58661d14d73d5734574f96130..13be16b5f76d48c14e55bac7440336425a9696c5 100644 --- a/src/types/models.ts +++ b/src/types/models.ts @@ -1,4 +1,3 @@ -import { bioEntityContentSchema } from '@/models/bioEntityContentSchema'; import { chemicalSchema } from '@/models/chemicalSchema'; import { disease } from '@/models/disease'; import { drugSchema } from '@/models/drugSchema'; @@ -7,12 +6,17 @@ import { organism } from '@/models/organism'; import { projectSchema } from '@/models/project'; import { z } from 'zod'; import { modelSchema } from '@/models/modelSchema'; +import { bioEntitySchema } from '@/models/bioEntitySchema'; +import { bioEntityResponseSchema } from '@/models/bioEntityResponseSchema'; +import { bioEntityContentSchema } from '@/models/bioEntityContentSchema'; export type Project = z.infer<typeof projectSchema>; export type Organism = z.infer<typeof organism>; export type Disease = z.infer<typeof disease>; export type Drug = z.infer<typeof drugSchema>; export type Mirna = z.infer<typeof mirnaSchema>; +export type BioEntity = z.infer<typeof bioEntitySchema>; export type BioEntityContent = z.infer<typeof bioEntityContentSchema>; +export type BioEntityResponse = z.infer<typeof bioEntityResponseSchema>; export type Model = z.infer<typeof modelSchema>; export type Chemical = z.infer<typeof chemicalSchema>; diff --git a/src/utils/mockNetworkResponse.ts b/src/utils/mockNetworkResponse.ts index 4f7bd1098b390c116d72c591feda2ecf14eab949..5da43a50207f60216ccb865297bbfba033b16cff 100644 --- a/src/utils/mockNetworkResponse.ts +++ b/src/utils/mockNetworkResponse.ts @@ -1,8 +1,13 @@ // eslint-disable-next-line import/no-extraneous-dependencies import MockAdapter from 'axios-mock-adapter'; -import { axiosInstance } from '@/services/api/utils/axiosInstance'; +import { axiosInstance, axiosInstanceExperimentalAPI } from '@/services/api/utils/axiosInstance'; export const mockNetworkResponse = (): MockAdapter => { const mock = new MockAdapter(axiosInstance); return mock; }; + +export const mockNetworkExperimentalAPIResponse = (): MockAdapter => { + const mock = new MockAdapter(axiosInstanceExperimentalAPI); + return mock; +}; diff --git a/src/utils/testing/getReduxWrapperWithStore.tsx b/src/utils/testing/getReduxWrapperWithStore.tsx index b698584c6db44d64dd07f29a3447cfcd8ead2de3..292ba729cea050ae72e5e20dae4c65fc6fb72aca 100644 --- a/src/utils/testing/getReduxWrapperWithStore.tsx +++ b/src/utils/testing/getReduxWrapperWithStore.tsx @@ -1,4 +1,4 @@ -import bioEntityContentsReducer from '@/redux/bioEntityContents/bioEntityContents.slice'; +import bioEntityReducer from '@/redux/bioEntity/bioEntity.slice'; import chemicalsReducer from '@/redux/chemicals/chemicals.slice'; import drawerReducer from '@/redux/drawer/drawer.slice'; import drugsReducer from '@/redux/drugs/drugs.slice'; @@ -31,7 +31,7 @@ export const getReduxWrapperWithStore: GetReduxWrapperUsingSliceReducer = ( drugs: drugsReducer, mirnas: mirnasReducer, chemicals: chemicalsReducer, - bioEntityContents: bioEntityContentsReducer, + bioEntity: bioEntityReducer, drawer: drawerReducer, models: modelsReducer, },