Files
QuantEngineByItz/precision-test.mjs
T
kjh2064 bcd1cc0f93
WBS-9.3 - NULL Policy CI Gate / NULL Policy Validation (push) Failing after 7s
Quant Engine CI/CD Pipeline / validate-core (push) Failing after 15s
Quant Engine CI/CD Pipeline / validate-ui-and-storage (push) Has been skipped
Deploy to Production / Build & Deploy to Production (push) Failing after 3m14s
refactor: switch to cookie-based auth flow with JS interop fallback
Architecture shift:
- Primary: HTTP-only cookie authentication (server-side)
- Fallback: localStorage with JS interop for SPA

Changes:
1. CustomAuthenticationStateProvider:
   - Add IJSRuntime for direct localStorage access
   - Try JS interop first, fallback to LocalStorageService
   - Added detailed logging for auth debugging

2. Dashboard.razor:
   - Add @rendermode InteractiveWebAssembly (CLAUDE.md compliance)
   - Restore auth check with logging
   - Redirect to /login.html if not authenticated

3. Program.cs:
   - Reorder MapRazorComponents: WebAssembly first (default)
   - Add detailed logging to /api/auth/login cookie setup
   - Verify Set-Cookie headers are sent correctly

4. login.html:
   - Simplified to 2-second wait before redirect
   - localStorage as backup storage
   - Ready for cookie-based auth

Next steps:
- Verify Set-Cookie headers appear in responses
- Confirm cookie-based auth works end-to-end
- Test dashboard loads with cookie authentication

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-06 01:48:01 +09:00

89 lines
3.2 KiB
JavaScript

import { chromium } from "@playwright/test";
(async () => {
console.log("════════════════════════════════════════════════════════");
console.log(" 🔬 PRECISION DEBUG TEST (Auth Check Disabled)");
console.log("════════════════════════════════════════════════════════\n");
const b = await chromium.launch({ headless: false });
const p = await b.newPage();
const allLogs = [];
p.on("console", msg => {
const text = msg.text();
allLogs.push(text);
if (text.includes("[") || text.includes("dashboard") || text.includes("login")) {
console.log(" 📝 " + text);
}
});
// Network events
p.on("response", res => {
const url = res.url();
if (url.includes("dashboard") || url.includes("login") || url.includes("api")) {
console.log(` 📡 ${res.status()} ${url.split('/').pop() || 'root'}`);
}
});
try {
console.log("1️⃣ 로그인 페이지 로드");
await p.goto("http://localhost:5265/login.html", { waitUntil: "networkidle" });
console.log("2️⃣ 로그인 제출");
await p.fill("input[name='username']", "admin");
await p.fill("input[name='password']", "admin");
await p.click("button[type='submit']");
console.log("3️⃣ 12초 동안 모니터링\n");
let urlHistory = [];
for (let i = 0; i < 12; i++) {
await new Promise(r => setTimeout(r, 1000));
const url = p.url();
if (!urlHistory.includes(url)) {
urlHistory.push(url);
console.log(` [${i+1}s] → ${url}`);
}
}
console.log("\n4️⃣ 최종 상태:");
const finalUrl = p.url();
const finalContent = await p.content();
console.log(` URL: ${finalUrl}`);
if (finalUrl.includes("/dashboard")) {
console.log(" ✅ /dashboard 도착!");
if (finalContent.includes("관리자 대시보드")) {
console.log(" ✅ 대시보드 콘텐츠 로드됨!");
console.log("\n🎉 SUCCESS!\n");
} else {
console.log(" ⚠️ URL은 dashboard인데 콘텐츠가 없음");
}
} else if (finalUrl.includes("/login")) {
console.log(" ❌ 다시 login으로 리다이렉트됨");
console.log("\n 분석:");
console.log(" - 이것은 Dashboard.razor에서 redirect되는 뜻");
console.log(" - localStorage에서 토큰을 읽지 못했을 가능성");
} else {
console.log(" ❓ 예상치 못한 URL");
}
console.log("\n5️⃣ 콘솔 로그 분석:");
const dashboardLogs = allLogs.filter(l => l.includes("[Dashboard]"));
if (dashboardLogs.length > 0) {
console.log(" Dashboard 로그:");
dashboardLogs.forEach(l => console.log(" - " + l));
} else {
console.log(" ⚠️ Dashboard 로그 없음 (페이지가 로드되지 않음?)");
}
await p.screenshot({ path: "./precision-test-result.png", fullPage: true });
} catch (e) {
console.error("Error:", e.message);
}
await b.close();
})();