Admins, signed-in connections and the master localhost site, for a test that drives the admin
through its LiveViews — the core's or an extension's.
setup :serve_localhost!serve_localhost!/1 caches a master localhost site, marks the CMS installed, saves one page on
the site and signs boss@example.com in as a * admin of it, then hands the test
%{conn: conn, site: site, page: page}. The rest build what a test needs beside that: an admin
with other permissions (create_admin/3, narrow_conn/2), a user with none, a connection on
another host, and the flashes a LiveView shows.
The site cache (MishkaCmsCore.Runtime.States.SiteState) and the installed mark are the node's,
not the test's sandbox, so a test using serve_localhost!/1 is async: false.
Summary
Functions
A fresh connection on a site's own address, localhost unless told — serve_localhost!/1's is
already signed in.
Puts site in the site cache, as the runtime does when it loads it.
Clears both flashes of view, and answers view.
A user registered with a password, on site_id (nil for a master user), holding
permissions — every one by default.
A registered master user holding no permission.
The text of the info and error flashes view shows, tags removed.
Signs user in on conn, in master mode.
A connection on localhost signed in as a new admin of site holding only permissions.
The permission named name, created when it does not exist yet.
A setup callback: the master localhost site, created and cached, the CMS marked installed, one
page on the site drawing the context's :template (a hero section when it has none), and the
context's conn (a new one when it has none) on localhost, signed in as a * admin. Both
marks are cleared when the test exits.
Functions
@spec build_conn_for_host(String.t()) :: Plug.Conn.t()
A fresh connection on a site's own address, localhost unless told — serve_localhost!/1's is
already signed in.
Puts site in the site cache, as the runtime does when it loads it.
Clears both flashes of view, and answers view.
A user registered with a password, on site_id (nil for a master user), holding
permissions — every one by default.
A registered master user holding no permission.
The text of the info and error flashes view shows, tags removed.
@spec log_in(Plug.Conn.t(), struct()) :: Plug.Conn.t()
Signs user in on conn, in master mode.
@spec narrow_conn(struct(), [String.t()]) :: Plug.Conn.t()
A connection on localhost signed in as a new admin of site holding only permissions.
The permission named name, created when it does not exist yet.
@spec serve_localhost!(map()) :: %{ conn: Plug.Conn.t(), site: struct(), page: struct() }
A setup callback: the master localhost site, created and cached, the CMS marked installed, one
page on the site drawing the context's :template (a hero section when it has none), and the
context's conn (a new one when it has none) on localhost, signed in as a * admin. Both
marks are cleared when the test exits.