registration

This commit is contained in:
Priec
2026-08-05 12:07:14 +02:00
parent 7f93865f7d
commit b69a7c09a3
12 changed files with 259 additions and 2 deletions

View File

@@ -136,6 +136,7 @@ fn router(state: AppState) -> Router {
.route("/static/app.css", get(stylesheet))
.merge(pages::analytics::router())
.merge(pages::login::router())
.merge(pages::register::router())
.merge(pages::admin::admin::router())
.merge(pages::admin::table_definition::router())
.merge(pages::add_table::router())
@@ -198,7 +199,7 @@ mod tests {
#[tokio::test]
async fn every_backend_free_page_renders_the_shared_shell() {
for path in ["/", "/login"] {
for path in ["/", "/login", "/register"] {
let (status, body) = get(path).await;
assert!(status.is_success(), "{path} returned {status}");
assert!(
@@ -230,9 +231,34 @@ mod tests {
async fn signed_out_navbar_offers_login_instead_of_logout() {
let (_, body) = get("/").await;
assert!(body.contains("href=\"/login\""));
assert!(body.contains("href=\"/register\""));
assert!(!body.contains("hx-post=\"/logout\""));
}
/// The register form carries every `RegisterRequest` field the TUI client
/// asks for, and the suggestion lists for the three the client suggests.
#[tokio::test]
async fn the_register_form_offers_the_same_fields_as_the_client() {
let (_, body) = get("/register").await;
for field in [
"username",
"email",
"password",
"password_confirmation",
"role",
"timezone",
"phone_country",
] {
assert!(
body.contains(&format!("name=\"{field}\"")),
"the register form is missing the {field} field"
);
}
assert!(body.contains("value=\"accountant\""));
assert!(body.contains("value=\"Europe/Bratislava\""));
assert!(body.contains("value=\"SK\""));
}
/// Every table-definition endpoint is mounted, and every one of them is
/// behind a session: without a cookie there is no request to sign, so each
/// answers with the redirect to the login page rather than a 404 or a call