fix(client): PR #135 review — T1/T3/H4-H7 blocking + nits

Code changes addressing PR #135 review (Tyre + Hoshe):

- **T3 (blocking):** test_merge_path_flows_sprint37.gd `_load_main_menu`
  and `_load_char_create` now assert the scene loaded instead of silently
  returning. Missing .tscn → red test, not falsely green.
- **T1:** sim_bridge.gd signal `handshake_complete(protocol_version: int)`
  was D-192 residue with no listeners. Drop the int parameter entirely
  and the literal-0 emit.
- **H4:** test_new_game_catalog_snapshot_resolves_loading_state now
  asserts SimBridge.state == CONNECTED terminus, not just the loading
  flag — guarantees full flow completion, not merely flag-clear.
- **H5:** test_protocol_bridge.gd file-level comment refreshed; drops
  reference to removed protocol-version check tests.
- **H6:** test_p0_regressions.gd `_make_snapshot_bytes` comment refreshed
  and version field removed from fixture dict (D-192: not required).
- **H7:** test_merge_path_flows_sprint37.gd `_make_catalog_snapshot`
  drops version field from fixture dict (D-192).

Follow-up tickets filed for reviewer suggestions:
- **T2:** #889 — revive EntityRenderer sprite constants coverage
  (D-044 ENTITY_WIDTH/HEIGHT, asserted by deleted test_sprite_integration).
- **T4:** #890 — UI timeout fallback for bookmark catalog wait in
  main_menu (systemic 'catalog never arrives' class beyond #872's
  TCP-batch race).
- **T5/T6:** #891 — scene-flow test tier docs + test-only reset
  helpers (SimBridge.reset_for_test, MetaStack.reset_for_test) +
  minimal public API on scenes so UI refactors don't break all four
  flow tests simultaneously.

Verification:
- `make lint-client` — no script errors
- `gdlint client/scripts/ client/ui/` — no problems
- `make test-client` — 2428/2488 passing. 60 remaining failures are
  pre-existing, unrelated to sprint 37 (test_dialogue_sprint20 #558
  signals, test_input_roundtrip integration-sans-server, etc.).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-22 10:06:39 +02:00
co-authored by Claude Opus 4.7
parent 469377caa6
commit 60733738f2
4 changed files with 26 additions and 14 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ extends Node
# Signals
signal connection_state_changed(old_state: ConnectionState, new_state: ConnectionState)
signal snapshot_received(snapshot: Dictionary)
signal handshake_complete(protocol_version: int)
signal handshake_complete
signal handshake_failed(reason: String)
# Connection states
@@ -281,7 +281,7 @@ func _process(delta: float) -> void: # gdlint:disable=max-returns
_set_state(ConnectionState.ERROR)
return
handshake_complete.emit(0) # D-192: protocol_version field dropped; signal kept for API compat
handshake_complete.emit()
_set_state(ConnectionState.CONNECTED)
# #646: Request full settings dump on connect — hydrates GameState.ai_enhanced_dialogue_enabled
# from server SQLite so the client reflects the authoritative persisted state (D-138).
+18 -7
View File
@@ -49,18 +49,22 @@ func after_test() -> void:
func _load_main_menu() -> void:
var packed := load(MAIN_MENU_SCENE_PATH) as PackedScene
if packed == null:
push_warning("TestMergePathFlowsSprint37: main_menu.tscn not found — skipping")
return
# Hard-fail on missing scene (PR #135 review T3): silent skip turns a broken
# merge-path test into a uselessly green one.
assert_that(packed).override_failure_message(
"main_menu.tscn missing — merge-path coverage is broken, not skipped"
).is_not_null()
_scene = packed.instantiate()
add_child(_scene)
func _load_char_create() -> void:
var packed := load(CHAR_CREATE_SCENE_PATH) as PackedScene
if packed == null:
push_warning("TestMergePathFlowsSprint37: character_creation.tscn not found — skipping")
return
# Hard-fail on missing scene (PR #135 review T3): silent skip turns a broken
# merge-path test into a uselessly green one.
assert_that(packed).override_failure_message(
"character_creation.tscn missing — merge-path coverage is broken, not skipped"
).is_not_null()
_scene = packed.instantiate()
# Seed required state so Start is not disabled (guard added in PR #134 / R2-Hoshe-1).
# Individual tests override these as needed. add_child() must run first so
@@ -75,9 +79,9 @@ func _load_char_create() -> void:
func _make_catalog_snapshot() -> Dictionary:
## Minimal valid snapshot with a bookmark_catalog for flow-1 testing.
## D-192: no version field required; decode accepts snapshots with or without.
return {
"tick": 0,
"version": 23,
"entities": [],
"game_time": {"day": 0, "time_of_day": 0, "day_phase": "Morning", "tick_rate": "Full"},
"player_facing": "North",
@@ -164,6 +168,13 @@ func test_new_game_catalog_snapshot_resolves_loading_state() -> void:
assert_bool(_scene._waiting_for_catalog).override_failure_message(
"_waiting_for_catalog must be false after catalog snapshot delivered — #872 regression"
).is_false()
# PR #135 review H4: assert the SimBridge terminus, not just the loading flag.
# In test mode connect_to_sim() jumps state to CONNECTED synchronously; this
# guarantees the flow reached its terminal state, not merely that the catalog
# flag cleared.
assert_int(SimBridge.state).override_failure_message(
"SimBridge must be in CONNECTED terminus after catalog resolves — flow completion guard"
).is_equal(SimBridge.ConnectionState.CONNECTED)
assert_bool(GameState.bookmark_catalog.size() > 0).override_failure_message(
"GameState.bookmark_catalog must be populated after catalog snapshot applied"
).is_true()
+4 -3
View File
@@ -43,12 +43,13 @@ func after_test() -> void:
# -- Helpers -------------------------------------------------------------------
## Encode a minimal valid snapshot as MessagePack bytes.
## Protocol.decode_snapshot() requires: tick, version, entities (with kind as
## bare string for unit enum variants per rmp_serde wire format).
## Protocol.decode_snapshot() requires: tick, entities (with kind as bare string
## for unit enum variants per rmp_serde wire format). D-192 dropped the version
## field — kept here inertly in existing fixtures so decode still accepts either
## shape while older tests migrate.
func _make_snapshot_bytes(overrides: Dictionary = {}) -> PackedByteArray:
var snapshot := {
"tick": overrides.get("tick", 1),
"version": 23,
"entities": overrides.get("entities", [{
"entity_id": 1,
"x": 10.0,
+2 -2
View File
@@ -1,8 +1,8 @@
## D-030 Layer 1: Protocol bridge tests for ObserverSnapshot features.
## Validates player_stance (D-053) and player_inventory (D-065) decode,
## GameState storage, SimBridge test mode, input encoding for stance toggles,
## protocol version checks, and fixture round-trips.
## Spec refs: D-053, D-065, D-020, #449
## and fixture round-trips. Protocol version checks removed per D-192.
## Spec refs: D-053, D-065, D-020, #449, D-192
class_name TestProtocolBridge
extends GdUnitTestSuite