Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions apps/client/src/features/auth/auth.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ import {
PostRefreshResponseSchema,
} from '@/features/auth/auth.dto';

const AUTH_BASE_URL = '/api/auth';

export const login = (body: PostLoginRequestDTO) =>
axios
.post<PostLoginResponseDTO>(`${AUTH_BASE_URL}/login`, PostLoginRequestSchema.parse(body))
.post<PostLoginResponseDTO>(`/api/auth/login`, PostLoginRequestSchema.parse(body))
.then((res) => PostLoginResponseSchema.parse(res.data));

export const logout = () => axios.post(`${AUTH_BASE_URL}/logout`);
export const logout = () => axios.post(`/api/auth/logout`);

export const refresh = () =>
axios
.post<PostRefreshResponseDTO>(`${AUTH_BASE_URL}/token`, undefined, {
.post<PostRefreshResponseDTO>(`/api/auth/token`, undefined, {
withCredentials: true,
})
.then((res) => PostRefreshResponseSchema.parse(res.data));
13 changes: 12 additions & 1 deletion apps/client/src/routes/session/$sessionId/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createFileRoute, redirect } from '@tanstack/react-router';
import { useEffect } from 'react';

import { refresh, useAuthStore } from '@/features/auth';
import { getSessionToken, useSessionStore } from '@/features/session';
Expand All @@ -7,8 +8,18 @@ import { getQuestions } from '@/features/session/qna';

import { QuestionList } from '@/components';

function SessionComponent() {
const { sessionTitle } = useSessionStore();

useEffect(() => {
if (sessionTitle) document.title = `Ask-It - ${sessionTitle}`;
}, [sessionTitle]);

return <QuestionList />;
}

export const Route = createFileRoute('/session/$sessionId/')({
component: QuestionList,
component: SessionComponent,
beforeLoad: async ({ params: { sessionId } }) => {
const {
reset,
Expand Down
5 changes: 1 addition & 4 deletions apps/client/tests/HomePage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ test('회원 가입이 이미 중복된 닉네임이 있어서 실패하는 경
await expect(signUpButton).toBeDisabled();
});

test('로그인 / 로그아웃 플로우 전체 테스트', async ({ page }) => {
test('로그인 플로우 전체 테스트', async ({ page }) => {
await page.click('text=로그인');

const loginButton = page.getByRole('button', { name: '로그인' }).nth(1);
Expand All @@ -151,7 +151,4 @@ test('로그인 / 로그아웃 플로우 전체 테스트', async ({ page }) =>
expect((await response).status()).toBe(200);

await expect(page.locator('text=로그인 되었습니다.')).toBeVisible();

await page.click('text=로그아웃');
await expect(page.locator('text=로그아웃 되었습니다.')).toBeVisible();
});
Loading