From 2832ccca015847a65c97ec6a45e4d99962f98b5a Mon Sep 17 00:00:00 2001 From: Piotr Gawron <p.gawron@atcomp.pl> Date: Thu, 16 May 2024 13:26:02 +0200 Subject: [PATCH] userPrivilegesSchema is not used anymore --- .../Modal/LoginModal/LoginModal.component.test.tsx | 5 +---- src/models/fixtures/userPrivilegesFixture.ts | 9 --------- src/models/userPrivilegesSchema.ts | 4 ---- src/redux/apiPath.ts | 1 - src/redux/user/user.reducers.test.ts | 5 ++--- src/redux/user/user.utils.ts | 7 ++----- src/types/models.ts | 3 +-- 7 files changed, 6 insertions(+), 28 deletions(-) delete mode 100644 src/models/fixtures/userPrivilegesFixture.ts diff --git a/src/components/FunctionalArea/Modal/LoginModal/LoginModal.component.test.tsx b/src/components/FunctionalArea/Modal/LoginModal/LoginModal.component.test.tsx index 5f95c9ac..38870538 100644 --- a/src/components/FunctionalArea/Modal/LoginModal/LoginModal.component.test.tsx +++ b/src/components/FunctionalArea/Modal/LoginModal/LoginModal.component.test.tsx @@ -10,7 +10,6 @@ import { apiPath } from '@/redux/apiPath'; import { HttpStatusCode } from 'axios'; import { loginFixture } from '@/models/fixtures/loginFixture'; import { overlaysFixture } from '@/models/fixtures/overlaysFixture'; -import { userPrivilegesFixture } from '@/models/fixtures/userPrivilegesFixture'; import { MODAL_INITIAL_STATE_MOCK } from '@/redux/modal/modal.mock'; import { userFixture } from '@/models/fixtures/userFixture'; import { LoginModal } from './LoginModal.component'; @@ -180,9 +179,7 @@ describe('LoginModal - component', () => { }); it('should close modal after successful login as user', async () => { mockedAxiosClient.onPost(apiPath.postLogin()).reply(HttpStatusCode.Ok, loginFixture); - mockedAxiosClient - .onGet(apiPath.userPrivileges(loginFixture.login)) - .reply(HttpStatusCode.Ok, userPrivilegesFixture); + mockedAxiosClient.onGet(apiPath.user(loginFixture.login)).reply(HttpStatusCode.Ok, userFixture); mockedAxiosClient .onGet( apiPath.getAllUserOverlaysByCreatorQuery({ diff --git a/src/models/fixtures/userPrivilegesFixture.ts b/src/models/fixtures/userPrivilegesFixture.ts deleted file mode 100644 index fcddc70c..00000000 --- a/src/models/fixtures/userPrivilegesFixture.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ZOD_SEED } from '@/constants'; -// eslint-disable-next-line import/no-extraneous-dependencies -import { createFixture } from 'zod-fixture'; -import { userPrivilegesSchema } from '../userPrivilegesSchema'; - -export const userPrivilegesFixture = createFixture(userPrivilegesSchema, { - seed: ZOD_SEED, - array: { min: 2, max: 2 }, -}); diff --git a/src/models/userPrivilegesSchema.ts b/src/models/userPrivilegesSchema.ts index f6beb466..06a49146 100644 --- a/src/models/userPrivilegesSchema.ts +++ b/src/models/userPrivilegesSchema.ts @@ -4,7 +4,3 @@ export const userPrivilegeSchema = z.object({ privilegeType: z.string(), objectId: z.string().nullable(), }); - -export const userPrivilegesSchema = z.object({ - privileges: z.array(userPrivilegeSchema), -}); diff --git a/src/redux/apiPath.ts b/src/redux/apiPath.ts index a24bc240..7a46759f 100644 --- a/src/redux/apiPath.ts +++ b/src/redux/apiPath.ts @@ -93,6 +93,5 @@ export const apiPath = { getAllPlugins: (): string => `/plugins/`, getSubmapConnections: (): string => `projects/${PROJECT_ID}/submapConnections/`, logout: (): string => `doLogout`, - userPrivileges: (login: string): string => `users/${login}?columns=privileges`, user: (login: string): string => `users/${login}`, }; diff --git a/src/redux/user/user.reducers.test.ts b/src/redux/user/user.reducers.test.ts index 43cb814f..3033a51a 100644 --- a/src/redux/user/user.reducers.test.ts +++ b/src/redux/user/user.reducers.test.ts @@ -8,7 +8,6 @@ import { mockNetworkResponse } from '@/utils/mockNetworkResponse'; import { HttpStatusCode } from 'axios'; import { loginFixture } from '@/models/fixtures/loginFixture'; import { sessionFixture } from '@/models/fixtures/sessionFixture'; -import { userPrivilegesFixture } from '@/models/fixtures/userPrivilegesFixture'; import { userFixture } from '@/models/fixtures/userFixture'; import { apiPath } from '../apiPath'; import userReducer from './user.slice'; @@ -71,8 +70,8 @@ describe('user reducer', () => { it('should update store after successful getSessionValid query', async () => { mockedAxiosClient.onGet(apiPath.getSessionValid()).reply(HttpStatusCode.Ok, sessionFixture); mockedAxiosClient - .onGet(apiPath.userPrivileges(sessionFixture.login)) - .reply(HttpStatusCode.Ok, userPrivilegesFixture); + .onGet(apiPath.user(sessionFixture.login)) + .reply(HttpStatusCode.Ok, userFixture); mockedAxiosClient .onGet(apiPath.user(sessionFixture.login)) diff --git a/src/redux/user/user.utils.ts b/src/redux/user/user.utils.ts index 89a7afb8..ecb9c623 100644 --- a/src/redux/user/user.utils.ts +++ b/src/redux/user/user.utils.ts @@ -1,8 +1,5 @@ -import { UserPrivileges } from '@/types/models'; +import { UserPrivilege } from '@/types/models'; -export const hasPrivilege = ( - privileges: UserPrivileges['privileges'], - privilegeType: string, -): boolean => { +export const hasPrivilege = (privileges: UserPrivilege[], privilegeType: string): boolean => { return privileges.some(privilege => privilege.privilegeType === privilegeType); }; diff --git a/src/types/models.ts b/src/types/models.ts index ff160b0d..0b6b9373 100644 --- a/src/types/models.ts +++ b/src/types/models.ts @@ -59,7 +59,7 @@ import { submapConnection } from '@/models/submapConnection'; import { targetElementSchema } from '@/models/targetElementSchema'; import { targetSchema } from '@/models/targetSchema'; import { targetSearchNameResult } from '@/models/targetSearchNameResult'; -import { userPrivilegeSchema, userPrivilegesSchema } from '@/models/userPrivilegesSchema'; +import { userPrivilegeSchema } from '@/models/userPrivilegesSchema'; import { z } from 'zod'; import { userSchema } from '@/models/userSchema'; @@ -112,7 +112,6 @@ export type GeneVariant = z.infer<typeof geneVariant>; export type TargetSearchNameResult = z.infer<typeof targetSearchNameResult>; export type TargetElement = z.infer<typeof targetElementSchema>; export type SubmapConnection = z.infer<typeof submapConnection>; -export type UserPrivileges = z.infer<typeof userPrivilegesSchema>; export type UserPrivilege = z.infer<typeof userPrivilegeSchema>; export type User = z.infer<typeof userSchema>; export type MarkerType = z.infer<typeof markerTypeSchema>; -- GitLab