View Source Pages.Driver.LiveView (Pages v3.0.0)

A page driver for interacting with Phoenix.LiveView pages.

Summary

Functions

Called from Pages.click/4 when the given page is a LiveView.

Called from Pages.handle_redirect/1 when the given page is a LiveView.

Perform a live redirect to the given path.

Attempt to open the current page in a web browser.

Called from Pages.render_change/3 when the given page is a LiveView.

Called from Pages.render_hook/3 when the given page is a LiveView.

Called from Pages.render_upload/4 when the given page is a LiveView.

Called from Pages.rerender/1 when the given page is a LiveView.

Called from Pages.submit_form/2 when the given page is a LiveView.

Called from Pages.update_form/5 when the given page is a LiveView.

Initialize a live with the given path.

Find a child component, and pass it as a new Page into the given function.

Types

t()

@type t() :: %Pages.Driver.LiveView{
  conn: Plug.Conn.t(),
  context: %{required(atom()) => any()},
  live: any(),
  rendered: binary() | nil
}

Functions

click(page, atom, maybe_title, selector)

Called from Pages.click/4 when the given page is a LiveView.

handle_redirect(page)

@spec handle_redirect(Pages.Driver.t()) :: Pages.Driver.t()

Called from Pages.handle_redirect/1 when the given page is a LiveView.

live_redirect(page, destination_path)

@spec live_redirect(Pages.Driver.t(), binary()) :: Pages.result()

Perform a live redirect to the given path.

When issuing a live_redirect from one live view to another live view where the routes cross between two live_sessions, then live view will not just remount the socket, but will issue a redirect. In this case, if the test pages have been initialized via Phoenix.ConnTest.build_conn/0, the test adapter will have the URI host set to be www.example.com... the live_redirect will be seen as an external redirect.

When using live_redirect/2 between two live sessions, ensure that the initial test setup (for example in ConnCase) instead calls Phoenix.ConnTest.build_conn(:get, "http://localhost:4002/"), so that redirects are seen as internal redirects.

This is not implemented in Pages due to its specificity to LiveView and LiveViewTest.

new(conn, context)

new(conn, context, request_path, params \\ %{})

open_browser(page)

@spec open_browser(Pages.Driver.t()) :: Pages.Driver.t()

Attempt to open the current page in a web browser.

render_change(page, selector, value)

@spec render_change(Pages.Driver.t(), HtmlQuery.Css.selector(), Enum.t()) ::
  Pages.result()

Called from Pages.render_change/3 when the given page is a LiveView.

render_hook(page, event, value_attrs, options)

@spec render_hook(Pages.Driver.t(), binary(), Pages.attrs_t(), keyword()) ::
  Pages.result()

Called from Pages.render_hook/3 when the given page is a LiveView.

render_upload(page, upload, entry_name, percent)

@spec render_upload(Pages.Driver.t(), Pages.live_view_upload(), binary(), integer()) ::
  Pages.result()

Called from Pages.render_upload/4 when the given page is a LiveView.

rerender(page)

@spec rerender(Pages.Driver.t()) :: Pages.result()

Called from Pages.rerender/1 when the given page is a LiveView.

submit_form(page, selector)

@spec submit_form(Pages.Driver.t(), HtmlQuery.Css.selector()) :: Pages.result()

Called from Pages.submit_form/2 when the given page is a LiveView.

submit_form(page, selector, schema, form_attrs, hidden_attrs)

Called from Pages.submit_form/4 and Pages.submit_form/5 when the given page is a LiveView.

update_form(page, selector, schema, attrs, opts)

Called from Pages.update_form/5 when the given page is a LiveView.

visit(page, path)

@spec visit(Pages.Driver.t(), binary()) :: Pages.result()

Initialize a live with the given path.

This is called from Pages.visit/2 when the conn indicates that the pages is a LiveView, and should only be called directly if the parent function does not work for some reason.

with_child_component(page, child_id, fun)

Find a child component, and pass it as a new Page into the given function.

Rerenders the top-level page upon completion. See Pages.with_child_component/3.