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
2 changed files with 58 additions and 35 deletions
|
|
@ -3,11 +3,7 @@
|
|||
// stripping, so the `.ts` module is imported as it is.
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import {
|
||||
bodyText,
|
||||
jobsHref,
|
||||
wantedRun,
|
||||
} from "../src/pages/builds/builds-types.ts";
|
||||
import { bodyText, wantedRun } from "../src/pages/builds/builds-types.ts";
|
||||
|
||||
const base = {
|
||||
id: "atlas-abc-1",
|
||||
|
|
@ -53,8 +49,3 @@ test("a run with no text for its outcome shows no body", () => {
|
|||
assert.equal(bodyText({ ...base, outcome: "failed" }), null);
|
||||
assert.equal(bodyText({ ...base, outcome: "built", error_tail: "x" }), null);
|
||||
});
|
||||
|
||||
test("an old builds link goes to the jobs page and keeps its query", () => {
|
||||
assert.equal(jobsHref("run=atlas-abc-1"), "/jobs?run=atlas-abc-1");
|
||||
assert.equal(jobsHref(""), "/jobs");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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