swarm-ui: move the shell's route layout predicates out and test them
isFullBleedRoute and isWideBodyRoute are plain functions of a path, so they move from Shell.tsx to shell/routes.ts, where the new tests cover the start page, the hive directory's move to /hives, the terminal paths and the wide-body routes.
This commit is contained in:
parent
417125b33c
commit
01e58219cf
3 changed files with 78 additions and 32 deletions
42
frontend/packages/swarm-ui/test/routes.test.mjs
Normal file
42
frontend/packages/swarm-ui/test/routes.test.mjs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
// The shell's per-route layout: which paths are full-bleed, which get the
|
||||
// wide body. Run by `npm test`.
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { isFullBleedRoute, isWideBodyRoute } from "../src/shell/routes.ts";
|
||||
|
||||
test("the start page is full-bleed", () => {
|
||||
assert.equal(isFullBleedRoute("/"), true);
|
||||
});
|
||||
|
||||
test("the hive directory moved off / and is not full-bleed", () => {
|
||||
assert.equal(isFullBleedRoute("/hives"), false);
|
||||
assert.equal(isWideBodyRoute("/hives"), false);
|
||||
});
|
||||
|
||||
test("an agent's terminal and a subagent's are full-bleed", () => {
|
||||
assert.equal(isFullBleedRoute("/agents/iris/terminal"), true);
|
||||
assert.equal(
|
||||
isFullBleedRoute("/agents/iris/subagents/scout-1/terminal"),
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test("the agents page and other routes are not full-bleed", () => {
|
||||
for (const path of ["/agents", "/agents/iris", "/jobs", "/issues"]) {
|
||||
assert.equal(isFullBleedRoute(path), false, path);
|
||||
}
|
||||
});
|
||||
|
||||
test("a terminal path with extra segments is not full-bleed", () => {
|
||||
assert.equal(isFullBleedRoute("/agents/iris/terminal/extra"), false);
|
||||
assert.equal(isFullBleedRoute("/agents//terminal"), false);
|
||||
});
|
||||
|
||||
test("the wide-body routes are exactly the table pages", () => {
|
||||
for (const path of ["/issues", "/agents", "/review-runs", "/review-tryout"]) {
|
||||
assert.equal(isWideBodyRoute(path), true, path);
|
||||
}
|
||||
for (const path of ["/", "/jobs", "/schedules", "/components"]) {
|
||||
assert.equal(isWideBodyRoute(path), false, path);
|
||||
}
|
||||
});
|
||||
Loading…
Reference in a new issue