absinthe-graphql / absinthe_graphql_ws

Add graphql-ws websocket transport for Absinthe
https://hexdocs.pm/absinthe_graphql_ws/overview.html
MIT License
66 stars 20 forks source link

Testing Subscriptions #11

Open acrogenesis opened 2 years ago

acrogenesis commented 2 years ago

I'm having trouble updating the SubscriptionCase the absinthe book uses for testing the subscriptions. How are you testing your subscriptions?

06-chp.subscriptions/4-publish/test/support/subscription_case.ex

defmodule PlateSlateWeb.SubscriptionCase do
  @moduledoc """
  This module defines the test case to be used by
  subscription tests
  """

  use ExUnit.CaseTemplate

  using do
    quote do
      # Import conveniences for testing with channels
      use PlateSlateWeb.ChannelCase
      use Absinthe.Phoenix.SubscriptionTest, schema: PlateSlateWeb.Schema
      import Plug.Conn
      import Phoenix.ConnTest

      setup do
        {:ok, socket} =
          Phoenix.ChannelTest.connect(
            PlateSlateWeb.UserSocket,
            Application.get_env(:valiot_app, :token_helper).header
          )

        {:ok, socket} = Absinthe.Phoenix.SubscriptionTest.join_absinthe(socket)

        {:ok, socket: socket}
      end
    end
  end
end
sax commented 2 years ago

Oh yeah, that module is specific to Phoenix channels: https://github.com/absinthe-graphql/absinthe_phoenix/blob/master/lib/absinthe/phoenix/subscription_test.ex

We wound up building a test client using gun. Now that you bring it up, it would have made far more sense to have done that as a part of this library.

@austinworks do you think the test client could be added to this repo?

maxsalven commented 2 years ago

@sax any plans to add testing capabilities to this library?

maxsalven commented 6 months ago

Is there anything I can do to help?

acrogenesis commented 2 months ago

@benwilson512 @sax hey now that the project is in absinthe-graphql org it might make sense to look into this again?

zoedsoupe commented 1 month ago

i could also try to help with this testing setup