<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="362530" data-post-id="362530">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sodapopcan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/120/34668_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sodapopcan
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>FWIW we’ve been using Playwright quite successfully as well!  It’s especially nice if you’re already using PhoenixTest.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="362530" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/wallaby-testing-when-browser-session-is-required-i-e-login/8034/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-362530" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="362530"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #21"></div>
  </section>
</div>
    <div class="postbit" id="362542" data-post-id="362542">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ravecat" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ravecat/120/34767_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ravecat
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>could you share a code example? I often see mention of such a solution, but I can’t imagine how to do it compactly enough.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="362542" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/wallaby-testing-when-browser-session-is-required-i-e-login/8034/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-362542" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="362542"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #22"></div>
  </section>
</div>
    <div class="postbit" id="362581" data-post-id="362581">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="hubertlepicki" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hubertlepicki/120/6822_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  hubertlepicki
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>In your router:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">
  if Mix.env() == :test do
    scope "/autologin", Web do
      pipe_through(:browser)
      get("/:account_id", AutologinTestController, :autologin)
    end
  end

</code></pre>
<p>And then in your <code>test/support/autologin_test_controller.ex</code>:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Web.AutologinTestController do
  @moduledoc "This controller is used for tests only and is compiled
  in MIX_ENV=test environment only. It allows to log in to accounts by
  visiting /autologin/:account_id, working around Oauth2/Google login."

  use Web, :controller

  def autologin(conn, %{"account_id" =&gt; account_id}) do
    account = DB.Repo.get!(DB.Account, account_id)
    Web.LogIn.login(conn, account)
  end
end
</code></pre>
<p>Adjust for your code structure, but that’s roughly it. A few lines.</p>
<p>Remember to wrap the route in the if clause and then also put the controller in <code>test/support</code> rather than usual location so it doesn’t get compiled in other environments.</p>
<p>The Web.Login.login/2 is the same function that’s used by actual controllers so you are sure it’s setting all the session variables the same way as production code.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="362581" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/wallaby-testing-when-browser-session-is-required-i-e-login/8034/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-362581" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="362581"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>