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