Search documentation of Plushie

# Plushie.Automation.File (Plushie v0.7.2)

Copy Markdown View Source

Parser for `.plushie` automation files.

The `.plushie` format is a superset of iced's `.ice` test script format, adding Plushie-specific instructions like `assert_text` and `assert_model`.

## Format

    app: MyApp.Counter
    viewport: 800x600
    theme: dark
    backend: mock
    -----
    click "#increment"
    expect "Count: 1"
    screenshot "counter-at-1"

`backend` selects which renderer mode the runner starts. `viewport` is used as the default capture size for `screenshot` instructions. The full parsed header is also forwarded to `app.init/1` under the `:script` option when run through `Plushie.Automation.Runner`.

`theme` is script metadata only. It is available to the app through `init(opts[:script])` if the app wants to interpret it, but the runner does not force renderer or widget themes on your behalf.

See `Plushie.Automation.Runner` for execution.

## Summary

### Types

header()
instruction()
t()

### Functions

parse(content)

Parses `.plushie` automation source from a string.

parse_file(path)

Parses a `.plushie` automation file from a path.

## Types

# header()

    @type header() :: %{
      app: module() | nil,
      viewport: {non_neg_integer(), non_neg_integer()},
      theme: String.t(),
      backend: Plushie.Automation.backend_mode()
    }

# instruction()

    @type instruction() ::
      {:click, String.t()}
      | {:type_text, String.t(), String.t()}
      | {:type_key, String.t()}
      | {:press, String.t()}
      | {:release, String.t()}
      | {:move, String.t()}
      | {:move_to, non_neg_integer(), non_neg_integer()}
      | {:toggle, String.t(), boolean() | nil}
      | {:select, String.t(), String.t()}
      | {:slide, String.t(), number()}
      | {:expect, String.t()}
      | {:screenshot, String.t()}
      | {:assert_text, String.t(), String.t()}
      | {:assert_model, String.t()}
      | {:wait, non_neg_integer()}

# t()

    @type t() :: %{header: header(), instructions: [instruction()]}

## Functions

# parse(content)

    @spec parse(content :: String.t()) :: {:ok, t()} | {:error, String.t()}

Parses `.plushie` automation source from a string.

# parse_file(path)

    @spec parse_file(path :: String.t()) :: {:ok, t()} | {:error, String.t()}

Parses a `.plushie` automation file from a path.