Commit 37e02ea
committed
test(dogfood): identify the demotion history row by what it records, not its position (#4586)
The Dogfood Regression Gate failed on this file's own new assertion:
expected '{"role":"admin"}' to contain 'member'
Not a defect in what `trackHistory` stores — the audit writer's `update` leg
writes a CHANGED-FIELDS DIFF, `old_value` the before-state and `new_value` the
after-state (`diff()` in `audit-writers.ts` fills both halves), so a demotion
really is recorded as `{"role":"admin"}` → `{"role":"member"}`. The audit
question "who changed X from member to admin" was already answerable; #4586
adds WHO to a row that already knew WHAT.
The defect was the TEST's row SELECTION. It took `rows[rows.length - 1]` as
"the newest row", which is wrong twice over:
1. `find` without an explicit sort is unordered, so the last element is not
the newest anything;
2. the audit row lands ASYNCHRONOUSLY after the endpoint returns, so at the
moment the demotion test polled, the only `update` row present was the
PROMOTION from the earlier test — and it asserted the demotion's
expectation against it.
Locally green, red in CI, because `packages/qa/dogfood` sits outside the
`--filter` scope the change was verified under.
`waitForHistoryMatching` now waits for the row that says the thing under test,
so both hazards are gone. The demotion case additionally pins the pair
(`old_value` admin → `new_value` member) and asserts the promotion survives as
a DISTINCT row keeping its own actor.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012C2cd7tL8QDoZ2QKN3djJ51 parent be6967e commit 37e02ea
1 file changed
Lines changed: 51 additions & 7 deletions
Lines changed: 51 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
72 | 93 | | |
73 | | - | |
74 | | - | |
| 94 | + | |
| 95 | + | |
75 | 96 | | |
76 | 97 | | |
77 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
78 | 103 | | |
79 | 104 | | |
80 | 105 | | |
| |||
246 | 271 | | |
247 | 272 | | |
248 | 273 | | |
249 | | - | |
250 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
251 | 285 | | |
252 | 286 | | |
253 | 287 | | |
254 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
255 | 299 | | |
256 | 300 | | |
257 | 301 | | |
| |||
0 commit comments