mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-21 01:23:40 +00:00
feat(console): give each group its own routes URL
Resolve the selected group from /admin/groups/{groupId}, validate console paths, and use browser history for back navigation. Keep Groups active and let an active mobile-tab tap return to the list. Scope pending route loads to their group and retain the count beside long headings.
This commit is contained in:
1 parent
ba95456e67
commit
535bfa98ce
11 files changed
+249
-63
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import { describe, it, expect } from "bun:test";
|
||||
import { adminGroupPath, parseAdminPath } from "../app/utils/admin-path";
|
||||
|
||||
describe("parseAdminPath", () => {
|
||||
it("maps the console pages", () => {
|
||||
expect(parseAdminPath(undefined)).toEqual({ view: "overview", groupId: null });
|
||||
expect(parseAdminPath([])).toEqual({ view: "overview", groupId: null });
|
||||
expect(parseAdminPath("logs")).toEqual({ view: "logs", groupId: null });
|
||||
expect(parseAdminPath(["groups"])).toEqual({ view: "groups", groupId: null });
|
||||
expect(parseAdminPath(["metrics"])).toEqual({ view: "metrics", groupId: null });
|
||||
});
|
||||
|
||||
it("opens a group's routes under /admin/groups/{groupId}", () => {
|
||||
expect(parseAdminPath(["groups", "inst-12345678"])).toEqual({
|
||||
view: "groups",
|
||||
groupId: "inst-12345678",
|
||||
});
|
||||
// A trailing slash adds an empty segment.
|
||||
expect(parseAdminPath(["groups", ""])).toEqual({ view: "groups", groupId: null });
|
||||
expect(parseAdminPath(["groups", "acme", ""])).toEqual({ view: "groups", groupId: "acme" });
|
||||
});
|
||||
|
||||
it("rejects unknown pages and sub-pages", () => {
|
||||
expect(parseAdminPath(["foo"])).toBeNull();
|
||||
expect(parseAdminPath(["logs", "x"])).toBeNull();
|
||||
expect(parseAdminPath(["groups", "acme", "routes"])).toBeNull();
|
||||
expect(parseAdminPath(["constructor"])).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("adminGroupPath", () => {
|
||||
it("encodes the group id", () => {
|
||||
expect(adminGroupPath("acme")).toBe("/admin/groups/acme");
|
||||
expect(adminGroupPath("a/b c")).toBe("/admin/groups/a%2Fb%20c");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user