fix(housekeeping): satisfy ase route types
This commit is contained in:
1 parent
a9bdd6bd5d
commit
67cb4b488d
2 files changed
+20
-10
No files matched your search
@@ -232,7 +232,7 @@ describe("housekeeping registry", () => {
|
|||||||
{
|
{
|
||||||
id: "users",
|
id: "users",
|
||||||
labelKey: "pages.housekeeping.domains.people.title",
|
labelKey: "pages.housekeeping.domains.people.title",
|
||||||
href: "/ase/people/users",
|
href: "/ase/people/users" as `/ase${string}`,
|
||||||
capability: anyCapability(PERMS.USERS_VIEW),
|
capability: anyCapability(PERMS.USERS_VIEW),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -253,13 +253,13 @@ describe("housekeeping registry", () => {
|
|||||||
{
|
{
|
||||||
id: "users",
|
id: "users",
|
||||||
labelKey: "pages.housekeeping.domains.people.title",
|
labelKey: "pages.housekeeping.domains.people.title",
|
||||||
href: "/ase/people/users",
|
href: "/ase/people/users" as `/ase${string}`,
|
||||||
capability: anyCapability(PERMS.USERS_VIEW),
|
capability: anyCapability(PERMS.USERS_VIEW),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "staff",
|
id: "staff",
|
||||||
labelKey: "pages.housekeeping.domains.people.title",
|
labelKey: "pages.housekeeping.domains.people.title",
|
||||||
href: "/ase/people/users",
|
href: "/ase/people/users" as `/ase${string}`,
|
||||||
capability: anyCapability(PERMS.USERS_VIEW),
|
capability: anyCapability(PERMS.USERS_VIEW),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -272,7 +272,7 @@ describe("housekeeping registry", () => {
|
|||||||
const route = {
|
const route = {
|
||||||
id: "users",
|
id: "users",
|
||||||
labelKey: "pages.housekeeping.domains.people.title",
|
labelKey: "pages.housekeeping.domains.people.title",
|
||||||
href: "/ase/people/users",
|
href: "/ase/people/users" as `/ase${string}`,
|
||||||
capability: anyCapability(PERMS.USERS_VIEW),
|
capability: anyCapability(PERMS.USERS_VIEW),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -283,7 +283,10 @@ describe("housekeeping registry", () => {
|
|||||||
).toThrow("empty route id");
|
).toThrow("empty route id");
|
||||||
expect(() =>
|
expect(() =>
|
||||||
createHousekeepingRegistry([
|
createHousekeepingRegistry([
|
||||||
{ ...manifest("people"), routes: [{ ...route, href: " " }] },
|
{
|
||||||
|
...manifest("people"),
|
||||||
|
routes: [{ ...route, href: " " as `/ase${string}` }],
|
||||||
|
},
|
||||||
]),
|
]),
|
||||||
).toThrow("empty route href");
|
).toThrow("empty route href");
|
||||||
expect(() =>
|
expect(() =>
|
||||||
@@ -481,7 +484,7 @@ describe("housekeeping registry", () => {
|
|||||||
{
|
{
|
||||||
id: "users",
|
id: "users",
|
||||||
labelKey: "pages.housekeeping.domains.people.title",
|
labelKey: "pages.housekeeping.domains.people.title",
|
||||||
href: "/ase/people/users",
|
href: "/ase/people/users" as `/ase${string}`,
|
||||||
capability: { mode: "any", slugs: [] },
|
capability: { mode: "any", slugs: [] },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -494,7 +497,7 @@ describe("housekeeping registry", () => {
|
|||||||
const route = {
|
const route = {
|
||||||
id: "shared",
|
id: "shared",
|
||||||
labelKey: "pages.housekeeping.domains.people.title",
|
labelKey: "pages.housekeeping.domains.people.title",
|
||||||
href: "/ase/shared",
|
href: "/ase/shared" as `/ase${string}`,
|
||||||
capability: anyCapability(PERMS.USERS_VIEW),
|
capability: anyCapability(PERMS.USERS_VIEW),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -503,7 +506,9 @@ describe("housekeeping registry", () => {
|
|||||||
{ ...manifest("people"), routes: [route] },
|
{ ...manifest("people"), routes: [route] },
|
||||||
{
|
{
|
||||||
...manifest("content"),
|
...manifest("content"),
|
||||||
routes: [{ ...route, href: "/ase/content/shared" }],
|
routes: [
|
||||||
|
{ ...route, href: "/ase/content/shared" as `/ase${string}` },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
]),
|
]),
|
||||||
).toThrow("duplicate route id");
|
).toThrow("duplicate route id");
|
||||||
@@ -520,7 +525,10 @@ describe("housekeeping registry", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("accepts the canonical operations root and rejects legacy admin hrefs", () => {
|
it("accepts the canonical operations root and rejects legacy admin hrefs", () => {
|
||||||
const canonicalOperations = manifest("operations") as Record<string, unknown>;
|
const canonicalOperations = manifest("operations") as unknown as Record<
|
||||||
|
string,
|
||||||
|
unknown
|
||||||
|
>;
|
||||||
delete canonicalOperations.canonicalHref;
|
delete canonicalOperations.canonicalHref;
|
||||||
canonicalOperations.canonicalHref = "/ase";
|
canonicalOperations.canonicalHref = "/ase";
|
||||||
|
|
||||||
|
|||||||
@@ -11,5 +11,7 @@ export function toHousekeepingHref(
|
|||||||
throw new Error(`invalid canonical housekeeping href: ${href}`);
|
throw new Error(`invalid canonical housekeeping href: ${href}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return surface === "canonical" ? href : href.replace(/^\/ase/, "/ase-next");
|
return surface === "canonical"
|
||||||
|
? href
|
||||||
|
: (`/ase-next${href.slice(4)}` as `/ase-next${string}`);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user