Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 0 additions & 100 deletions apps/web/src/components/Sidebar.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
sortLogicalProjectsForSidebar,
resolveSidebarDropTarget,
pinOrderKeyBetween,
planPinnedReorder,
planSidebarThreadDrop,
sidebarMarkerId,
sidebarListItemId,
Expand Down Expand Up @@ -958,59 +957,6 @@ describe("reduceSidebarProjectScopeMenuState", () => {
});
});

describe("sortThreadsForSidebar", () => {
const sortable = (input: { id: string; createdAt: string }) => ({
id: input.id,
createdAt: input.createdAt,
});

it("orders by creation time, newest first, ignoring activity", () => {
const sorted = sortThreadsForSidebar([
sortable({ id: "oldest", createdAt: "2026-03-09T08:00:00.000Z" }),
sortable({ id: "newest", createdAt: "2026-03-09T12:00:00.000Z" }),
sortable({ id: "middle", createdAt: "2026-03-09T10:00:00.000Z" }),
]);

expect(sorted.map((thread) => thread.id)).toEqual(["newest", "middle", "oldest"]);
});

it("breaks creation-time ties by id so the order is stable", () => {
const sorted = sortThreadsForSidebar([
sortable({ id: "b", createdAt: "2026-03-09T10:00:00.000Z" }),
sortable({ id: "a", createdAt: "2026-03-09T10:00:00.000Z" }),
]);

expect(sorted.map((thread) => thread.id)).toEqual(["a", "b"]);
});

it("surfaces an un-settled thread at the top via its re-entry stamp", () => {
const sorted = sortThreadsForSidebar([
{
id: "old-unsettled",
createdAt: "2026-03-09T08:00:00.000Z",
unsettledAt: "2026-03-09T13:00:00.000Z",
},
sortable({ id: "newest", createdAt: "2026-03-09T12:00:00.000Z" }),
sortable({ id: "middle", createdAt: "2026-03-09T10:00:00.000Z" }),
]);

expect(sorted.map((thread) => thread.id)).toEqual(["old-unsettled", "newest", "middle"]);
});

it("ignores a re-entry stamp older than the thread's creation", () => {
const sorted = sortThreadsForSidebar([
{
id: "stale-stamp",
createdAt: "2026-03-09T10:00:00.000Z",
unsettledAt: "2026-03-09T09:00:00.000Z",
},
sortable({ id: "newest", createdAt: "2026-03-09T12:00:00.000Z" }),
]);

expect(sorted.map((thread) => thread.id)).toEqual(["newest", "stale-stamp"]);
});
});

describe("pinOrderKeyBetween", () => {
it("produces keys that sort between their bounds", () => {
const middle = pinOrderKeyBetween(null, null)!;
Expand Down Expand Up @@ -1062,52 +1008,6 @@ describe("pinOrderKeyBetween", () => {
});
});

describe("planPinnedReorder", () => {
it("writes only the moved thread when neighbors are keyed", () => {
const assignments = planPinnedReorder({
orderedIds: ["a", "c", "b"],
keysById: new Map([
["a", "f"],
["b", "m"],
["c", "t"],
]),
movedId: "c",
});
expect(assignments).toHaveLength(1);
expect(assignments[0]!.id).toBe("c");
expect(assignments[0]!.orderKey > "f" && assignments[0]!.orderKey < "m").toBe(true);
});

it("treats list edges as open bounds", () => {
const assignments = planPinnedReorder({
orderedIds: ["b", "a"],
keysById: new Map([
["a", "m"],
["b", null],
]),
movedId: "b",
});
expect(assignments).toHaveLength(1);
expect(assignments[0]!.orderKey < "m").toBe(true);
});

it("materializes keys for the whole section when a neighbor is keyless", () => {
const assignments = planPinnedReorder({
orderedIds: ["b", "a", "c"],
keysById: new Map([
["a", null],
["b", "m"],
["c", null],
]),
movedId: "b",
});
expect(assignments.map((entry) => entry.id)).toEqual(["b", "a", "c"]);
const keys = assignments.map((entry) => entry.orderKey);
expect([...keys].sort()).toEqual(keys);
expect(new Set(keys).size).toBe(keys.length);
});
});

describe("resolveSidebarDropTarget", () => {
const thread = (key: string, section: SidebarSection): SidebarListItem => ({
kind: "thread",
Expand Down
Loading