test(web): remove duplicate sidebar ordering tests (#14558)
Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
a3fb5392e3
commit
5a574a77d1
2 files changed
+1
-101
No files matched your search
@@ -34,7 +34,6 @@ import {
|
||||
sortLogicalProjectsForSidebar,
|
||||
resolveSidebarDropTarget,
|
||||
pinOrderKeyBetween,
|
||||
planPinnedReorder,
|
||||
planSidebarThreadDrop,
|
||||
sidebarMarkerId,
|
||||
sidebarListItemId,
|
||||
@@ -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)!;
|
||||
@@ -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",
|
||||
|
||||
@@ -872,7 +872,7 @@ export { sortActiveThreadsByOrderKey as sortThreadsForSidebar } from "@t3tools/c
|
||||
|
||||
// Pinned-reorder key math and the keyed sort live in client-runtime
|
||||
// (state/thread-sort) so web and mobile compute identical pinned orders.
|
||||
export { pinOrderKeyBetween, planPinnedReorder } from "@t3tools/client-runtime/state/thread-sort";
|
||||
export { pinOrderKeyBetween } from "@t3tools/client-runtime/state/thread-sort";
|
||||
export { sortPinnedThreadsByOrderKey as sortPinnedThreadsForSidebar } from "@t3tools/client-runtime/state/thread-sort";
|
||||
|
||||
const EMPTY_CONTENT_MATCH_KEYS: ReadonlySet<string> = new Set<string>();
|
||||
|
||||
Reference in new issue
Block a user