✨ Detecta errores de programación en desarrollo
Añade comprobaciones sin coste en producción:
- Falla con `debug_assert!` si `param_or*`/`extra_or*` piden otro tipo,
si `form:📅:Field` recibe un valor de otro tipo, si `grid::Tracks`
supera MAX_TRACKS o si `TestRequest::header()` recibe una cabecera
no válida.
- Avisa en desarrollo de las traducciones ausentes y, al arrancar, de
las claves de permiso repetidas.
- Corrige en Bootsier el título por defecto de los desplegables y los
botones de confirmación, que salían siempre en inglés. Evita también
el aviso de import sin usar en release de `core/extension/all.rs`.
This commit is contained in:
parent
c7888c85ac
commit
f9ab1f55a3
18 changed files with 203 additions and 49 deletions
34
extensions/pagetop-bootsier/tests/translations.rs
Normal file
34
extensions/pagetop-bootsier/tests/translations.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
// Verifies that the texts added by the theme on its own come translated from their own catalog.
|
||||
|
||||
use pagetop::prelude::*;
|
||||
use pagetop_bootsier::Bootsier;
|
||||
use pagetop_bootsier::theme::*;
|
||||
|
||||
fn request() -> HttpRequest {
|
||||
web::test::TestRequest::get().to_http_request()
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn a_dropdown_without_title_gets_the_translated_default() {
|
||||
let mut nav = Nav::new().with_item(bs::nav::Item::dropdown(
|
||||
Dropdown::new().with_item(dropdown::Item::link(Lc::n("x"), "/x")),
|
||||
));
|
||||
let mut cx = Context::new(request())
|
||||
.with_theme(&Bootsier)
|
||||
.with_langid(&Locale::resolve("es-ES"));
|
||||
let html = nav.render(&mut cx).await.into_string();
|
||||
assert!(html.contains("Menú desplegable"), "{html}");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn the_confirmation_buttons_are_translated() {
|
||||
let html = Page::new(request())
|
||||
.with_theme(&Bootsier)
|
||||
.with_langid(&Locale::resolve("es-ES"))
|
||||
.render()
|
||||
.await
|
||||
.unwrap()
|
||||
.into_string();
|
||||
assert!(html.contains(r#"data-confirm-ok="Aceptar""#), "{html}");
|
||||
assert!(html.contains(r#"data-confirm-cancel="Cancelar""#), "{html}");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue