Skip to content

plugin: Add unit tests for StateChip and allocation utility#10

Open
NAME-ASHWANIYADAV wants to merge 4 commits into
agones-dev:mainfrom
NAME-ASHWANIYADAV:test/statechip-and-allocation
Open

plugin: Add unit tests for StateChip and allocation utility#10
NAME-ASHWANIYADAV wants to merge 4 commits into
agones-dev:mainfrom
NAME-ASHWANIYADAV:test/statechip-and-allocation

Conversation

@NAME-ASHWANIYADAV

Copy link
Copy Markdown
Contributor

Type of change

  • 🚀 New feature / enhancement

What this PR does

Adds the project's first unit tests using Vitest:

  • StateChip (13 tests): Verifies all 11 Agones GameServer lifecycle states
    map to correct chip colors, including graceful fallback for unmapped states.
  • buildAllocationBody (15 tests): Validates the allocation payload builder
    with edge cases for label selectors, counter/list filters, mutations, and priorities.

28 tests total, all passing.

Test plan

Automated checks

  • npm run test (28 tests passing in ~2.6s)
  • npm run tsc
  • npm run lint

Comment thread src/components/StateChip.test.ts Outdated

@illume illume left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -21,7 +21,9 @@ type ChipColor = 'default' | 'primary' | 'secondary' | 'error' | 'info' | 'succe

const STATE_COLORS: Record<string, ChipColor> = {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add tsdocs to this and the fields.

Also using @see a link to the Agones docs for this object: Is it here? // https://agones.dev/site/docs/reference/gameserver/#gameserver-state-diagram

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added TSDocs for STATE_COLORS with a link to the Agones state diagram, and added descriptions for each state
Thanks for the review! 👍

@NAME-ASHWANIYADAV NAME-ASHWANIYADAV requested a review from illume June 15, 2026 12:07
Introduce robust unit tests for the StateChip component and the
buildAllocationBody utility using Vitest. This ensures that GameServer
lifecycle state colors map correctly and allocation payload generation
handles all form edge cases properly.

Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
@markmandel markmandel force-pushed the test/statechip-and-allocation branch from c8e1599 to e471f89 Compare June 16, 2026 02:53
@markmandel

Copy link
Copy Markdown
Member

Looks like we have a CI failure with your new CI setup! 😄 something to fix.

@NAME-ASHWANIYADAV

Copy link
Copy Markdown
Contributor Author

Looks like we have a CI failure with your new CI setup! 😄 something to fix.

🥀🥀

Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants