G7 증명과 G8 clean-head 승격 준비

This commit is contained in:
Yun Chan 2026-08-09 18:22:03 +09:00
parent 94c681d450
commit 5221f79e3f
52 changed files with 6876 additions and 506 deletions

View file

@ -590,6 +590,12 @@ function isOnline(seconds: number) {
}
async function openAdminAndReadHealth(page: Page) {
const userSnapshots: AdminUsersResponse[] = [];
const collectUsersResponse = async (response: Response) => {
if (!isAdminUsersResponse(response) || !response.ok()) return;
userSnapshots.push((await response.json()) as AdminUsersResponse);
};
page.on("response", collectUsersResponse);
const healthResponsePromise = page.waitForResponse(isAdminHealthResponse);
const usageResponsePromise = page.waitForResponse(isAdminUsageResponse);
const usersResponsePromise = page.waitForResponse(isAdminUsersResponse);
@ -613,10 +619,36 @@ async function openAdminAndReadHealth(page: Page) {
const health = (await healthResponse.json()) as AdminHealthResponse;
const usage = (await usageResponse.json()) as AdminUsageResponse;
const users = (await usersResponse.json()) as AdminUsersResponse;
const initialUsers = (await usersResponse.json()) as AdminUsersResponse;
const uptime = (await uptimeResponse.json()) as AdminUptimeResponse;
const tickets = (await ticketsResponse.json()) as AdminTicketsResponse;
expect(health.services.length).toBeGreaterThan(0);
if (userSnapshots.length === 0) userSnapshots.push(initialUsers);
let users = initialUsers;
await expect
.poll(
async () => {
const rendered = await page.locator(".vgops-kpi b").allTextContents();
const matchingSnapshot = userSnapshots.find((snapshot) => {
const activeSessions = snapshot.users.reduce(
(sum, user) => sum + Math.max(0, user.active_sessions),
0,
);
const onlineUsers = snapshot.users.filter((user) => isOnline(user.last_seen_at)).length;
return (
rendered[0] === countLabel(activeSessions) &&
rendered[1] === countLabel(onlineUsers) &&
rendered[2] === countLabel(snapshot.users.length)
);
});
if (matchingSnapshot) users = matchingSnapshot;
return Boolean(matchingSnapshot);
},
{ message: "관리자 KPI가 실제 /admin/users 응답 중 하나를 반영해야 한다" },
)
.toBe(true);
page.off("response", collectUsersResponse);
return { health, usage, users, uptime, tickets };
}