Commit 0f12799
authored
fix(folders): stop archived rows skewing sortOrder, hide them from admin, and cover the two untested modules (#6062)
* fix(folders): stop archived rows skewing sortOrder, hide them from admin, and cover the two untested modules
nextFolderSortOrder returned min - 1 over ALL rows including soft-deleted ones,
so every delete ratcheted the floor further negative and never recovered — an
archived folder at -400 forced the next new folder to -401 forever. Both minima
(folders and child resources) now see only rows a user can still see, which is
how the Files path has always worked.
The admin workspace-folders endpoint counted and paginated soft-deleted folders,
so an operator saw phantom folders and an inflated total, disagreeing with every
user-facing list.
Adds naming.test.ts and queries.test.ts. Both modules had zero tests and are
mocked at every call site, so their bodies executed in no test anywhere. That
left unasserted the two bug classes that caused real defects in the folder
migration: the suffix sequence (must start at (1) and skip taken suffixes) and
resourceType scoping on the id-keyed lookups, where a missing clause silently
files a knowledge base under a table folder.
Every assertion is mutation-checked. The first version of the sortOrder test was
vacuous — for a root folder the parent condition is itself an isNull node, so a
presence-only check passed with the soft-delete filter deleted; it now asserts
the specific column.
* refactor(testing): share the drizzle condition-tree helpers
Asserting on WHERE clauses is the only way to pin a filter the row-queue mocks
cannot enforce — a mock returns whatever was queued regardless of the predicate
— so this pattern spreads to every test that guards a query's scoping. It had
reached five local copies of the same flatten/has pair, four of them added by
the tests in this branch.
Moved to @sim/testing beside createMockSqlOperators, whose output shape they
parse, so the helper and the node types it depends on live together.1 parent 4793607 commit 0f12799
9 files changed
Lines changed: 500 additions & 36 deletions
File tree
- apps/sim
- app/api/v1/admin/workspaces/[id]/folders
- lib/folders
- packages/testing/src/mocks
Lines changed: 80 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
Lines changed: 15 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
49 | 61 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 62 | + | |
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
59 | | - | |
60 | | - | |
61 | | - | |
| 66 | + | |
62 | 67 | | |
63 | 68 | | |
64 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | 85 | | |
102 | 86 | | |
103 | 87 | | |
| |||
138 | 122 | | |
139 | 123 | | |
140 | 124 | | |
141 | | - | |
| 125 | + | |
142 | 126 | | |
143 | 127 | | |
144 | 128 | | |
| |||
150 | 134 | | |
151 | 135 | | |
152 | 136 | | |
153 | | - | |
154 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
155 | 141 | | |
156 | 142 | | |
157 | 143 | | |
| |||
169 | 155 | | |
170 | 156 | | |
171 | 157 | | |
172 | | - | |
| 158 | + | |
173 | 159 | | |
174 | 160 | | |
175 | 161 | | |
| |||
230 | 216 | | |
231 | 217 | | |
232 | 218 | | |
233 | | - | |
| 219 | + | |
234 | 220 | | |
235 | 221 | | |
236 | 222 | | |
| |||
299 | 285 | | |
300 | 286 | | |
301 | 287 | | |
302 | | - | |
| 288 | + | |
303 | 289 | | |
304 | 290 | | |
305 | 291 | | |
| |||
353 | 339 | | |
354 | 340 | | |
355 | 341 | | |
356 | | - | |
| 342 | + | |
357 | 343 | | |
358 | 344 | | |
359 | 345 | | |
| |||
373 | 359 | | |
374 | 360 | | |
375 | 361 | | |
376 | | - | |
| 362 | + | |
377 | 363 | | |
378 | 364 | | |
379 | 365 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
233 | 271 | | |
234 | 272 | | |
235 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
131 | 138 | | |
132 | 139 | | |
133 | 140 | | |
134 | 141 | | |
135 | 142 | | |
136 | 143 | | |
137 | 144 | | |
138 | | - | |
| 145 | + | |
| 146 | + | |
139 | 147 | | |
140 | 148 | | |
141 | 149 | | |
| |||
147 | 155 | | |
148 | 156 | | |
149 | 157 | | |
| 158 | + | |
150 | 159 | | |
151 | 160 | | |
152 | 161 | | |
| |||
0 commit comments