1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 require 'integration_helper'
7 class ApplicationLayoutTest < ActionDispatch::IntegrationTest
8 # These tests don't do state-changing API calls. Save some time by
9 # skipping the database reset.
10 reset_api_fixtures :after_each_test, false
11 reset_api_fixtures :after_suite, true
17 def verify_homepage user, invited, has_profile
18 profile_config = Rails.configuration.user_profile_form_fields
21 assert page.has_text?('Please log in'), 'Not found text - Please log in'
22 assert page.has_text?('The "Log in" button below will show you a Google sign-in page'), 'Not found text - google sign in page'
23 assert page.has_no_text?('My projects'), 'Found text - My projects'
24 assert page.has_link?("Log in to #{Rails.configuration.site_name}"), 'Not found text - log in to'
25 elsif user['is_active']
26 if profile_config && !has_profile
27 assert page.has_text?('Save profile'), 'No text - Save profile'
29 assert page.has_link?("Projects"), 'Not found link - Projects'
30 page.find("#projects-menu").click
31 assert_selector 'a', text: 'Search all projects'
32 assert_no_selector 'a', text: 'Browse public projects'
33 assert_selector 'a', text: 'Add a new project'
34 assert_selector 'li[class="dropdown-header"]', text: 'My projects'
37 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 . . .'
39 assert page.has_text?('Your account is inactive'), 'Not found text - Your account is inactive'
42 within('.navbar-fixed-top') do
44 assert_text Rails.configuration.site_name.downcase
45 assert_no_selector 'a', text: Rails.configuration.site_name.downcase
46 assert page.has_link?('Log in'), 'Not found link - Log in'
49 assert_selector 'a', text: Rails.configuration.site_name.downcase
50 assert(page.has_link?("notifications-menu"), 'no user menu')
51 page.find("#notifications-menu").click
52 within('.dropdown-menu') do
54 assert page.has_no_link?('Not active'), 'Found link - Not active'
55 assert page.has_no_link?('Sign agreements'), 'Found link - Sign agreements'
57 assert_selector "a[href=\"/projects/#{user['uuid']}\"]", text: 'Home project'
58 assert_selector "a[href=\"/users/#{user['uuid']}/virtual_machines\"]", text: 'Virtual machines'
59 assert_selector "a[href=\"/repositories\"]", text: 'Repositories'
60 assert_selector "a[href=\"/current_token\"]", text: 'Current token'
61 assert_selector "a[href=\"/users/#{user['uuid']}/ssh_keys\"]", text: 'SSH keys'
64 assert_selector "a[href=\"/users/#{user['uuid']}/profile\"]", text: 'Manage profile'
66 assert_no_selector "a[href=\"/users/#{user['uuid']}/profile\"]", text: 'Manage profile'
69 assert_no_selector 'a', text: 'Home project'
70 assert page.has_no_link?('Virtual machines'), 'Found link - Virtual machines'
71 assert page.has_no_link?('Repositories'), 'Found link - Repositories'
72 assert page.has_no_link?('Current token'), 'Found link - Current token'
73 assert page.has_no_link?('SSH keys'), 'Found link - SSH keys'
74 assert page.has_no_link?('Manage profile'), 'Found link - Manage profile'
76 assert page.has_link?('Log out'), 'No link - Log out'
84 within('.navbar-fixed-top') do
85 page.find("#arv-help").click
86 within('.dropdown-menu') do
87 assert_no_selector 'a', text:'Getting Started ...'
88 assert_selector 'a', text:'Public Pipelines and Data sets'
89 assert page.has_link?('Tutorials and User guide'), 'No link - Tutorials and User guide'
90 assert page.has_link?('API Reference'), 'No link - API Reference'
91 assert page.has_link?('SDK Reference'), 'No link - SDK Reference'
92 assert page.has_link?('Show version / debugging info ...'), 'No link - Show version / debugging info'
93 assert page.has_link?('Report a problem ...'), 'No link - Report a problem'
94 # Version info and Report a problem are tested in "report_issue_test.rb"
99 def verify_system_menu user
100 if user && user['is_admin']
101 assert page.has_link?('system-menu'), 'No link - system menu'
102 within('.navbar-fixed-top') do
103 page.find("#system-menu").click
104 within('.dropdown-menu') do
105 assert page.has_text?('Groups'), 'No text - Groups'
106 assert page.has_link?('Repositories'), 'No link - Repositories'
107 assert page.has_link?('Virtual machines'), 'No link - Virtual machines'
108 assert page.has_link?('SSH keys'), 'No link - SSH keys'
109 assert page.has_link?('API tokens'), 'No link - API tokens'
110 find('a', text: 'Users').click
113 assert page.has_text? 'Add a new user'
115 assert page.has_no_link?('system-menu'), 'Found link - system menu'
120 [nil, nil, false, false],
121 ['inactive', api_fixture('users')['inactive'], true, false],
122 ['inactive_uninvited', api_fixture('users')['inactive_uninvited'], false, false],
123 ['active', api_fixture('users')['active'], true, true],
124 ['admin', api_fixture('users')['admin'], true, true],
125 ['active_no_prefs', api_fixture('users')['active_no_prefs'], true, false],
126 ['active_no_prefs_profile_no_getting_started_shown',
127 api_fixture('users')['active_no_prefs_profile_no_getting_started_shown'], true, false],
128 ].each do |token, user, invited, has_profile|
130 test "visit home page for user #{token}" do
134 visit page_with_token(token)
138 verify_homepage user, invited, has_profile
139 verify_system_menu user
145 ['active_with_prefs_profile_no_getting_started_shown', false],
146 ].each do |token, getting_started_shown|
147 test "getting started help menu item #{getting_started_shown}" do
148 Rails.configuration.enable_getting_started_popup = true
150 visit page_with_token(token)
152 if getting_started_shown
153 within '.navbar-fixed-top' do
154 find('.help-menu > a').click
155 find('.help-menu .dropdown-menu a', text: 'Getting Started ...').click
159 within '.modal-content' do
160 assert_text 'Getting Started'
161 assert_selector 'button:not([disabled])', text: 'Next'
162 assert_no_selector 'button:not([disabled])', text: 'Prev'
164 # Use Next button to enable Prev button
166 assert_selector 'button:not([disabled])', text: 'Prev' # Prev button is now enabled
168 assert_no_selector 'button:not([disabled])', text: 'Prev' # Prev button is again disabled
170 # Click Next until last page is reached and verify that it is disabled
171 (0..20).each do |i| # currently we only have 4 pages, and don't expect to have more than 20 in future
174 find('button:not([disabled])', text: 'Next')
179 assert_no_selector 'button:not([disabled])', text: 'Next' # Next button is disabled
180 assert_selector 'button:not([disabled])', text: 'Prev' # Prev button is enabled
182 assert_selector 'button:not([disabled])', text: 'Next' # Next button is now enabled
184 first('button', text: 'x').click
186 assert_text 'Recent pipelines and processes' # seeing dashboard now
190 test "test arvados_public_data_doc_url config unset" do
191 Rails.configuration.arvados_public_data_doc_url = false
193 visit page_with_token('active')
194 within '.navbar-fixed-top' do
195 find('.help-menu > a').click
197 assert_no_selector 'a', text:'Public Pipelines and Data sets'
198 assert_no_selector 'a', text:'Getting Started ...'
200 assert page.has_link?('Tutorials and User guide'), 'No link - Tutorials and User guide'
201 assert page.has_link?('API Reference'), 'No link - API Reference'
202 assert page.has_link?('SDK Reference'), 'No link - SDK Reference'
203 assert page.has_link?('Show version / debugging info ...'), 'No link - Show version / debugging info'
204 assert page.has_link?('Report a problem ...'), 'No link - Report a problem'
208 test "no SSH public key notification when shell_in_a_box_url is configured" do
209 Rails.configuration.shell_in_a_box_url = 'example.com'
210 visit page_with_token('job_reader')
211 click_link 'notifications-menu'
212 assert_no_selector 'a', text:'Click here to set up an SSH public key for use with Arvados.'
213 assert_selector 'a', text:'Click here to learn how to run an Arvados Crunch pipeline'
217 ['Repositories', nil, 'active/crunchdispatchtest'],
218 ['Virtual machines', nil, 'testvm.shell'],
219 ['SSH keys', nil, 'public_key'],
220 ['Links', nil, 'link_class'],
221 ['Groups', nil, 'All users'],
222 ['Compute nodes', nil, 'ping_secret'],
223 ['Keep services', nil, 'service_ssl_flag'],
224 ['Keep disks', nil, 'bytes_free'],
225 ].each do |page_name, add_button_text, look_for|
226 test "test system menu #{page_name} link" do
227 visit page_with_token('admin')
228 within('.navbar-fixed-top') do
229 page.find("#system-menu").click
230 within('.dropdown-menu') do
231 assert_selector 'a', text: page_name
232 find('a', text: page_name).click
236 # click the add button if it exists
238 assert_selector 'button', text: "Add a new #{add_button_text}"
239 find('button', text: "Add a new #{add_button_text}").click
241 assert_no_selector 'button', text:"Add a new"
244 # look for unique property in the current page
252 ].each do |token, is_admin|
253 test "visit dashboard as #{token}" do
254 visit page_with_token(token)
256 assert_text 'Recent pipelines and processes' # seeing dashboard now
257 within('.recent-processes-actions') do
258 assert page.has_link?('Run a process')
259 assert page.has_link?('All processes')
262 within('.recent-processes') do
263 assert_text 'running'
265 within('.row-zzzzz-xvhdp-cr4runningcntnr') do
266 assert_text 'requester_for_running_cr'
269 assert_text 'zzzzz-d1hrv-twodonepipeline'
270 within('.row-zzzzz-d1hrv-twodonepipeline')do
271 assert_text 'No output'
274 assert_text 'completed container request'
275 within('.row-zzzzz-xvhdp-cr4completedctr')do
276 assert page.has_link? 'foo_file'
280 within('.compute-node-actions') do
282 assert page.has_link?('All nodes')
284 assert page.has_no_link?('All nodes')
288 within('.compute-node-summary-pane') do
290 assert_text 'compute0'