frontend: root test and typecheck scripts, and tests for the review runs wording and the terminal drag
npm test and npm run typecheck now run in every workspace that has them (the repo root had only build and clean). New tests cover RunsTypes (labels and tones for every outcome, the classification count) and termDrag (what a drag carries and how the hover reads it). instructions.ts cannot be imported by a test under Node because of its .js specifier for unified-diff.ts, so it is not covered, and the conventions doc says so.
This commit is contained in:
parent
96334845f0
commit
e4cfac6926
1 changed files with 102 additions and 0 deletions
46
frontend/packages/swarm-ui/test/term-drag.test.mjs
Normal file
46
frontend/packages/swarm-ui/test/term-drag.test.mjs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// What a drag of an agent's terminal carries, and how the hover reads it. Run by
|
||||
// `npm test`.
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import {
|
||||
AGENT_DRAG_TYPE,
|
||||
draggedAgent,
|
||||
endAgentDrag,
|
||||
startAgentDrag,
|
||||
} from "../src/agent/terminal/termDrag.ts";
|
||||
|
||||
function dragEvent() {
|
||||
const data = {};
|
||||
return {
|
||||
data,
|
||||
dataTransfer: {
|
||||
effectAllowed: "",
|
||||
setData: (type, value) => {
|
||||
data[type] = value;
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
test("a drag carries the agent, as its own type and as text", () => {
|
||||
const e = dragEvent();
|
||||
startAgentDrag(e, "iris");
|
||||
assert.equal(e.data[AGENT_DRAG_TYPE], "iris");
|
||||
assert.equal(e.data["text/plain"], "iris");
|
||||
assert.equal(e.dataTransfer.effectAllowed, "move");
|
||||
endAgentDrag();
|
||||
});
|
||||
|
||||
test("the hover reads the agent until the drag ends", () => {
|
||||
assert.equal(draggedAgent(), null);
|
||||
startAgentDrag(dragEvent(), "argus");
|
||||
assert.equal(draggedAgent(), "argus");
|
||||
endAgentDrag();
|
||||
assert.equal(draggedAgent(), null);
|
||||
});
|
||||
|
||||
test("a drag with no data transfer still records the agent", () => {
|
||||
startAgentDrag({}, "atlas");
|
||||
assert.equal(draggedAgent(), "atlas");
|
||||
endAgentDrag();
|
||||
});
|
||||
Loading…
Reference in a new issue