8784: Fix test for latest firefox.
[arvados.git] / apps / workbench / test / integration / report_issue_test.rb
1 require 'integration_helper'
2
3 class ReportIssueTest < ActionDispatch::IntegrationTest
4   setup do
5     need_javascript
6     @user_profile_form_fields = Rails.configuration.user_profile_form_fields
7   end
8
9   teardown do
10     Rails.configuration.user_profile_form_fields = @user_profile_form_fields
11   end
12
13   # test version info and report issue from help menu
14   def check_version_info_and_report_issue_from_help_menu
15     within '.navbar-fixed-top' do
16       find('.help-menu > a').click
17       within '.help-menu .dropdown-menu' do
18         assert page.has_link?('Tutorials and User guide'), 'No link - Tutorials and User guide'
19         assert page.has_link?('API Reference'), 'No link - API Reference'
20         assert page.has_link?('SDK Reference'), 'No link - SDK Reference'
21         assert page.has_link?('Show version / debugging info ...'), 'No link - Show version / debugging info'
22         assert page.has_link?('Report a problem ...'), 'No link - Report a problem'
23
24         # check show version info link
25         click_link 'Show version / debugging info ...'
26       end
27     end
28
29     within '.modal-content' do
30       assert page.has_text?('Version / debugging info'), 'No text - Version / debugging info'
31       assert page.has_no_text?('Report a problem'), 'Found text - Report a problem'
32       assert page.has_no_text?('Describe the problem?'), 'Found text - Describe the problem'
33       assert page.has_button?('Close'), 'No button - Close'
34       assert page.has_no_button?('Send problem report'), 'Found button - Send problem report'
35       history_links = all('a').select do |a|
36         a[:href] =~ %r!^https://arvados.org/projects/arvados/repository/changes\?rev=[0-9a-f]+$!
37       end
38       assert_operator(2, :<=, history_links.count,
39                       "Should have found two links to revision history " +
40                       "in #{history_links.inspect}")
41       click_button 'Close'
42     end
43
44     # check report issue link
45     within '.navbar-fixed-top' do
46       find('.help-menu > a').click
47       find('.help-menu .dropdown-menu a', text: 'Report a problem ...').click
48     end
49
50     within '.modal-content' do
51       assert page.has_text?('Report a problem'), 'No text - Report a problem'
52       assert page.has_no_text?('Version / debugging info'), 'Found text - Version / debugging info'
53       assert page.has_text?('Describe the problem'), 'No text - Describe the problem'
54       assert page.has_no_button?('Close'), 'Found button - Close'
55       assert page.has_text?('Send problem report'), 'Send problem report button text is not found'
56       assert page.has_no_button?('Send problem report'), 'Send problem report button is not disabled before entering problem description'
57       assert page.has_button?('Cancel'), 'No button - Cancel'
58
59       # enter a report text and click on report
60       page.find_field('report_issue_text').set 'my test report text'
61       assert page.has_button?('Send problem report'), 'Send problem report button not enabled after entering text'
62
63       report = mock
64       report.expects(:deliver).returns true
65       IssueReporter.expects(:send_report).returns report
66
67       click_button 'Send problem report'
68
69       # ajax success updated button texts and added footer message
70       assert page.has_no_text?('Send problem report'), 'Found button - Send problem report'
71       assert page.has_no_button?('Cancel'), 'Found button - Cancel'
72       assert page.has_text?('Report sent'), 'No text - Report sent'
73       assert page.has_button?('Close'), 'No text - Close'
74       assert page.has_text?('Thanks for reporting this issue'), 'No text - Thanks for reporting this issue'
75
76       click_button 'Close'
77     end
78   end
79
80   [
81     [nil, nil],
82     ['inactive', api_fixture('users')['inactive']],
83     ['inactive_uninvited', api_fixture('users')['inactive_uninvited']],
84     ['active', api_fixture('users')['active']],
85     ['admin', api_fixture('users')['admin']],
86     ['active_no_prefs', api_fixture('users')['active_no_prefs']],
87     ['active_no_prefs_profile_no_getting_started_shown',
88         api_fixture('users')['active_no_prefs_profile_no_getting_started_shown']],
89   ].each do |token, user|
90
91     test "check version info and report issue for user #{token}" do
92       if !token
93         visit ('/')
94       else
95         visit page_with_token(token)
96       end
97
98       check_version_info_and_report_issue_from_help_menu
99     end
100
101   end
102
103 end