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
This commit is contained in:
slhx agent
2026-05-25 23:21:43 +02:00
parent 227a408985
commit 9b06bc03df
+18 -2
View File
@@ -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("<h1>Docs</h1>"),
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() {