@@ -5,22 +5,6 @@ import { describe, expect, it } from "vitest";
|
5 | 5 | import { normalizeBrowserScreenshot } from "./screenshot.js"; |
6 | 6 | |
7 | 7 | describe("browser screenshot normalization", () => { |
8 | | -const unavailableImageBackend = process.platform === "win32" ? "sips" : "windows-native"; |
9 | | - |
10 | | -async function withUnavailableImageBackend<T>(fn: () => Promise<T>): Promise<T> { |
11 | | -const previousBackend = process.env.OPENCLAW_IMAGE_BACKEND; |
12 | | -process.env.OPENCLAW_IMAGE_BACKEND = unavailableImageBackend; |
13 | | -try { |
14 | | -return await fn(); |
15 | | -} finally { |
16 | | -if (previousBackend === undefined) { |
17 | | -delete process.env.OPENCLAW_IMAGE_BACKEND; |
18 | | -} else { |
19 | | -process.env.OPENCLAW_IMAGE_BACKEND = previousBackend; |
20 | | -} |
21 | | -} |
22 | | -} |
23 | | - |
24 | 8 | it("shrinks oversized images to <=2000x2000 and <=5MB", async () => { |
25 | 9 | const bigPng = createSolidPngBuffer(2100, 2100, { r: 12, g: 34, b: 56 }); |
26 | 10 | |
@@ -47,18 +31,4 @@ describe("browser screenshot normalization", () => {
|
47 | 31 | |
48 | 32 | expect(normalized.buffer.equals(jpeg)).toBe(true); |
49 | 33 | }); |
50 | | - |
51 | | -it("rejects screenshots above max side when no image processor is available", async () => { |
52 | | -const png = createSolidPngBuffer(420, 120, { r: 12, g: 34, b: 56 }); |
53 | | -expect(png.byteLength).toBeLessThan(5 * 1024 * 1024); |
54 | | - |
55 | | -await withUnavailableImageBackend(async () => { |
56 | | -await expect( |
57 | | -normalizeBrowserScreenshot(png, { |
58 | | -maxSide: 120, |
59 | | -maxBytes: 5 * 1024 * 1024, |
60 | | -}), |
61 | | -).rejects.toThrow(/image processor unavailable/i); |
62 | | -}); |
63 | | -}); |
64 | 34 | }); |