Helpers for Phoenix.LiveViewTest, to move, open, rename and pick in
tests with no browser.
import Narabe.Test
test "moves a card to Done", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/boards/1")
move(view, "board", card.id, parent: done.id, index: 0)
assert_reply(view, %{ok: true})
assert {"Done", ["Write the docs", "Ship"]} in columns(view, "board")
endmove/4 sends the list's on_move event with the move as the browser
sends it (Narabe.Move.to_params/1), to the LiveView or the component of
the list's phx-target; the reply is the LiveView's (assert_reply/2).
The page shows what the server renders next: unlike a browser, the test
does not move anything first.
Summary
Functions
A board's columns, in order: {label, card labels}.
Opens a tree item whose children are not loaded: sends on_expand.
The labels of a list's items (a board's cards, a tree's loaded items), in order.
Moves items (an id or a list of ids) of the list, tree or board with
the id list_id, and returns the rendered LiveView.
A tree's loaded items, in order: {label, level}, the top level being 1.
Picks an item of a tree picker in a form, as a click does: the form's
phx-change with the item's id. The form must have an id.
Renames a tree item: sends on_rename.
Selects items: sends on_select.
Functions
A board's columns, in order: {label, card labels}.
Opens a tree item whose children are not loaded: sends on_expand.
The labels of a list's items (a board's cards, a tree's loaded items), in order.
Moves items (an id or a list of ids) of the list, tree or board with
the id list_id, and returns the rendered LiveView.
Options: :after, :before (a neighbour's id), :parent (a tree
item's or a board column's id), :index (its place among its new
siblings), and columns: true for a board's columns.
@spec outline(struct(), String.t()) :: [{String.t(), pos_integer()}]
A tree's loaded items, in order: {label, level}, the top level being 1.
Picks an item of a tree picker in a form, as a click does: the form's
phx-change with the item's id. The form must have an id.
Renames a tree item: sends on_rename.
Selects items: sends on_select.