From 00590d59442b8a29748c18f8099df6b39219371a Mon Sep 17 00:00:00 2001 From: VinPropane Date: Wed, 17 Jun 2026 21:16:17 -0400 Subject: [PATCH] =?UTF-8?q?NEO-142:=20review=20follow-up=20=E2=80=94=20sta?= =?UTF-8?q?tic=20faction=20display=20names=20+=20gate=20rules=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use FactionStandingClient.display_name_for directly; add GdUnit coverage for faction_gate_rules_for helper. --- client/scripts/quest_hud_controller.gd | 5 --- client/test/quest_definitions_client_test.gd | 39 ++++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/client/scripts/quest_hud_controller.gd b/client/scripts/quest_hud_controller.gd index 82a3323..cffb00e 100644 --- a/client/scripts/quest_hud_controller.gd +++ b/client/scripts/quest_hud_controller.gd @@ -317,11 +317,6 @@ func _faction_gate_rules_for(quest_id: String) -> Array: func _faction_display_name(faction_id: String) -> String: - if ( - is_instance_valid(_faction_standing_client) - and _faction_standing_client.has_method("display_name_for") - ): - return str(_faction_standing_client.call("display_name_for", faction_id)) return FactionStandingClient.display_name_for(faction_id) diff --git a/client/test/quest_definitions_client_test.gd b/client/test/quest_definitions_client_test.gd index 65d4cfd..47ffce5 100644 --- a/client/test/quest_definitions_client_test.gd +++ b/client/test/quest_definitions_client_test.gd @@ -52,6 +52,16 @@ static func _four_quests_json() -> String: ) +static func _grid_contract_quests_json() -> String: + return ( + '{"schemaVersion":1,"quests":[' + + '{"id":"prototype_quest_grid_contract","displayName":"Grid Contract",' + + '"prerequisiteQuestIds":["prototype_quest_operator_chain"],' + + '"factionGateRules":[{"factionId":"prototype_faction_grid_operators","minStanding":15}],' + + '"steps":[]}]}' + ) + + func _make_client(transport: Node) -> Node: var c: Node = QuestDefinitionsClient.new() c.set("injected_http", transport) @@ -111,3 +121,32 @@ func test_display_name_for_falls_back_to_raw_id() -> void: var name: String = str(c.call("display_name_for", "unknown_quest_id")) # Assert assert_that(name).is_equal("unknown_quest_id") + + +func test_faction_gate_rules_for_returns_cached_gate_rows() -> void: + # Arrange + var transport := MockHttpTransport.new() + transport.body_json = _grid_contract_quests_json() + var c := _make_client(transport) + c.call("request_sync_from_server") + await get_tree().process_frame + # Act + var rules: Array = c.call("faction_gate_rules_for", "prototype_quest_grid_contract") as Array + # Assert + assert_that(rules.size()).is_equal(1) + var rule: Dictionary = rules[0] + assert_that(str(rule.get("factionId", ""))).is_equal("prototype_faction_grid_operators") + assert_that(int(rule.get("minStanding", -1))).is_equal(15) + + +func test_faction_gate_rules_for_returns_empty_when_quest_missing() -> void: + # Arrange + var transport := MockHttpTransport.new() + transport.body_json = _grid_contract_quests_json() + var c := _make_client(transport) + c.call("request_sync_from_server") + await get_tree().process_frame + # Act + var rules: Array = c.call("faction_gate_rules_for", "prototype_quest_gather_intro") as Array + # Assert + assert_that(rules.is_empty()).is_true()