forked from baron/baron-sso
71 lines
2.1 KiB
TypeScript
71 lines
2.1 KiB
TypeScript
import { expect, type Page, type Route, test } from "@playwright/test";
|
|
|
|
async function mockUserfrontApisForRepro(
|
|
page: Page,
|
|
options: { sessionStatus: number } = { sessionStatus: 401 },
|
|
): Promise<void> {
|
|
await page.route("**/api/v1/**", async (route: Route) => {
|
|
const requestUrl = new URL(route.request().url());
|
|
const path = requestUrl.pathname;
|
|
|
|
if (path.endsWith("/api/v1/user/me")) {
|
|
await route.fulfill({
|
|
status: options.sessionStatus,
|
|
contentType: "application/json",
|
|
body: JSON.stringify({ error: "unauthorized" }),
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (path.endsWith("/api/v1/client-log")) {
|
|
await route.fulfill({
|
|
status: 200,
|
|
contentType: "application/json",
|
|
body: JSON.stringify({ ok: true }),
|
|
});
|
|
return;
|
|
}
|
|
|
|
// Default mock for other APIs
|
|
await route.fulfill({
|
|
status: 200,
|
|
contentType: "application/json",
|
|
body: JSON.stringify({}),
|
|
});
|
|
});
|
|
}
|
|
|
|
test.describe("Issue #345 Reproduction (Log-based Validation)", () => {
|
|
test("비로그인 상태에서 login_challenge와 함께 signin 진입 시 루프 없이 로그가 정상 출력되어야 한다", async ({
|
|
page,
|
|
}) => {
|
|
const requests: string[] = [];
|
|
page.on("request", (request) => {
|
|
if (request.isNavigationRequest()) {
|
|
requests.push(request.url());
|
|
}
|
|
});
|
|
|
|
await mockUserfrontApisForRepro(page, { sessionStatus: 401 });
|
|
|
|
const targetUrl = "/ko/signin?login_challenge=repro_challenge_12345";
|
|
await page.goto(targetUrl);
|
|
|
|
// WASM 앱 로딩 및 로직 실행 대기
|
|
await page.waitForTimeout(7000);
|
|
|
|
const currentUrl = page.url();
|
|
const signinNavigations = requests.filter((url) => url.includes("/signin"));
|
|
|
|
// [검증 1] URL 유지 확인
|
|
expect(currentUrl).toContain("login_challenge=repro_challenge_12345");
|
|
|
|
// [검증 2] 리다이렉트 루프 발생 여부 확인 (최초 진입 1회만 있어야 함)
|
|
expect(signinNavigations.length).toBeLessThanOrEqual(1);
|
|
|
|
console.log(
|
|
"✅ 루프가 해결되었으며, URL 유지와 네비게이션 수로 정상 동작을 확인했습니다.",
|
|
);
|
|
});
|
|
});
|