NEO-142: review follow-up — static faction display names + gate rules tests
Use FactionStandingClient.display_name_for directly; add GdUnit coverage for faction_gate_rules_for helper.pull/182/head
parent
187ecc9c0d
commit
00590d5944
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue