dist-mcp / mcp / sourceNotation.test.js
dist-mcp / mcp / sourceNotation.test.js
import assert from "node:assert/strict";
import test from "node:test";
import { assertNoAttachmentNotation, collectAttachmentTokens, UnsupportedAttachmentNotationError } from "./sourceNotation.js";
const bionicPreset = { name: "bionic", includeBase64Preview: false, writeHtmlReportForMultipleResults: true, scratchpadFolderRequired: true };
const unslothPreset = { name: "unsloth", includeBase64Preview: true, writeHtmlReportForMultipleResults: false, scratchpadFolderRequired: true };
test("rejects aN in canvas (string form)", () => {
assert.throws(() => assertNoAttachmentNotation({ canvas: "a1" }, bionicPreset), UnsupportedAttachmentNotationError);
});
test("rejects aN case-insensitively and the bare shorthand form", () => {
assert.throws(() => assertNoAttachmentNotation({ canvas: "A5" }, bionicPreset), UnsupportedAttachmentNotationError);
assert.throws(() => assertNoAttachmentNotation({ canvas: "a" }, bionicPreset), UnsupportedAttachmentNotationError);
});
test("rejects aN inside a canvas array", () => {
assert.throws(() => assertNoAttachmentNotation({ canvas: ["a2"] }, bionicPreset), UnsupportedAttachmentNotationError);
});
test("rejects aN inside a moodboard array", () => {
assert.throws(() => assertNoAttachmentNotation({ moodboard: ["v1", "a3"] }, bionicPreset), UnsupportedAttachmentNotationError);
});
test("rejects aN inside a comma/space-separated moodboard string", () => {
assert.throws(() => assertNoAttachmentNotation({ moodboard: "v1, a3" }, bionicPreset), UnsupportedAttachmentNotationError);
assert.throws(() => assertNoAttachmentNotation({ moodboard: "v1 a3" }, bionicPreset), UnsupportedAttachmentNotationError);
});
test("passes vN/pN/iN, filenames, and absolute paths through unchanged", () => {
assert.doesNotThrow(() => assertNoAttachmentNotation({ canvas: "v1" }, bionicPreset));
assert.doesNotThrow(() => assertNoAttachmentNotation({ canvas: "p2" }, bionicPreset));
assert.doesNotThrow(() => assertNoAttachmentNotation({ canvas: "i3" }, bionicPreset));
assert.doesNotThrow(() => assertNoAttachmentNotation({ canvas: "source.png" }, bionicPreset));
assert.doesNotThrow(() => assertNoAttachmentNotation({ canvas: "/abs/path/source.png" }, bionicPreset));
assert.doesNotThrow(() => assertNoAttachmentNotation({ moodboard: ["v1", "p2", "i3"] }, bionicPreset));
assert.doesNotThrow(() => assertNoAttachmentNotation({ moodboard: "v1, p2 i3" }, bionicPreset));
});
test("tolerates missing canvas/moodboard (crop/mask/zoom-in schemas have no moodboard field at all)", () => {
assert.doesNotThrow(() => assertNoAttachmentNotation({}, bionicPreset));
});
test("no-ops entirely for the unsloth preset", () => {
assert.doesNotThrow(() => assertNoAttachmentNotation({ canvas: "a1" }, unslothPreset));
assert.doesNotThrow(() => assertNoAttachmentNotation({ moodboard: ["a2", "aN"] }, unslothPreset));
});
test("collectAttachmentTokens gathers deduplicated aN-shaped tokens from canvas and moodboard", () => {
assert.deepEqual(collectAttachmentTokens({ canvas: "a1", moodboard: ["a2", "a1"] }), ["a1", "a2"]);
assert.deepEqual(collectAttachmentTokens({ moodboard: "a3, a4 a3" }), ["a3", "a4"]);
assert.deepEqual(collectAttachmentTokens({ canvas: "v1" }), []);
});
import assert from "node:assert/strict";
import test from "node:test";
import { assertNoAttachmentNotation, collectAttachmentTokens, UnsupportedAttachmentNotationError } from "./sourceNotation.js";
const bionicPreset = { name: "bionic", includeBase64Preview: false, writeHtmlReportForMultipleResults: true, scratchpadFolderRequired: true };
const unslothPreset = { name: "unsloth", includeBase64Preview: true, writeHtmlReportForMultipleResults: false, scratchpadFolderRequired: true };
test("rejects aN in canvas (string form)", () => {
assert.throws(() => assertNoAttachmentNotation({ canvas: "a1" }, bionicPreset), UnsupportedAttachmentNotationError);
});
test("rejects aN case-insensitively and the bare shorthand form", () => {
assert.throws(() => assertNoAttachmentNotation({ canvas: "A5" }, bionicPreset), UnsupportedAttachmentNotationError);
assert.throws(() => assertNoAttachmentNotation({ canvas: "a" }, bionicPreset), UnsupportedAttachmentNotationError);
});
test("rejects aN inside a canvas array", () => {
assert.throws(() => assertNoAttachmentNotation({ canvas: ["a2"] }, bionicPreset), UnsupportedAttachmentNotationError);
});
test("rejects aN inside a moodboard array", () => {
assert.throws(() => assertNoAttachmentNotation({ moodboard: ["v1", "a3"] }, bionicPreset), UnsupportedAttachmentNotationError);
});
test("rejects aN inside a comma/space-separated moodboard string", () => {
assert.throws(() => assertNoAttachmentNotation({ moodboard: "v1, a3" }, bionicPreset), UnsupportedAttachmentNotationError);
assert.throws(() => assertNoAttachmentNotation({ moodboard: "v1 a3" }, bionicPreset), UnsupportedAttachmentNotationError);
});
test("passes vN/pN/iN, filenames, and absolute paths through unchanged", () => {
assert.doesNotThrow(() => assertNoAttachmentNotation({ canvas: "v1" }, bionicPreset));
assert.doesNotThrow(() => assertNoAttachmentNotation({ canvas: "p2" }, bionicPreset));
assert.doesNotThrow(() => assertNoAttachmentNotation({ canvas: "i3" }, bionicPreset));
assert.doesNotThrow(() => assertNoAttachmentNotation({ canvas: "source.png" }, bionicPreset));
assert.doesNotThrow(() => assertNoAttachmentNotation({ canvas: "/abs/path/source.png" }, bionicPreset));
assert.doesNotThrow(() => assertNoAttachmentNotation({ moodboard: ["v1", "p2", "i3"] }, bionicPreset));
assert.doesNotThrow(() => assertNoAttachmentNotation({ moodboard: "v1, p2 i3" }, bionicPreset));
});
test("tolerates missing canvas/moodboard (crop/mask/zoom-in schemas have no moodboard field at all)", () => {
assert.doesNotThrow(() => assertNoAttachmentNotation({}, bionicPreset));
});
test("no-ops entirely for the unsloth preset", () => {
assert.doesNotThrow(() => assertNoAttachmentNotation({ canvas: "a1" }, unslothPreset));
assert.doesNotThrow(() => assertNoAttachmentNotation({ moodboard: ["a2", "aN"] }, unslothPreset));
});
test("collectAttachmentTokens gathers deduplicated aN-shaped tokens from canvas and moodboard", () => {
assert.deepEqual(collectAttachmentTokens({ canvas: "a1", moodboard: ["a2", "a1"] }), ["a1", "a2"]);
assert.deepEqual(collectAttachmentTokens({ moodboard: "a3, a4 a3" }), ["a3", "a4"]);
assert.deepEqual(collectAttachmentTokens({ canvas: "v1" }), []);
});