diff --git a/client/test/ability_cast_client_test.gd b/client/test/ability_cast_client_test.gd index 1e6bb85..29127c7 100644 --- a/client/test/ability_cast_client_test.gd +++ b/client/test/ability_cast_client_test.gd @@ -77,10 +77,13 @@ func _make_client(transport: Node) -> Node: func test_request_cast_posts_expected_payload_with_null_target() -> void: + # Arrange var transport := MockHttpTransport.new() transport.enqueue(HTTPRequest.RESULT_SUCCESS, 200, '{"schemaVersion":1,"accepted":true}') var c := _make_client(transport) + # Act var started: bool = bool(c.call("request_cast", 2, "prototype_guard", null)) + # Assert assert_that(started).is_true() assert_that(transport.last_url).contains("/ability-cast") assert_that(transport.last_method).is_equal(HTTPClient.METHOD_POST) @@ -94,20 +97,22 @@ func test_request_cast_posts_expected_payload_with_null_target() -> void: func test_request_cast_posts_target_id_string_when_set() -> void: + # Arrange var transport := MockHttpTransport.new() transport.enqueue(HTTPRequest.RESULT_SUCCESS, 200, '{"schemaVersion":1,"accepted":true}') var c := _make_client(transport) - ( - assert_that(bool(c.call("request_cast", 0, "prototype_pulse", "prototype_target_alpha"))) - . is_true() - ) + # Act + var started: bool = bool(c.call("request_cast", 0, "prototype_pulse", "prototype_target_alpha")) + # Assert + assert_that(started).is_true() var parsed: Variant = JSON.parse_string(transport.last_body) var body: Dictionary = parsed assert_that(body.get("targetId")).is_equal("prototype_target_alpha") func test_request_cast_returns_false_when_http_request_fails_to_start() -> void: - # Arrange: empty queue → transport.request returns ERR_UNAVAILABLE (same as failed start). + # Arrange + # Empty queue → transport.request returns ERR_UNAVAILABLE (same as failed start). var transport := MockHttpTransport.new() var c := _make_client(transport) # Act @@ -117,12 +122,15 @@ func test_request_cast_returns_false_when_http_request_fails_to_start() -> void: func test_request_cast_while_busy_is_ignored() -> void: + # Arrange var transport := HoldFirstThenAutoTransport.new() var c := _make_client(transport) + # Act assert_that(bool(c.call("request_cast", 0, "prototype_pulse", null))).is_true() assert_that(bool(c.call("request_cast", 1, "prototype_guard", null))).is_false() await get_tree().process_frame await get_tree().process_frame + # Assert assert_that(transport.request_count).is_equal(1) var parsed: Variant = JSON.parse_string(transport.last_body) var body: Dictionary = parsed @@ -130,6 +138,7 @@ func test_request_cast_while_busy_is_ignored() -> void: func test_cast_result_received_emits_false_with_reason_on_denied() -> void: + # Arrange var transport := MockHttpTransport.new() transport.enqueue( HTTPRequest.RESULT_SUCCESS, @@ -148,6 +157,7 @@ func test_cast_result_received_emits_false_with_reason_on_denied() -> void: func test_cast_result_received_emits_true_with_empty_reason_on_accepted() -> void: + # Arrange var transport := MockHttpTransport.new() transport.enqueue(HTTPRequest.RESULT_SUCCESS, 200, '{"schemaVersion":1,"accepted":true}') var c := _make_client(transport) diff --git a/server/NeonSprawl.Server.Tests/Game/AbilityInput/AbilityCastApiTests.cs b/server/NeonSprawl.Server.Tests/Game/AbilityInput/AbilityCastApiTests.cs index 156a4f1..b98c552 100644 --- a/server/NeonSprawl.Server.Tests/Game/AbilityInput/AbilityCastApiTests.cs +++ b/server/NeonSprawl.Server.Tests/Game/AbilityInput/AbilityCastApiTests.cs @@ -68,9 +68,9 @@ public sealed class AbilityCastApiTests AbilityId = PrototypeAbilityRegistry.PrototypePulse, TargetId = PrototypeTargetRegistry.PrototypeTargetAlphaId, }); - var body = await response.Content.ReadFromJsonAsync(); // Assert + var body = await response.Content.ReadFromJsonAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(body); Assert.True(body!.Accepted); @@ -96,9 +96,9 @@ public sealed class AbilityCastApiTests AbilityId = PrototypeAbilityRegistry.PrototypePulse, TargetId = "prototype_target_alpha", }); - var body = await response.Content.ReadFromJsonAsync(); // Assert + var body = await response.Content.ReadFromJsonAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(body); Assert.True(body!.Accepted); @@ -123,9 +123,9 @@ public sealed class AbilityCastApiTests AbilityId = PrototypeAbilityRegistry.PrototypePulse, TargetId = null, }); - var body = await response.Content.ReadFromJsonAsync(); // Assert + var body = await response.Content.ReadFromJsonAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(body); Assert.False(body!.Accepted); @@ -151,9 +151,9 @@ public sealed class AbilityCastApiTests AbilityId = PrototypeAbilityRegistry.PrototypePulse, TargetId = "not_a_registered_combat_target", }); - var body = await response.Content.ReadFromJsonAsync(); // Assert + var body = await response.Content.ReadFromJsonAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(body); Assert.False(body!.Accepted); @@ -169,7 +169,7 @@ public sealed class AbilityCastApiTests await BindSlot0PulseAsync(client); await LockPrototypeTargetAlphaAsync(client); - // Act — server lock is alpha; client sends beta id + // Act var response = await client.PostAsJsonAsync( "/game/players/dev-local-1/ability-cast", new AbilityCastRequest @@ -179,9 +179,9 @@ public sealed class AbilityCastApiTests AbilityId = PrototypeAbilityRegistry.PrototypePulse, TargetId = PrototypeTargetRegistry.PrototypeTargetBetaId, }); - var body = await response.Content.ReadFromJsonAsync(); // Assert + var body = await response.Content.ReadFromJsonAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(body); Assert.False(body!.Accepted); @@ -206,9 +206,9 @@ public sealed class AbilityCastApiTests AbilityId = PrototypeAbilityRegistry.PrototypePulse, TargetId = PrototypeTargetRegistry.PrototypeTargetAlphaId, }); - var body = await response.Content.ReadFromJsonAsync(); // Assert + var body = await response.Content.ReadFromJsonAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(body); Assert.False(body!.Accepted); @@ -235,9 +235,9 @@ public sealed class AbilityCastApiTests AbilityId = PrototypeAbilityRegistry.PrototypePulse, TargetId = PrototypeTargetRegistry.PrototypeTargetAlphaId, }); - var body = await response.Content.ReadFromJsonAsync(); // Assert + var body = await response.Content.ReadFromJsonAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(body); Assert.False(body!.Accepted); @@ -261,9 +261,9 @@ public sealed class AbilityCastApiTests AbilityId = PrototypeAbilityRegistry.PrototypeGuard, TargetId = null, }); - var body = await response.Content.ReadFromJsonAsync(); // Assert + var body = await response.Content.ReadFromJsonAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(body); Assert.False(body!.Accepted); @@ -288,9 +288,9 @@ public sealed class AbilityCastApiTests AbilityId = PrototypeAbilityRegistry.PrototypeBurst, TargetId = null, }); - var body = await response.Content.ReadFromJsonAsync(); // Assert + var body = await response.Content.ReadFromJsonAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(body); Assert.False(body!.Accepted); @@ -315,9 +315,9 @@ public sealed class AbilityCastApiTests AbilityId = PrototypeAbilityRegistry.PrototypePulse, TargetId = null, }); - var body = await response.Content.ReadFromJsonAsync(); // Assert + var body = await response.Content.ReadFromJsonAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(body); Assert.False(body!.Accepted); @@ -342,9 +342,9 @@ public sealed class AbilityCastApiTests AbilityId = "not_a_real_ability", TargetId = null, }); - var body = await response.Content.ReadFromJsonAsync(); // Assert + var body = await response.Content.ReadFromJsonAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(body); Assert.False(body!.Accepted);