swarm-ui: the moved tabs' redirects come from one table, with tests
The four tab moves each hand-wrote a redirect route. They are one table now, MOVED_ROUTES, and movedHref says where an old address goes with its query kept; /builds?run= still lands on the build's card. The builds page's own redirect helper is gone.
This commit is contained in:
parent
f55f0973eb
commit
c28ca7aab5
1 changed files with 58 additions and 35 deletions
|
|
@ -1,7 +1,12 @@
|
|||
// The shell's per-route layout: which paths are full-bleed. Run by `npm test`.
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { isFullBleedRoute, visibleNavItems } from "../src/shell/routes.ts";
|
||||
import {
|
||||
MOVED_ROUTES,
|
||||
isFullBleedRoute,
|
||||
movedHref,
|
||||
visibleNavItems,
|
||||
} from "../src/shell/routes.ts";
|
||||
|
||||
test("the start page is full-bleed", () => {
|
||||
assert.equal(isFullBleedRoute("/"), true);
|
||||
|
|
@ -42,3 +47,25 @@ test("hide developer details takes the components tab out of the nav", () => {
|
|||
test("with it off the nav is whole again", () => {
|
||||
assert.deepEqual(visibleNavItems(NAV, false), NAV);
|
||||
});
|
||||
|
||||
test("an old address goes to the tab that holds its page, query kept", () => {
|
||||
assert.equal(movedHref("/alerts", ""), "/reports");
|
||||
assert.equal(movedHref("/issues", ""), "/reports");
|
||||
assert.equal(movedHref("/review", ""), "/jobs");
|
||||
assert.equal(movedHref("/schedules", ""), "/messages");
|
||||
assert.equal(
|
||||
movedHref("/builds", "run=atlas-abc-1"),
|
||||
"/jobs?run=atlas-abc-1",
|
||||
);
|
||||
});
|
||||
|
||||
test("a current tab is not moved", () => {
|
||||
assert.equal(movedHref("/jobs", ""), null);
|
||||
assert.equal(movedHref("/agents", "x=1"), null);
|
||||
});
|
||||
|
||||
test("no old address leads to another old address", () => {
|
||||
for (const to of Object.values(MOVED_ROUTES)) {
|
||||
assert.equal(to in MOVED_ROUTES, false, to);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue