feat(build): make generated page helper canonical
Move canonical examples and docs snippets from raw render/page calls to generated ui::page helpers, hide generated render behind doc(hidden), and let form resources participate in generated target inspection for tests. req: canonical_authoring/005 req: dx/006 req: codegen/002 req: public_api/002 req: test/001
This commit is contained in:
+15
-19
@@ -254,18 +254,18 @@ pub struct AppShell {
|
||||
}
|
||||
|
||||
pub fn home_page(ctx: &AppContext) -> Html {
|
||||
hemx::page(&AppShell {
|
||||
ui::page(&AppShell {
|
||||
title: "hemx SaaS tutorial",
|
||||
runtime_src: runtime_js_path(),
|
||||
body: hemx::page(&Dashboard::from_context(ctx)),
|
||||
body: ui::page(&Dashboard::from_context(ctx)),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn settings_page(ctx: &AppContext) -> Html {
|
||||
hemx::page(&AppShell {
|
||||
ui::page(&AppShell {
|
||||
title: "hemx SaaS tutorial settings",
|
||||
runtime_src: runtime_js_path(),
|
||||
body: hemx::page(&Dashboard::settings(ctx)),
|
||||
body: ui::page(&Dashboard::settings(ctx)),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ fn project_summary(total: usize) -> String {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use hemx_axum::{InteractionForm, InteractionRequest};
|
||||
use hemx_test::{inspect, inspect_batch};
|
||||
use hemx_test::{any_root_selector, inspect, inspect_batch, target_selector};
|
||||
use scraper::{Html as ParsedHtml, Selector};
|
||||
|
||||
fn form<I>(handle: hemx::Handle<I>, fields: &[(&str, &str)]) -> InteractionForm {
|
||||
@@ -353,15 +353,13 @@ mod tests {
|
||||
let html = home_page(&ctx);
|
||||
let document = ParsedHtml::parse_document(html.as_str());
|
||||
|
||||
assert_eq!(document.select(&selector(any_root_selector())).count(), 1);
|
||||
assert_eq!(
|
||||
document
|
||||
.select(&selector("[data-hemx-root='dashboard']"))
|
||||
.count(),
|
||||
1
|
||||
);
|
||||
assert_eq!(
|
||||
document
|
||||
.select(&selector("form[data-hemx-form='new_project']"))
|
||||
.select(&selector(&format!(
|
||||
"form{}",
|
||||
target_selector(dashboard::new_project)
|
||||
)))
|
||||
.count(),
|
||||
1
|
||||
);
|
||||
@@ -389,15 +387,13 @@ mod tests {
|
||||
let html = settings_page(&ctx);
|
||||
let document = ParsedHtml::parse_document(html.as_str());
|
||||
|
||||
assert_eq!(document.select(&selector(any_root_selector())).count(), 1);
|
||||
assert_eq!(
|
||||
document
|
||||
.select(&selector("[data-hemx-root='dashboard']"))
|
||||
.count(),
|
||||
1
|
||||
);
|
||||
assert_eq!(
|
||||
document
|
||||
.select(&selector("[data-hemx-slot='page_panel'] .settings-page"))
|
||||
.select(&selector(&format!(
|
||||
"{} .settings-page",
|
||||
target_selector(dashboard::page_panel)
|
||||
)))
|
||||
.count(),
|
||||
1
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user