Skip to content

Conversation

@S1M0N38
Copy link
Collaborator

@S1M0N38 S1M0N38 commented Jan 21, 2026

I'd like to have a better testing for the gamestate object generate by all endpoints.
Maybe some tests are redundant but I'd like to have a set of tests that I can use if I need to change something in the src/lua/utils/gamestate.lua. These new tests are specific to test the gamestate dict generated.

  • TestGamestateTopLevel
  • TestGamestateRound
  • TestGamestateBlinds
  • TestGamestateAreas
  • TestGamestateCards
  • TestGamestateCardValue
  • TestGamestateCardModifier
  • TestGamestateCardState
  • TestGamestateCardCost
  • TestGamestateHands
  • TestGamestateVouchers
  • TestGamestatePhaseSpecific (?)

@S1M0N38 S1M0N38 marked this pull request as ready for review January 22, 2026 16:28
Copilot AI review requested due to automatic review settings January 22, 2026 16:28
@S1M0N38
Copy link
Collaborator Author

S1M0N38 commented Jan 22, 2026

We delay the other tests for future release. the stuff for the #145 are tested

@S1M0N38 S1M0N38 merged commit 505f73d into main Jan 22, 2026
8 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR significantly enhances testing for the gamestate object returned by Lua endpoints. The changes add comprehensive test coverage for gamestate structure validation, including top-level fields, rounds, blinds, areas, and card properties. Additionally, the PR includes important refactoring to the gamestate utility to prevent memory leaks by properly cleaning up UI nodes.

Changes:

  • Added 800+ lines of comprehensive tests for gamestate object structure and fields
  • Introduced new test fixtures to support various game states
  • Refactored get_card_ui_description() to avoid hover side effects and prevent memory leaks by cleaning up DynaText objects

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.

File Description
tests/lua/endpoints/test_gamestate.py Added extensive test classes covering gamestate top-level fields, rounds, blinds, areas (jokers, consumables, cards, hand, pack, shop, vouchers, packs), and card properties (id, key, set, label, value, modifier, state, cost)
tests/fixtures/fixtures.json Added new fixtures for various game states (BLIND_SELECT, SELECTING_HAND, SHOP, SMODS_BOOSTER_OPENED) to support new tests
src/lua/utils/gamestate.lua Added cleanup_ui_nodes() function to prevent memory leaks, refactored get_card_ui_description() to avoid hover side effects, and fixed spelling error

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fixture_name = "state-BLIND_SELECT--deck-BLUE--stake-RED"
load_fixture(client, "gamestate", fixture_name)
response = api(client, "set", {"money": 42})
assert response["result"]["seed"] == "TEST123"
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The test docstring says "Test money field after using set to modify it" but the assertion is checking the "seed" field instead of the "money" field. The assertion should be checking that the money was set to 42.

Suggested change
assert response["result"]["seed"] == "TEST123"
assert response["result"]["money"] == 42

Copilot uses AI. Check for mistakes.
Comment on lines +361 to +362
reponse = api(client, "buy", {"card": 0})
assert reponse["result"]["shop"]["count"] == 1
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

Misspelled variable name "reponse" should be "response".

Copilot uses AI. Check for mistakes.
Comment on lines +386 to +387
reponse = api(client, "buy", {"voucher": 0})
assert reponse["result"]["vouchers"]["count"] == 0
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

Misspelled variable name "reponse" should be "response".

Copilot uses AI. Check for mistakes.
assert response["result"]["round_num"] == 5

def test_won_false_extraction(self, client: httpx.Client) -> None:
"""Test won field after defeating ante 8 boss."""
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The docstring says "Test won field after defeating ante 8 boss" but the test is checking that the won field is False at the start of the run in BLIND_SELECT state, not after defeating a boss. The docstring should describe what the test actually does, such as "Test won field is false at start of run" or "Test won field before winning the game".

Suggested change
"""Test won field after defeating ante 8 boss."""
"""Test won field is False at start of run in BLIND_SELECT state."""

Copilot uses AI. Check for mistakes.
Comment on lines +72 to +77
def test_round_num_extractions(self, client: httpx.Client) -> None:
"""Test round_num field after using `set` to modify it."""
fixture_name = "state-BLIND_SELECT--deck-BLUE--stake-RED"
load_fixture(client, "gamestate", fixture_name)
response = api(client, "set", {"round": 5})
assert response["result"]["round_num"] == 5
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

Inconsistent naming: method name uses "extractions" (plural) but should use "extraction" (singular) to match other test method names like test_deck_extraction, test_stake_extraction, etc.

Copilot uses AI. Check for mistakes.
Comment on lines +409 to +410
reponse = api(client, "buy", {"pack": 0})
assert reponse["result"]["packs"]["count"] == 1
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

Misspelled variable name "reponse" should be "response".

Copilot uses AI. Check for mistakes.
Comment on lines +65 to +72
def test_ante_num_extractions(self, client: httpx.Client) -> None:
"""Test ante_num field after using `set` to modify it."""
fixture_name = "state-BLIND_SELECT--deck-BLUE--stake-RED"
load_fixture(client, "gamestate", fixture_name)
response = api(client, "set", {"ante": 5})
assert response["result"]["ante_num"] == 5

def test_round_num_extractions(self, client: httpx.Client) -> None:
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

Inconsistent naming: method name uses "extractions" (plural) but should use "extraction" (singular) to match other test method names like test_deck_extraction, test_stake_extraction, etc.

Suggested change
def test_ante_num_extractions(self, client: httpx.Client) -> None:
"""Test ante_num field after using `set` to modify it."""
fixture_name = "state-BLIND_SELECT--deck-BLUE--stake-RED"
load_fixture(client, "gamestate", fixture_name)
response = api(client, "set", {"ante": 5})
assert response["result"]["ante_num"] == 5
def test_round_num_extractions(self, client: httpx.Client) -> None:
def test_ante_num_extraction(self, client: httpx.Client) -> None:
"""Test ante_num field after using `set` to modify it."""
fixture_name = "state-BLIND_SELECT--deck-BLUE--stake-RED"
load_fixture(client, "gamestate", fixture_name)
response = api(client, "set", {"ante": 5})
assert response["result"]["ante_num"] == 5
def test_round_num_extraction(self, client: httpx.Client) -> None:

Copilot uses AI. Check for mistakes.
assert gamestate["blinds"]["big"]["status"] == "SKIPPED"
assert gamestate["blinds"]["boss"]["status"] == "SELECT"

def test_blinds_progession_extraction(self, client: httpx.Client) -> None:
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

Misspelled word "progession" should be "progression".

Suggested change
def test_blinds_progession_extraction(self, client: httpx.Client) -> None:
def test_blinds_progression_extraction(self, client: httpx.Client) -> None:

Copilot uses AI. Check for mistakes.
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.

1 participant