# `Alternera.Resource.UI.Test`
[🔗](https://github.com/10e-ab/alternera-sdk/blob/v0.9.0/alternera_resource_ui/lib/alternera/resource/ui/test.ex#L1)

The test kit for a package's own UI, run with no proxy around.

    # test/test_helper.exs
    Alternera.Resource.UI.Test.start!()

    defmodule Finance.UITest do
      use Alternera.Resource.UI.Test

      resource_ui_contract Finance.Resources

      test "the converter converts", %{tenant: tenant} do
        ctx = ui_ctx(tenant, %{system: true}, resource: Finance.UnitOfMeasure)
        {:ok, view, _html} = live_ui(Finance.Converter, ctx)
        ...
      end
    end

`use` imports `Phoenix.LiveViewTest` and this module's functions, and
sets the endpoint. `resource_ui_contract/1` generates a test that every
declared UI module is the kind its declaration needs
(`Alternera.Resource.UI.Check`).

`live_ui/3` mounts a component in a harness that plays the host
(`Alternera.Resource.UI.Test.Harness`): every request the
component makes of the host arrives in the test as
`{:resource_ui, request}`, and notifications are drawn in `#harness-notifications`.
Records go through `Alternera.Resource.UI.Test.Host`, Ash with the
context's tenant and actor.

# `live_ui`
*macro* 

Mounts `module` in the harness. A surface gets `params` (option
`:params`) and `arg` (option `:arg`); any other component gets the
option `:assigns` beside `ctx`. Returns `live_isolated/3`'s result.

# `resource_ui_contract`
*macro* 

Generates a test that `domain`'s UI declarations name modules of the right kind.

# `run_ui_action`

Runs a declared action as the host's runner would, without the dialog.

# `start!`

```elixir
@spec start!() :: :ok
```

Configures and starts the test endpoint; call it once in `test_helper.exs`.

# `ui_ctx`

```elixir
@spec ui_ctx(String.t() | struct(), term(), keyword()) ::
  Alternera.Resource.UI.Context.t()
```

A context for a test: options `:resource` (a resource module),
`:package` (default `"test"`), `:can_write?` (default `true`) and
`:timezone`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
