Merge branch 'master' into 3112-report-bug. Also, break search testing into a separat...
[arvados.git] / apps / workbench / test / integration / report_issue_test.rb
1 require 'integration_helper'
2 require 'selenium-webdriver'
3 require 'headless'
4
5 class ApplicationLayoutTest < ActionDispatch::IntegrationTest
6   setup do
7     headless = Headless.new
8     headless.start
9     Capybara.current_driver = :selenium
10
11     @user_profile_form_fields = Rails.configuration.user_profile_form_fields
12   end
13
14   teardown do
15     Rails.configuration.user_profile_form_fields = @user_profile_form_fields
16   end
17
18   # test version info and report issue from help menu
19   def check_version_info_and_report_issue_from_help_menu
20     within('.navbar-fixed-top') do
21       page.find("#arv-help").click
22       within('.dropdown-menu') do
23         assert page.has_link?('Tutorials and User guide'), 'No link - Tutorials and User guide'
24         assert page.has_link?('API Reference'), 'No link - API Reference'
25         assert page.has_link?('SDK Reference'), 'No link - SDK Reference'
26         assert page.has_link?('Show version / debugging info'), 'No link - Show version / debugging info'
27         assert page.has_link?('Report a problem'), 'No link - Report a problem'
28
29         # check show version info link
30         click_link 'Show version / debugging info'
31       end
32     end
33
34     within '.modal-content' do
35       assert page.has_text?('Version / debugging info'), 'No text - Version / debugging info'
36       assert page.has_no_text?('Report a problem'), 'Found text - Report a problem'
37       assert page.has_text?('Server version'), 'No text - Server version'
38       assert page.has_text?('Server restarted at'), 'No text - Server restarted at'
39       assert page.has_text?('Workbench version'), 'No text - Workbench version'
40       assert page.has_text?('Arvados base'), 'No text - Arvados base'
41       assert page.has_text?('Additional info'), 'No text - Additional info'
42       assert page.has_no_text?('Found a problem?'), 'Found text - Found a problem'
43       assert page.has_button?('Close'), 'No button - Close'
44       assert page.has_no_button?('Report issue'), 'Found button - Report issue'
45       click_button 'Close'
46     end
47
48     # check report issue link
49     within('.navbar-fixed-top') do
50       page.find("#arv-help").click
51       within('.dropdown-menu') do
52         click_link 'Report a problem'
53       end
54     end
55
56     within '.modal-content' do
57       assert page.has_text?('Report a problem'), 'No text - Report a problem'
58       assert page.has_no_text?('Version / debugging info'), 'Found text - Version / debugging info'
59       assert page.has_text?('Server version'), 'No text - Server version'
60       assert page.has_text?('Server restarted at'), 'No text - Server restarted at'
61       assert page.has_text?('Workbench version'), 'No text - Workbench version'
62       assert page.has_text?('Arvados base'), 'No text - Arvados base'
63       assert page.has_text?('Additional info'), 'No text - Additional info'
64       assert page.has_text?('Found a problem?'), 'No text - Found a problem'
65       assert page.has_no_button?('Close'), 'Found button - Close'
66       assert page.has_button?('Report issue'), 'No button - Report issue'
67       assert page.has_button?('Cancel'), 'No button - Cancel'
68
69       # enter a report text and click on report
70       page.find_field('report_issue_text').set 'my test report text'
71       click_button 'Report issue'
72
73       # ajax success updated button texts and added footer message
74       assert page.has_no_button?('Report issue'), 'Found button - Report issue'
75       assert page.has_no_button?('Cancel'), 'Found button - Cancel'
76       assert page.has_text?('Report sent'), 'No text - Report sent'
77       assert page.has_button?('Close'), 'No text - Close'
78       assert page.has_text?('Thanks for reporting this issue'), 'No text - Thanks for reporting this issue'
79
80       click_button 'Close'
81     end
82   end
83
84   [
85     [nil, nil],
86     ['inactive', api_fixture('users')['inactive']],
87     ['inactive_uninvited', api_fixture('users')['inactive_uninvited']],
88     ['active', api_fixture('users')['active']],
89     ['admin', api_fixture('users')['admin']],
90     ['active_no_prefs', api_fixture('users')['active_no_prefs']],
91     ['active_no_prefs_profile', api_fixture('users')['active_no_prefs_profile']],
92   ].each do |token, user|
93
94     test "check help for user #{token}" do
95       if !token
96         visit ('/')
97       else
98         visit page_with_token(token)
99       end
100
101       check_version_info_and_report_issue_from_help_menu
102     end
103
104   end
105
106 end