Search documentation of Plushie

# Plushie.Test.Session (Plushie v0.7.2)

Copy Markdown View Source

A test session wrapping a running Plushie app.

Created by `Plushie.Test.Case` setup. All interaction functions delegate to `Plushie.Test.Backend.Runtime`.

## Summary

### Types

selector()

Test selector.

t()

### Functions

advance_frame(session, timestamp)
await_async(session, tag, timeout \\ 5000)
canvas_move(session, selector, x, y, opts \\ [])
canvas_press(session, selector, x, y, button \\ "left", opts \\ [])
canvas_release(session, selector, x, y, button \\ "left", opts \\ [])
click(session, selector, opts \\ [])
find(session, selector, opts \\ [])
find!(session, selector, opts \\ [])
model(session)
move_to(session, x, y)
pane_focus_cycle(session, selector, opts \\ [])
paste(session, selector, text, opts \\ [])
press(session, key)
register_effect_stub(session, kind, response)
release(session, key)
reset(session)
runtime(session)

Returns the underlying Plushie.Runtime pid for direct interaction.

screenshot(session, name, opts \\ [])
scroll(session, selector, delta_x \\ 0, delta_y \\ 0, opts \\ [])
select(session, selector, value, opts \\ [])
slide(session, selector, value, opts \\ [])
sort(session, selector, column, direction \\ "asc", opts \\ [])
start(app, opts \\ [])

Starts a new test session.

stop(session)
submit(session, selector, opts \\ [])
toggle(session, selector, value \\ nil, opts \\ [])
tree(session)
tree_hash(session, name)
type_key(session, key)
type_text(session, selector, text, opts \\ [])
unregister_effect_stub(session, kind)

## Types

# selector()

    @type selector() :: Plushie.Automation.Session.selector()

Test selector.

String selectors follow these rules:

- `"#save"` matches a unique local widget ID
- `"#form/save"` matches an exact scoped ID
- bare strings like `"Save"` match visible text

# t()

    @type t() :: %Plushie.Test.Session{pid: pid()}

## Functions

# advance_frame(session, timestamp)

    @spec advance_frame(session :: t(), timestamp :: non_neg_integer()) :: :ok

# await_async(session, tag, timeout \\ 5000)

    @spec await_async(session :: t(), tag :: atom(), timeout :: non_neg_integer()) :: :ok

# canvas_move(session, selector, x, y, opts \\ [])

    @spec canvas_move(
      session :: t(),
      selector :: selector(),
      x :: number(),
      y :: number(),
      opts :: keyword()
    ) :: :ok

# canvas_press(session, selector, x, y, button \\ "left", opts \\ [])

    @spec canvas_press(
      session :: t(),
      selector :: selector(),
      x :: number(),
      y :: number(),
      button :: String.t(),
      opts :: keyword()
    ) :: :ok

# canvas_release(session, selector, x, y, button \\ "left", opts \\ [])

    @spec canvas_release(
      session :: t(),
      selector :: selector(),
      x :: number(),
      y :: number(),
      button :: String.t(),
      opts :: keyword()
    ) :: :ok

# click(session, selector, opts \\ [])

    @spec click(session :: t(), selector :: selector(), opts :: keyword()) :: :ok

# find(session, selector, opts \\ [])

    @spec find(session :: t(), selector :: selector(), opts :: keyword()) ::
      Plushie.Automation.Element.t() | nil

# find!(session, selector, opts \\ [])

    @spec find!(session :: t(), selector :: selector(), opts :: keyword()) ::
      Plushie.Automation.Element.t()

# model(session)

    @spec model(session :: t()) :: term()

# move_to(session, x, y)

    @spec move_to(session :: t(), x :: number(), y :: number()) :: :ok

# pane_focus_cycle(session, selector, opts \\ [])

    @spec pane_focus_cycle(session :: t(), selector :: selector(), opts :: keyword()) ::
      :ok

# paste(session, selector, text, opts \\ [])

    @spec paste(
      session :: t(),
      selector :: selector(),
      text :: String.t(),
      opts :: keyword()
    ) :: :ok

# press(session, key)

    @spec press(session :: t(), key :: String.t()) :: :ok

# register_effect_stub(session, kind, response)

    @spec register_effect_stub(
      session :: t(),
      kind :: Plushie.Effect.kind(),
      response :: term()
    ) :: :ok

# release(session, key)

    @spec release(session :: t(), key :: String.t()) :: :ok

# reset(session)

    @spec reset(session :: t()) :: :ok

# runtime(session)

    @spec runtime(session :: t()) :: pid()

Returns the underlying Plushie.Runtime pid for direct interaction.

# screenshot(session, name, opts \\ [])

    @spec screenshot(session :: t(), name :: String.t(), opts :: keyword()) ::
      Plushie.Test.Screenshot.t()

# scroll(session, selector, delta_x \\ 0, delta_y \\ 0, opts \\ [])

    @spec scroll(
      session :: t(),
      selector :: selector(),
      delta_x :: number(),
      delta_y :: number(),
      opts :: keyword()
    ) :: :ok

# select(session, selector, value, opts \\ [])

    @spec select(
      session :: t(),
      selector :: selector(),
      value :: term(),
      opts :: keyword()
    ) :: :ok

# slide(session, selector, value, opts \\ [])

    @spec slide(
      session :: t(),
      selector :: selector(),
      value :: number(),
      opts :: keyword()
    ) :: :ok

# sort(session, selector, column, direction \\ "asc", opts \\ [])

    @spec sort(
      session :: t(),
      selector :: selector(),
      column :: String.t(),
      direction :: String.t(),
      opts :: keyword()
    ) :: :ok

# start(app, opts \\ [])

    @spec start(app :: module(), opts :: keyword()) :: t()

Starts a new test session.

# stop(session)

    @spec stop(session :: t()) :: :ok

# submit(session, selector, opts \\ [])

    @spec submit(session :: t(), selector :: selector(), opts :: keyword()) :: :ok

# toggle(session, selector, value \\ nil, opts \\ [])

    @spec toggle(
      session :: t(),
      selector :: selector(),
      value :: boolean() | nil,
      opts :: keyword()
    ) :: :ok

# tree(session)

    @spec tree(session :: t()) :: map()

# tree_hash(session, name)

    @spec tree_hash(session :: t(), name :: String.t()) :: Plushie.Test.TreeHash.t()

# type_key(session, key)

    @spec type_key(session :: t(), key :: String.t()) :: :ok

# type_text(session, selector, text, opts \\ [])

    @spec type_text(
      session :: t(),
      selector :: selector(),
      text :: String.t(),
      opts :: keyword()
    ) :: :ok

# unregister_effect_stub(session, kind)

    @spec unregister_effect_stub(session :: t(), kind :: Plushie.Effect.kind()) :: :ok