From 9b06bc03df3bbda6c8776449a550c907331e54ca Mon Sep 17 00:00:00 2001 From: slhx agent Date: Mon, 25 May 2026 23:21:43 +0200 Subject: [PATCH] test(v0): render page swap content from hemplate Exercise the v0 page-swap effect with a renderable hemplate view payload instead of an ad hoc HTML-looking text literal. req: view/001 req: html_safety/002 req: page_swap/002 req: page_swap/003 --- examples/v0/src/lib.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/examples/v0/src/lib.rs b/examples/v0/src/lib.rs index a126aad..51cb967 100644 --- a/examples/v0/src/lib.rs +++ b/examples/v0/src/lib.rs @@ -36,6 +36,12 @@ mod tests { title: String, } + #[derive(Hemplate)] + #[hemplate = "partials"] + struct DocsContent { + message: &'static str, + } + // req: examples/001 req: ceremony/001 req: build/001 req: build/005 req: codegen/002 #[test] fn counter_updates_a_generated_slot() { @@ -85,12 +91,12 @@ mod tests { assert!(matches!(effect.ops(), [Effect::Put { .. }])); } - // req: examples/001 req: page_swap/002 req: page_swap/003 req: build/001 req: build/005 + // req: examples/001 req: page_swap/002 req: page_swap/003 req: build/001 req: build/005 req: view/001 #[test] fn page_swap_updates_content_and_history() { fn load_docs() -> impl IntoEffect { ( - ui::slots::content.text("

Docs

"), + ui::slots::content.html(render_docs_content("This page was swapped.")), ui::slots::title.text("Docs"), push("/docs"), ) @@ -100,9 +106,19 @@ mod tests { assert!(effect.has_slot(ui::slots::content)); assert!(effect.has_slot(ui::slots::title)); + assert!(matches!(effect.ops().first(), Some(Effect::Put { payload: Payload::Html(_), .. }))); assert!(matches!(effect.ops().last(), Some(Effect::Navigate { url, mode: NavigateMode::Push, .. }) if url == "/docs")); } + fn render_docs_content(message: &'static str) -> SafeHtml { + // req: html_safety/002 req: view/001 + SafeHtml::trusted( + DocsContent { message } + .render() + .expect("v0 docs content renders"), + ) + } + // req: examples/001 req: progressive_disclosure/001 req: build/001 req: build/005 req: codegen/004 #[test] fn auth_flow_reads_typed_input_and_updates_status() {