Repository navigation
test(aimlapi): consolidate malformed lease-receipt tests into one table - #2327
Conversation
jatmn
left a comment
There was a problem hiding this comment.
— jatmn's PR Review agent
Head: 4eb59f43a65f7a91115eac7b15dd43e7d93f55df
Range reviewed: 78445348676d6c5797fc11d89eaaf0157d69de1b..4eb59f43a65f7a91115eac7b15dd43e7d93f55df (one commit, one file)
Merge readiness
- Scope: Surgical and standalone — only
src/integrations/aimlapi/topupState.test.tschanges; no production, docs, or workflow drift. Fits an upgrade-plan test-audit slice. - Branch freshness: Head is 2 commits behind live
main(19bb39c8845a6920bb04ad8d70652ad520861b87). GitHub reportsmergeable: truewithmergeable_state: blocked(typical for required checks / branch policy). Rebase before merge if your stack requires a linear history on currentmain. - CI at head (
4eb59f43): All 21 check runs completed — 20 success, web skipped. Includestypecheck,smoke-and-tests,dedicated-tests, all eightunit-testsshards, launcher compatibility,pr-intent-scan, and CodeQL / CodeQL (javascript-typescript) / Analyze (javascript-typescript) success. Commit status context CodeRabbit: success.
Consolidation verification (requested)
| # | Row label (head) | Lease field | Owner fixture | Timestamp fixture | Asserted function | Oracle |
|---|---|---|---|---|---|---|
| 1 | exchangeLease / malformed owner | exchangeLease |
12345 |
Date.now() via 'now' |
claimAimlapiTopupState |
/does not match the expected format/ |
| 2 | exchangeLease / malformed timestamp | exchangeLease |
'some-owner' |
'not-a-number' |
same | same |
| 3 | exchangeLease / missing timestamp | exchangeLease |
'some-owner' |
field deleted | same | same |
| 4 | exchangeLease / missing owner | exchangeLease |
field deleted | Date.now() via 'now' |
same | same |
| 5–8 | keyMintLease / … | keyMintLease |
(same four patterns) | (same) | same | same |
- Fixtures one-to-one: Each row matches the corresponding merge-base test title and seeded JSON (
*Owner/*Atmutations). Using'now'→Date.now()at write time is equivalent to the prior inlineDate.now()calls. - Per-case extras: The eight lease tests never asserted receipt bytes, lock cleanup, or a second throw (unlike the schema-validation test immediately above, which still does). Nothing was dropped from these cases.
- Function coverage: Every row still calls
claimAimlapiTopupState({ ...intent, amountUsdMinor: 5000 })afteruseTemporaryConfig→ claim →saveAimlapiTopupState→ corrupt file — same setup as merge-base. - Regression signal:
bun test src/integrations/aimlapi/topupState.test.ts— 75 pass, 219expect()calls on merge-base and head; filteredmalformed lease pairs— 8/8 on head. Removing fail-closed validation would fail these rows.
Minor PR-description drift (not a code finding): Inline comments explaining fail-closed vs isLeaseLive were removed; row labels name scenarios but do not fully replace that prose.
Automated review audit
| Source | Status | Action |
|---|---|---|
| CodeRabbit | Issue comment shows review in progress on this head; no inline review comments on the diff. Commit status success. | No unaddressed actionable findings to promote. |
| CodeQL | At head: analysis checks success. (Earlier snapshot had a neutral aggregate warning about a missing javascript-typescript config on the PR ref; live head runs completed green.) |
Drift only — not a PR defect; no open CodeQL alert tied to this hunk. |
Value recommendation
Keep (modest, real value — not churn). The refactor removes four near-copied loop bodies, keeps eight independent registrations and the same oracles, and makes adding a ninth malformed lease case a one-line table edit. Benefit is maintainability inside a deliberate test-audit pass, not new coverage — but the consolidation is faithful and low risk.
Outcome
🟢 Thanks for the contribution. I do not see any actionable issues from my review.
Summary
src/integrations/aimlapi/topupState.test.ts(aforloop overexchangeLease/keyMintLeasethat declared four near-identical test bodies each) into onetest.eachtable,malformed lease pairs fail closed: %s. All eight cases stay independently registered with the same fixture values and the same/does not match the expected format/assertion.topupState.test.tsliteral matrices, keep the client/transport/onboarding integration boundaries and thetopup.test.tsparse/validation table.Impact
src/integrations/models/aimlapi.ts, so no model capability/limit table applies to this slice, and no removed-model deny-list existed here to keep.Tests: 177 registered before, 177 after (topupState.test.ts: 75 to 75 registered, 71 to 68 declarations). No tests removed.
Loosened assertions: none. The two inline comments explaining the non-string owner and one-sided pair cases were folded into the table row labels.
Testing
bun test --isolate src/integrations/aimlapi/*.test.ts: 177 pass, 0 failbun run integrations:check: passbun run typecheck: passbun run check: pass (all shards exit 0)src/integrations/aimlapi/topupState.test.tsNotes
Summary by CodeRabbit