Fixtures for this library's suite and an extension's: sites, users, permissions, and the runtime records (components, layouts, pages, error pages, JS hooks, media) that everything else is built on.
These are the same wrappers the CMS's factory exposes. They ship in lib so an extension's suite
imports them instead of re-stating them, since a dependency cannot reach into another project's
test/support. The generators behind them are MishkaCmsCore.Dev.Generator.
Records are tenant-scoped, so each wrapper pops :site_id and passes it as the Ash tenant; a
nil tenant means the global row.
Summary
Functions
The named rows of the Chelekom kit this library ships, as palette entries (name, attrs,
slots, template), in the order asked. The bundle is 12 MB, so call it from setup_all.
rows of resource, written in one bulk create through its :create action under tenant (nil
for global rows), as a fixture: for a suite that needs more rows than one page of a read holds,
where a create per row costs seconds. Each row is the action's input, and nothing is compiled.
A user holding permission_names, returned with :permissions loaded so it can be used directly
as an Ash actor: without a further load.
A component module put by hand at the name the compilers would have built for name on site (a
site, or nil for a global one), drawing html — for a test about the canvas rather than the
compile pipeline.
An attrs declaration holding one of every option shape the Chelekom kit ships, for a test about
what a save keeps.
A template reading every attribute every_option_shape/0 declares, so a default lost on the way
raises KeyError the first time the component renders without that attribute.
The same cleanup create_component!/1 registers, for a name the component only takes during the
test — a rename builds a second module, under the new name.
Chelekom's Form Wrapper and Simple Form copied as wrapper and simple, the Simple Form calling
the copied wrapper and no longer requiring for: a pair only their markup marks as forms. rows
holds both originals, as chelekom_rows/1 answers them.
Functions
The named rows of the Chelekom kit this library ships, as palette entries (name, attrs,
slots, template), in the order asked. The bundle is 12 MB, so call it from setup_all.
rows of resource, written in one bulk create through its :create action under tenant (nil
for global rows), as a fixture: for a suite that needs more rows than one page of a read holds,
where a create per row costs seconds. Each row is the action's input, and nothing is compiled.
A user holding permission_names, returned with :permissions loaded so it can be used directly
as an Ash actor: without a further load.
Authorization in this CMS turns on two independent things — WHICH permissions a user holds and
WHICH site they belong to — so most policy tests need the same three actors: a master
(site_id: nil) with roles, a tenant with the same roles, and a tenant with none. Permissions are
looked up before being created so several actors can share one named permission in a test.
master = create_user_with_permissions!(["admin:dashboard:*"])
tenant = create_user_with_permissions!(["admin:dashboard:*"], site_id: site.id)
nobody = create_user!(site_id: site.id)
A component module put by hand at the name the compilers would have built for name on site (a
site, or nil for a global one), drawing html — for a test about the canvas rather than the
compile pipeline.
It answers the site it stands for as a compiled one does, since
MishkaCmsCore.Runtime.LiveViewHelpers draws a module only for its own site, and it goes when the
test does.
An attrs declaration holding one of every option shape the Chelekom kit ships, for a test about
what a save keeps.
Defaults of nil, "", false, true, 0, 1.0 and []; values that include nil, as
chelekom-button's type does; editor; and default_struct on a struct attribute. Rows are
string-keyed, as a row read back from the database is. every_option_template/0 reads each one.
A template reading every attribute every_option_shape/0 declares, so a default lost on the way
raises KeyError the first time the component renders without that attribute.
The same cleanup create_component!/1 registers, for a name the component only takes during the
test — a rename builds a second module, under the new name.
Chelekom's Form Wrapper and Simple Form copied as wrapper and simple, the Simple Form calling
the copied wrapper and no longer requiring for: a pair only their markup marks as forms. rows
holds both originals, as chelekom_rows/1 answers them.