R28-1 R28-4: 收口网页门禁与公网 smoke
这个提交包含在:
@@ -0,0 +1,145 @@
|
||||
import { expect, test, type Page, type TestInfo } from "@playwright/test";
|
||||
|
||||
import { getExpectedWecomStatus, loginLiveUser, logoutLiveUser } from "./helpers/liveAuth";
|
||||
import { openProfileSettings } from "./helpers/navigation";
|
||||
import {
|
||||
assertBackupModulesCollapsed,
|
||||
assertMainNavVisible,
|
||||
assertPortalLoaded,
|
||||
assertWecomBindingCardVisible,
|
||||
fetchWecomConfig,
|
||||
} from "./helpers/smokeAssertions";
|
||||
|
||||
async function attachDebugArtifacts(page: Page, testInfo: TestInfo, consoleMessages: string[]) {
|
||||
await testInfo.attach("current-url.txt", {
|
||||
body: Buffer.from(page.url() || "about:blank"),
|
||||
contentType: "text/plain",
|
||||
});
|
||||
|
||||
await testInfo.attach("console.log", {
|
||||
body: Buffer.from(consoleMessages.join("\n") || "(no console output)"),
|
||||
contentType: "text/plain",
|
||||
});
|
||||
|
||||
try {
|
||||
const wecomConfig = await fetchWecomConfig(page);
|
||||
await testInfo.attach("wecom-config.json", {
|
||||
body: Buffer.from(JSON.stringify(wecomConfig, null, 2)),
|
||||
contentType: "application/json",
|
||||
});
|
||||
} catch (error) {
|
||||
await testInfo.attach("wecom-config-error.txt", {
|
||||
body: Buffer.from(String(error)),
|
||||
contentType: "text/plain",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
test.describe("live smoke", () => {
|
||||
test.skip(process.env.E2E_MODE !== "live", "仅在 live smoke 模式下执行");
|
||||
test.describe.configure({ mode: "serial" });
|
||||
|
||||
test("公网基础探活与企微配置状态", async ({ request, page }, testInfo) => {
|
||||
const consoleMessages: string[] = [];
|
||||
page.on("console", (message) => {
|
||||
consoleMessages.push(`[${message.type()}] ${message.text()}`);
|
||||
});
|
||||
|
||||
try {
|
||||
const readyResponse = await request.get("/ready");
|
||||
expect(readyResponse.ok()).toBeTruthy();
|
||||
|
||||
await page.goto("/login");
|
||||
await expect(page.getByTestId("login-identifier")).toBeVisible();
|
||||
|
||||
const wecomConfig = await fetchWecomConfig(page);
|
||||
expect(wecomConfig.status).toBe(200);
|
||||
expect(wecomConfig.data?.status).toBe(getExpectedWecomStatus());
|
||||
} finally {
|
||||
await attachDebugArtifacts(page, testInfo, consoleMessages);
|
||||
}
|
||||
});
|
||||
|
||||
test("管理员只读网页 smoke", async ({ page }, testInfo) => {
|
||||
const consoleMessages: string[] = [];
|
||||
page.on("console", (message) => {
|
||||
consoleMessages.push(`[${message.type()}] ${message.text()}`);
|
||||
});
|
||||
|
||||
let userName = "管理员";
|
||||
try {
|
||||
const admin = await loginLiveUser(page, "admin");
|
||||
userName = admin.name;
|
||||
|
||||
await assertPortalLoaded(page);
|
||||
await assertMainNavVisible(page);
|
||||
await assertBackupModulesCollapsed(page);
|
||||
|
||||
await page.goto("/team");
|
||||
await expect(page.getByRole("heading", { name: "团队状态", exact: true })).toBeVisible();
|
||||
|
||||
await page.goto("/projects");
|
||||
await expect(page.getByRole("heading", { name: "项目", exact: true })).toBeVisible();
|
||||
|
||||
await page.goto("/announcements");
|
||||
await expect(page.getByRole("heading", { name: "公告", exact: true })).toBeVisible();
|
||||
|
||||
await page.goto("/system/workspace");
|
||||
await expect(page.getByRole("heading", { name: "工作区设置", exact: true })).toBeVisible();
|
||||
|
||||
await page.goto("/system/feature-flags");
|
||||
await expect(page.getByRole("heading", { name: "功能开关", exact: true })).toBeVisible();
|
||||
|
||||
await page.goto("/audit-logs");
|
||||
await expect(page.getByRole("heading", { name: "审计工作台", exact: true })).toBeVisible();
|
||||
|
||||
await openProfileSettings(page, userName);
|
||||
await assertWecomBindingCardVisible(page);
|
||||
|
||||
await logoutLiveUser(page, { name: userName });
|
||||
} finally {
|
||||
await attachDebugArtifacts(page, testInfo, consoleMessages);
|
||||
}
|
||||
});
|
||||
|
||||
test("员工只读网页 smoke", async ({ page }, testInfo) => {
|
||||
const consoleMessages: string[] = [];
|
||||
page.on("console", (message) => {
|
||||
consoleMessages.push(`[${message.type()}] ${message.text()}`);
|
||||
});
|
||||
|
||||
let userName = "员工";
|
||||
try {
|
||||
const employee = await loginLiveUser(page, "employee");
|
||||
userName = employee.name;
|
||||
|
||||
await assertPortalLoaded(page);
|
||||
await assertMainNavVisible(page);
|
||||
|
||||
await page.goto("/team");
|
||||
await expect(page.getByRole("heading", { name: "团队状态", exact: true })).toBeVisible();
|
||||
|
||||
await page.goto("/projects");
|
||||
await expect(page.getByRole("heading", { name: "项目", exact: true })).toBeVisible();
|
||||
|
||||
await page.goto("/announcements");
|
||||
await expect(page.getByRole("heading", { name: "公告", exact: true })).toBeVisible();
|
||||
|
||||
await page.goto("/system/workspace");
|
||||
await expect(page.getByRole("heading", { name: "工作区设置", exact: true })).toBeVisible();
|
||||
|
||||
await page.goto("/system/feature-flags");
|
||||
await expect(page.getByRole("heading", { name: "功能开关", exact: true })).toBeVisible();
|
||||
|
||||
await page.goto("/audit-logs");
|
||||
await expect(page.getByRole("heading", { name: "审计工作台", exact: true })).toBeVisible();
|
||||
|
||||
await openProfileSettings(page, userName);
|
||||
await assertWecomBindingCardVisible(page);
|
||||
|
||||
await logoutLiveUser(page, { name: userName });
|
||||
} finally {
|
||||
await attachDebugArtifacts(page, testInfo, consoleMessages);
|
||||
}
|
||||
});
|
||||
});
|
||||
在新工单中引用
屏蔽一个用户