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

Phoenix.LiveViewTest doesn't seem to work without sessions #820

Closed
egze opened this issue Apr 25, 2020 · 2 comments
Closed

Phoenix.LiveViewTest doesn't seem to work without sessions #820

egze opened this issue Apr 25, 2020 · 2 comments

Comments

@egze
Copy link
Contributor

egze commented Apr 25, 2020

Environment

  • Elixir version (elixir -v): Elixir 1.10.2 (compiled with Erlang/OTP 22)
  • Phoenix version (mix deps): 1.5.1
  • Phoenix LiveView version (mix deps): 0.12.1
  • NodeJS version (node -v): v13.12.0
  • NPM version (npm -v): 6.14.4
  • Operating system: macOS 10.15.4

Actual behavior

I am trying to run my website without cookies (for GDPR reasons).

  • I removed :fetch_session, :fetch_live_flash, :protect_from_forgery plugs from router.
  • Removed websocket: [connect_info: [session: @session_options]] from Phoenix.LiveView.Socket config.
  • Removed plug Plug.Session.
  • Removed _csrf_token config from app.js.

The application is working fine and no cookies are created, also all live view functionality is working (phx-click).

What is not working:

When I run mix test, I get:

  1) test shows privacy policy (AppWeb.PageLiveTest)
     test/app_web/live/page_live_test.exs:23
     ** (ArgumentError) session not fetched, call fetch_session/2
     code: {:ok, live_view, _disconnected_html} = live(conn, "/")
     stacktrace:
       (plug 1.10.0) lib/plug/conn.ex:1557: Plug.Conn.get_session/1
       (phoenix_live_view 0.12.1) lib/phoenix_live_view/test/live_view_test.ex:343: Phoenix.LiveViewTest.do_connect/7
       test/app_web/live/page_live_test.exs:24: (test)

Expected behavior

I expect that tests still work if the application if configured as sessionless/cookieless. Or that live function has a parameter to not try to load the session.

@josevalim
Copy link
Member

Good call! Please let us know if you want to submit a PR, otherwise I will give it a shot later.

@egze
Copy link
Contributor Author

egze commented Apr 25, 2020

I absolutely want to give it a shot. Will write later what I’m planning to change when I look in detail how it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants