use pagetop::prelude::*; // The help text of a field gets an id and the control points to it with `aria-describedby`, so // screen readers announce it when the control gets the focus. async fn render(component: &mut impl Component) -> String { component .render(&mut Context::default()) .await .into_string() } fn help() -> Lc { Lc::n("Help") } // **< Form fields >******************************************************************************** #[pagetop::test] async fn single_controls_point_to_their_help_text() { let cases: [(String, &str); 5] = [ ( render( &mut form::input::Field::text() .with_name("a") .with_help_text(help()), ) .await, "edit-a-input-help", ), ( render(&mut form::Number::new().with_name("b").with_help_text(help())).await, "edit-b-input-help", ), ( render(&mut form::Range::new().with_name("c").with_help_text(help())).await, "edit-c-range-help", ), ( render(&mut form::Textarea::new().with_name("d").with_help_text(help())).await, "edit-d-textarea-help", ), ( render( &mut form::select::Field::new() .with_name("e") .with_help_text(help()), ) .await, "edit-e-select-help", ), ]; for (html, id) in cases { assert!( html.contains(&format!(r#"aria-describedby="{id}""#)), "{html}" ); assert!( html.contains(&format!(r#"