object-detection-lab / tests /capstone.test.mjs
miyuki17's picture
Unify course navigation and connected learning path
29d301f verified
Raw History Blame Contribute Delete
1.85 kB
import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
const root = new URL("../", import.meta.url);
const read = (name) => readFileSync(new URL(name, root), "utf8");
test("connected studio preserves every DOM contract required by the existing detector and generator", () => {
const studio = read("detect-create.html");
const requiredIds = [
"image-input", "model-select", "model-note", "threshold", "threshold-value",
"run-button", "status", "progress-wrap", "progress-bar", "canvas-wrap",
"result-canvas", "summary", "detections-body", "runtime-badge", "sample-grid",
"shuffle-examples", "flow-concepts", "flow-prompt", "flow-model",
"flow-generate", "flow-status", "flow-image", "flow-receipt", "flow-open",
];
for (const id of requiredIds) {
assert.match(studio, new RegExp(`\\bid="${id}"`), `Missing required #${id}`);
}
assert.match(studio, /src="\.\/app\.js"/);
assert.match(studio, /aria-current="page"/);
assert.match(studio, /href="\.\/detect-create\.html"/);
assert.match(studio, /Only your edited text, seed and steps/);
});
test("the standalone detector keeps its learning lab and links to the separate capstone", () => {
const detection = read("index.html");
assert.match(detection, /id="run-button"/);
assert.match(detection, /how-to-start\.html/);
assert.match(detection, /href="\.\/detect-create\.html"/);
assert.doesNotMatch(detection, /id="flow-generate"/);
});
test("generator calls remain opt-in and send text parameters rather than the source photo", () => {
const flow = read("workflow.js");
assert.match(flow, /generateButton\?\.addEventListener\("click", async/);
assert.match(flow, /prompt, seed: config\.seed, steps: config\.steps/);
assert.doesNotMatch(flow, /predict\([^\n]*image(Input|Data|Blob)/);
});