Files
clawhub/convex/skillPresentationImageNode.test.ts
Patrick Erichsen fd610627e0 feat: ingest and render skill presentation metadata (#3261)
* feat: ingest skill presentation metadata

* feat: render skill icons and clean titles

* feat: add skill presentation backfill

* fix: preserve hosted icons during backfill

* docs: clarify backfill icon ownership

* fix: track skill presentation provenance
2026-07-24 18:36:28 -05:00

32 lines
966 B
TypeScript

import { describe, expect, it } from "vitest";
import { validateRasterInternal } from "./skillPresentationImageNode";
type WrappedHandler = {
_handler: (
ctx: unknown,
args: { bytes: ArrayBuffer; contentType: "image/png" },
) => Promise<boolean>;
};
const validateRaster = (validateRasterInternal as unknown as WrappedHandler)._handler;
const png = Uint8Array.from(
Buffer.from(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=",
"base64",
),
);
describe("validateRasterInternal", () => {
it("fully decodes valid raster bytes and rejects truncated images", async () => {
await expect(
validateRaster({}, { bytes: new Uint8Array(png).buffer, contentType: "image/png" }),
).resolves.toBe(true);
await expect(
validateRaster(
{},
{ bytes: new Uint8Array(png.slice(0, 40)).buffer, contentType: "image/png" },
),
).resolves.toBe(false);
});
});