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