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
enduse 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.
Summary
Functions
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.
Generates a test that domain's UI declarations name modules of the right kind.
Runs a declared action as the host's runner would, without the dialog.
Configures and starts the test endpoint; call it once in test_helper.exs.
A context for a test: options :resource (a resource module),
:package (default "test"), :can_write? (default true) and
:timezone.
Functions
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.
Generates a test that domain's UI declarations name modules of the right kind.
Runs a declared action as the host's runner would, without the dialog.
@spec start!() :: :ok
Configures and starts the test endpoint; call it once in test_helper.exs.
@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.