mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 20:05:46 -06:00
perf(test): make update UI proof capture opt-in (#129057)
This commit is contained in:
committed by
GitHub
parent
0a04f23bc3
commit
bbae605946
@@ -10,6 +10,7 @@ const suite = createControlUiE2eSuite({
|
||||
unavailableMessage: (executablePath) => `Playwright Chromium is unavailable at ${executablePath}`,
|
||||
});
|
||||
|
||||
const captureUiProofEnabled = process.env.OPENCLAW_CAPTURE_UI_PROOF === "1";
|
||||
const NATIVE_UPDATE_DECLINED_EVENT = "openclaw:native-update-declined";
|
||||
const MANAGED_UPDATE_HANDOFF_RESPONSE = {
|
||||
ok: true,
|
||||
@@ -26,6 +27,17 @@ async function openUpdateConfirmation(page: Page): Promise<void> {
|
||||
await updateIssue.locator(".sidebar-update-card__action").click();
|
||||
}
|
||||
|
||||
async function captureUpdateProof(
|
||||
page: Page,
|
||||
artifactDir: string,
|
||||
fileName: string,
|
||||
): Promise<void> {
|
||||
if (!captureUiProofEnabled) {
|
||||
return;
|
||||
}
|
||||
await page.screenshot({ path: path.join(artifactDir, fileName) });
|
||||
}
|
||||
|
||||
suite.define(() => {
|
||||
it("explains a disabled update to a read-only mobile operator", async () => {
|
||||
const artifactDir = path.resolve(".artifacts/control-ui-e2e/update-read-only-mobile");
|
||||
@@ -35,7 +47,9 @@ suite.define(() => {
|
||||
hasTouch: true,
|
||||
isMobile: true,
|
||||
locale: "en-US",
|
||||
recordVideo: { dir: artifactDir, size: { height: 1200, width: 555 } },
|
||||
recordVideo: captureUiProofEnabled
|
||||
? { dir: artifactDir, size: { height: 1200, width: 555 } }
|
||||
: undefined,
|
||||
serviceWorkers: "block",
|
||||
viewport: { height: 1200, width: 555 },
|
||||
},
|
||||
@@ -65,7 +79,7 @@ suite.define(() => {
|
||||
expect(await action.evaluate((element) => (element as HTMLButtonElement).disabled)).toBe(
|
||||
false,
|
||||
);
|
||||
await page.screenshot({ path: path.join(artifactDir, "disabled-update.png") });
|
||||
await captureUpdateProof(page, artifactDir, "disabled-update.png");
|
||||
|
||||
const actionBounds = await action.boundingBox();
|
||||
if (!actionBounds) {
|
||||
@@ -86,7 +100,7 @@ suite.define(() => {
|
||||
await expect.poll(() => tooltip.getAttribute("data-e2e-after-show")).not.toBeNull();
|
||||
expect(await tooltip.textContent()).toContain("Administrator access is required");
|
||||
expect(await gateway.getRequests("update.run")).toHaveLength(0);
|
||||
await page.screenshot({ path: path.join(artifactDir, "disabled-update-tooltip.png") });
|
||||
await captureUpdateProof(page, artifactDir, "disabled-update-tooltip.png");
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -96,7 +110,9 @@ suite.define(() => {
|
||||
await suite.withPage(
|
||||
{
|
||||
locale: "en-US",
|
||||
recordVideo: { dir: artifactDir, size: { height: 720, width: 1280 } },
|
||||
recordVideo: captureUiProofEnabled
|
||||
? { dir: artifactDir, size: { height: 720, width: 1280 } }
|
||||
: undefined,
|
||||
serviceWorkers: "block",
|
||||
viewport: { height: 720, width: 1280 },
|
||||
},
|
||||
@@ -145,7 +161,7 @@ suite.define(() => {
|
||||
await updateIssue.locator(".sidebar-update-card__compact-reason").waitFor();
|
||||
expect(await page.locator(".sidebar-footer-update").count()).toBe(1);
|
||||
expect(pageErrors).toEqual([]);
|
||||
await page.screenshot({ path: path.join(artifactDir, "package-update-failure.png") });
|
||||
await captureUpdateProof(page, artifactDir, "package-update-failure.png");
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -155,7 +171,9 @@ suite.define(() => {
|
||||
await suite.withPage(
|
||||
{
|
||||
locale: "en-US",
|
||||
recordVideo: { dir: artifactDir, size: { height: 720, width: 1280 } },
|
||||
recordVideo: captureUiProofEnabled
|
||||
? { dir: artifactDir, size: { height: 720, width: 1280 } }
|
||||
: undefined,
|
||||
serviceWorkers: "block",
|
||||
viewport: { height: 720, width: 1280 },
|
||||
},
|
||||
@@ -203,7 +221,7 @@ suite.define(() => {
|
||||
.waitFor();
|
||||
expect(await page.locator(".sidebar-footer-update").count()).toBe(1);
|
||||
expect(pageErrors).toEqual([]);
|
||||
await page.screenshot({ path: path.join(artifactDir, "coalesced-restart-banner.png") });
|
||||
await captureUpdateProof(page, artifactDir, "coalesced-restart-banner.png");
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -232,7 +250,9 @@ suite.define(() => {
|
||||
await suite.withPage(
|
||||
{
|
||||
locale: "en-US",
|
||||
recordVideo: { dir: artifactDir, size: { height: 720, width: 1280 } },
|
||||
recordVideo: captureUiProofEnabled
|
||||
? { dir: artifactDir, size: { height: 720, width: 1280 } }
|
||||
: undefined,
|
||||
serviceWorkers: "block",
|
||||
viewport: { height: 720, width: 1280 },
|
||||
},
|
||||
@@ -293,9 +313,7 @@ suite.define(() => {
|
||||
expect(await gateway.getRequests("update.run")).toHaveLength(1);
|
||||
expect(await gateway.getRequests("update.status")).toHaveLength(expectedStatusRequests);
|
||||
expect(pageErrors).toEqual([]);
|
||||
await page.screenshot({
|
||||
path: path.join(artifactDir, `managed-handoff-${artifactName}.png`),
|
||||
});
|
||||
await captureUpdateProof(page, artifactDir, `managed-handoff-${artifactName}.png`);
|
||||
},
|
||||
);
|
||||
},
|
||||
@@ -367,7 +385,7 @@ suite.define(() => {
|
||||
);
|
||||
await expect.poll(async () => (await gateway.getRequests("update.run")).length).toBe(1);
|
||||
expect(pageErrors).toEqual([]);
|
||||
await page.screenshot({ path: path.join(artifactDir, "gateway-update-target.png") });
|
||||
await captureUpdateProof(page, artifactDir, "gateway-update-target.png");
|
||||
} finally {
|
||||
await context.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user