forked from baron/baron-sso
profile mock 추가
This commit is contained in:
@@ -19,6 +19,18 @@ test.describe("Authentication", () => {
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
// Default mock for user profile
|
||||
await page.route("**/api/v1/user/me", async (route) => {
|
||||
await route.fulfill({
|
||||
json: {
|
||||
id: "admin-user",
|
||||
name: "Admin User",
|
||||
email: "admin@example.com",
|
||||
role: "super_admin",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test("should redirect unauthorized users to login page", async ({ page }) => {
|
||||
@@ -74,13 +86,17 @@ test.describe("Authentication", () => {
|
||||
});
|
||||
|
||||
await page.goto("/");
|
||||
await expect(page.locator("aside")).toBeVisible();
|
||||
|
||||
// Wait for the auth loading to finish
|
||||
await expect(page.locator(".animate-spin")).not.toBeVisible();
|
||||
|
||||
// Mock window.confirm
|
||||
page.on("dialog", (dialog) => dialog.accept());
|
||||
|
||||
// Click logout button (label: ui.admin.nav.logout)
|
||||
await page.click('button:has-text("Logout"), button:has-text("로그아웃")');
|
||||
// Click logout button in the sidebar (use nav container to be specific)
|
||||
await page.click(
|
||||
'nav button:has-text("Logout"), nav button:has-text("로그아웃")',
|
||||
);
|
||||
|
||||
await expect(page).toHaveURL(/\/login/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user