mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 15:14:31 +00:00
perf(test): speed up screenshot normalization e2e fixture
This commit is contained in:
@@ -1,14 +1,17 @@
|
|||||||
import crypto from "node:crypto";
|
|
||||||
import sharp from "sharp";
|
import sharp from "sharp";
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { normalizeBrowserScreenshot } from "./screenshot.js";
|
import { normalizeBrowserScreenshot } from "./screenshot.js";
|
||||||
|
|
||||||
describe("browser screenshot normalization", () => {
|
describe("browser screenshot normalization", () => {
|
||||||
it("shrinks oversized images to <=2000x2000 and <=5MB", async () => {
|
it("shrinks oversized images to <=2000x2000 and <=5MB", async () => {
|
||||||
const width = 2300;
|
const bigPng = await sharp({
|
||||||
const height = 2300;
|
create: {
|
||||||
const raw = crypto.randomBytes(width * height * 3);
|
width: 2100,
|
||||||
const bigPng = await sharp(raw, { raw: { width, height, channels: 3 } })
|
height: 2100,
|
||||||
|
channels: 3,
|
||||||
|
background: { r: 12, g: 34, b: 56 },
|
||||||
|
},
|
||||||
|
})
|
||||||
.png({ compressionLevel: 0 })
|
.png({ compressionLevel: 0 })
|
||||||
.toBuffer();
|
.toBuffer();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user