Complete resilient Steam login flow
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
extends SceneTree
|
||||
|
||||
var failures := 0
|
||||
var login: Control
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
login = load("res://scripts/ui/login_screen.gd").new()
|
||||
root.add_child(login)
|
||||
await process_frame
|
||||
_test_elapsed_timeout_clears_flow()
|
||||
_test_transient_failure_keeps_transaction()
|
||||
_test_leaving_completion_cancels_flow()
|
||||
login.queue_free()
|
||||
await process_frame
|
||||
quit(1 if failures > 0 else 0)
|
||||
|
||||
|
||||
func _test_elapsed_timeout_clears_flow() -> void:
|
||||
login.steam_transaction_id = "expired-transaction"
|
||||
login.steam_poll_deadline_msec = 1
|
||||
login.poll_timer.start()
|
||||
login._poll_steam()
|
||||
_assert(login.steam_transaction_id.is_empty(), "elapsed Steam login deadline should clear the transaction")
|
||||
_assert(login.poll_timer.is_stopped(), "elapsed Steam login deadline should stop polling")
|
||||
|
||||
|
||||
func _test_transient_failure_keeps_transaction() -> void:
|
||||
login.steam_transaction_id = "retry-transaction"
|
||||
login.steam_poll_deadline_msec = Time.get_ticks_msec() + 300000
|
||||
login.steam_poll_failures = 2
|
||||
login._on_steam_status(HTTPRequest.RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray())
|
||||
_assert(login.steam_transaction_id == "retry-transaction", "temporary connection failures should preserve the Steam transaction")
|
||||
_assert(login.steam_poll_failures == 3, "temporary connection failures should be tracked without consuming the deadline")
|
||||
|
||||
|
||||
func _test_leaving_completion_cancels_flow() -> void:
|
||||
login.mode = "steam"
|
||||
login.steam_transaction_id = "cancel-transaction"
|
||||
login.poll_timer.start()
|
||||
login._set_mode("login")
|
||||
_assert(login.steam_transaction_id.is_empty(), "leaving Steam account completion should clear its transaction")
|
||||
_assert(login.poll_timer.is_stopped(), "leaving Steam account completion should stop polling")
|
||||
|
||||
|
||||
func _assert(condition: bool, message: String) -> void:
|
||||
if condition:
|
||||
return
|
||||
failures += 1
|
||||
push_error(message)
|
||||
@@ -0,0 +1 @@
|
||||
uid://cnqc7wymmiwdd
|
||||
Reference in New Issue
Block a user