fix(auth): align restricted header and logout state
This commit is contained in:
@@ -17,6 +17,7 @@ test("已登录管理员可以打开审计日志页面", async ({ page }) => {
|
||||
});
|
||||
|
||||
test("已认证但未授权的账号会看到明确说明", async ({ page }) => {
|
||||
await page.addInitScript(() => window.localStorage.clear());
|
||||
await page.route("**/api/v1/access-context", (route) =>
|
||||
route.fulfill({
|
||||
status: 403,
|
||||
@@ -31,12 +32,44 @@ test("已认证但未授权的账号会看到明确说明", async ({ page }) =>
|
||||
await expect(
|
||||
page.getByText("身份认证已成功,但当前账号尚未由系统管理员启用"),
|
||||
).toBeVisible();
|
||||
await expect(page.getByText("TJWater 智慧水务平台")).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "退出登录" })).toBeVisible();
|
||||
const accountMenu = page.getByRole("button", {
|
||||
name: "E2E 测试用户 账号菜单",
|
||||
});
|
||||
await expect(accountMenu).toBeVisible();
|
||||
await accountMenu.click();
|
||||
await expect(page.getByRole("menuitem", { name: "登出" })).toBeVisible();
|
||||
await expect(page.getByRole("menuitem", { name: "切换项目" })).toHaveCount(0);
|
||||
await page.keyboard.press("Escape");
|
||||
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await expect(page.getByText("账号尚未获得访问权限")).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "退出登录" })).toBeVisible();
|
||||
await expect(accountMenu).toBeVisible();
|
||||
});
|
||||
|
||||
test("无权访问项目时可以在窄屏切换项目", async ({ page }) => {
|
||||
await page.route("**/api/v1/access-context", (route) =>
|
||||
route.fulfill({
|
||||
status: 403,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ detail: "No access to project" }),
|
||||
}),
|
||||
);
|
||||
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await page.goto("/");
|
||||
|
||||
await expect(page.getByText("无权访问当前项目")).toBeVisible();
|
||||
await page
|
||||
.getByRole("button", { name: "E2E 测试用户 账号菜单" })
|
||||
.click();
|
||||
await page.getByRole("menuitem", { name: "切换项目" }).click();
|
||||
|
||||
const projectDialog = page.getByRole("dialog");
|
||||
await expect(projectDialog).toBeVisible();
|
||||
const bounds = await projectDialog.boundingBox();
|
||||
expect(bounds).not.toBeNull();
|
||||
expect(bounds!.x).toBeGreaterThanOrEqual(0);
|
||||
expect(bounds!.x + bounds!.width).toBeLessThanOrEqual(390);
|
||||
});
|
||||
|
||||
test("系统管理员可以手动同步 Keycloak 用户目录", async ({ page }) => {
|
||||
|
||||
Reference in New Issue
Block a user