1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 require 'integration_helper'
7 class SearchBoxTest < ActionDispatch::IntegrationTest
13 def verify_search_box user
14 if user && user['is_active']
15 aproject_uuid = api_fixture('groups')['aproject']['uuid']
16 # let's search for aproject by uuid
17 within('.navbar-fixed-top') do
18 page.has_field?('search this site')
19 page.find_field('search this site').set aproject_uuid
20 page.find('.glyphicon-search').click
23 # we should now be in aproject as a result of search
24 assert_selector 'a', text:'Data collections'
25 click_link 'Data collections'
26 assert_selector "#Data_collections[data-object-uuid='#{aproject_uuid}']", "Expected to be in user page after search click"
28 # let's search again for an invalid uuid
29 within('.navbar-fixed-top') do
30 search_for = String.new user['uuid']
32 page.find_field('search this site').set search_for
33 page.find('.glyphicon-search').click
36 # we should see 'not found' error page
37 assert page.has_text?('Not Found'), 'No text - Not Found'
38 assert page.has_link?('Report problem'), 'No text - Report problem'
39 click_link 'Report problem'
40 within '.modal-content' do
41 assert page.has_text?('Report a problem'), 'No text - Report a problem'
42 assert page.has_no_text?('Version / debugging info'), 'No text - Version / debugging info'
43 assert page.has_text?('Describe the problem'), 'No text - Describe the problem'
44 assert page.has_text?('Send problem report'), 'Send problem report button text is not found'
45 assert page.has_no_button?('Send problem report'), 'Send problem report button is not disabled before entering problem description'
46 assert page.has_button?('Cancel'), 'No button - Cancel'
48 # enter a report text and click on report
49 page.find_field('report_issue_text').set 'my test report text'
50 assert page.has_button?('Send problem report'), 'Send problem report button not enabled after entering text'
51 click_button 'Send problem report'
53 # ajax success updated button texts and added footer message
54 assert page.has_no_text?('Send problem report'), 'Found button - Send problem report'
55 assert page.has_no_button?('Cancel'), 'Found button - Cancel'
56 assert page.has_text?('Report sent'), 'No text - Report sent'
57 assert page.has_button?('Close'), 'No text - Close'
58 assert page.has_text?('Thanks for reporting this issue'), 'No text - Thanks for reporting this issue'
63 # let's search for the anonymously accessible project
64 publicly_accessible_project = api_fixture('groups')['anonymously_accessible_project']
66 within('.navbar-fixed-top') do
67 # search again for the anonymously accessible project
68 page.find_field('search this site').set publicly_accessible_project['name'][0,10]
69 page.find('.glyphicon-search').click
72 within '.modal-content' do
73 assert page.has_text?('All projects'), 'No text - All projects'
74 assert page.has_text?('Search'), 'No text - Search'
75 assert page.has_text?('Cancel'), 'No text - Cancel'
76 assert_selector('div', text: publicly_accessible_project['name'])
77 find(:xpath, '//div[./span[contains(.,publicly_accessible_project["uuid"])]]').click
82 # seeing "Unrestricted public data" now
83 assert page.has_text?(publicly_accessible_project['name']), 'No text - publicly accessible project name'
84 assert page.has_text?(publicly_accessible_project['description']), 'No text - publicly accessible project description'
86 within('.navbar-fixed-top') do
87 page.has_no_field?('search this site')
94 ['inactive', api_fixture('users')['inactive']],
95 ['inactive_uninvited', api_fixture('users')['inactive_uninvited']],
96 ['active', api_fixture('users')['active']],
97 ['admin', api_fixture('users')['admin']],
98 ].each do |token, user|
100 test "test search box for user #{token}" do
101 visit page_with_token(token)
103 verify_search_box user