1 require 'integration_helper'
3 class ApplicationLayoutTest < ActionDispatch::IntegrationTest
4 # These tests don't do state-changing API calls. Save some time by
5 # skipping the database reset.
6 reset_api_fixtures :after_each_test, false
7 reset_api_fixtures :after_suite, true
13 def verify_homepage user, invited, has_profile
14 profile_config = Rails.configuration.user_profile_form_fields
17 assert page.has_text?('Please log in'), 'Not found text - Please log in'
18 assert page.has_text?('The "Log in" button below will show you a Google sign-in page'), 'Not found text - google sign in page'
19 assert page.has_no_text?('My projects'), 'Found text - My projects'
20 assert page.has_link?("Log in to #{Rails.configuration.site_name}"), 'Not found text - log in to'
21 elsif user['is_active']
22 if profile_config && !has_profile
23 assert page.has_text?('Save profile'), 'No text - Save profile'
25 assert page.has_link?("Projects"), 'Not found link - Projects'
26 page.find("#projects-menu").click
27 assert_selector 'a', text: 'Search all projects'
28 assert_no_selector 'a', text: 'Browse public projects'
29 assert_selector 'a', text: 'Add a new project'
30 assert_selector 'li[class="dropdown-header"]', text: 'My projects'
33 assert page.has_text?('Please check the box below to indicate that you have read and accepted the user agreement'), 'Not found text - Please check the box below . . .'
35 assert page.has_text?('Your account is inactive'), 'Not found text - Your account is inactive'
38 within('.navbar-fixed-top') do
40 assert_text Rails.configuration.site_name.downcase
41 assert_no_selector 'a', text: Rails.configuration.site_name.downcase
42 assert page.has_link?('Log in'), 'Not found link - Log in'
45 assert_selector 'a', text: Rails.configuration.site_name.downcase
46 assert(page.has_link?("notifications-menu"), 'no user menu')
47 page.find("#notifications-menu").click
48 within('.dropdown-menu') do
50 assert page.has_no_link?('Not active'), 'Found link - Not active'
51 assert page.has_no_link?('Sign agreements'), 'Found link - Sign agreements'
53 assert_selector "a[href=\"/projects/#{user['uuid']}\"]", text: 'Home project'
54 assert_selector "a[href=\"/users/#{user['uuid']}/virtual_machines\"]", text: 'Virtual machines'
55 assert_selector "a[href=\"/users/#{user['uuid']}/repositories\"]", text: 'Repositories'
56 assert_selector "a[href=\"/current_token\"]", text: 'Current token'
57 assert_selector "a[href=\"/users/#{user['uuid']}/ssh_keys\"]", text: 'SSH keys'
60 assert_selector "a[href=\"/users/#{user['uuid']}/profile\"]", text: 'Manage profile'
62 assert_no_selector "a[href=\"/users/#{user['uuid']}/profile\"]", text: 'Manage profile'
65 assert_no_selector 'a', text: 'Home project'
66 assert page.has_no_link?('Virtual machines'), 'Found link - Virtual machines'
67 assert page.has_no_link?('Repositories'), 'Found link - Repositories'
68 assert page.has_no_link?('Current token'), 'Found link - Current token'
69 assert page.has_no_link?('SSH keys'), 'Found link - SSH keys'
70 assert page.has_no_link?('Manage profile'), 'Found link - Manage profile'
72 assert page.has_link?('Log out'), 'No link - Log out'
80 within('.navbar-fixed-top') do
81 page.find("#arv-help").click
82 within('.dropdown-menu') do
83 assert_selector 'a', text:'Getting Started ...'
84 assert_selector 'a', text:'Public Pipelines and Data sets'
85 assert page.has_link?('Tutorials and User guide'), 'No link - Tutorials and User guide'
86 assert page.has_link?('API Reference'), 'No link - API Reference'
87 assert page.has_link?('SDK Reference'), 'No link - SDK Reference'
88 assert page.has_link?('Show version / debugging info ...'), 'No link - Show version / debugging info'
89 assert page.has_link?('Report a problem ...'), 'No link - Report a problem'
90 # Version info and Report a problem are tested in "report_issue_test.rb"
95 def verify_system_menu user
96 if user && user['is_admin']
97 assert page.has_link?('system-menu'), 'No link - system menu'
98 within('.navbar-fixed-top') do
99 page.find("#system-menu").click
100 within('.dropdown-menu') do
101 assert page.has_text?('Groups'), 'No text - Groups'
102 assert page.has_link?('Repositories'), 'No link - Repositories'
103 assert page.has_link?('Virtual machines'), 'No link - Virtual machines'
104 assert page.has_link?('SSH keys'), 'No link - SSH keys'
105 assert page.has_link?('API tokens'), 'No link - API tokens'
106 find('a', text: 'Users').click
109 assert page.has_text? 'Add a new user'
111 assert page.has_no_link?('system-menu'), 'Found link - system menu'
116 [nil, nil, false, false],
117 ['inactive', api_fixture('users')['inactive'], true, false],
118 ['inactive_uninvited', api_fixture('users')['inactive_uninvited'], false, false],
119 ['active', api_fixture('users')['active'], true, true],
120 ['admin', api_fixture('users')['admin'], true, true],
121 ['active_no_prefs', api_fixture('users')['active_no_prefs'], true, false],
122 ['active_no_prefs_profile_no_getting_started_shown',
123 api_fixture('users')['active_no_prefs_profile_no_getting_started_shown'], true, false],
124 ].each do |token, user, invited, has_profile|
126 test "visit home page for user #{token}" do
130 visit page_with_token(token)
133 verify_homepage user, invited, has_profile
136 test "check help for user #{token}" do
140 visit page_with_token(token)
146 test "test system menu for user #{token}" do
150 visit page_with_token(token)
153 verify_system_menu user
157 test "test getting started help menu item" do
158 visit page_with_token('active')
159 within '.navbar-fixed-top' do
160 find('.help-menu > a').click
161 find('.help-menu .dropdown-menu a', text: 'Getting Started ...').click
164 within '.modal-content' do
165 assert_text 'Getting Started'
166 assert_selector 'button:not([disabled])', text: 'Next'
167 assert_no_selector 'button:not([disabled])', text: 'Prev'
169 # Use Next button to enable Prev button
171 assert_selector 'button:not([disabled])', text: 'Prev' # Prev button is now enabled
173 assert_no_selector 'button:not([disabled])', text: 'Prev' # Prev button is again disabled
175 # Click Next until last page is reached and verify that it is disabled
176 (0..20).each do |i| # currently we only have 4 pages, and don't expect to have more than 20 in future
179 find('button:not([disabled])', text: 'Next')
184 assert_no_selector 'button:not([disabled])', text: 'Next' # Next button is disabled
185 assert_selector 'button:not([disabled])', text: 'Prev' # Prev button is enabled
187 assert_selector 'button:not([disabled])', text: 'Next' # Next button is now enabled
189 first('button', text: 'x').click
191 assert_text 'Active pipelines' # seeing dashboard now
194 test "test arvados_public_data_doc_url config unset" do
195 Rails.configuration.arvados_public_data_doc_url = false
197 visit page_with_token('active')
198 within '.navbar-fixed-top' do
199 find('.help-menu > a').click
201 assert_no_selector 'a', text:'Public Pipelines and Data sets'
203 assert_selector 'a', text:'Getting Started ...'
204 assert page.has_link?('Tutorials and User guide'), 'No link - Tutorials and User guide'
205 assert page.has_link?('API Reference'), 'No link - API Reference'
206 assert page.has_link?('SDK Reference'), 'No link - SDK Reference'
207 assert page.has_link?('Show version / debugging info ...'), 'No link - Show version / debugging info'
208 assert page.has_link?('Report a problem ...'), 'No link - Report a problem'
212 test "no SSH public key notification when shell_in_a_box_url is configured" do
213 Rails.configuration.shell_in_a_box_url = 'example.com'
214 visit page_with_token('job_reader')
215 click_link 'notifications-menu'
216 assert_no_selector 'a', text:'Click here to set up an SSH public key for use with Arvados.'
217 assert_selector 'a', text:'Click here to learn how to run an Arvados Crunch pipeline'
221 ['Repositories', nil, 's0uqq'],
222 ['Virtual machines', 'virtual machine', 'current_user_logins'],
223 ['SSH keys', nil, 'public_key'],
224 ['Links', nil, 'link_class'],
225 ['Groups', nil, 'All users'],
226 ['Compute nodes', nil, 'ping_secret'],
227 ['Keep services', 'keep service', 'service_ssl_flag'],
228 ['Keep disks', 'keep disk', 'bytes_free'],
229 ].each do |page_name, add_button_text, look_for|
230 test "test system menu #{page_name} link" do
231 visit page_with_token('admin')
232 within('.navbar-fixed-top') do
233 page.find("#system-menu").click
234 within('.dropdown-menu') do
235 assert_selector 'a', text: page_name
236 find('a', text: page_name).click
240 # click the add button if it exists
242 assert_selector 'button', text: "Add a new #{add_button_text}"
243 find('button', text: "Add a new #{add_button_text}").click
245 assert_no_selector 'button', text:"Add a new"
248 # look for unique property in the current page