Test case for the extension's JSON API, standing in for the CMS's MishkaCmsWeb.ConnCase.
Same contract as the CMS's — a sandboxed connection per test and a conn to drive it with — but
pointed at the endpoint config :mishka_cms_core, endpoint: … names: MishkaCmsCore.TestEndpoint
in this library's own suite, an extension's test endpoint in its suite. So the suite runs without
the CMS around it. See MishkaCmsCore.Repo for how the database is reached.
make_api_request/3 is here rather than in the factory: it builds requests, it does not build data.
Summary
Functions
@spec make_api_request(String.t(), term(), keyword()) :: Plug.Conn.t()
Calls the JSON:API the way a client does, and returns the Plug.Conn it answered with.
The conn is built by hand rather than through Phoenix.ConnTest.post/3 because JSON:API puts
structure in the query string — page[limit]=2, included_page[posts][limit]=1 — which Plug
leaves as flat bracketed keys. parse_json_api_params/1 folds those back into the nested maps the
router expects.
host matters: the tenant plug resolves which site a request belongs to from it, so a test that
changes hosts is testing a different tenant.
Every request goes through the test router's :api pipeline, whose
MishkaCmsCore.Runtime.Plugs.AdminSurfacePlug puts it on the admin API's surface as the CMS's
does: a policy asking for an area asks for admin:api:<area>.
Options
:method— defaults to"POST":host— defaults to"localhost":headers— extra request headers, e.g. the bearer token from signing in