Files
chatkit/test/check-file-inputs.test.js
CatoandClaude Opus 5.5 70824785e8 fix(check): comments are not inputs (0.4.1) (#11)
* ci(publish): a merged version bump releases itself

Publishing waited for someone to push a v* tag after the merge. That step
is easy to forget and impossible from an agent session (the git proxy
refuses tag pushes), so 0.4.0 sat merged and unpublished — exactly the
"fix merged, nobody has it" gap the release was meant to close.

publish.yml now also runs on pushes to main and on dispatch; the existing
registry check makes every merge that did not change the version a green
no-op. A release from main tags the commit v<version> itself, so versions
stay traceable. The auto-merge sweep re-arms publish.yml after a
GITHUB_TOKEN merge, which starts no push workflow on its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BWXjqiHm8jFta4FXuc7Tck

* fix(check): comments are not inputs; 0.4.1

The first run across the fleet flagged one line in loki — a comment
recording the old bug (`<input accept="image/*,text/*…">`). Comment lines,
block comments and trailing comments are skipped now. "/*" counts as a
comment only after space, "{" or "(", because inside an accept value it
follows a letter ("image/*") — a test pins that a trailing comment cannot
hide the real input before it.

0.4.0 was never published; this ships as 0.4.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BWXjqiHm8jFta4FXuc7Tck

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-07 04:52:55 -07:00

27 lines
1.2 KiB
JavaScript

// The fleet's file-input check: the one rule every app runs in CI.
import { test } from "node:test";
import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import { fileURLToPath } from "node:url";
const bin = fileURLToPath(new URL("../bin/chatkit-check-file-inputs.mjs", import.meta.url));
const fixtures = fileURLToPath(new URL("./fixtures/file-inputs/", import.meta.url));
const run = (dir) => spawnSync(process.execPath, [bin, dir], { encoding: "utf8" });
test("single-family inputs, ambiguous containers and justified exceptions pass", () => {
const r = run(`${fixtures}ok`);
assert.equal(r.status, 0, r.stderr);
assert.match(r.stdout, /none mixes file families/);
});
test("a mixed accept fails, naming the file, line and families", () => {
const r = run(`${fixtures}bad`);
assert.equal(r.status, 1);
assert.match(r.stderr, /Mixed\.tsx:1 .*image \+ document/);
assert.match(r.stderr, /Mixed\.tsx:2 .*audio \+ document/);
assert.match(r.stderr, /@bitbaum\/chatkit\/attach/);
// A trailing comment must not hide the input before it ("image/*" holds "/*").
assert.match(r.stderr, /Trailing\.tsx:1 /);
assert.match(r.stderr, /Trailing\.tsx:2 /);
});