修复认证验证码投递与登录入口体验 05-27-oa-auth-delivery-wecom-entry-fix
这个提交包含在:
@@ -15,8 +15,30 @@ function envelope(data: unknown) {
|
||||
};
|
||||
}
|
||||
|
||||
function mockPasswordLogin(page: import("@playwright/test").Page) {
|
||||
function authCapabilitiesPayload(emailReady = true) {
|
||||
return {
|
||||
emailDelivery: {
|
||||
ready: emailReady,
|
||||
statusReasons: emailReady ? [] : ["email_disabled"],
|
||||
},
|
||||
emailLoginCode: {
|
||||
enabled: emailReady,
|
||||
},
|
||||
passwordReset: {
|
||||
enabled: emailReady,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function mockPasswordLogin(page: import("@playwright/test").Page, emailReady = true) {
|
||||
return Promise.all([
|
||||
page.route("**/api/auth/capabilities", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(envelope(authCapabilitiesPayload(emailReady))),
|
||||
});
|
||||
}),
|
||||
page.route("**/api/auth/sso/providers", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
@@ -66,8 +88,15 @@ function mockPasswordLogin(page: import("@playwright/test").Page) {
|
||||
]);
|
||||
}
|
||||
|
||||
async function mockGuestAuthChrome(page: import("@playwright/test").Page) {
|
||||
async function mockGuestAuthChrome(page: import("@playwright/test").Page, emailReady = true) {
|
||||
await Promise.all([
|
||||
page.route("**/api/auth/capabilities", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(envelope(authCapabilitiesPayload(emailReady))),
|
||||
});
|
||||
}),
|
||||
page.route("**/api/auth/sso/providers", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
@@ -397,10 +426,33 @@ test("邮箱验证码登录可发送验证码并进入工作台", async ({ page
|
||||
expect(verifyPayloads).toEqual([{ email: "[email protected]", code: "654321" }]);
|
||||
});
|
||||
|
||||
test("邮件服务不可用时登录和找回密码禁用验证码发送", async ({ page }) => {
|
||||
await mockGuestAuthChrome(page, false);
|
||||
|
||||
await page.goto("/login");
|
||||
await page.getByTestId("login-mode-email-code").click();
|
||||
await expect(page.getByTestId("login-email-delivery-status")).toContainText("邮件验证码暂不可用");
|
||||
await page.getByTestId("login-email-code-email").fill("[email protected]");
|
||||
await expect(page.getByTestId("login-email-code-request")).toBeDisabled();
|
||||
|
||||
await page.goto("/forgot-password");
|
||||
await expect(page.getByTestId("forgot-password-email-delivery-status")).toContainText("邮件验证码暂不可用");
|
||||
await page.getByTestId("forgot-password-email").fill("[email protected]");
|
||||
await expect(page.getByTestId("forgot-password-request-code")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("找回密码流程使用邮箱验证码重置新密码", async ({ page }) => {
|
||||
const requestedEmails: string[] = [];
|
||||
const resetPayloads: unknown[] = [];
|
||||
|
||||
await page.route("**/api/auth/capabilities", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(envelope(authCapabilitiesPayload())),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/auth/forgot-password", async (route) => {
|
||||
const payload = route.request().postDataJSON() as { email?: string };
|
||||
requestedEmails.push(String(payload.email ?? ""));
|
||||
@@ -473,10 +525,10 @@ test("Portal 员工视角优先显示今日动作顺序", async ({ page }) => {
|
||||
|
||||
await expect(page.locator("summary").filter({ hasText: "我的申请与资产 / 继续工作" })).toBeVisible();
|
||||
await expect(page.getByRole("tab", { name: "公告" })).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "快捷操作栏" })).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "团队全员状态" })).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "今日待办聚合" })).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "近期动态流" })).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "常用" })).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "团队状态" })).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "待处理" })).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "通知" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("Portal 管理视角重排正确,备用模块默认折叠", async ({ page }) => {
|
||||
@@ -501,7 +553,7 @@ test("Portal 管理视角重排正确,备用模块默认折叠", async ({ page
|
||||
"portal-card-weekly_help",
|
||||
]);
|
||||
|
||||
await expect(page.locator("summary").filter({ hasText: "角色重点 / 常用入口" })).toBeVisible();
|
||||
await expect(page.locator("summary").filter({ hasText: "角色重点" })).toBeVisible();
|
||||
await expect(page.getByText("试点观测摘要")).toBeVisible();
|
||||
await expect(page.getByRole("link", { name: "采购申请" })).not.toBeVisible();
|
||||
await page.locator("summary").filter({ hasText: "备用模块" }).click();
|
||||
@@ -594,7 +646,7 @@ test("Portal 域管理角色也进入经理视图", async ({ page }) => {
|
||||
|
||||
await login(page, EMPLOYEE);
|
||||
|
||||
await expect(page.locator("summary").filter({ hasText: "角色重点 / 常用入口" })).toBeVisible();
|
||||
await expect(page.locator("summary").filter({ hasText: "角色重点" })).toBeVisible();
|
||||
await expect(page.locator('[aria-label="portal-card-pending_approvals"]')).toBeVisible();
|
||||
await expect(page.locator('[aria-label="portal-card-team_presence"]')).toBeVisible();
|
||||
});
|
||||
|
||||
@@ -15,31 +15,52 @@ function mockWecomConfigPayload() {
|
||||
};
|
||||
}
|
||||
|
||||
test("E2E 企微入口:普通浏览器下企微按钮为次级入口", async ({ page }) => {
|
||||
function envelope(data: unknown) {
|
||||
return {
|
||||
requestId: "mock-request",
|
||||
data,
|
||||
};
|
||||
}
|
||||
|
||||
async function mockAuthBase(page: import("@playwright/test").Page) {
|
||||
await page.route("**/api/auth/capabilities", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(envelope({
|
||||
emailDelivery: { ready: true, statusReasons: [] },
|
||||
emailLoginCode: { enabled: true },
|
||||
passwordReset: { enabled: true },
|
||||
})),
|
||||
});
|
||||
});
|
||||
await page.route("**/api/auth/sso/providers", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(envelope([])),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function mockWecomConfig(page: import("@playwright/test").Page) {
|
||||
await page.route("**/api/auth/wecom/config", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
requestId: "mock-wecom-config",
|
||||
data: mockWecomConfigPayload(),
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.route("**/api/auth/wecom/login?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "text/plain",
|
||||
body: "mock wecom login entry",
|
||||
body: JSON.stringify(envelope(mockWecomConfigPayload())),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
test("E2E 企微入口:普通浏览器下只提示企业微信工作台打开", async ({ page }) => {
|
||||
await mockAuthBase(page);
|
||||
await mockWecomConfig(page);
|
||||
|
||||
await page.goto("/login");
|
||||
await expect(page.getByTestId("login-password-primary-panel")).toBeVisible();
|
||||
await expect(page.getByTestId("wecom-entry-secondary")).toBeVisible();
|
||||
|
||||
await page.getByTestId("wecom-entry-secondary").click();
|
||||
await expect(page).toHaveURL(/\/api\/auth\/wecom\/login\?returnTo=/);
|
||||
await expect(page.getByTestId("wecom-entry-browser-notice")).toContainText("请从企业微信工作台打开 OA");
|
||||
await expect(page.getByTestId("wecom-entry-secondary")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("E2E 企微入口:企业微信场景优先显示企微 CTA,并展示未绑定提示", async ({ page }) => {
|
||||
@@ -49,16 +70,8 @@ test("E2E 企微入口:企业微信场景优先显示企微 CTA,并展示未
|
||||
value: "Mozilla/5.0 wxwork/4.1.20 MicroMessenger/7.0.1",
|
||||
});
|
||||
});
|
||||
await page.route("**/api/auth/wecom/config", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
requestId: "mock-wecom-config",
|
||||
data: mockWecomConfigPayload(),
|
||||
}),
|
||||
});
|
||||
});
|
||||
await mockAuthBase(page);
|
||||
await mockWecomConfig(page);
|
||||
await page.route("**/api/auth/wecom/login?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
|
||||
在新工单中引用
屏蔽一个用户