oa-email-code-login 实现邮箱验证码登录
这个提交包含在:
@@ -350,6 +350,53 @@ test("登录页提供找回密码、密码显隐,PWA 更新不会清空正在
|
||||
await expect(page).toHaveURL(/\/forgot-password$/);
|
||||
});
|
||||
|
||||
test("邮箱验证码登录可发送验证码并进入工作台", async ({ page }) => {
|
||||
const codeRequests: unknown[] = [];
|
||||
const verifyPayloads: unknown[] = [];
|
||||
|
||||
await mockGuestAuthChrome(page);
|
||||
await mockMe(page, ["employee"], "Employee");
|
||||
|
||||
await page.route("**/api/auth/email-login/code", async (route) => {
|
||||
codeRequests.push(route.request().postDataJSON());
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(envelope({})),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/auth/email-login/verify", async (route) => {
|
||||
verifyPayloads.push(route.request().postDataJSON());
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(envelope({
|
||||
accessToken: "email-code-access-token",
|
||||
expiresIn: 900,
|
||||
mustChangePassword: false,
|
||||
})),
|
||||
headers: {
|
||||
"set-cookie": "has_session=1; Path=/; SameSite=Strict",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto("/login?redirect=%2Fportal");
|
||||
await page.getByTestId("login-mode-email-code").click();
|
||||
await expect(page.getByTestId("login-email-code-panel")).toBeVisible();
|
||||
|
||||
await page.getByTestId("login-email-code-email").fill("[email protected]");
|
||||
await page.getByTestId("login-email-code-request").click();
|
||||
await expect(page.getByTestId("login-email-code-message")).toContainText("如账号可用");
|
||||
expect(codeRequests).toEqual([{ email: "[email protected]" }]);
|
||||
|
||||
await page.getByTestId("login-email-code").fill("654321");
|
||||
await page.getByTestId("login-email-code-submit").click();
|
||||
await expect(page).toHaveURL(/\/portal$/);
|
||||
expect(verifyPayloads).toEqual([{ email: "[email protected]", code: "654321" }]);
|
||||
});
|
||||
|
||||
test("找回密码流程使用邮箱验证码重置新密码", async ({ page }) => {
|
||||
const requestedEmails: string[] = [];
|
||||
const resetPayloads: unknown[] = [];
|
||||
|
||||
在新工单中引用
屏蔽一个用户