This commit is contained in:
parent
6e3123091a
commit
aeddaa6972
69 changed files with 3178 additions and 424 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { expect, test, type Page, type Route, type TestInfo } from "@playwright/test";
|
||||
import type { DeliberatePracticeReadModel } from "../src/pages/session-review/deliberatePracticeApi";
|
||||
|
|
@ -664,35 +665,131 @@ async function expectAtMainScrollStart(
|
|||
}
|
||||
|
||||
async function expectLearnerMobileNavIntegrity(page: Page) {
|
||||
const result = await page.locator(".vg-nav").evaluate((nav) => {
|
||||
const navRect = nav.getBoundingClientRect();
|
||||
return Array.from(nav.querySelectorAll<HTMLElement>(".vg-nav__item")).map(
|
||||
(item) => {
|
||||
const primaryItems = await page
|
||||
.locator(".vg-nav__item--mobile-primary")
|
||||
.evaluateAll((items) =>
|
||||
items.map((item) => {
|
||||
const rect = item.getBoundingClientRect();
|
||||
const navRect = item.closest<HTMLElement>(".vg-nav")?.getBoundingClientRect();
|
||||
return {
|
||||
label: item.textContent?.trim() ?? "",
|
||||
left: rect.left,
|
||||
right: rect.right,
|
||||
height: rect.height,
|
||||
navLeft: navRect.left,
|
||||
navRight: navRect.right,
|
||||
navLeft: navRect?.left ?? Number.NaN,
|
||||
navRight: navRect?.right ?? Number.NaN,
|
||||
};
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
expect(result.map((item) => item.label)).toEqual([
|
||||
"대시보드",
|
||||
"학습",
|
||||
"기록",
|
||||
"설정",
|
||||
expect(primaryItems.map((item) => item.label)).toEqual([
|
||||
"학습자 홈",
|
||||
"상담 연습",
|
||||
"학습 기록",
|
||||
]);
|
||||
for (const item of result) {
|
||||
for (const item of primaryItems) {
|
||||
expect(item.left, `${item.label} left`).toBeGreaterThanOrEqual(item.navLeft);
|
||||
expect(item.right, `${item.label} right`).toBeLessThanOrEqual(item.navRight);
|
||||
expect(item.height, `${item.label} touch target height`).toBeGreaterThanOrEqual(
|
||||
44,
|
||||
);
|
||||
}
|
||||
|
||||
const menuButton = page.getByRole("button", { name: "전체 메뉴", exact: true });
|
||||
await expect(menuButton).toBeVisible();
|
||||
await expect(menuButton).toBeEnabled();
|
||||
const menuBounds = await menuButton.evaluate((button) => {
|
||||
const rect = button.getBoundingClientRect();
|
||||
const navRect = button.closest<HTMLElement>(".vg-nav")?.getBoundingClientRect();
|
||||
return {
|
||||
left: rect.left,
|
||||
right: rect.right,
|
||||
height: rect.height,
|
||||
navLeft: navRect?.left ?? Number.NaN,
|
||||
navRight: navRect?.right ?? Number.NaN,
|
||||
};
|
||||
});
|
||||
expect(menuBounds.left, "전체 메뉴 left").toBeGreaterThanOrEqual(menuBounds.navLeft);
|
||||
expect(menuBounds.right, "전체 메뉴 right").toBeLessThanOrEqual(menuBounds.navRight);
|
||||
expect(menuBounds.height, "전체 메뉴 touch target height").toBeGreaterThanOrEqual(44);
|
||||
|
||||
await menuButton.click();
|
||||
const dialog = page.locator("#vg-all-menu-dialog");
|
||||
await expect(dialog).toBeVisible();
|
||||
const settingsLink = dialog.getByRole("link", { name: "설정", exact: true });
|
||||
await expect(settingsLink).toBeVisible();
|
||||
await expect(settingsLink).toBeEnabled();
|
||||
await page.getByRole("button", { name: "전체 메뉴 닫기", exact: true }).click();
|
||||
await expect(dialog).not.toBeVisible();
|
||||
}
|
||||
|
||||
async function expectDesktopPrestartStickyAction(
|
||||
page: Page,
|
||||
testInfo: TestInfo,
|
||||
) {
|
||||
if (!testInfo.project.name.includes("desktop")) return;
|
||||
|
||||
const geometry = await page.evaluate(() => {
|
||||
const main = document.querySelector<HTMLElement>(".vg-main");
|
||||
const actions = document.querySelector<HTMLElement>(
|
||||
".sx-page--prestart .sx-prestart__actions",
|
||||
);
|
||||
if (!main || !actions) throw new Error("prestart sticky action fixture unavailable");
|
||||
|
||||
const toBox = (rect: DOMRect) => ({
|
||||
top: rect.top,
|
||||
bottom: rect.bottom,
|
||||
height: rect.height,
|
||||
left: rect.left,
|
||||
right: rect.right,
|
||||
});
|
||||
const mainBefore = toBox(main.getBoundingClientRect());
|
||||
const actionBefore = toBox(actions.getBoundingClientRect());
|
||||
main.scrollTop = main.scrollHeight;
|
||||
const mainAfter = toBox(main.getBoundingClientRect());
|
||||
const actionAfter = toBox(actions.getBoundingClientRect());
|
||||
const scrollTop = main.scrollTop;
|
||||
const scrollHeight = main.scrollHeight;
|
||||
const clientHeight = main.clientHeight;
|
||||
main.scrollTop = 0;
|
||||
return {
|
||||
viewport: { width: innerWidth, height: innerHeight },
|
||||
mainBefore,
|
||||
actionBefore,
|
||||
mainAfter,
|
||||
actionAfter,
|
||||
scrollTop,
|
||||
scrollHeight,
|
||||
clientHeight,
|
||||
};
|
||||
});
|
||||
const diagnostic = JSON.stringify(geometry);
|
||||
expect(geometry.viewport).toEqual({ width: 1440, height: 900 });
|
||||
if (geometry.scrollHeight > geometry.clientHeight) {
|
||||
expect(geometry.scrollTop, diagnostic).toBeGreaterThan(0);
|
||||
}
|
||||
expect(geometry.actionBefore.top, diagnostic).toBeGreaterThanOrEqual(
|
||||
geometry.mainBefore.top,
|
||||
);
|
||||
expect(geometry.actionBefore.bottom, diagnostic).toBeLessThanOrEqual(
|
||||
geometry.mainBefore.bottom,
|
||||
);
|
||||
expect(geometry.actionAfter.top, diagnostic).toBeGreaterThanOrEqual(
|
||||
geometry.mainAfter.top,
|
||||
);
|
||||
expect(geometry.actionAfter.bottom, diagnostic).toBeLessThanOrEqual(
|
||||
geometry.mainAfter.bottom,
|
||||
);
|
||||
expect(geometry.actionAfter.height, diagnostic).toBeGreaterThanOrEqual(44);
|
||||
|
||||
const evidenceDirectory = process.env.E2E_EVIDENCE_DIR;
|
||||
if (evidenceDirectory) {
|
||||
await writeFile(
|
||||
path.resolve(evidenceDirectory, "self-directed-prestart-sticky-geometry-chromium-desktop.json"),
|
||||
`${JSON.stringify(geometry, null, 2)}\n`,
|
||||
"utf8",
|
||||
);
|
||||
}
|
||||
await capture(page, testInfo, "self-directed-prestart-sticky", false);
|
||||
}
|
||||
|
||||
async function expectNoPhysicalMediaAccess(page: Page) {
|
||||
|
|
@ -893,7 +990,12 @@ async function expectMobileActiveVisualIntegrity(page: Page) {
|
|||
expect(result.latestReplyVisible, diagnostic).toBe(true);
|
||||
}
|
||||
|
||||
async function capture(page: Page, testInfo: TestInfo, stage: string) {
|
||||
async function capture(
|
||||
page: Page,
|
||||
testInfo: TestInfo,
|
||||
stage: string,
|
||||
fullPage = true,
|
||||
) {
|
||||
if (process.env.E2E_SKIP_EVIDENCE_CAPTURE === "1") return;
|
||||
const safeProject = testInfo.project.name.replace(/[^a-z0-9-]+/gi, "-").toLowerCase();
|
||||
const evidenceDirectory = process.env.E2E_EVIDENCE_DIR;
|
||||
|
|
@ -901,7 +1003,7 @@ async function capture(page: Page, testInfo: TestInfo, stage: string) {
|
|||
path: evidenceDirectory
|
||||
? path.resolve(evidenceDirectory, `self-directed-loop-${stage}-${safeProject}.png`)
|
||||
: testInfo.outputPath(`self-directed-loop-${stage}.png`),
|
||||
fullPage: true,
|
||||
fullPage,
|
||||
animations: "disabled",
|
||||
});
|
||||
}
|
||||
|
|
@ -913,7 +1015,7 @@ test.describe("학습자 자기주도 전체 루프 — 실제 src UI / route fi
|
|||
await routeSelfDirectedUiFixture(page);
|
||||
await page.goto("/learn");
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "오늘 이어갈 회기를 먼저 봅니다." }),
|
||||
page.getByRole("heading", { name: "오늘의 상담 연습", exact: true, level: 1 }),
|
||||
).toBeVisible();
|
||||
|
||||
// index.html의 첫 watchdog(3.5초)과 실제 자기주도 경로 전환을 겹친다.
|
||||
|
|
@ -971,7 +1073,7 @@ test.describe("학습자 자기주도 전체 루프 — 실제 src UI / route fi
|
|||
|
||||
await page.goto("/learn");
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "오늘 이어갈 회기를 먼저 봅니다." }),
|
||||
page.getByRole("heading", { name: "오늘의 상담 연습", exact: true, level: 1 }),
|
||||
).toBeVisible();
|
||||
await expect(page.getByLabel("AI 코치")).toContainText(
|
||||
"첫 회기를 시작할 차례입니다.",
|
||||
|
|
@ -1040,8 +1142,14 @@ test.describe("학습자 자기주도 전체 루프 — 실제 src UI / route fi
|
|||
}
|
||||
const persona = page.getByRole("option", { name: /P1/ });
|
||||
await persona.click();
|
||||
await page.getByRole("button", { name: "새 회기 시작" }).click();
|
||||
await expect(page).toHaveURL(/\/learn\/session\/P1$/);
|
||||
await page
|
||||
.getByRole("button", { name: "완전히 새로 시작", exact: true })
|
||||
.click();
|
||||
await expect(page).toHaveURL(
|
||||
(url) =>
|
||||
url.pathname === "/learn/session/P1" &&
|
||||
url.searchParams.get("continuity") === "fresh",
|
||||
);
|
||||
|
||||
const goals = page.getByRole("group", { name: "이번 회기 목표 선택" });
|
||||
await expect(goals.getByRole("button", { name: /라포/ })).toHaveAttribute(
|
||||
|
|
@ -1223,7 +1331,9 @@ test.describe("학습자 자기주도 전체 루프 — 실제 src UI / route fi
|
|||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await page.evaluate(() => new Promise(requestAnimationFrame));
|
||||
}
|
||||
await page.getByRole("button", { name: "새 회기 시작" }).click();
|
||||
await page
|
||||
.getByRole("button", { name: "완전히 새로 시작", exact: true })
|
||||
.click();
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "처방 연습 · 장면 다시 보기" }),
|
||||
).toBeVisible();
|
||||
|
|
@ -1241,6 +1351,12 @@ test.describe("학습자 자기주도 전체 루프 — 실제 src UI / route fi
|
|||
"인간중심",
|
||||
);
|
||||
await expect(prescribedSettings.locator(".sx-prestart__settings-body")).not.toBeVisible();
|
||||
await expectDesktopPrestartStickyAction(page, testInfo);
|
||||
const voiceDisclosure = page.locator(
|
||||
".sx-page--prestart .sx-prestart__voice-disclosure",
|
||||
);
|
||||
await voiceDisclosure.scrollIntoViewIfNeeded();
|
||||
await expect(voiceDisclosure).toBeVisible();
|
||||
await expectInsideInitialViewport(
|
||||
page,
|
||||
".sx-prestart__actions .vg-btn",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue