diff --git a/client/tests/test_snapshot_parsing.gd b/client/tests/test_snapshot_parsing.gd index 3fd78c17e..cc414d805 100644 --- a/client/tests/test_snapshot_parsing.gd +++ b/client/tests/test_snapshot_parsing.gd @@ -7,13 +7,12 @@ extends GdUnitTestSuite var _valid_snapshot: Dictionary = { "tick": 1, "entities": [ - {"entity_id": 1, "x": 10.0, "y": 15.0, "z": 0, "kind": {"variant": "Npc", "data": null}}, + {"entity_id": 1, "x": 10.0, "y": 15.0, "z": 0, "kind": {"variant": "Player", "data": null}}, {"entity_id": 2, "x": 5.0, "y": 20.0, "z": 0, "kind": {"variant": "Npc", "data": null}}, ], } func test_apply_valid_snapshot() -> void: - GameState.player_entity_id = 1 GameState.apply_snapshot(_valid_snapshot) assert_that(GameState.current_tick).is_equal(1) @@ -32,17 +31,22 @@ func test_empty_snapshot_no_crash() -> void: assert_that(GameState.visible_entities.size()).is_equal(0) func test_no_player_entity_position_unchanged() -> void: - GameState.player_entity_id = 999 # No entity with this ID GameState.player_position = Vector2(5, 5) - GameState.apply_snapshot(_valid_snapshot) + # Snapshot with only NPCs — no Player entity, so position should not change + var npc_only_snapshot := { + "tick": 1, + "entities": [ + {"entity_id": 1, "x": 10.0, "y": 15.0, "z": 0, "kind": {"variant": "Npc", "data": null}}, + ], + } + GameState.apply_snapshot(npc_only_snapshot) - # Position stays at previous value since no matching entity + # Position stays at previous value since no Player entity found assert_that(GameState.player_position).is_equal(Vector2(5, 5)) func test_missing_fields_partial_update() -> void: - # First apply valid snapshot - GameState.player_entity_id = 1 + # First apply valid snapshot (contains Player entity at 10,15) GameState.apply_snapshot(_valid_snapshot) assert_that(GameState.player_position).is_equal(Vector2(10, 15))