mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-20 05:07:34 +00:00
test: tighten browser cdp screenshot assertions
This commit is contained in:
@@ -107,9 +107,7 @@ describe("CDP screenshot params", () => {
|
||||
await captureScreenshot({ wsUrl: "ws://localhost:9222/devtools/page/X", format: "png" });
|
||||
|
||||
const call = requireSentMessage("Page.captureScreenshot");
|
||||
expect(call.params).toMatchObject({
|
||||
format: "png",
|
||||
});
|
||||
expect(call.params?.format).toBe("png");
|
||||
expect(call.params).not.toHaveProperty("fromSurface");
|
||||
expect(call.params).not.toHaveProperty("captureBeyondViewport");
|
||||
expect(call.params).not.toHaveProperty("clip");
|
||||
@@ -152,27 +150,23 @@ describe("CDP screenshot params", () => {
|
||||
}
|
||||
|
||||
// Expand: uses saved DPR, mobile defaults to false
|
||||
expect(firstSetCall.params).toMatchObject({
|
||||
width: 1200,
|
||||
height: 3000,
|
||||
deviceScaleFactor: 2,
|
||||
mobile: false,
|
||||
});
|
||||
expect(firstSetCall.params?.width).toBe(1200);
|
||||
expect(firstSetCall.params?.height).toBe(3000);
|
||||
expect(firstSetCall.params?.deviceScaleFactor).toBe(2);
|
||||
expect(firstSetCall.params?.mobile).toBe(false);
|
||||
|
||||
// Clear is called first in the finally block
|
||||
requireSentMessage("Emulation.clearDeviceMetricsOverride");
|
||||
const captureCall = requireSentMessage("Page.captureScreenshot");
|
||||
expect(captureCall.params).toMatchObject({ captureBeyondViewport: true });
|
||||
expect(captureCall.params?.captureBeyondViewport).toBe(true);
|
||||
|
||||
// Viewport drifted after clear → re-apply saved dimensions
|
||||
expect(secondSetCall.params).toMatchObject({
|
||||
width: 800,
|
||||
height: 600,
|
||||
deviceScaleFactor: 2,
|
||||
mobile: false,
|
||||
screenWidth: 800,
|
||||
screenHeight: 600,
|
||||
});
|
||||
expect(secondSetCall.params?.width).toBe(800);
|
||||
expect(secondSetCall.params?.height).toBe(600);
|
||||
expect(secondSetCall.params?.deviceScaleFactor).toBe(2);
|
||||
expect(secondSetCall.params?.mobile).toBe(false);
|
||||
expect(secondSetCall.params?.screenWidth).toBe(800);
|
||||
expect(secondSetCall.params?.screenHeight).toBe(600);
|
||||
});
|
||||
|
||||
it("fullPage on non-emulated tab: clears and does NOT re-apply emulation", async () => {
|
||||
|
||||
Reference in New Issue
Block a user