From 2d4dacfc98e506fc7c529ba33bd538bf8cbb48af Mon Sep 17 00:00:00 2001 From: "M. E. Abdelsalam" Date: Sun, 8 Dec 2024 08:15:53 +0200 Subject: [PATCH] fix: absurd deploy erros have been fixed. --- apps/nova/src/pages/Call.tsx | 4 ++-- packages/headless/src/calls.ts | 8 ++++---- packages/models/src/cache/index.ts | 4 ++++ services/server/tests/api/call.test.ts | 9 +++++++++ services/server/tests/wss/call.test.ts | 9 +++++++++ 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/apps/nova/src/pages/Call.tsx b/apps/nova/src/pages/Call.tsx index 2957b206..c9142205 100644 --- a/apps/nova/src/pages/Call.tsx +++ b/apps/nova/src/pages/Call.tsx @@ -54,7 +54,7 @@ const Call: React.FC = () => { const ctype = useMemo(() => { if (callType != "lesson" && callType != "interview") return null; return callType; - }, [id]); + }, [callType]); const callRoom = useFindCallRoomById(!isGhost ? callId : null); @@ -166,7 +166,7 @@ const Call: React.FC = () => { ) ); - // console.log({ ghostStreams }); + useEffect(() => console.log({ ghostStreams }), [ghostStreams]); const callViewProps: CallViewProps = useMemo( () => ({ diff --git a/packages/headless/src/calls.ts b/packages/headless/src/calls.ts index 6cab3998..1ab95333 100644 --- a/packages/headless/src/calls.ts +++ b/packages/headless/src/calls.ts @@ -1044,16 +1044,16 @@ export function useCallMembers(callId: number | null, callType: ICall.Type | nul const [members, setMembers] = useState([]); useEffect(() => { if (data) setMembers(data) - }, [isPending]) + }, [data, isPending]) // define WSS events callbacks const onMemberJoinWssCallback: CallEventsCallback = useCallback(payload => { setMembers(prev => [...prev, payload.userId]); - }, [callId]) + }, []) const onMemberLeaveWssCallback: CallEventsCallback = useCallback(payload => { setMembers(prev => prev.filter(id => id !== payload.userId)); - }, [callId]) + }, []) // define react callbacks const joinCall = useCallback(() => { @@ -1079,7 +1079,7 @@ export function useCallMembers(callId: number | null, callType: ICall.Type | nul socket.off(Wss.ServerEvent.MemberLeftCall); leaveCall(); } - }, [callId, socket]) + }, [callId, socket, joinCall, leaveCall, onMemberLeaveWssCallback, onMemberJoinWssCallback]) return members; } diff --git a/packages/models/src/cache/index.ts b/packages/models/src/cache/index.ts index 7c3cc01d..928c1e5b 100644 --- a/packages/models/src/cache/index.ts +++ b/packages/models/src/cache/index.ts @@ -28,4 +28,8 @@ export class Cache { async connect() { await this.client.connect(); } + + async disconnect() { + await this.client.quit(); + } } diff --git a/services/server/tests/api/call.test.ts b/services/server/tests/api/call.test.ts index c6fffb87..064fcd95 100644 --- a/services/server/tests/api/call.test.ts +++ b/services/server/tests/api/call.test.ts @@ -6,6 +6,15 @@ import { expect } from "chai"; import { cache } from "@/lib/cache"; describe("/api/v1/call", () => { + + beforeAll(async () => { + await cache.connect(); + }); + + afterAll(async () => { + await cache.disconnect(); + }); + beforeEach(async () => { await flush(); await cache.flush(); diff --git a/services/server/tests/wss/call.test.ts b/services/server/tests/wss/call.test.ts index 19db37c0..99d46f8a 100644 --- a/services/server/tests/wss/call.test.ts +++ b/services/server/tests/wss/call.test.ts @@ -17,8 +17,17 @@ describe("calls test suite", () => { let tutorApi: Api; let studentApi: Api; + beforeAll(async () => { + await cache.connect(); + }); + + afterAll(async () => { + await cache.disconnect(); + }); + beforeEach(async () => { await flush(); + await cache.flush(); tutorApi = await Api.forTutor(); tutor = await tutorApi.findCurrentUser();