feat: R27-2 R27-5 优化企微入口与 Portal 体验
这个提交包含在:
@@ -2,20 +2,29 @@ import { expect, test } from "@playwright/test";
|
||||
|
||||
import { EMPLOYEE, login } from "./helpers/auth";
|
||||
|
||||
test("E2E 企微入口:登录页展示入口并保留账号密码回退", async ({ page }) => {
|
||||
function mockWecomConfigPayload() {
|
||||
return {
|
||||
enabled: true,
|
||||
entryEnabled: true,
|
||||
oauthEnabled: true,
|
||||
corpId: "wx-test-corp",
|
||||
agentId: "1000001",
|
||||
loginUrl: "/api/auth/wecom/login?returnTo=%2Fportal",
|
||||
bindEnabled: true,
|
||||
defaultReturnTo: "/portal",
|
||||
status: "ready",
|
||||
statusReasons: [],
|
||||
};
|
||||
}
|
||||
|
||||
test("E2E 企微入口:普通浏览器下企微按钮为次级入口", async ({ 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: {
|
||||
enabled: true,
|
||||
corpId: "wx-test-corp",
|
||||
agentId: "1000001",
|
||||
oauthEnabled: true,
|
||||
loginUrl: "/api/auth/wecom/login?returnTo=%2Fportal",
|
||||
},
|
||||
data: mockWecomConfigPayload(),
|
||||
}),
|
||||
});
|
||||
});
|
||||
@@ -28,13 +37,46 @@ test("E2E 企微入口:登录页展示入口并保留账号密码回退", asyn
|
||||
});
|
||||
|
||||
await page.goto("/login");
|
||||
await expect(page.getByRole("button", { name: "使用企业微信进入工作台" })).toBeVisible();
|
||||
await expect(page.getByTestId("login-password-primary-panel")).toBeVisible();
|
||||
await expect(page.getByTestId("wecom-entry-secondary")).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "使用企业微信进入工作台" }).click();
|
||||
await page.getByTestId("wecom-entry-secondary").click();
|
||||
await expect(page).toHaveURL(/\/api\/auth\/wecom\/login\?returnTo=/);
|
||||
|
||||
await login(page, EMPLOYEE);
|
||||
await page.goto("/settings/profile");
|
||||
await expect(page.getByText("企业微信绑定")).toBeVisible();
|
||||
await expect(page.getByText(/接入状态:/)).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "企业微信绑定" })).toBeVisible();
|
||||
await expect(page.getByText("接入状态", { exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test("E2E 企微入口:企业微信场景优先显示企微 CTA,并展示未绑定提示", async ({ page }) => {
|
||||
await page.addInitScript(() => {
|
||||
Object.defineProperty(window.navigator, "userAgent", {
|
||||
configurable: true,
|
||||
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 page.route("**/api/auth/wecom/login?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "text/plain",
|
||||
body: "mock wecom login entry",
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto("/login?redirect=%2Fportal&wecom=unbound");
|
||||
await expect(page.getByTestId("login-wecom-primary-panel")).toBeVisible();
|
||||
await expect(page.getByTestId("wecom-entry-primary")).toBeVisible();
|
||||
await expect(page.getByTestId("login-wecom-notice")).toContainText("当前企业微信账号尚未绑定");
|
||||
await expect(page.getByTestId("login-password-secondary-panel")).toBeVisible();
|
||||
});
|
||||
|
||||
在新工单中引用
屏蔽一个用户