api-surface #1

Merged
luna merged 51 commits from api-surface into mistress 2026-07-05 14:43:13 +00:00
2 changed files with 12 additions and 2 deletions
Showing only changes of commit 5169107563 - Show all commits

style: format gateway_integration_test and slash_test

Claude-Session: https://claude.ai/code/session_01T4vgXtQLs2wfNwn6B1m4hm
Luna 2026-07-05 07:41:35 -03:00

View file

@ -98,6 +98,7 @@ defmodule Dexcord.GatewayIntegrationTest do
# A dispatch reaches the user handler...
FakeGateway.push_dispatch(fake, "MESSAGE_CREATE", %{"content" => "hi"}, 7)
assert_receive {:handler_event, {:MESSAGE_CREATE, %Dexcord.Message{content: "hi"}}},
@event_timeout
@ -258,6 +259,7 @@ defmodule Dexcord.GatewayIntegrationTest do
# The statem survived: a following real dispatch still reaches the user handler.
FakeGateway.push_dispatch(fake, "MESSAGE_CREATE", %{"content" => "alive"}, 6)
assert_receive {:handler_event, {:MESSAGE_CREATE, %Dexcord.Message{content: "alive"}}},
@event_timeout
@ -290,6 +292,7 @@ defmodule Dexcord.GatewayIntegrationTest do
# Advance the live session's seq.
FakeGateway.push_dispatch(fake, "MESSAGE_CREATE", %{"content" => "x"}, 42)
assert_receive {:handler_event, {:MESSAGE_CREATE, %Dexcord.Message{content: "x"}}},
@event_timeout
@ -302,6 +305,7 @@ defmodule Dexcord.GatewayIntegrationTest do
# Trickle a dispatch from the abandoned session during the reidentify wait.
FakeGateway.push_dispatch(fake, "MESSAGE_CREATE", %{"content" => "noise"}, 9_999)
assert_receive {:handler_event, {:MESSAGE_CREATE, %Dexcord.Message{content: "noise"}}},
@event_timeout
@ -547,6 +551,7 @@ defmodule Dexcord.GatewayIntegrationTest do
assert_frame(2)
assert_receive {:handler_event, {:READY, _}}, @event_timeout
FakeGateway.push_dispatch(fake, "MESSAGE_CREATE", %{"content" => "seed"}, 5)
assert_receive {:handler_event, {:MESSAGE_CREATE, %Dexcord.Message{content: "seed"}}},
@event_timeout
@ -562,6 +567,7 @@ defmodule Dexcord.GatewayIntegrationTest do
assert_receive {:handler_event, {:MESSAGE_CREATE, %Dexcord.Message{content: "c"}}},
@event_timeout
assert_receive {:handler_event, {:RESUMED, _}}, @event_timeout
# Seq advanced to the last replayed dispatch.

View file

@ -57,13 +57,17 @@ defmodule Dexcord.SlashTest do
end
test "dispatch/2 routes a type-3 (component) interaction to handle_component/2 by custom_id" do
itx = Interaction.from_map(%{"type" => 3, "data" => %{"custom_id" => "refresh"}, "id" => "2"})
itx =
Interaction.from_map(%{"type" => 3, "data" => %{"custom_id" => "refresh"}, "id" => "2"})
assert Slash.dispatch(itx, Commands) == :ok
assert_received {:component, "refresh", %Dexcord.Interaction{type: :message_component}}
end
test "dispatch/2 routes a type-5 (modal) interaction to handle_modal/2 by custom_id" do
itx = Interaction.from_map(%{"type" => 5, "data" => %{"custom_id" => "feedback"}, "id" => "3"})
itx =
Interaction.from_map(%{"type" => 5, "data" => %{"custom_id" => "feedback"}, "id" => "3"})
assert Slash.dispatch(itx, Commands) == :ok
assert_received {:modal, "feedback", %Dexcord.Interaction{type: :modal_submit}}
end