This commit is contained in:
parent
6e3123091a
commit
aeddaa6972
69 changed files with 3178 additions and 424 deletions
|
|
@ -153,24 +153,42 @@ test.describe("full sweep — shared shell, GNB, and routing guards", () => {
|
|||
const topbarRect = element.getBoundingClientRect();
|
||||
const controls = Array.from(
|
||||
element.querySelectorAll<HTMLElement>(
|
||||
".vg-topbar__brand, .vg-topbar__switch-link, .vg-iconbtn",
|
||||
".vg-topbar__brand, .vg-topbar__switch-link, .vg-topbar__switch-select, .vg-iconbtn",
|
||||
),
|
||||
).map((control) => {
|
||||
const rect = control.getBoundingClientRect();
|
||||
return {
|
||||
label:
|
||||
control.getAttribute("aria-label") ??
|
||||
control.getAttribute("title") ??
|
||||
control.textContent?.trim() ??
|
||||
control.className,
|
||||
left: rect.left,
|
||||
right: rect.right,
|
||||
top: rect.top,
|
||||
bottom: rect.bottom,
|
||||
width: rect.width,
|
||||
height: rect.height,
|
||||
};
|
||||
});
|
||||
)
|
||||
.map((control) => {
|
||||
const style = getComputedStyle(control);
|
||||
const rect = control.getBoundingClientRect();
|
||||
return {
|
||||
kind: control.classList.contains("vg-topbar__switch-link")
|
||||
? "role-link"
|
||||
: control.classList.contains("vg-topbar__switch-select")
|
||||
? "role-select"
|
||||
: "shared",
|
||||
label:
|
||||
control.getAttribute("aria-label") ??
|
||||
control.getAttribute("title") ??
|
||||
control.textContent?.trim() ??
|
||||
control.className,
|
||||
options:
|
||||
control instanceof HTMLSelectElement
|
||||
? Array.from(control.options, (option) => option.text)
|
||||
: [],
|
||||
value: control instanceof HTMLSelectElement ? control.value : null,
|
||||
visible:
|
||||
rect.width > 0 &&
|
||||
rect.height > 0 &&
|
||||
style.display !== "none" &&
|
||||
style.visibility !== "hidden",
|
||||
left: rect.left,
|
||||
right: rect.right,
|
||||
top: rect.top,
|
||||
bottom: rect.bottom,
|
||||
width: rect.width,
|
||||
height: rect.height,
|
||||
};
|
||||
})
|
||||
.filter((control) => control.visible);
|
||||
return {
|
||||
controls,
|
||||
topbarLeft: topbarRect.left,
|
||||
|
|
@ -182,15 +200,30 @@ test.describe("full sweep — shared shell, GNB, and routing guards", () => {
|
|||
};
|
||||
});
|
||||
|
||||
const labels = topbar.controls.map((control) => control.label);
|
||||
expect(labels.slice(0, 4)).toEqual([
|
||||
"Vignette",
|
||||
"학습자 공간",
|
||||
"교수 콘솔",
|
||||
"운영 콘솔",
|
||||
]);
|
||||
expect(labels[4]).toMatch(/^(라이트|다크) 모드로$/);
|
||||
expect(labels[5]).toBe("로그아웃");
|
||||
const visibleSharedControls = topbar.controls.filter((control) => control.kind === "shared");
|
||||
expect(visibleSharedControls).toHaveLength(3);
|
||||
expect(visibleSharedControls[0].label).toBe("Vignette");
|
||||
expect(visibleSharedControls[1].label).toMatch(/^(라이트|다크) 모드로$/);
|
||||
expect(visibleSharedControls[2].label).toBe("로그아웃");
|
||||
|
||||
const visibleRoleLinks = topbar.controls.filter((control) => control.kind === "role-link");
|
||||
const visibleRoleSelects = topbar.controls.filter((control) => control.kind === "role-select");
|
||||
if (viewport.width > 720) {
|
||||
expect(visibleRoleLinks.map((control) => control.label)).toEqual([
|
||||
"학습자 공간",
|
||||
"교수 콘솔",
|
||||
"운영 콘솔",
|
||||
]);
|
||||
expect(visibleRoleSelects).toHaveLength(0);
|
||||
} else {
|
||||
expect(visibleRoleLinks).toHaveLength(0);
|
||||
expect(visibleRoleSelects).toHaveLength(1);
|
||||
expect(visibleRoleSelects[0]).toMatchObject({
|
||||
label: "공간 선택",
|
||||
value: "admin",
|
||||
options: ["학습자", "교수자", "관리자"],
|
||||
});
|
||||
}
|
||||
for (const control of topbar.controls) {
|
||||
expect(control.width, `${control.label} ${viewport.width}px width`).toBeGreaterThanOrEqual(44);
|
||||
expect(control.height, `${control.label} ${viewport.width}px height`).toBeGreaterThanOrEqual(44);
|
||||
|
|
@ -208,6 +241,15 @@ test.describe("full sweep — shared shell, GNB, and routing guards", () => {
|
|||
);
|
||||
}
|
||||
expect(topbar.scrollWidth).toBe(topbar.viewportWidth);
|
||||
|
||||
if (viewport.width <= 720) {
|
||||
const roleSelect = page.getByRole("combobox", { name: "공간 선택" });
|
||||
await roleSelect.selectOption("teacher");
|
||||
await expect(page).toHaveURL(/\/teach$/);
|
||||
await expect(page.locator("body")).toHaveAttribute("data-role", "instructor");
|
||||
await page.goto("/admin");
|
||||
await expect(page.locator(".vg-topbar")).toBeVisible({ timeout: 15_000 });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue