增加企微旧包刷新护栏(07-27-yang-jun-reimbursement-readiness)
这个提交包含在:
@@ -551,6 +551,89 @@ test("Portal 管理视角按角色分发待处理和团队卡点", async ({ page
|
||||
await expect(page.getByText("试点观测摘要")).not.toBeVisible();
|
||||
});
|
||||
|
||||
async function prepareEmployeePortal(page: import("@playwright/test").Page) {
|
||||
await mockPasswordLogin(page);
|
||||
await mockNavigation(page, "employee");
|
||||
await mockPortalHome(page, "employee");
|
||||
await mockAttendanceToday(page);
|
||||
await mockNotificationList(page);
|
||||
await mockMe(page, ["employee"], "陈工程");
|
||||
await login(page, EMPLOYEE);
|
||||
}
|
||||
|
||||
async function triggerVisibleBuildCheck(page: import("@playwright/test").Page, clientBuildSha: string) {
|
||||
const readyRequest = page.waitForRequest((request) => new URL(request.url()).pathname === "/ready");
|
||||
await page.evaluate((buildSha) => {
|
||||
document.documentElement.dataset.buildSha = buildSha;
|
||||
document.dispatchEvent(new Event("visibilitychange"));
|
||||
}, clientBuildSha);
|
||||
await readyRequest;
|
||||
}
|
||||
|
||||
test("已登录页面回到前台时发现旧构建并提示用户刷新", async ({ page }) => {
|
||||
let readyChecks = 0;
|
||||
await page.route("**/ready", async (route) => {
|
||||
readyChecks += 1;
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(envelope({ ok: true, buildSha: "222222222222" })),
|
||||
});
|
||||
});
|
||||
await prepareEmployeePortal(page);
|
||||
await page.setViewportSize({ width: 375, height: 667 });
|
||||
await page.goto("/mobile");
|
||||
await expect(page.getByTestId("mobile-today-focus")).toBeVisible();
|
||||
|
||||
await triggerVisibleBuildCheck(page, "111111111111");
|
||||
|
||||
const notice = page.getByTestId("app-pwa-update-notice");
|
||||
await expect(notice).toBeVisible();
|
||||
await expect(notice).toContainText("发现新版本");
|
||||
const refreshButton = notice.getByRole("button", { name: "点击刷新" });
|
||||
await expect(refreshButton).toBeVisible();
|
||||
await page.evaluate(() => document.dispatchEvent(new Event("visibilitychange")));
|
||||
await expect.poll(() => readyChecks).toBe(1);
|
||||
const refreshButtonBox = await refreshButton.boundingBox();
|
||||
expect(refreshButtonBox?.height ?? 0).toBeGreaterThanOrEqual(44);
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth)).toBeLessThanOrEqual(2);
|
||||
|
||||
await page.setViewportSize({ width: 667, height: 375 });
|
||||
await expect(notice).toBeVisible();
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth)).toBeLessThanOrEqual(2);
|
||||
await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: "domcontentloaded" }),
|
||||
refreshButton.click(),
|
||||
]);
|
||||
await expect(page).toHaveURL(/\/mobile$/);
|
||||
});
|
||||
|
||||
test("已登录页面回到前台时构建一致保持静默", async ({ page }) => {
|
||||
await page.route("**/ready", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(envelope({ ok: true, buildSha: "333333333333" })),
|
||||
});
|
||||
});
|
||||
await prepareEmployeePortal(page);
|
||||
|
||||
await triggerVisibleBuildCheck(page, "333333333333");
|
||||
|
||||
await expect(page.getByTestId("app-pwa-update-notice")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("已登录页面回到前台时版本检查失败保持静默", async ({ page }) => {
|
||||
await page.route("**/ready", async (route) => {
|
||||
await route.fulfill({ status: 503, contentType: "application/json", body: "{}" });
|
||||
});
|
||||
await prepareEmployeePortal(page);
|
||||
|
||||
await triggerVisibleBuildCheck(page, "444444444444");
|
||||
|
||||
await expect(page.getByTestId("app-pwa-update-notice")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("Portal 新员工只显示轻量欢迎入口,不再显示快速上手清单", async ({ page }) => {
|
||||
await page.addInitScript(() => {
|
||||
window.localStorage.setItem("hyb_oa_show_welcome", "1");
|
||||
|
||||
在新工单中引用
屏蔽一个用户