NEO-151: Loop contract reset helper until capped GET is empty

Bugbot: Bruno pre-request cleanup now clears all contract instances,
not just the first active + 10 completed page from GET /contracts.
pull/193/head
VinPropane 2026-06-28 11:07:47 -04:00
parent 0888262f13
commit 5f2ab34fa2
2 changed files with 33 additions and 18 deletions

View File

@ -4,6 +4,10 @@ async function resetAllContractInstances(bru) {
const playerId = bru.getEnvVar("playerId") || bru.getVar("playerId");
const jsonHeaders = { headers: { "Content-Type": "application/json" } };
// GET is capped (active + 10 completed); loop until no rows remain so older
// completed instances outside the first page are cleared too.
const maxPasses = 100;
for (let pass = 0; pass < maxPasses; pass += 1) {
const listResponse = await axios.get(
`${baseUrl}/game/players/${playerId}/contracts`,
jsonHeaders,
@ -27,4 +31,9 @@ async function resetAllContractInstances(bru) {
);
}
throw new Error(
`resetAllContractInstances exceeded ${maxPasses} passes; contract list may still be non-empty`,
);
}
module.exports = { resetAllContractInstances };

View File

@ -47,6 +47,12 @@ None.
- ~~Nit: **`GetContracts_ShouldReturnCompletionRewardSummary_WhenContractCompletedAfterEncounterClear`** invokes **`TryCompleteOnEncounterClear`** under **`// Act`** before the GET — consider moving completion into **`// Arrange`** so Act is HTTP-only (AAA clarity).~~ **Done.**
- ~~Nit: Plan §1 Postgres snippet mentions **`completed_at DESC`** but kickoff + README + implementation use **`issuedAt` desc** — update the plan technical section on merge to remove the stale SQL note (implementation is correct).~~ **Done.**
## Bugbot (PR #193)
| Severity | Location | Finding | Status |
|----------|----------|---------|--------|
| Low | `reset-contract-instances-helper.js:27` | Reset helper only cleared one capped GET page (active + 10 completed); older rows could survive pre-request cleanup | **Done.** — loop GET → reset until list empty (max 100 passes) |
## Verification
```bash