require "test_helper" class SearchControllerTest < ActionDispatch::IntegrationTest test "header includes a search form with submit" do login_as users(:admin) get organizations_path(project_code: "matchlivetv") assert_response :success assert_includes response.body, 'action="/p/matchlivetv/search"' assert_includes response.body, 'method="get"' assert_includes response.body, 'name="q"' assert_includes response.body, 'type="submit"' end test "search finds organization by name" do login_as users(:admin) get search_path(project_code: "matchlivetv", q: "ASD Test") assert_response :success assert_match(/ASD Test Calcio/, response.body) end test "search finds contact by last name" do login_as users(:admin) get search_path(project_code: "matchlivetv", q: "Rossi") assert_response :success assert_match(/Mario Rossi/, response.body) end test "empty search does not error" do login_as users(:admin) get search_path(project_code: "matchlivetv") assert_response :success assert_match(/Nessun risultato/, response.body) end end