ctb_io_webui/controllers/
search.rs1use axum::{extract::State, response::Response};
23
24use crate::json_value;
25use crate::session_auth::AuthenticatedUser;
26use crate::{AppState, RequestState, respond_page};
27
28pub async fn get_index(
29 State(state): State<AppState>,
30 req: RequestState,
31 _user: AuthenticatedUser,
32) -> Response {
33 respond_page(&state, req, "search.index", &json_value!({}))
34}
35
36#[cfg(test)]
37#[allow(
38 clippy::panic,
39 clippy::expect_used,
40 clippy::unwrap_used,
41 clippy::unwrap_in_result,
42 clippy::panic_in_result_fn,
43 clippy::indexing_slicing,
44 clippy::arithmetic_side_effects,
45 reason = "Standard repository test boilerplate"
46)]
47mod tests {
48 use crate::test_helpers::{
49 assert_eq_or_print_body, assert_or_print_body, test_get_with_login,
50 };
51
52 #[crate::ctb_test("tokio")]
53 async fn can_get_index() {
54 let Ok((status, body, _lock)) =
55 test_get_with_login("/search", None, function_name!()).await
56 else {
57 panic!("Failed to perform test_get_with_login");
58 };
59 assert_eq_or_print_body(status, 200, &body);
60 assert_or_print_body(body.contains("name=\"search-text\""), &body);
61 }
62}