文件
hyb-oa/client/tests/e2e/wecom-entry.spec.ts
T

41 行
1.3 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { EMPLOYEE, login } from "./helpers/auth";
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",
},
}),
});
});
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");
await expect(page.getByRole("button", { name: "使用企业微信进入工作台" })).toBeVisible();
await page.getByRole("button", { name: "使用企业微信进入工作台" }).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();
});