refactor(housekeeping): adopt ase route namespace
This commit is contained in:
1 parent
74756dfed2
commit
f72a2b6c74
32 files changed
+388
-264
No files matched your search
@@ -25,7 +25,7 @@ const manifest = (
|
||||
labelKey: `pages.housekeeping.domains.${id}.title`,
|
||||
descriptionKey: `pages.housekeeping.domains.${id}.description`,
|
||||
iconId: "settings",
|
||||
previewHref: `/admin-next/${id}`,
|
||||
canonicalHref: id === "operations" ? "/ase" : `/ase/${id}`,
|
||||
capability: anyCapability(capabilitySlug),
|
||||
routes: [],
|
||||
searchProviders: [],
|
||||
@@ -73,7 +73,7 @@ const expectedManifests = [
|
||||
{
|
||||
id: "operations",
|
||||
iconId: "inbox",
|
||||
previewHref: "/admin-next/operations",
|
||||
canonicalHref: "/ase",
|
||||
labelKey: "pages.housekeeping.domains.operations.title",
|
||||
descriptionKey: "pages.housekeeping.domains.operations.description",
|
||||
slugs: [PERMS.ADMIN_DASHBOARD],
|
||||
@@ -81,7 +81,7 @@ const expectedManifests = [
|
||||
{
|
||||
id: "people",
|
||||
iconId: "users",
|
||||
previewHref: "/admin-next/people",
|
||||
canonicalHref: "/ase/people",
|
||||
labelKey: "pages.housekeeping.domains.people.title",
|
||||
descriptionKey: "pages.housekeeping.domains.people.description",
|
||||
slugs: [
|
||||
@@ -112,7 +112,7 @@ const expectedManifests = [
|
||||
{
|
||||
id: "content",
|
||||
iconId: "file-text",
|
||||
previewHref: "/admin-next/content",
|
||||
canonicalHref: "/ase/content",
|
||||
labelKey: "pages.housekeeping.domains.content.title",
|
||||
descriptionKey: "pages.housekeeping.domains.content.description",
|
||||
slugs: [
|
||||
@@ -135,7 +135,7 @@ const expectedManifests = [
|
||||
{
|
||||
id: "economy",
|
||||
iconId: "gem",
|
||||
previewHref: "/admin-next/economy",
|
||||
canonicalHref: "/ase/economy",
|
||||
labelKey: "pages.housekeeping.domains.economy.title",
|
||||
descriptionKey: "pages.housekeeping.domains.economy.description",
|
||||
slugs: [
|
||||
@@ -148,7 +148,7 @@ const expectedManifests = [
|
||||
{
|
||||
id: "hotel",
|
||||
iconId: "hotel",
|
||||
previewHref: "/admin-next/hotel",
|
||||
canonicalHref: "/ase/hotel",
|
||||
labelKey: "pages.housekeeping.domains.hotel.title",
|
||||
descriptionKey: "pages.housekeeping.domains.hotel.description",
|
||||
slugs: [
|
||||
@@ -165,7 +165,7 @@ const expectedManifests = [
|
||||
{
|
||||
id: "system",
|
||||
iconId: "settings",
|
||||
previewHref: "/admin-next/system",
|
||||
canonicalHref: "/ase/system",
|
||||
labelKey: "pages.housekeeping.domains.system.title",
|
||||
descriptionKey: "pages.housekeeping.domains.system.description",
|
||||
slugs: [
|
||||
@@ -208,9 +208,9 @@ describe("housekeeping registry", () => {
|
||||
it("rejects invalid preview and empty translation keys", () => {
|
||||
expect(() =>
|
||||
createHousekeepingRegistry([
|
||||
{ ...manifest("people"), previewHref: "/admin-next/operations" },
|
||||
{ ...manifest("people"), canonicalHref: "/ase" },
|
||||
]),
|
||||
).toThrow("invalid preview href");
|
||||
).toThrow("invalid canonical href");
|
||||
expect(() =>
|
||||
createHousekeepingRegistry([{ ...manifest("people"), labelKey: " " }]),
|
||||
).toThrow("empty label key");
|
||||
@@ -232,13 +232,13 @@ describe("housekeeping registry", () => {
|
||||
{
|
||||
id: "users",
|
||||
labelKey: "pages.housekeeping.domains.people.title",
|
||||
href: "/admin-next/people/users",
|
||||
href: "/ase/people/users",
|
||||
capability: anyCapability(PERMS.USERS_VIEW),
|
||||
},
|
||||
{
|
||||
id: "users",
|
||||
labelKey: "pages.housekeeping.domains.people.title",
|
||||
href: "/admin-next/people/staff",
|
||||
href: "/ase/people/staff",
|
||||
capability: anyCapability(PERMS.USERS_VIEW),
|
||||
},
|
||||
],
|
||||
@@ -253,13 +253,13 @@ describe("housekeeping registry", () => {
|
||||
{
|
||||
id: "users",
|
||||
labelKey: "pages.housekeeping.domains.people.title",
|
||||
href: "/admin-next/people/users",
|
||||
href: "/ase/people/users",
|
||||
capability: anyCapability(PERMS.USERS_VIEW),
|
||||
},
|
||||
{
|
||||
id: "staff",
|
||||
labelKey: "pages.housekeeping.domains.people.title",
|
||||
href: "/admin-next/people/users",
|
||||
href: "/ase/people/users",
|
||||
capability: anyCapability(PERMS.USERS_VIEW),
|
||||
},
|
||||
],
|
||||
@@ -272,7 +272,7 @@ describe("housekeeping registry", () => {
|
||||
const route = {
|
||||
id: "users",
|
||||
labelKey: "pages.housekeeping.domains.people.title",
|
||||
href: "/admin-next/people/users",
|
||||
href: "/ase/people/users",
|
||||
capability: anyCapability(PERMS.USERS_VIEW),
|
||||
};
|
||||
|
||||
@@ -319,7 +319,7 @@ describe("housekeeping registry", () => {
|
||||
expect(actual).toMatchObject({
|
||||
id: expected.id,
|
||||
iconId: expected.iconId,
|
||||
previewHref: expected.previewHref,
|
||||
canonicalHref: expected.canonicalHref,
|
||||
labelKey: expected.labelKey,
|
||||
descriptionKey: expected.descriptionKey,
|
||||
});
|
||||
@@ -481,7 +481,7 @@ describe("housekeeping registry", () => {
|
||||
{
|
||||
id: "users",
|
||||
labelKey: "pages.housekeeping.domains.people.title",
|
||||
href: "/admin-next/people/users",
|
||||
href: "/ase/people/users",
|
||||
capability: { mode: "any", slugs: [] },
|
||||
},
|
||||
],
|
||||
@@ -494,7 +494,7 @@ describe("housekeeping registry", () => {
|
||||
const route = {
|
||||
id: "shared",
|
||||
labelKey: "pages.housekeeping.domains.people.title",
|
||||
href: "/admin-next/shared",
|
||||
href: "/ase/shared",
|
||||
capability: anyCapability(PERMS.USERS_VIEW),
|
||||
};
|
||||
|
||||
@@ -503,7 +503,7 @@ describe("housekeeping registry", () => {
|
||||
{ ...manifest("people"), routes: [route] },
|
||||
{
|
||||
...manifest("content"),
|
||||
routes: [{ ...route, href: "/admin-next/content/shared" }],
|
||||
routes: [{ ...route, href: "/ase/content/shared" }],
|
||||
},
|
||||
]),
|
||||
).toThrow("duplicate route id");
|
||||
@@ -518,3 +518,22 @@ describe("housekeeping registry", () => {
|
||||
).toThrow("duplicate route href");
|
||||
});
|
||||
});
|
||||
|
||||
it("accepts the canonical operations root and rejects legacy admin hrefs", () => {
|
||||
const canonicalOperations = manifest("operations") as Record<string, unknown>;
|
||||
delete canonicalOperations.canonicalHref;
|
||||
canonicalOperations.canonicalHref = "/ase";
|
||||
|
||||
expect(() =>
|
||||
createHousekeepingRegistry([
|
||||
canonicalOperations as unknown as HousekeepingDomainManifest,
|
||||
]),
|
||||
).not.toThrow();
|
||||
|
||||
canonicalOperations.canonicalHref = "/admin";
|
||||
expect(() =>
|
||||
createHousekeepingRegistry([
|
||||
canonicalOperations as unknown as HousekeepingDomainManifest,
|
||||
]),
|
||||
).toThrow("invalid canonical href");
|
||||
});
|
||||
Reference in new issue
Block a user