NEO-122: Surface quest accept in-flight and failed-start HUD feedback.

Show sending/busy/could-not-start copy on Q and Shift+Q accept paths and
lock the behavior with GdUnit key-input tests.
pull/161/head
VinPropane 2026-06-07 14:55:47 -04:00
parent bada3024c2
commit 5e146cd934
2 changed files with 65 additions and 1 deletions

View File

@ -5,6 +5,7 @@ extends Node
const QuestProgressClient := preload("res://scripts/quest_progress_client.gd")
const GATHER_QUEST_ID := "prototype_quest_gather_intro"
const ACCEPT_IDLE_HINT := "Quest accept: — (Q gather / Shift+Q next)"
const ACCEPT_SENDING_HINT := "Quest accept: sending…"
var _progress_client: Node = null
var _defs_client: Node = null
@ -293,7 +294,9 @@ func _request_accept(quest_id: String) -> bool:
_render_accept_feedback_label("Quest accept: failed — client unavailable")
return false
var started: bool = bool(_progress_client.call("request_accept", quest_id))
if not started:
if started:
_render_accept_feedback_label(ACCEPT_SENDING_HINT)
else:
_render_accept_feedback_label("Quest accept: failed — could not start")
return started

View File

@ -60,6 +60,21 @@ class PendingAcceptHttpTransport:
return OK
class FailStartAcceptHttpTransport:
extends Node
signal request_completed(
result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray
)
func request(
_url: String,
_custom_headers: PackedStringArray = PackedStringArray(),
_method: HTTPClient.Method = HTTPClient.METHOD_POST,
_request_data: String = ""
) -> Error:
return ERR_UNAVAILABLE
func _make_progress_client(sync_transport: Node, accept_transport: Node = null) -> Node:
var c: Node = QuestProgressClient.new()
c.set("injected_sync_http", sync_transport)
@ -123,6 +138,38 @@ func test_try_accept_key_input_handles_q_key() -> void:
var handled: bool = bool(built["controller"].call("try_accept_key_input", event))
# Assert
assert_bool(handled).is_true()
assert_str(built["accept_label"].text).contains("sending")
func test_try_accept_key_input_shows_busy_while_accept_in_flight() -> void:
# Arrange
var built: Dictionary = await _build_controller(
NoopHttpTransport.new(), PendingAcceptHttpTransport.new(), NoopHttpTransport.new()
)
var event := InputEventKey.new()
event.pressed = true
event.keycode = KEY_Q
built["controller"].call("try_accept_key_input", event)
# Act
var handled: bool = bool(built["controller"].call("try_accept_key_input", event))
# Assert
assert_bool(handled).is_true()
assert_str(built["accept_label"].text).contains("busy")
func test_try_accept_key_input_shows_failed_when_post_wont_start() -> void:
# Arrange
var built: Dictionary = await _build_controller(
NoopHttpTransport.new(), FailStartAcceptHttpTransport.new(), NoopHttpTransport.new()
)
var event := InputEventKey.new()
event.pressed = true
event.keycode = KEY_Q
# Act
var handled: bool = bool(built["controller"].call("try_accept_key_input", event))
# Assert
assert_bool(handled).is_true()
assert_str(built["accept_label"].text).contains("could not start")
func test_progress_label_shows_loading_before_snapshot() -> void:
@ -196,6 +243,20 @@ func test_request_accept_shows_busy_feedback() -> void:
assert_str(accept_label.text).contains("busy")
func test_request_accept_shows_sending_when_post_starts() -> void:
# Arrange
var built: Dictionary = await _build_controller(
NoopHttpTransport.new(), PendingAcceptHttpTransport.new(), NoopHttpTransport.new()
)
var controller: Node = built["controller"]
var accept_label: Label = built["accept_label"]
# Act
var started: bool = bool(controller.call("_request_accept", QuestHudController.GATHER_QUEST_ID))
# Assert
assert_bool(started).is_true()
assert_str(accept_label.text).contains("sending")
func _not_started_snapshot() -> Dictionary:
return {
"schemaVersion": 1,