TestDispatch.click_link

You're seeing just the function click_link, go back to TestDispatch module for more information.
Link to this function

click_link(tree \\ nil, conn, test_selector, test_value \\ nil)

View Source

Finds a link by a given conn, test_selector and an optional test_value.

Hereby it tries to get a response from the conn and find the first <a></a> element that has the combination of the test_selector and test_value. The link that is found will be dispatched with Phoenix.ConnTest.dispatch/4. The method will be derived from the link by the data-method attribute and has "get" as default. The path will be taken from the href.

Examples

With the given page on "/posts/1"

<html>
<body>
  <h1>Post</h1>
  <a href="/posts/1" data-method="delete" test-selector="post-123-delete-post">
   Remove
  </a>
  <table>
    <th>Comment</td>
    <th>Upvote</td>
    <tr>
      <td>This is perfect</td>
      <td>
        <a href="/posts/1/comments/1"
           data-method="post"
           test-value="1"
           test-selector="post-123-upvote-comment" >
          Upvote Comment
      </td>
    </tr>
  </table>
</body>
</html>
iex> conn = build_conn() |> get("/posts/1")
iex> result = click_link(conn, "post-123-delete-post")
iex> with %Plug.Conn{request_path: "/posts/1", method: "DELETE"} <- result, do: :ok
:ok

iex> conn = build_conn() |> get("/posts/1")
iex> result = click_link(conn, "post-123-upvote-comment", "1")
iex> with %Plug.Conn{request_path: "/posts/1/comments/1", method: "POST"} <- result, do: :ok
:ok