The selected Space used to live in sessionStorage and ride along invisibly with every collection route. It now lives in the URL: collection pages exist both globally and beneath /spaces/:spaceUid, and the Space context derives its scope from the current location. - Add a Space route branch (Home, Explore, Calendar, Attachments) guarded by a SpaceRoute that shows loading, unavailable, and retry states. - Resolve collection routes through one matchPath-based helper built from the route constants; build Space-scoped paths with buildCollectionPath. - Fetch the route Space directly, seeded from the switcher list so pages are not held behind a second round-trip. - Turn the Space switcher into plain links that preserve the current collection view and query. - Drop the remembered-Space machinery: clearSelectedSpace/selectMemos, the compose-placement policy, routeSupportsCollectionScope, and the quick-find switchToAll flag are all implied by the URL now. - Return from memo details to the full origin URL, including its Space. - Add space.unavailable and space.back-to-memos strings; align the Azerbaijani catalog with English.
92 lines
2.6 KiB
TypeScript
92 lines
2.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { getRouteActionPolicy, getSidebarRouteKind } from "@/components/AppSidebar/routes";
|
|
|
|
describe("sidebar route content", () => {
|
|
it.each([
|
|
["/", "home"],
|
|
["/archived", "archived"],
|
|
["/explore", "explore"],
|
|
["/Explore/", "explore"],
|
|
["/ARCHIVED/", "archived"],
|
|
["/u/steven", "profile"],
|
|
["/U/Steven/", "profile"],
|
|
["/views", "views"],
|
|
["/Views/", "views"],
|
|
["/calendar", "calendar"],
|
|
["/calendar/2026/08", "calendar"],
|
|
["/Calendar/2026/08/02/", "calendar"],
|
|
["/attachments", "attachments"],
|
|
["/Attachments/", "attachments"],
|
|
["/inbox", "inbox"],
|
|
["/Inbox/", "inbox"],
|
|
["/setting", "settings"],
|
|
["/Setting/", "settings"],
|
|
["/memos/abc", "memo"],
|
|
["/Memos/ABC/", "memo"],
|
|
["/memos/shares/token", "memo"],
|
|
["/Memos/Shares/token/", "memo"],
|
|
["/about", "common"],
|
|
["/403", "common"],
|
|
["/404", "common"],
|
|
["/unknown", "common"],
|
|
])("maps %s to %s content", (path, kind) => {
|
|
expect(getSidebarRouteKind(path)).toBe(kind);
|
|
});
|
|
|
|
it.each(["/", "/explore"])("keeps search in the route collection on %s", (path) => {
|
|
expect(getRouteActionPolicy(path)).toEqual({
|
|
searchScope: "route-collection",
|
|
});
|
|
});
|
|
|
|
it.each(["/archived", "/ARCHIVED/"])("keeps %s in the user archive", (path) => {
|
|
expect(getRouteActionPolicy(path)).toEqual({
|
|
searchScope: "user-collection",
|
|
});
|
|
});
|
|
|
|
it.each(["/attachments", "/calendar/2026/08/02"])("keeps the route scope when %s sends search to Home", (path) => {
|
|
expect(getRouteActionPolicy(path)).toEqual({
|
|
searchScope: "route-collection",
|
|
searchDestination: "/",
|
|
});
|
|
});
|
|
|
|
it("keeps Profile search on Profile", () => {
|
|
expect(getRouteActionPolicy("/u/steven")).toEqual({
|
|
searchScope: "profile",
|
|
searchDestination: "/u/steven",
|
|
});
|
|
});
|
|
|
|
it("normalizes a Profile route without changing its spelling", () => {
|
|
expect(getRouteActionPolicy("/U/Steven/")).toEqual({
|
|
searchScope: "profile",
|
|
searchDestination: "/U/Steven",
|
|
});
|
|
});
|
|
|
|
it("keeps a normalized Explore route in the route scope", () => {
|
|
const path = "/Explore/";
|
|
expect(getRouteActionPolicy(path)).toEqual({
|
|
searchScope: "route-collection",
|
|
});
|
|
});
|
|
|
|
it.each([
|
|
"/inbox",
|
|
"/setting",
|
|
"/views",
|
|
"/about",
|
|
"/memos/abc",
|
|
"/memos/shares/token",
|
|
"/403",
|
|
"/404",
|
|
"/unknown",
|
|
])("sends search to All on %s", (path) => {
|
|
expect(getRouteActionPolicy(path)).toEqual({
|
|
searchScope: "all",
|
|
searchDestination: "/",
|
|
});
|
|
});
|
|
});
|