List the last visited workspace first in the rail

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-28 19:48:38 +01:00
co-authored by Claude Opus 5.5
parent c1c866876e
commit d352ac924a
17 changed files with 190 additions and 20 deletions
+21
View File
@@ -0,0 +1,21 @@
import { describe, expect, test } from "bun:test";
import type { WorkspaceWithActivity } from "@/src/types";
import orderRailWorkspaces from "./order-rail-workspaces";
const workspaces = [1, 2, 3, 4].map((id) => ({ id, name: `W${id}` }) as WorkspaceWithActivity);
function ids(list: WorkspaceWithActivity[]) {
return list.map((workspace) => workspace.id);
}
describe("orderRailWorkspaces", () => {
test("the last visited workspace leads, the rest keep their order", () => {
expect(ids(orderRailWorkspaces({ workspaces, first_id: 3 }))).toEqual([3, 1, 2, 4]);
});
test("unchanged without one, or when it isn't listed", () => {
expect(ids(orderRailWorkspaces({ workspaces }))).toEqual([1, 2, 3, 4]);
expect(ids(orderRailWorkspaces({ workspaces, first_id: null }))).toEqual([1, 2, 3, 4]);
expect(ids(orderRailWorkspaces({ workspaces, first_id: 9 }))).toEqual([1, 2, 3, 4]);
});
});