Skip to content

Commit 5a574a7

Browse files
test(web): remove duplicate sidebar ordering tests (#14558)
Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
1 parent a3fb539 commit 5a574a7

2 files changed

Lines changed: 1 addition & 101 deletions

File tree

‎apps/web/src/components/Sidebar.logic.test.ts‎

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import {
3434
sortLogicalProjectsForSidebar,
3535
resolveSidebarDropTarget,
3636
pinOrderKeyBetween,
37-
planPinnedReorder,
3837
planSidebarThreadDrop,
3938
sidebarMarkerId,
4039
sidebarListItemId,
@@ -958,59 +957,6 @@ describe("reduceSidebarProjectScopeMenuState", () => {
958957
});
959958
});
960959

961-
describe("sortThreadsForSidebar", () => {
962-
const sortable = (input: { id: string; createdAt: string }) => ({
963-
id: input.id,
964-
createdAt: input.createdAt,
965-
});
966-
967-
it("orders by creation time, newest first, ignoring activity", () => {
968-
const sorted = sortThreadsForSidebar([
969-
sortable({ id: "oldest", createdAt: "2026-03-09T08:00:00.000Z" }),
970-
sortable({ id: "newest", createdAt: "2026-03-09T12:00:00.000Z" }),
971-
sortable({ id: "middle", createdAt: "2026-03-09T10:00:00.000Z" }),
972-
]);
973-
974-
expect(sorted.map((thread) => thread.id)).toEqual(["newest", "middle", "oldest"]);
975-
});
976-
977-
it("breaks creation-time ties by id so the order is stable", () => {
978-
const sorted = sortThreadsForSidebar([
979-
sortable({ id: "b", createdAt: "2026-03-09T10:00:00.000Z" }),
980-
sortable({ id: "a", createdAt: "2026-03-09T10:00:00.000Z" }),
981-
]);
982-
983-
expect(sorted.map((thread) => thread.id)).toEqual(["a", "b"]);
984-
});
985-
986-
it("surfaces an un-settled thread at the top via its re-entry stamp", () => {
987-
const sorted = sortThreadsForSidebar([
988-
{
989-
id: "old-unsettled",
990-
createdAt: "2026-03-09T08:00:00.000Z",
991-
unsettledAt: "2026-03-09T13:00:00.000Z",
992-
},
993-
sortable({ id: "newest", createdAt: "2026-03-09T12:00:00.000Z" }),
994-
sortable({ id: "middle", createdAt: "2026-03-09T10:00:00.000Z" }),
995-
]);
996-
997-
expect(sorted.map((thread) => thread.id)).toEqual(["old-unsettled", "newest", "middle"]);
998-
});
999-
1000-
it("ignores a re-entry stamp older than the thread's creation", () => {
1001-
const sorted = sortThreadsForSidebar([
1002-
{
1003-
id: "stale-stamp",
1004-
createdAt: "2026-03-09T10:00:00.000Z",
1005-
unsettledAt: "2026-03-09T09:00:00.000Z",
1006-
},
1007-
sortable({ id: "newest", createdAt: "2026-03-09T12:00:00.000Z" }),
1008-
]);
1009-
1010-
expect(sorted.map((thread) => thread.id)).toEqual(["newest", "stale-stamp"]);
1011-
});
1012-
});
1013-
1014960
describe("pinOrderKeyBetween", () => {
1015961
it("produces keys that sort between their bounds", () => {
1016962
const middle = pinOrderKeyBetween(null, null)!;
@@ -1062,52 +1008,6 @@ describe("pinOrderKeyBetween", () => {
10621008
});
10631009
});
10641010

1065-
describe("planPinnedReorder", () => {
1066-
it("writes only the moved thread when neighbors are keyed", () => {
1067-
const assignments = planPinnedReorder({
1068-
orderedIds: ["a", "c", "b"],
1069-
keysById: new Map([
1070-
["a", "f"],
1071-
["b", "m"],
1072-
["c", "t"],
1073-
]),
1074-
movedId: "c",
1075-
});
1076-
expect(assignments).toHaveLength(1);
1077-
expect(assignments[0]!.id).toBe("c");
1078-
expect(assignments[0]!.orderKey > "f" && assignments[0]!.orderKey < "m").toBe(true);
1079-
});
1080-
1081-
it("treats list edges as open bounds", () => {
1082-
const assignments = planPinnedReorder({
1083-
orderedIds: ["b", "a"],
1084-
keysById: new Map([
1085-
["a", "m"],
1086-
["b", null],
1087-
]),
1088-
movedId: "b",
1089-
});
1090-
expect(assignments).toHaveLength(1);
1091-
expect(assignments[0]!.orderKey < "m").toBe(true);
1092-
});
1093-
1094-
it("materializes keys for the whole section when a neighbor is keyless", () => {
1095-
const assignments = planPinnedReorder({
1096-
orderedIds: ["b", "a", "c"],
1097-
keysById: new Map([
1098-
["a", null],
1099-
["b", "m"],
1100-
["c", null],
1101-
]),
1102-
movedId: "b",
1103-
});
1104-
expect(assignments.map((entry) => entry.id)).toEqual(["b", "a", "c"]);
1105-
const keys = assignments.map((entry) => entry.orderKey);
1106-
expect([...keys].sort()).toEqual(keys);
1107-
expect(new Set(keys).size).toBe(keys.length);
1108-
});
1109-
});
1110-
11111011
describe("resolveSidebarDropTarget", () => {
11121012
const thread = (key: string, section: SidebarSection): SidebarListItem => ({
11131013
kind: "thread",

‎apps/web/src/components/Sidebar.logic.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ export { sortActiveThreadsByOrderKey as sortThreadsForSidebar } from "@t3tools/c
872872

873873
// Pinned-reorder key math and the keyed sort live in client-runtime
874874
// (state/thread-sort) so web and mobile compute identical pinned orders.
875-
export { pinOrderKeyBetween, planPinnedReorder } from "@t3tools/client-runtime/state/thread-sort";
875+
export { pinOrderKeyBetween } from "@t3tools/client-runtime/state/thread-sort";
876876
export { sortPinnedThreadsByOrderKey as sortPinnedThreadsForSidebar } from "@t3tools/client-runtime/state/thread-sort";
877877

878878
const EMPTY_CONTENT_MATCH_KEYS: ReadonlySet<string> = new Set<string>();

0 commit comments

Comments
 (0)