Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing authenticated Routes #18

Open
optikfluffel opened this issue Feb 18, 2024 · 0 comments
Open

Testing authenticated Routes #18

optikfluffel opened this issue Feb 18, 2024 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@optikfluffel
Copy link

It would be cool to have some Helpers for testing authenticated Routes, or an example on how to do this.

Something in the like of:

defmodule DemoWeb.PageControllerTest do
  use DemoWeb.ConnCase

  describe "GET /" do
    test " shows Sign In link", %{conn: conn} do
      conn = get(conn, ~p"/")
      assert html_response(conn, 200) =~ "Sign In"
    end

    test "shows Sign Out link, when authenticated", %{conn: conn} do
      user = IdentityFixtures.user_fixture()

      conn =
        conn
        |> WebauthnComponents.TestHelpers.authenticate(user)
        |> get(~p"/")

      assert html_response(conn, 200) =~ "Sign Out"
    end
  end
end
@type1fool type1fool self-assigned this Nov 11, 2024
@type1fool type1fool added the documentation Improvements or additions to documentation label Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Development

No branches or pull requests

2 participants