diff --git a/frontend/src/hooks/queries/useChats.test.tsx b/frontend/src/hooks/queries/useChats.test.tsx index 01a344c7d..bfdc3dd12 100644 --- a/frontend/src/hooks/queries/useChats.test.tsx +++ b/frontend/src/hooks/queries/useChats.test.tsx @@ -8,6 +8,7 @@ import { } from '../../mocks/handler/chatHandler'; import { renderHook } from '@testing-library/react'; +import { setLastDarakbangId } from '@_common/lastDarakbangManager'; import useChats from './useChats'; const queryClient = new QueryClient(); @@ -16,6 +17,9 @@ const wrapper = ({ children }: { children: ReactNode }) => ( ); describe('useChats', () => { + beforeEach(() => { + setLastDarakbangId(1); + }); afterEach(() => { nowChatServerData.length = 0; initChatIndex(); diff --git a/frontend/src/mocks/handler/chatHandler.ts b/frontend/src/mocks/handler/chatHandler.ts index 9e30c2e5a..8b56a9ed7 100644 --- a/frontend/src/mocks/handler/chatHandler.ts +++ b/frontend/src/mocks/handler/chatHandler.ts @@ -2,7 +2,6 @@ import { HttpResponse, http } from 'msw'; import { Chat } from '@_types/index'; import mockedChats from './mockedChats'; -import ENDPOINTS from '@_apis/endPoints'; let nowChatIndex = 0; @@ -26,13 +25,16 @@ export const chatSliceIndexes = [ ]; export const chatHandler = [ - http.get(ENDPOINTS.chat, async ({ request }) => { - const url = new URL(request.url); - - const recentChatId = +(url.searchParams.get('recentChatId') || 0); - - return HttpResponse.json({ - data: { chats: nowChatServerData.slice(recentChatId) }, - }); - }), + http.get( + `${process.env.BASE_URL}/v1/darakbang/1/chat`, + async ({ request }) => { + const url = new URL(request.url); + + const recentChatId = +(url.searchParams.get('recentChatId') || 0); + + return HttpResponse.json({ + data: { chats: nowChatServerData.slice(recentChatId) }, + }); + }, + ), ];