Files
clean-architecture-frontend…/tests/e2e/reference-form.spec.ts
T
DongHyeonkaandClaude Opus 5.5 9960a619fa test(e2e): keep the reference en-US check in the sample's spec (08-04)
The check named reference paths from i18n.spec.ts, which the sample
removal keeps, so the removed fixture would carry reference residue.
reference-form.spec.ts is removed with the sample.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 00:13:39 +09:00

81 lines
3.0 KiB
TypeScript

import type { Page } from "@playwright/test";
import { expect, test } from "../support/browser/strict-browser-test.ts";
async function openReferenceForm(page: Page) {
await page.goto("/examples/reference-resources/new");
await page.getByRole("button", { name: "로그인 시작" }).click();
await expect(
page.getByRole("heading", { name: "Reference resource 만들기" }),
).toBeVisible();
}
test("validates a reference form and focuses the first invalid field", async ({
page,
}) => {
await openReferenceForm(page);
await page.getByRole("button", { name: "저장" }).click();
const firstField = page.getByRole("textbox", { name: /새 항목 이름/ });
await expect(firstField).toBeFocused();
await expect(firstField).toHaveAttribute("aria-invalid", "true");
await expect(page.getByRole("alert")).toContainText("입력 내용을 확인해 주세요.");
});
test("guards dirty cancellation and restores focus when writing continues", async ({
page,
}) => {
await openReferenceForm(page);
await page
.getByRole("textbox", { name: /새 항목 이름/ })
.fill("Unsaved reference");
const cancel = page.getByRole("button", { name: "취소" });
await cancel.click();
await expect(
page.getByRole("dialog", { name: "저장하지 않은 변경이 있습니다." }),
).toBeVisible();
await page.getByRole("button", { name: "계속 작성" }).click();
await expect(cancel).toBeFocused();
await expect(page).toHaveURL(/\/examples\/reference-resources\/new$/);
});
test("keeps the form template within a 320px viewport", async ({ page }) => {
await page.setViewportSize({ width: 320, height: 720 });
await openReferenceForm(page);
const viewport = await page.evaluate(() => ({
clientWidth: document.documentElement.clientWidth,
scrollWidth: document.documentElement.scrollWidth,
}));
expect(viewport.scrollWidth).toBeLessThanOrEqual(viewport.clientWidth);
});
// 08-04. Feature screens take their words from the catalog. This lives with
// the sample's specs so removing the sample removes it too.
test("renders the reference screens without Korean copy in en-US", async ({
page,
}) => {
await page.route("http://localhost:8080/api/reference-resources?*", (route) =>
route.fulfill({
json: [
{
id: "browser-reference",
name: "Browser reference",
createdAt: "2026-07-26T00:00:00.000Z",
},
],
}),
);
await page.goto("/examples/reference-resources");
await page.getByRole("button", { name: "로그인 시작" }).click();
await expect(page.getByRole("link", { name: "Browser reference" })).toBeVisible();
await page.getByRole("combobox", { name: "언어" }).selectOption("en-US");
const main = page.getByRole("main");
await expect(main.getByRole("status")).toHaveText("Total items: 1");
await expect(main).not.toContainText(/[가-힣]/);
await main.getByRole("button", { name: "Create item" }).click();
await expect(main.getByRole("button", { name: "Save" })).toBeVisible();
await expect(main).not.toContainText(/[가-힣]/);
});