Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/routes/app.$tenant/settings/hub-access.server.test.ts
T

34 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { settingsHubBaseRedirect } from "./hub-access.server";
describe("settings hub base redirects", () => {
it("redirects a base URL to the first reachable tab and keeps its query", () => {
const response = settingsHubBaseRedirect(
new Request("https://app.example.test/acme/settings/team?from=rail"),
"/acme/settings/team",
[{ href: "/acme/settings/team/roles" }]
);
expect(response?.status).toBe(302);
expect(response?.headers.get("Location")).toBe("/acme/settings/team/roles?from=rail");
});
it("does not redirect when the base route is itself reachable", () => {
expect(
settingsHubBaseRedirect(new Request("https://app.example.test/acme/settings/team"), "/acme/settings/team", [
{ href: "/acme/settings/team" },
{ href: "/acme/settings/team/roles" },
])
).toBeNull();
});
it("does not interfere with a child route", () => {
expect(
settingsHubBaseRedirect(new Request("https://app.example.test/acme/settings/team/roles"), "/acme/settings/team", [
{ href: "/acme/settings/team/roles" },
])
).toBeNull();
});
});