1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class SearchControllerTest < ActionController::TestCase
8 # These tests don't do state-changing API calls. Save some time by
9 # skipping the database reset.
10 reset_api_fixtures :after_each_test, false
11 reset_api_fixtures :after_suite, true
13 include Rails.application.routes.url_helpers
15 test 'Get search dialog' do
16 get :choose, params: {
20 action_href: url_for(host: 'localhost', controller: :actions, action: :show),
21 action_data: {}.to_json,
22 }, session: session_for(:active), xhr: true
23 assert_response :success
26 test 'Get search results for all projects' do
27 get :choose, params: {
30 }, session: session_for(:active), xhr: true
31 assert_response :success
32 assert_not_empty(json_response['content'],
33 'search results for all projects should not be empty')
36 test 'Get search results for empty project' do
37 get :choose, params: {
40 project_uuid: api_fixture('groups')['empty_project']['uuid'],
41 }, session: session_for(:active), xhr: true
42 assert_response :success
43 assert_empty(json_response['content'],
44 'search results for empty project should be empty')
47 test 'search results for aproject and verify recursive contents' do
48 get :choose, params: {
51 project_uuid: api_fixture('groups')['aproject']['uuid'],
52 }, session: session_for(:active), xhr: true
53 assert_response :success
54 assert_not_empty(json_response['content'],
55 'search results for aproject should not be empty')
57 json_response['content'].scan /<div[^>]+>/ do |div_tag|
58 div_tag.scan(/\ data-object-uuid=\"(.*?)\"/).each do |uuid,|
63 assert_includes(items, api_fixture('collections')['collection_to_move_around_in_aproject']['uuid'])
64 assert_includes(items, api_fixture('groups')['asubproject']['uuid'])
65 assert_includes(items, api_fixture('collections')['baz_collection_name_in_asubproject']['uuid'])
66 assert_includes(items,
67 api_fixture('groups')['subproject_in_asubproject_with_same_name_as_one_in_active_user_home']['uuid'])