폼전송 기능 수정
CI / test (push) Failing after 4m53s
CI / e2e (push) Has been skipped
CI / pr_and_merge (push) Has been skipped

This commit is contained in:
2025-12-07 19:11:06 +09:00
parent 96fa34cd86
commit 243083261f
27 changed files with 1025 additions and 5 deletions
+103
View File
@@ -155,3 +155,106 @@ test("프리뷰 폼 제출 후 제출 내역 페이지에서 데이터가 보여
await expect(page.getByText(messageValue)).toBeVisible();
}
});
test("퍼블릭 페이지 폼 제출 후 제출 내역 페이지에서 데이터가 보여야 한다", async ({ page, request }) => {
const now = Date.now();
const email = `public-form-e2e-${now}@example.com`;
const password = "public-form-e2e-password";
const projectSlug = `public-form-e2e-project-${now}`;
const signupRes = await request.post("/api/auth/signup", {
headers: { "Content-Type": "application/json" },
data: { email, password },
});
expect(signupRes.status()).toBe(201);
const setCookieHeader = signupRes.headers()["set-cookie"];
expect(setCookieHeader).toBeTruthy();
const cookieHeaderString = Array.isArray(setCookieHeader)
? setCookieHeader.join("; ")
: (setCookieHeader as string);
const match = cookieHeaderString.match(/pb_access=([^;]+)/);
expect(match).not.toBeNull();
const accessToken = match![1];
await page.context().addCookies([
{
name: "pb_access",
value: accessToken,
domain: "localhost",
path: "/",
httpOnly: true,
secure: false,
sameSite: "Lax",
},
]);
await page.goto("/editor");
const propertiesSidebar = page.getByTestId("properties-sidebar");
await propertiesSidebar.getByLabel("프로젝트 제목").fill("E2E 퍼블릭 폼 프로젝트");
await propertiesSidebar.getByLabel("프로젝트 주소 (slug)").fill(projectSlug);
await page.getByRole("button", { name: "입력(Input)" }).click();
await page.getByRole("button", { name: "입력(Input)" }).click();
await page.getByRole("button", { name: "입력(Input)" }).click();
await page.getByRole("button", { name: "버튼" }).click();
await page.getByRole("button", { name: "폼 컨트롤러" }).click();
const fieldMappingGroup = page.getByRole("group", { name: "폼 필드 매핑" });
const fieldCheckboxes = fieldMappingGroup.locator("> label > input[type='checkbox']");
const fieldCount = await fieldCheckboxes.count();
for (let i = 0; i < fieldCount; i += 1) {
await fieldCheckboxes.nth(i).check({ force: true });
}
const submitSelect = page.getByRole("combobox", { name: "Submit 버튼" });
await submitSelect.selectOption({ index: 1 });
await page.getByRole("button", { name: "메뉴 ▼" }).click();
await page.getByRole("button", { name: "프로젝트 저장/불러오기" }).click();
await page.getByRole("button", { name: "저장 (로컬 + 서버)" }).click();
await expect(page).toHaveURL(/\/_?projects/);
await expect(page.getByText(projectSlug)).toBeVisible();
await page.goto(`/p/${projectSlug}`);
const nameValue = "홍길동";
const emailValue = `public-submitted-${now}@example.com`;
const messageValue = "퍼블릭 E2E 테스트 메시지";
const inputs = page.locator("input.pb-input");
const inputCount = await inputs.count();
expect(inputCount).toBeGreaterThanOrEqual(2);
await inputs.nth(0).fill(nameValue);
await inputs.nth(1).fill(emailValue);
if (inputCount >= 3) {
await inputs.nth(2).fill(messageValue);
}
await page.getByRole("button", { name: "버튼" }).click();
await expect(page.getByText("성공적으로 전송되었습니다.")).toBeVisible();
await page.goto("/projects");
await expect(page).toHaveURL(/\/_?projects/);
const submissionsRow = page.locator("tr", { hasText: projectSlug }).first();
await submissionsRow.getByRole("link", { name: "폼 제출 내역" }).click();
await expect(page).toHaveURL(new RegExp(`/projects/${projectSlug}/submissions`));
await expect(page.getByRole("heading", { name: "폼 제출 내역" })).toBeVisible();
await expect(page.getByText(projectSlug)).toBeVisible();
await expect(page.getByText(nameValue)).toBeVisible();
await expect(page.getByText(emailValue)).toBeVisible();
if (inputCount >= 3) {
await expect(page.getByText(messageValue)).toBeVisible();
}
});