perf(test): reduce repeated image work in web auto-reply e2e

This commit is contained in:
Peter Steinberger
2026-02-14 00:21:46 +00:00
parent 1c928e493d
commit 784e7c1fd5

View File

@@ -160,6 +160,10 @@ describe("web auto-reply", () => {
}, },
] as const; ] as const;
const width = 1200;
const height = 1200;
const sharedRaw = crypto.randomBytes(width * height * 3);
for (const fmt of formats) { for (const fmt of formats) {
// Force a small cap to ensure compression is exercised for every format. // Force a small cap to ensure compression is exercised for every format.
setLoadConfigMock(() => ({ agents: { defaults: { mediaMaxMb: 1 } } })); setLoadConfigMock(() => ({ agents: { defaults: { mediaMaxMb: 1 } } }));
@@ -181,10 +185,7 @@ describe("web auto-reply", () => {
return { close: vi.fn() }; return { close: vi.fn() };
}; };
const width = 1200; const big = await fmt.make(sharedRaw, { width, height });
const height = 1200;
const raw = crypto.randomBytes(width * height * 3);
const big = await fmt.make(raw, { width, height });
expect(big.length).toBeGreaterThan(1 * 1024 * 1024); expect(big.length).toBeGreaterThan(1 * 1024 * 1024);
const fetchMock = vi.spyOn(globalThis, "fetch").mockResolvedValue({ const fetchMock = vi.spyOn(globalThis, "fetch").mockResolvedValue({
@@ -244,8 +245,8 @@ describe("web auto-reply", () => {
const bigPng = await sharp({ const bigPng = await sharp({
create: { create: {
width: 2600, width: 1800,
height: 2600, height: 1800,
channels: 3, channels: 3,
background: { r: 0, g: 0, b: 255 }, background: { r: 0, g: 0, b: 255 },
}, },