Conversation
WalkthroughPack entries now include a non-negative ChangesCosmetic pack bonus display
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/core/CosmeticSchemas.ts (1)
82-87:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAdd tests for the PackSchema changes.
This change modifies a core schema but includes no tests. Per coding guidelines: "All changes to
src/core/must include tests."Add validation tests covering:
- Pack with
bonusAmount: 0(valid)- Pack with
bonusAmount: 100(valid)- Pack with
bonusAmount: -1(should fail — negative)- Pack with
bonusAmount: 1.5(should fail — not an integer)- Pack without
bonusAmount(should fail — required field)Follow the pattern used in existing schema tests like
tests/client/clan/ClanApiSchemas.test.ts, using.safeParse()and checkingresult.success.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/core/CosmeticSchemas.ts` around lines 82 - 87, Add unit tests for PackSchema in the test suite mirroring existing schema tests (e.g., tests/client/clan/ClanApiSchemas.test.ts): import PackSchema from CosmeticSchemas and use PackSchema.safeParse() to assert success for bonusAmount: 0 and bonusAmount: 100, and assert failure for bonusAmount: -1 (negative), bonusAmount: 1.5 (non-integer), and when bonusAmount is omitted (required). Name the new test file under the same tests directory, use clear test cases for each scenario, and assert result.success accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/core/CosmeticSchemas.ts`:
- Line 86: The schema currently defines bonusAmount as a required field
(bonusAmount: z.number().int().nonnegative()) which contradicts the PR and
breaks validation for existing packs without it; change the Zod schema for
bonusAmount in CosmeticSchemas.ts to be optional or provide a default
(recommended) so existing data passes validation—either make bonusAmount
optional (e.g., bonusAmount: z.number().int().nonnegative().optional()) or
supply a default value via z.default(...) so callers/UI don’t need extra null
checks.
---
Outside diff comments:
In `@src/core/CosmeticSchemas.ts`:
- Around line 82-87: Add unit tests for PackSchema in the test suite mirroring
existing schema tests (e.g., tests/client/clan/ClanApiSchemas.test.ts): import
PackSchema from CosmeticSchemas and use PackSchema.safeParse() to assert success
for bonusAmount: 0 and bonusAmount: 100, and assert failure for bonusAmount: -1
(negative), bonusAmount: 1.5 (non-integer), and when bonusAmount is omitted
(required). Name the new test file under the same tests directory, use clear
test cases for each scenario, and assert result.success accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 01d995ca-d340-40d9-b7bb-bb06848515a5
📒 Files selected for processing (3)
resources/lang/en.jsonsrc/client/components/CosmeticButton.tssrc/core/CosmeticSchemas.ts
Description:
Show bonus amount on currency packs
bonusAmountfield toPackSchema(non-negative int)+X FREE!) on pack tiles whenbonusAmount > 0cosmetics.freetranslation key withnumFreeparamDescribe the PR.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
evan