From 162c117a5a7345b9ccfd0ed17d907c9050d65b31 Mon Sep 17 00:00:00 2001 From: slhx agent Date: Tue, 26 May 2026 01:38:01 +0200 Subject: [PATCH] test(v0): use component-scoped generated APIs Drop the v0 example's global export opt-in and update tests to use component-scoped slots and forms, matching the checked public API path. req: component/003 req: build/001 --- examples/v0/build.rs | 2 +- examples/v0/src/lib.rs | 40 ++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/examples/v0/build.rs b/examples/v0/build.rs index f507d87..5f2e967 100644 --- a/examples/v0/build.rs +++ b/examples/v0/build.rs @@ -1,3 +1,3 @@ fn main() { - slhx_build::app().global_exports(true).run().unwrap(); + slhx_build::app().run().unwrap(); } diff --git a/examples/v0/src/lib.rs b/examples/v0/src/lib.rs index fccb4c8..1c68942 100644 --- a/examples/v0/src/lib.rs +++ b/examples/v0/src/lib.rs @@ -49,12 +49,12 @@ mod tests { #[test] fn counter_updates_a_generated_slot() { fn increment(count: u64) -> impl IntoEffect { - ui::slots::counter_value.text(count + 1) + ui::counter::slots::counter_value.text(count + 1) } let effect = inspect(increment(1)); - assert!(effect.has_slot(ui::slots::counter_value)); + assert!(effect.has_slot(ui::counter::slots::counter_value)); assert!(matches!(effect.ops(), [Effect::Put { .. }])); } @@ -63,12 +63,12 @@ mod tests { fn form_handler_is_checked_against_hemplate_form() { #[slhx::handler] fn add_todo(_form: slhx::Form) -> impl IntoEffect { - ui::slots::todo_list.text("queued") + ui::todos::slots::todo_list.text("queued") } let effect = inspect(add_todo(TodoInput::FORM)); - assert!(effect.has_slot(ui::slots::todo_list)); + assert!(effect.has_slot(ui::todos::slots::todo_list)); assert!(matches!(effect.ops(), [Effect::Put { payload: Payload::Text(_), .. }])); } @@ -77,7 +77,7 @@ mod tests { fn todos_append_keyed_rows_from_form_input() { fn add_todo(input: TodoInput) -> impl IntoEffect { let todo = Todo { id: 7, title: input.title }; - ui::slots::todo_row.append( + ui::todos::slots::todo_row.append( todo.id.to_string(), &TodoRow { title: todo.title }, ) @@ -85,7 +85,7 @@ mod tests { let effect = inspect(add_todo(TodoInput { title: "Ship v0".into() })); - assert!(effect.has_resource(ui::slots::todo_row.id())); + assert!(effect.has_resource(ui::todos::slots::todo_row.id())); assert!(matches!(effect.ops(), [Effect::Insert { key, payload, .. }] if key == "7" && matches!(payload, Payload::Html(_)))); } @@ -94,12 +94,12 @@ mod tests { fn wizard_form_handler_is_checked_against_hemplate_form() { #[slhx::handler] fn next_step(_form: slhx::Form) -> impl IntoEffect { - ui::slots::wizard_step.text("queued") + ui::wizard::slots::wizard_step.text("queued") } let effect = inspect(next_step(WizardInput::FORM)); - assert!(effect.has_slot(ui::slots::wizard_step)); + assert!(effect.has_slot(ui::wizard::slots::wizard_step)); assert!(matches!(effect.ops(), [Effect::Put { payload: Payload::Text(_), .. }])); } @@ -107,12 +107,12 @@ mod tests { #[test] fn wizard_form_swaps_the_current_step() { fn next_step(input: WizardInput) -> impl IntoEffect { - ui::slots::wizard_step.text(format!("Step {}", input.step + 1)) + ui::wizard::slots::wizard_step.text(format!("Step {}", input.step + 1)) } let effect = inspect(next_step(WizardInput { step: 1 })); - assert!(effect.has_slot(ui::slots::wizard_step)); + assert!(effect.has_slot(ui::wizard::slots::wizard_step)); assert!(matches!(effect.ops(), [Effect::Put { .. }])); } @@ -121,18 +121,18 @@ mod tests { fn page_swap_updates_content_and_history() { fn load_docs() -> impl IntoEffect { ( - ui::slots::content.render(&DocsContent { + ui::page_swap::slots::content.render(&DocsContent { message: "This page was swapped.", }), - ui::slots::title.text("Docs"), + ui::page_swap::slots::title.text("Docs"), push("/docs"), ) } let effect = inspect(load_docs()); - assert!(effect.has_slot(ui::slots::content)); - assert!(effect.has_slot(ui::slots::title)); + assert!(effect.has_slot(ui::page_swap::slots::content)); + assert!(effect.has_slot(ui::page_swap::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")); } @@ -142,12 +142,12 @@ mod tests { fn auth_form_handler_is_checked_against_hemplate_form() { #[slhx::handler] fn login(_form: slhx::Form) -> impl IntoEffect { - ui::slots::login_status.text("queued") + ui::auth::slots::login_status.text("queued") } let effect = inspect(login(Credentials::FORM)); - assert!(effect.has_slot(ui::slots::login_status)); + assert!(effect.has_slot(ui::auth::slots::login_status)); assert!(matches!(effect.ops(), [Effect::Put { payload: Payload::Text(_), .. }])); } @@ -161,12 +161,12 @@ mod tests { "Try again" }; - ui::slots::login_status.text(status) + ui::auth::slots::login_status.text(status) } let effect = inspect(login(Credentials { email: "demo@example.com".into(), password: "secret".into() })); - assert!(effect.has_slot(ui::slots::login_status)); + assert!(effect.has_slot(ui::auth::slots::login_status)); assert!(matches!(effect.ops(), [Effect::Put { .. }])); } @@ -174,12 +174,12 @@ mod tests { #[test] fn sse_notifications_update_a_generated_slot() { fn notification(message: &str) -> impl IntoEffect { - ui::slots::notifications.text(message) + ui::notifications::slots::notifications.text(message) } let effect = inspect(notification("Build finished")); - assert!(effect.has_slot(ui::slots::notifications)); + assert!(effect.has_slot(ui::notifications::slots::notifications)); assert!(matches!(effect.ops(), [Effect::Put { .. }])); } }