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 page.has_text?('Projects shared with me'), 'Not found text - Project shared with me'
30 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 . . .'
32 assert page.has_text?('Your account is inactive'), 'Not found text - Your account is inactive'
35 within('.navbar-fixed-top') do
37 assert_text Rails.configuration.site_name.downcase
38 assert_no_selector 'a', text: Rails.configuration.site_name.downcase
39 assert page.has_link?('Log in'), 'Not found link - Log in'
42 assert_selector 'a', text: Rails.configuration.site_name.downcase
43 assert(page.has_link?("notifications-menu"), 'no user menu')
44 page.find("#notifications-menu").click
45 within('.dropdown-menu') do
47 assert page.has_no_link?('Not active'), 'Found link - Not active'
48 assert page.has_no_link?('Sign agreements'), 'Found link - Sign agreements'
50 assert_selector "a[href=\"/projects/#{user['uuid']}\"]", text: 'Home project'
51 assert page.has_link?('Manage account'), 'No link - Manage account'
54 assert page.has_link?('Manage profile'), 'No link - Manage profile'
56 assert page.has_no_link?('Manage profile'), 'Found link - Manage profile'
59 assert_no_selector 'a', text: 'Home project'
60 assert page.has_no_link?('Manage account'), 'Found link - Manage account'
61 assert page.has_no_link?('Manage profile'), 'Found link - Manage profile'
63 assert page.has_link?('Log out'), 'No link - Log out'
71 within('.navbar-fixed-top') do
72 page.find("#arv-help").click
73 within('.dropdown-menu') do
74 assert_selector 'a', text:'Getting Started ...'
75 assert_selector 'a', text:'Public Pipelines and Data sets'
76 assert page.has_link?('Tutorials and User guide'), 'No link - Tutorials and User guide'
77 assert page.has_link?('API Reference'), 'No link - API Reference'
78 assert page.has_link?('SDK Reference'), 'No link - SDK Reference'
79 assert page.has_link?('Show version / debugging info ...'), 'No link - Show version / debugging info'
80 assert page.has_link?('Report a problem ...'), 'No link - Report a problem'
81 # Version info and Report a problem are tested in "report_issue_test.rb"
86 def verify_system_menu user
87 if user && user['is_admin']
88 assert page.has_link?('system-menu'), 'No link - system menu'
89 within('.navbar-fixed-top') do
90 page.find("#system-menu").click
91 within('.dropdown-menu') do
92 assert page.has_text?('Groups'), 'No text - Groups'
93 assert page.has_link?('Repositories'), 'No link - Repositories'
94 assert page.has_link?('Virtual machines'), 'No link - Virtual machines'
95 assert page.has_link?('SSH keys'), 'No link - SSH keys'
96 assert page.has_link?('API tokens'), 'No link - API tokens'
97 find('a', text: 'Users').click
100 assert page.has_text? 'Add a new user'
102 assert page.has_no_link?('system-menu'), 'Found link - system menu'
107 [nil, nil, false, false],
108 ['inactive', api_fixture('users')['inactive'], true, false],
109 ['inactive_uninvited', api_fixture('users')['inactive_uninvited'], false, false],
110 ['active', api_fixture('users')['active'], true, true],
111 ['admin', api_fixture('users')['admin'], true, true],
112 ['active_no_prefs', api_fixture('users')['active_no_prefs'], true, false],
113 ['active_no_prefs_profile_no_getting_started_shown',
114 api_fixture('users')['active_no_prefs_profile_no_getting_started_shown'], true, false],
115 ].each do |token, user, invited, has_profile|
117 test "visit home page for user #{token}" do
121 visit page_with_token(token)
124 verify_homepage user, invited, has_profile
127 test "check help for user #{token}" do
131 visit page_with_token(token)
137 test "test system menu for user #{token}" do
141 visit page_with_token(token)
144 verify_system_menu user
148 test "test getting started help menu item" do
149 visit page_with_token('active')
150 within '.navbar-fixed-top' do
151 find('.help-menu > a').click
152 find('.help-menu .dropdown-menu a', text: 'Getting Started ...').click
155 within '.modal-content' do
156 assert_text 'Getting Started'
157 assert_selector 'button:not([disabled])', text: 'Next'
158 assert_no_selector 'button:not([disabled])', text: 'Prev'
160 # Use Next button to enable Prev button
162 assert_selector 'button:not([disabled])', text: 'Prev' # Prev button is now enabled
164 assert_no_selector 'button:not([disabled])', text: 'Prev' # Prev button is again disabled
166 # Click Next until last page is reached and verify that it is disabled
167 (0..20).each do |i| # currently we only have 4 pages, and don't expect to have more than 20 in future
170 find('button:not([disabled])', text: 'Next')
175 assert_no_selector 'button:not([disabled])', text: 'Next' # Next button is disabled
176 assert_selector 'button:not([disabled])', text: 'Prev' # Prev button is enabled
178 assert_selector 'button:not([disabled])', text: 'Next' # Next button is now enabled
180 first('button', text: 'x').click
182 assert_text 'Active pipelines' # seeing dashboard now
185 test "test arvados_public_data_doc_url config unset" do
186 Rails.configuration.arvados_public_data_doc_url = false
188 visit page_with_token('active')
189 within '.navbar-fixed-top' do
190 find('.help-menu > a').click
192 assert_no_selector 'a', text:'Public Pipelines and Data sets'
194 assert_selector 'a', text:'Getting Started ...'
195 assert page.has_link?('Tutorials and User guide'), 'No link - Tutorials and User guide'
196 assert page.has_link?('API Reference'), 'No link - API Reference'
197 assert page.has_link?('SDK Reference'), 'No link - SDK Reference'
198 assert page.has_link?('Show version / debugging info ...'), 'No link - Show version / debugging info'
199 assert page.has_link?('Report a problem ...'), 'No link - Report a problem'