Helpers for a host's own test suite, over plain Ring maps and rendered
bodies. Nothing here needs ring-mock or any other library, so it ships in
the jar. The shapes parsed are the base's own — the cookies Ring's session
middleware sets, the CSRF token the shell and security/csrf-field emit —
which is why the base owns these readers rather than every host's tests.
Helpers for a host's own test suite, over plain Ring maps and rendered bodies. Nothing here needs ring-mock or any other library, so it ships in the jar. The shapes parsed are the base's own — the cookies Ring's session middleware sets, the CSRF token the shell and `security/csrf-field` emit — which is why the base owns these readers rather than every host's tests.
(browser handler)A browser over handler, as a value: an empty cookie jar, no CSRF token yet, no
page. visit answers the browser after a request; nothing is mutated, so a test can
keep two tabs of one person by holding two values.
Why the base ships it: every host's suite wrote the same one, and the first lost an afternoon to the one trap it has — a jar chained from the last response alone drops the session cookie at the first page that sets none, so every request after the login looks signed out. This one accumulates.
A browser over `handler`, as a value: an empty cookie jar, no CSRF token yet, no page. `visit` answers the browser after a request; nothing is mutated, so a test can keep two tabs of one person by holding two values. Why the base ships it: every host's suite wrote the same one, and the first lost an afternoon to the one trap it has — a jar chained from the last response alone drops the session cookie at the first page that sets none, so every request after the login looks signed out. This one accumulates.
(cookies response)Every cookie response sets, name to value, the way a browser keeps
them: a deletion (Max-Age of zero or less) is nil, a cookie to forget.
Every cookie `response` sets, name to value, the way a browser keeps them: a deletion (`Max-Age` of zero or less) is nil, a cookie to forget.
(csrf-token response)The CSRF token a rendered response carries, from the hidden field of a
classic form or from the shell's <body> attribute; nil when the body is
not a string or holds neither.
The CSRF token a rendered `response` carries, from the hidden field of a classic form or from the shell's `<body>` attribute; nil when the body is not a string or holds neither.
(fragment request)request as htmx sends it for a swap, so the base renders a fragment —
even a request already marked as a whole-document one.
`request` as htmx sends it for a swap, so the base renders a fragment — even a request already marked as a whole-document one.
(visit b method path)(visit b method path params)(visit b method path params opts)The browser after sending method (:get or :post) to path with form params,
holding the final :response and, as :path, where it landed — the address bar, with
its query string, after every redirect was followed.
{:htmx? true}, as the header the shell makes htmx send,
with the headers of a swap. A POST with no token known throws: a 403 that looked
like the application's fault is the failure it replaces. After a login the session,
and with it the token, is new — GET a page before the next POST.HX-Redirect is left in the response for the test to read, as htmx would act on it
and a server-side test cannot.{:remote-addr "…"} sets the source address, for anything keyed by it.The jar keeps what cookies reads — a cookie set again replaces the old value and a
deletion (Max-Age of zero or less, which is how Ring deletes) forgets it — and
ignores Path, Domain and Expires: one site, every path.
The browser after sending `method` (`:get` or `:post`) to `path` with form `params`,
holding the final `:response` and, as `:path`, where it landed — the address bar, with
its query string, after every redirect was followed.
- A POST carries the CSRF token of the last page that had one, as the hidden field a
form would send — or, with `{:htmx? true}`, as the header the shell makes htmx send,
with the headers of a swap. A POST with no token known throws: a 403 that looked
like the application's fault is the failure it replaces. After a login the session,
and with it the token, is new — GET a page before the next POST.
- A 301, 302 or 303 is followed as a GET through the same jar, up to ten times; an
`HX-Redirect` is left in the response for the test to read, as htmx would act on it
and a server-side test cannot.
- `{:remote-addr "…"}` sets the source address, for anything keyed by it.
The jar keeps what `cookies` reads — a cookie set again replaces the old value and a
deletion (`Max-Age` of zero or less, which is how Ring deletes) forgets it — and
ignores `Path`, `Domain` and `Expires`: one site, every path.(with-cookies request response)request carrying the cookies it already had and every one response
set, the way a browser follows a redirect: a cookie set again replaces the
old value, a deletion forgets it. The second request of a login test, the
swap after a page. Unchanged when the jar does not change.
`request` carrying the cookies it already had and every one `response` set, the way a browser follows a redirect: a cookie set again replaces the old value, a deletion forgets it. The second request of a login test, the swap after a page. Unchanged when the jar does not change.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |