4465: add API/Workbench Github links to help modal
[arvados.git] / apps / workbench / test / integration / report_issue_test.rb
1 require 'integration_helper'
2 require 'selenium-webdriver'
3 require 'headless'
4 require_relative '../../app/helpers/version_helper'
5
6 class ReportIssueTest < ActionDispatch::IntegrationTest
7   include VersionHelper
8
9   setup do
10     headless = Headless.new
11     headless.start
12     Capybara.current_driver = :selenium
13
14     @user_profile_form_fields = Rails.configuration.user_profile_form_fields
15   end
16
17   teardown do
18     Rails.configuration.user_profile_form_fields = @user_profile_form_fields
19   end
20
21   # test version info and report issue from help menu
22   def check_version_info_and_report_issue_from_help_menu
23     within('.navbar-fixed-top') do
24       page.find("#arv-help").click
25       within('.dropdown-menu') do
26         assert page.has_link?('Tutorials and User guide'), 'No link - Tutorials and User guide'
27         assert page.has_link?('API Reference'), 'No link - API Reference'
28         assert page.has_link?('SDK Reference'), 'No link - SDK Reference'
29         assert page.has_link?('Show version / debugging info ...'), 'No link - Show version / debugging info'
30         assert page.has_link?('Report a problem ...'), 'No link - Report a problem'
31
32         # check show version info link
33         click_link 'Show version / debugging info ...'
34       end
35     end
36
37     within '.modal-content' do
38       assert page.has_text?('Version / debugging info'), 'No text - Version / debugging info'
39       assert page.has_no_text?('Report a problem'), 'Found text - Report a problem'
40       assert page.has_no_text?('Describe the problem?'), 'Found text - Describe the problem'
41       assert page.has_link?(api_version), 'No link for API version'
42       assert page.has_link?(wb_version_text), 'No link for Workbench version'
43       assert page.has_button?('Close'), 'No button - Close'
44       assert page.has_no_button?('Send problem report'), 'Found button - Send problem report'
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?('Describe the problem'), 'No text - Describe the problem'
60       assert page.has_no_button?('Close'), 'Found button - Close'
61       assert page.has_text?('Send problem report'), 'Send problem report button text is not found'
62       assert page.has_no_button?('Send problem report'), 'Send problem report button is not disabled before entering problem description'
63       assert page.has_button?('Cancel'), 'No button - Cancel'
64
65       # enter a report text and click on report
66       page.find_field('report_issue_text').set 'my test report text'
67       assert page.has_button?('Send problem report'), 'Send problem report button not enabled after entering text'
68       click_button 'Send problem report'
69
70       # ajax success updated button texts and added footer message
71       assert page.has_no_text?('Send problem report'), 'Found button - Send problem report'
72       assert page.has_no_button?('Cancel'), 'Found button - Cancel'
73       assert page.has_text?('Report sent'), 'No text - Report sent'
74       assert page.has_button?('Close'), 'No text - Close'
75       assert page.has_text?('Thanks for reporting this issue'), 'No text - Thanks for reporting this issue'
76
77       click_button 'Close'
78     end
79   end
80
81   [
82     [nil, nil],
83     ['inactive', api_fixture('users')['inactive']],
84     ['inactive_uninvited', api_fixture('users')['inactive_uninvited']],
85     ['active', api_fixture('users')['active']],
86     ['admin', api_fixture('users')['admin']],
87     ['active_no_prefs', api_fixture('users')['active_no_prefs']],
88     ['active_no_prefs_profile', api_fixture('users')['active_no_prefs_profile']],
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