test(axum): exercise interaction helper path

Move public axum response tests off direct HandlerRegistry construction so the checked test surface follows interactions()/on() just like canonical examples.

req: axum_integration/003

req: ceremony/001

req: dx/003
This commit is contained in:
slhx agent
2026-06-02 00:33:23 +02:00
parent 1e53a6f7df
commit ee25441be7
+13 -10
View File
@@ -2,7 +2,7 @@ use axum::http::{header, HeaderMap};
use axum::response::IntoResponse;
use scraper::{Html, Selector};
use slhx_axum::{
interactions, runtime_js, DispatchRejection, EffectResponse, HandlerRegistry, InteractionForm,
interactions, runtime_js, DispatchRejection, EffectResponse, InteractionForm,
InteractionFormRejection, InteractionRequest, PageMode, PageRequest, PageResponse,
SLHX_CONTENT_TYPE, SLHX_FINGERPRINT_HEADER, SLHX_PARTIAL_HEADER, SLHX_RUNTIME_CONTENT_TYPE,
SLHX_TITLE_HEADER,
@@ -169,16 +169,19 @@ fn interaction_request_dispatches_with_concise_handlers_helper() {
}
#[test]
fn handler_registry_dispatches_by_checked_handle() {
fn interactions_dispatch_by_checked_handle() {
// req: ceremony/004 req: public_api/001
let title = Slot::<String>::new(7);
let create = Handle::<()>::new(42);
let registry = HandlerRegistry::new(BuildFingerprint(123)).register_handle(create, move |form| {
title.text(form.value("title").unwrap_or(""))
});
let request = InteractionRequest::from(InteractionForm::for_handle(
create,
[("title".into(), "Hello".into())],
));
let response = registry
.dispatch(InteractionForm::for_handle(create, [("title".into(), "Hello".into())]))
let response = request
.dispatch(interactions(BuildFingerprint(123)).on(create, move |form| {
title.text(form.value("title").unwrap_or(""))
}))
.unwrap();
assert_eq!(response.batch.fingerprint, BuildFingerprint(123));
@@ -186,11 +189,11 @@ fn handler_registry_dispatches_by_checked_handle() {
}
#[test]
fn handler_registry_rejects_unknown_handle_ids() {
let registry = HandlerRegistry::new(BuildFingerprint(123));
fn interactions_reject_unknown_handle_ids() {
let request = InteractionRequest::from(InteractionForm::new(9, []));
assert_eq!(
registry.dispatch(InteractionForm::new(9, [])).unwrap_err(),
request.dispatch(interactions(BuildFingerprint(123))).unwrap_err(),
DispatchRejection::UnknownHandle(9)
);
}