Skip to content

Commit a35ad20

Browse files
committed
test: shrink image sanitizer fixtures
1 parent 7d74c29 commit a35ad20

2 files changed

Lines changed: 13 additions & 17 deletions

File tree

src/agents/tool-images.test.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ describe("tool image sanitizing", () => {
1414
};
1515

1616
const createWidePng = async () => {
17-
const width = 2600;
18-
const height = 400;
17+
const width = 420;
18+
const height = 120;
1919
const raw = Buffer.alloc(width * height * 3, 0x7f);
2020
return sharp(raw, {
2121
raw: { width, height, channels: 3 },
@@ -25,9 +25,9 @@ describe("tool image sanitizing", () => {
2525
};
2626

2727
it("shrinks oversized images to the configured byte limit", async () => {
28-
const maxBytes = 128 * 1024;
29-
const width = 900;
30-
const height = 900;
28+
const maxBytes = 16 * 1024;
29+
const width = 300;
30+
const height = 300;
3131
const raw = Buffer.alloc(width * height * 3, 0xff);
3232
const bigPng = await sharp(raw, {
3333
raw: { width, height, channels: 3 },
@@ -57,12 +57,14 @@ describe("tool image sanitizing", () => {
5757
const images = [
5858
{ type: "image" as const, data: png.toString("base64"), mimeType: "image/png" },
5959
];
60-
const { images: out, dropped } = await sanitizeImageBlocks(images, "test");
60+
const { images: out, dropped } = await sanitizeImageBlocks(images, "test", {
61+
maxDimensionPx: 120,
62+
});
6163
expect(dropped).toBe(0);
6264
expect(out.length).toBe(1);
6365
const meta = await sharp(Buffer.from(out[0].data, "base64")).metadata();
64-
expect(meta.width).toBeLessThanOrEqual(1200);
65-
expect(meta.height).toBeLessThanOrEqual(1200);
66+
expect(meta.width).toBeLessThanOrEqual(120);
67+
expect(meta.height).toBeLessThanOrEqual(120);
6668
}, 20_000);
6769

6870
it("shrinks images that exceed max dimension even if size is small", async () => {
@@ -76,11 +78,11 @@ describe("tool image sanitizing", () => {
7678
},
7779
];
7880

79-
const out = await sanitizeContentBlocksImages(blocks, "test");
81+
const out = await sanitizeContentBlocksImages(blocks, "test", { maxDimensionPx: 120 });
8082
const image = getImageBlock(out);
8183
const meta = await sharp(Buffer.from(image.data, "base64")).metadata();
82-
expect(meta.width).toBeLessThanOrEqual(1200);
83-
expect(meta.height).toBeLessThanOrEqual(1200);
84+
expect(meta.width).toBeLessThanOrEqual(120);
85+
expect(meta.height).toBeLessThanOrEqual(120);
8486
expect(image.mimeType).toBe("image/jpeg");
8587
}, 20_000);
8688

src/plugins/bundle-commands.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ vi.mock("./config-state.js", () => ({
3333
}) => ({
3434
activated: params.config?.entries?.[params.id]?.enabled !== false,
3535
}),
36-
resolveEffectiveEnableState: (params: {
37-
config?: { entries?: Record<string, { enabled?: boolean }> };
38-
id: string;
39-
}) => ({
40-
enabled: params.config?.entries?.[params.id]?.enabled !== false,
41-
}),
4236
}));
4337

4438
const { loadEnabledClaudeBundleCommands } = await import("./bundle-commands.js");

0 commit comments

Comments
 (0)