fix(client): align tests with kind-based player detection
Tests used entity_id matching to find the player, but game_state now finds the player by kind.variant == "Player". Update test fixture to include a Player entity and remove stale player_entity_id assignments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user