| ... | ... | @@ -117,56 +117,6 @@ describe("sortThreads", () => { |
| 117 | 117 | ]); |
| 118 | 118 | }); |
| 119 | 119 | |
| 120 | | it("falls back to createdAt when updatedAt is invalid", () => { |
| 121 | | const sorted = sortThreads( |
| 122 | | [ |
| 123 | | makeThread({ |
| 124 | | id: ThreadId.make("thread-1"), |
| 125 | | createdAt: "2026-03-09T10:00:00.000Z", |
| 126 | | updatedAt: "invalid-date" as never, |
| 127 | | messages: [], |
| 128 | | }), |
| 129 | | makeThread({ |
| 130 | | id: ThreadId.make("thread-2"), |
| 131 | | createdAt: "2026-03-09T09:00:00.000Z", |
| 132 | | updatedAt: "2026-03-09T09:30:00.000Z", |
| 133 | | messages: [], |
| 134 | | }), |
| 135 | | ], |
| 136 | | "updated_at", |
| 137 | | ); |
| 138 | | |
| 139 | | expect(sorted.map((thread) => thread.id)).toEqual([ |
| 140 | | ThreadId.make("thread-1"), |
| 141 | | ThreadId.make("thread-2"), |
| 142 | | ]); |
| 143 | | }); |
| 144 | | |
| 145 | | it("falls back to id ordering when threads have no sortable timestamps", () => { |
| 146 | | const sorted = sortThreads( |
| 147 | | [ |
| 148 | | makeThread({ |
| 149 | | id: ThreadId.make("thread-1"), |
| 150 | | createdAt: "invalid-created-at" as never, |
| 151 | | updatedAt: "invalid-updated-at" as never, |
| 152 | | messages: [], |
| 153 | | }), |
| 154 | | makeThread({ |
| 155 | | id: ThreadId.make("thread-2"), |
| 156 | | createdAt: "invalid-created-at" as never, |
| 157 | | updatedAt: "invalid-updated-at" as never, |
| 158 | | messages: [], |
| 159 | | }), |
| 160 | | ], |
| 161 | | "updated_at", |
| 162 | | ); |
| 163 | | |
| 164 | | expect(sorted.map((thread) => thread.id)).toEqual([ |
| 165 | | ThreadId.make("thread-2"), |
| 166 | | ThreadId.make("thread-1"), |
| 167 | | ]); |
| 168 | | }); |
| 169 | | |
| 170 | 120 | it("can sort threads by createdAt when configured", () => { |
| 171 | 121 | const sorted = sortThreads( |
| 172 | 122 | [ |