Signs a browser in for tests with PhoenixTest.Playwright, without a passkey ceremony.
A ceremony takes about as long as the rest of a typical browser test. Tests whose subject comes after signing in can start from a session cookie instead. The page and its socket then load the account as after a real sign-in.
test "the library opens", %{conn: conn} do
account = Repo.insert!(%User{username: "ada"})
conn |> sign_in(account, MyAppWeb.Endpoint.session_options()) |> visit("/")
endThe module exists only when phoenix_test_playwright is a dependency.
Summary
Functions
Stores a new session for account and sets it as the browser's session cookie.
Functions
Stores a new session for account and sets it as the browser's session cookie.
session_options are the options the endpoint passes to Plug.Session. They name the cookie
and carry its signing and encryption salts. Returns conn.
The cookie also names the session's LiveView socket, as Ithibati.Web.Gate.log_in/2 does.
Revoking the session then disconnects the browser's LiveViews. The endpoint needs PubSub.