Skip to content

test: cover Humans Vs Nations buckets in the profile stats tree schema - #4904

Closed
evanpelle wants to merge 1 commit into
mainfrom
hvn-profile-stats-regression-tests
Closed

test: cover Humans Vs Nations buckets in the profile stats tree schema#4904
evanpelle wants to merge 1 commit into
mainfrom
hvn-profile-stats-regression-tests

Conversation

@evanpelle

Copy link
Copy Markdown
Collaborator

Summary

Regression tests for the production parse failure where fetchPlayerById rejected any profile carrying Humans vs Nations games:

fetchPlayerById: Zod validation failed ... path: ["stats", "Public", "Humans Vs Nations"] "Invalid input"

The API buckets HvN games under a "Humans Vs Nations" key in the profile stats tree, but GameModeStatsSchema used to key the record with z.enum(GameMode) (only Free For All / Team), so the whole profile parse failed and the profile came up empty. #4873 already fixed the schema by introducing PlayerStatsGameModes; this PR pins that behavior so it can't regress:

  • a profile with "Humans Vs Nations" buckets under Public and Private (the exact failing prod payload shape) parses, and the leaf bigints come through
  • a genuinely unknown mode bucket ("Battle Royale") is still rejected

Test plan

  • npx vitest tests/ApiSchemas.test.ts --run — 131 passed

🤖 Generated with Claude Code

Production profiles with HvN games failed the whole PlayerProfileSchema
parse until #4873 widened the stats record key beyond z.enum(GameMode).
Pin that behavior: HvN buckets under Public/Private parse (the exact
failing prod payload shape), and unknown mode keys are still rejected.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 13d96725-ee4d-4b62-bf8e-b3fe9bc69e49

📥 Commits

Reviewing files that changed from the base of the PR and between f01aaf9 and 0416bf4.

📒 Files selected for processing (1)
  • tests/ApiSchemas.test.ts

Walkthrough

The PR adds PlayerProfileSchema regression tests for supported nested stats buckets, bigint coercion, and rejection of unknown mode buckets.

Changes

Player profile schema tests

Layer / File(s) Summary
Stats bucket validation
tests/ApiSchemas.test.ts
Tests accept "Humans Vs Nations" in public and private stats, parse string win counts as bigint, and reject the unknown "Battle Royale" bucket.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: ryanbarlow97, iiamlewis

Poem

Stats find their proper place,
Bigints guard each winning trace.
Known modes pass through the gate,
Unknown battles meet their fate.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes regression tests for Humans Vs Nations profile-stat buckets.
Description check ✅ Passed The description directly explains the regression tests, schema behavior, rejected unknown modes, and test results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

1 participant