Files
koc-loop/tests/result-screenshots.test.mjs

32 lines
946 B
JavaScript
Raw Normal View History

import assert from "node:assert/strict";
import test from "node:test";
import {
MAX_RESULT_SCREENSHOTS,
parseResultScreenshotKeys,
serializeResultScreenshotKeys,
} from "../lib/result-screenshots.ts";
test("keeps legacy task result screenshots readable", () => {
assert.deepEqual(
parseResultScreenshotKeys("task-results/dist-1/shot-1.png"),
["task-results/dist-1/shot-1.png"],
);
});
test("serializes multiple task screenshots safely and caps their count", () => {
const keys = Array.from(
{ length: MAX_RESULT_SCREENSHOTS + 3 },
(_, index) => `task-results/dist-1/shot-${index + 1}.png`,
);
const serialized = serializeResultScreenshotKeys([
...keys,
"content-assets/not-allowed.png",
]);
assert.equal(parseResultScreenshotKeys(serialized).length, MAX_RESULT_SCREENSHOTS);
assert.ok(
parseResultScreenshotKeys(serialized).every((key) =>
key.startsWith("task-results/"),
),
);
});