3 class SearchControllerTest < ActionController::TestCase
4 # These tests don't do state-changing API calls. Save some time by
5 # skipping the database reset.
6 reset_api_fixtures :after_each_test, false
7 reset_api_fixtures :after_suite, true
9 include Rails.application.routes.url_helpers
11 test 'Get search dialog' do
16 action_href: url_for(host: 'localhost', controller: :actions, action: :show),
17 action_data: {}.to_json,
18 }, session_for(:active)
19 assert_response :success
22 test 'Get search results for all projects' do
26 }, session_for(:active)
27 assert_response :success
28 assert_not_empty(json_response['content'],
29 'search results for all projects should not be empty')
32 test 'Get search results for empty project' do
36 project_uuid: api_fixture('groups')['empty_project']['uuid'],
37 }, session_for(:active)
38 assert_response :success
39 assert_empty(json_response['content'],
40 'search results for empty project should be empty')
43 test 'search results for aproject and verify recursive contents' do
47 project_uuid: api_fixture('groups')['aproject']['uuid'],
48 }, session_for(:active)
49 assert_response :success
50 assert_not_empty(json_response['content'],
51 'search results for aproject should not be empty')
53 json_response['content'].scan /<div[^>]+>/ do |div_tag|
54 div_tag.scan(/\ data-object-uuid=\"(.*?)\"/).each do |uuid,|
59 assert_includes(items, api_fixture('collections')['collection_to_move_around_in_aproject']['uuid'])
60 assert_includes(items, api_fixture('groups')['asubproject']['uuid'])
61 assert_includes(items, api_fixture('collections')['baz_collection_name_in_asubproject']['uuid'])
62 assert_includes(items,
63 api_fixture('groups')['subproject_in_asubproject_with_same_name_as_one_in_active_user_home']['uuid'])