R28-1 R28-4: 收口网页门禁与公网 smoke
这个提交包含在:
@@ -0,0 +1,67 @@
|
||||
import { expect, type Page } from "@playwright/test";
|
||||
|
||||
export type WecomEntryConfig = {
|
||||
enabled: boolean;
|
||||
entryEnabled: boolean;
|
||||
oauthEnabled: boolean;
|
||||
corpId: string;
|
||||
agentId: string;
|
||||
loginUrl: string | null;
|
||||
bindEnabled: boolean;
|
||||
defaultReturnTo: string;
|
||||
status: string;
|
||||
statusReasons: string[];
|
||||
};
|
||||
|
||||
type Envelope<T> = {
|
||||
data: T;
|
||||
error?: {
|
||||
code?: string;
|
||||
message?: string;
|
||||
};
|
||||
};
|
||||
|
||||
export async function assertPortalLoaded(page: Page) {
|
||||
await expect(page).toHaveURL(/\/portal/);
|
||||
await expect(page.getByRole("heading", { name: "Portal" })).toBeVisible();
|
||||
await expect(page.getByRole("link", { name: "Portal" }).first()).toBeVisible();
|
||||
}
|
||||
|
||||
export async function assertMainNavVisible(page: Page) {
|
||||
await expect(page.getByRole("link", { name: "Portal" }).first()).toBeVisible();
|
||||
await expect(page.getByRole("link", { name: "团队" }).first()).toBeVisible();
|
||||
await expect(page.getByRole("link", { name: "项目" }).first()).toBeVisible();
|
||||
}
|
||||
|
||||
export async function assertBackupModulesCollapsed(page: Page) {
|
||||
const summary = page.locator("summary").filter({ hasText: "备用模块" }).first();
|
||||
await expect(summary).toBeVisible();
|
||||
const details = summary.locator("xpath=ancestor::details[1]");
|
||||
const isOpen = await details.evaluate((node) => (node as HTMLDetailsElement).open);
|
||||
expect(isOpen).toBe(false);
|
||||
await expect(page.getByRole("link", { name: "采购申请" })).not.toBeVisible();
|
||||
}
|
||||
|
||||
export async function assertWecomBindingCardVisible(page: Page) {
|
||||
await expect(page.getByRole("heading", { name: "企业微信绑定" })).toBeVisible();
|
||||
await expect(page.getByText("接入状态", { exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
export async function fetchWecomConfig(page: Page) {
|
||||
const response = await page.request.get("/api/auth/wecom/config");
|
||||
const text = await response.text();
|
||||
let parsed: Envelope<WecomEntryConfig> | null = null;
|
||||
|
||||
try {
|
||||
parsed = text ? JSON.parse(text) as Envelope<WecomEntryConfig> : null;
|
||||
} catch {
|
||||
parsed = null;
|
||||
}
|
||||
|
||||
return {
|
||||
status: response.status(),
|
||||
ok: response.ok(),
|
||||
body: text,
|
||||
data: parsed?.data ?? null,
|
||||
};
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户