oa-login-password-recovery-ux 改进登录找回密码体验
这个提交包含在:
@@ -66,6 +66,36 @@ function mockPasswordLogin(page: import("@playwright/test").Page) {
|
||||
]);
|
||||
}
|
||||
|
||||
async function mockGuestAuthChrome(page: import("@playwright/test").Page) {
|
||||
await Promise.all([
|
||||
page.route("**/api/auth/sso/providers", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(envelope([])),
|
||||
});
|
||||
}),
|
||||
page.route("**/api/auth/wecom/config", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(envelope({
|
||||
enabled: false,
|
||||
entryEnabled: false,
|
||||
oauthEnabled: false,
|
||||
corpId: "",
|
||||
agentId: "",
|
||||
loginUrl: null,
|
||||
bindEnabled: false,
|
||||
defaultReturnTo: "/portal",
|
||||
status: "disabled",
|
||||
statusReasons: ["disabled"],
|
||||
})),
|
||||
});
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
function mockNotificationList(page: import("@playwright/test").Page) {
|
||||
return page.route((url) => {
|
||||
return url.pathname === "/api/notifications";
|
||||
@@ -283,6 +313,93 @@ function mockPortalHome(page: import("@playwright/test").Page, mode: "employee"
|
||||
});
|
||||
}
|
||||
|
||||
test("登录页提供找回密码、密码显隐,PWA 更新不会清空正在输入的内容", async ({ page }) => {
|
||||
await mockGuestAuthChrome(page);
|
||||
|
||||
await page.goto("/login");
|
||||
|
||||
await page.getByTestId("login-identifier").fill("[email protected]");
|
||||
await page.getByTestId("login-password").fill("PasswordA1234");
|
||||
|
||||
await expect(page.getByTestId("login-password")).toHaveAttribute("type", "password");
|
||||
await page.getByRole("button", { name: "显示密码" }).click();
|
||||
await expect(page.getByTestId("login-password")).toHaveAttribute("type", "text");
|
||||
await expect(page.getByTestId("login-identifier")).toHaveValue("[email protected]");
|
||||
await expect(page.getByTestId("login-password")).toHaveValue("PasswordA1234");
|
||||
|
||||
await page.evaluate(() => {
|
||||
window.dispatchEvent(new CustomEvent("hyb-oa:pwa-update-ready", {
|
||||
detail: {
|
||||
applyUpdate: () => {
|
||||
window.sessionStorage.setItem("pwa-update-applied", "1");
|
||||
},
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
||||
await expect(page.getByTestId("auth-pwa-update-notice")).toBeVisible();
|
||||
await expect(page.getByTestId("login-identifier")).toHaveValue("[email protected]");
|
||||
await expect(page.getByTestId("login-password")).toHaveValue("PasswordA1234");
|
||||
|
||||
await page.getByRole("button", { name: "稍后" }).click();
|
||||
await expect(page.getByTestId("auth-pwa-update-notice")).toBeHidden();
|
||||
await expect(page.getByTestId("login-identifier")).toHaveValue("[email protected]");
|
||||
await expect(page.getByTestId("login-password")).toHaveValue("PasswordA1234");
|
||||
|
||||
await page.getByRole("link", { name: "忘记密码?" }).click();
|
||||
await expect(page).toHaveURL(/\/forgot-password$/);
|
||||
});
|
||||
|
||||
test("找回密码流程使用邮箱验证码重置新密码", async ({ page }) => {
|
||||
const requestedEmails: string[] = [];
|
||||
const resetPayloads: unknown[] = [];
|
||||
|
||||
await page.route("**/api/auth/forgot-password", async (route) => {
|
||||
const payload = route.request().postDataJSON() as { email?: string };
|
||||
requestedEmails.push(String(payload.email ?? ""));
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(envelope({})),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/auth/reset-password", async (route) => {
|
||||
resetPayloads.push(route.request().postDataJSON());
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(envelope({})),
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto("/forgot-password");
|
||||
await page.getByTestId("forgot-password-email").fill("[email protected]");
|
||||
await page.getByTestId("forgot-password-request-code").click();
|
||||
|
||||
await expect(page.getByTestId("forgot-password-message")).toContainText("如账号可用");
|
||||
expect(requestedEmails).toEqual(["[email protected]"]);
|
||||
|
||||
await page.getByTestId("forgot-password-code").fill("123456");
|
||||
await page.getByTestId("forgot-password-new").fill("NewPassword1234");
|
||||
await page.getByTestId("forgot-password-confirm").fill("NewPassword1234");
|
||||
|
||||
await page.getByRole("button", { name: "显示密码" }).first().click();
|
||||
await expect(page.getByTestId("forgot-password-new")).toHaveAttribute("type", "text");
|
||||
await expect(page.getByTestId("forgot-password-new")).toHaveValue("NewPassword1234");
|
||||
|
||||
await page.getByTestId("forgot-password-submit").click();
|
||||
|
||||
await expect(page).toHaveURL(/\/login$/);
|
||||
expect(resetPayloads).toEqual([
|
||||
{
|
||||
email: "[email protected]",
|
||||
code: "123456",
|
||||
newPassword: "NewPassword1234",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test("Portal 员工视角优先显示今日动作顺序", async ({ page }) => {
|
||||
await mockPasswordLogin(page);
|
||||
await mockNavigation(page, "employee");
|
||||
|
||||
在新工单中引用
屏蔽一个用户