plugin: Add unit tests for StateChip and allocation utility#10
plugin: Add unit tests for StateChip and allocation utility#10NAME-ASHWANIYADAV wants to merge 2 commits into
Conversation
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>
| }); | ||
|
|
||
| // Unknown / unmapped states should not crash (fallback to 'default') | ||
| it.each(['PortAllocation', 'Starting', 'SomeUnknownState', ''])( |
There was a problem hiding this comment.
It might be out of the scope of these unit tests, but I would probably add the PortAllocation and Starting as info from the stateChip.tsx to match all the states (maybe also the created / deleted, not fully sure about these ones)
https://agones.dev/site/docs/reference/gameserver/#gameserver-state-diagram
WDYT ?
There was a problem hiding this comment.
At the same time I just seen your comment L 21-24, I'd say let's map them and add a unit test for a case which doesn't exist ?
There was a problem hiding this comment.
I have mapped PortAllocation and Starting as info in StateChip.tsx and moved them into the info test group.
The fallback test now only covers states that don't actually exist in Agones. Thanks for the pointer to the state diagram 👍
Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
Type of change
What this PR does
Adds the project's first unit tests using Vitest:
map to correct chip colors, including graceful fallback for unmapped states.
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 tscnpm run lint