mirror of
https://github.com/openclaw/clawhub.git
synced 2026-08-14 00:47:57 +00:00
* 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
32 lines
966 B
TypeScript
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);
|
|
});
|
|
});
|