Merge branch 'master' into 3699-arv-copy
[arvados.git] / apps / workbench / test / integration / report_issue_test.rb
1 require 'integration_helper'
2 require 'selenium-webdriver'
3 require 'headless'
4
5 class ReportIssueTest < 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_no_text?('Describe the problem?'), 'Found text - Describe the problem'
38       assert page.has_button?('Close'), 'No button - Close'
39       assert page.has_no_button?('Send problem report'), 'Found button - Send problem report'
40       click_button 'Close'
41     end
42
43     # check report issue link
44     within('.navbar-fixed-top') do
45       page.find("#arv-help").click
46       within('.dropdown-menu') do
47         click_link 'Report a problem ...'
48       end
49     end
50
51     within '.modal-content' do
52       assert page.has_text?('Report a problem'), 'No text - Report a problem'
53       assert page.has_no_text?('Version / debugging info'), 'Found text - Version / debugging info'
54       assert page.has_text?('Describe the problem'), 'No text - Describe the problem'
55       assert page.has_no_button?('Close'), 'Found button - Close'
56       assert page.has_text?('Send problem report'), 'Send problem report button text is not found'
57       assert page.has_no_button?('Send problem report'), 'Send problem report button is not disabled before entering problem description'
58       assert page.has_button?('Cancel'), 'No button - Cancel'
59
60       # enter a report text and click on report
61       page.find_field('report_issue_text').set 'my test report text'
62       assert page.has_button?('Send problem report'), 'Send problem report button not enabled after entering text'
63       click_button 'Send problem report'
64
65       # ajax success updated button texts and added footer message
66       assert page.has_no_text?('Send problem report'), 'Found button - Send problem report'
67       assert page.has_no_button?('Cancel'), 'Found button - Cancel'
68       assert page.has_text?('Report sent'), 'No text - Report sent'
69       assert page.has_button?('Close'), 'No text - Close'
70       assert page.has_text?('Thanks for reporting this issue'), 'No text - Thanks for reporting this issue'
71
72       click_button 'Close'
73     end
74   end
75
76   [
77     [nil, nil],
78     ['inactive', api_fixture('users')['inactive']],
79     ['inactive_uninvited', api_fixture('users')['inactive_uninvited']],
80     ['active', api_fixture('users')['active']],
81     ['admin', api_fixture('users')['admin']],
82     ['active_no_prefs', api_fixture('users')['active_no_prefs']],
83     ['active_no_prefs_profile', api_fixture('users')['active_no_prefs_profile']],
84   ].each do |token, user|
85
86     test "check version info and report issue for user #{token}" do
87       if !token
88         visit ('/')
89       else
90         visit page_with_token(token)
91       end
92
93       check_version_info_and_report_issue_from_help_menu
94     end
95
96   end
97
98 end