Add 'apps/arv-web/' from commit 'f9732ad8460d013c2f28363655d0d1b91894dca5'
[arvados.git] / apps / workbench / test / integration / search_box_test.rb
1 require 'integration_helper'
2
3 class SearchBoxTest < ActionDispatch::IntegrationTest
4   setup do
5     need_javascript
6   end
7
8   # test the search box
9   def verify_search_box user
10     if user && user['is_active']
11       # let's search for a valid uuid
12       within('.navbar-fixed-top') do
13         page.has_field?('search')
14         page.find_field('search').set user['uuid']
15         page.find('.glyphicon-search').click
16       end
17
18       # we should now be in the user's home project as a result of search
19       assert_selector "#Data_collections[data-object-uuid='#{user['uuid']}']", "Expected to be in user page after search click"
20
21       # let's search again for an invalid valid uuid
22       within('.navbar-fixed-top') do
23         search_for = String.new user['uuid']
24         search_for[0]='1'
25         page.find_field('search').set search_for
26         page.find('.glyphicon-search').click
27       end
28
29       # we should see 'not found' error page
30       assert page.has_text?('Not Found'), 'No text - Not Found'
31       assert page.has_link?('Report problem'), 'No text - Report problem'
32       click_link 'Report problem'
33       within '.modal-content' do
34         assert page.has_text?('Report a problem'), 'No text - Report a problem'
35         assert page.has_no_text?('Version / debugging info'), 'No text - Version / debugging info'
36         assert page.has_text?('Describe the problem'), 'No text - Describe the problem'
37         assert page.has_text?('Send problem report'), 'Send problem report button text is not found'
38         assert page.has_no_button?('Send problem report'), 'Send problem report button is not disabled before entering problem description'
39         assert page.has_button?('Cancel'), 'No button - Cancel'
40
41         # enter a report text and click on report
42         page.find_field('report_issue_text').set 'my test report text'
43         assert page.has_button?('Send problem report'), 'Send problem report button not enabled after entering text'
44         click_button 'Send problem report'
45
46         # ajax success updated button texts and added footer message
47         assert page.has_no_text?('Send problem report'), 'Found button - Send problem report'
48         assert page.has_no_button?('Cancel'), 'Found button - Cancel'
49         assert page.has_text?('Report sent'), 'No text - Report sent'
50         assert page.has_button?('Close'), 'No text - Close'
51         assert page.has_text?('Thanks for reporting this issue'), 'No text - Thanks for reporting this issue'
52
53         click_button 'Close'
54       end
55
56       # let's search for the anonymously accessible project
57       publicly_accessible_project = api_fixture('groups')['anonymously_accessible_project']
58
59       within('.navbar-fixed-top') do
60         # search again for the anonymously accessible project
61         page.find_field('search').set publicly_accessible_project['name'][0,10]
62         page.find('.glyphicon-search').click
63       end
64
65       within '.modal-content' do
66         assert page.has_text?('All projects'), 'No text - All projects'
67         assert page.has_text?('Search'), 'No text - Search'
68         assert page.has_text?('Cancel'), 'No text - Cancel'
69         assert_selector('div', text: publicly_accessible_project['name'])
70         find(:xpath, '//div[./span[contains(.,publicly_accessible_project["uuid"])]]').click
71
72         click_button 'Show'
73       end
74
75       # seeing "Unrestricted public data" now
76       assert page.has_text?(publicly_accessible_project['name']), 'No text - publicly accessible project name'
77       assert page.has_text?(publicly_accessible_project['description']), 'No text - publicly accessible project description'
78     else
79       within('.navbar-fixed-top') do
80         page.has_no_field?('search')
81       end
82     end
83   end
84
85   [
86     [nil, nil],
87     ['inactive', api_fixture('users')['inactive']],
88     ['inactive_uninvited', api_fixture('users')['inactive_uninvited']],
89     ['active', api_fixture('users')['active']],
90     ['admin', api_fixture('users')['admin']],
91   ].each do |token, user|
92
93     test "test search box for user #{token}" do
94       visit page_with_token(token)
95
96       verify_search_box user
97     end
98
99   end
100
101 end