폼 전송 TDD추가 및 암호화 적용 중
This commit is contained in:
@@ -139,3 +139,90 @@ test("서로 다른 유저는 /projects 에서 자신의 프로젝트만 볼 수
|
||||
await expect(page.getByText("user-a-project")).toBeVisible();
|
||||
await expect(page.getByText("유저 B 프로젝트")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("프로젝트 목록에서 '폼 제출 내역' 링크를 클릭하면 해당 프로젝트의 제출 내역 페이지로 이동해야 한다", async ({ page }) => {
|
||||
// 로그인된 사용자 시나리오를 가정한다.
|
||||
await page.route("**/api/auth/me", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ id: "user-e2e", email: "e2e@example.com", tokenVersion: 1 }),
|
||||
});
|
||||
});
|
||||
|
||||
// /api/projects 응답을 목킹해 목록 페이지에 하나의 프로젝트가 보이도록 한다.
|
||||
await page.route("**/api/projects", async (route) => {
|
||||
const request = route.request();
|
||||
const url = new URL(request.url());
|
||||
const method = request.method();
|
||||
|
||||
if (url.pathname === "/api/projects" && method === "GET") {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify([
|
||||
{
|
||||
id: "1",
|
||||
title: "테스트 프로젝트 A",
|
||||
slug: "test-project-a",
|
||||
status: "DRAFT",
|
||||
createdAt: new Date("2025-01-01T00:00:00.000Z").toISOString(),
|
||||
updatedAt: new Date("2025-01-01T00:00:00.000Z").toISOString(),
|
||||
},
|
||||
]),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await route.fulfill({
|
||||
status: 404,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ message: "Not implemented in E2E mock" }),
|
||||
});
|
||||
});
|
||||
|
||||
// 선택한 프로젝트의 폼 제출 내역 API 응답도 목킹해, 제출 데이터가 테이블에 렌더링되는지 검증한다.
|
||||
await page.route("**/api/projects/test-project-a/submissions", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify([
|
||||
{
|
||||
id: "sub-1",
|
||||
projectId: "1",
|
||||
userId: "user-e2e",
|
||||
createdAt: new Date("2025-01-02T12:34:56.000Z").toISOString(),
|
||||
payload: {
|
||||
name: "홍길동",
|
||||
email: "user@example.com",
|
||||
phone: "010-1234-5678",
|
||||
birthdate: "1990-01-01",
|
||||
message: "안녕하세요",
|
||||
},
|
||||
},
|
||||
]),
|
||||
});
|
||||
});
|
||||
|
||||
// 프로젝트 목록 페이지로 이동한다.
|
||||
await page.goto("/projects");
|
||||
|
||||
// 목록에 테스트 프로젝트가 보여야 한다.
|
||||
await expect(page.getByText("테스트 프로젝트 A")).toBeVisible();
|
||||
await expect(page.getByText("test-project-a")).toBeVisible();
|
||||
|
||||
// 액션 영역의 "폼 제출 내역" 링크를 클릭하면 제출 내역 페이지로 이동해야 한다.
|
||||
await page.getByRole("link", { name: "폼 제출 내역" }).click();
|
||||
|
||||
await expect(page).toHaveURL(/\/projects\/test-project-a\/submissions/);
|
||||
|
||||
// 제출 내역 페이지의 헤더와 slug, 제출 데이터가 렌더링되어야 한다.
|
||||
await expect(page.getByRole("heading", { name: "폼 제출 내역" })).toBeVisible();
|
||||
await expect(page.getByText("test-project-a")).toBeVisible();
|
||||
|
||||
await expect(page.getByText("홍길동")).toBeVisible();
|
||||
await expect(page.getByText("user@example.com")).toBeVisible();
|
||||
await expect(page.getByText("010-1234-5678")).toBeVisible();
|
||||
await expect(page.getByText("1990-01-01")).toBeVisible();
|
||||
await expect(page.getByText("message: 안녕하세요")).toBeVisible();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user