1 require 'integration_helper'
2 require 'selenium-webdriver'
5 class ApplicationLayoutTest < ActionDispatch::IntegrationTest
7 headless = Headless.new
9 Capybara.current_driver = :selenium
12 def verify_homepage user, invited, has_profile
13 profile_config = Rails.configuration.user_profile_form_fields
16 assert page.has_text?('Please log in'), 'Not found text - Please log in'
17 assert page.has_text?('The "Log in" button below will show you a Google sign-in page'), 'Not found text - google sign in page'
18 assert page.has_no_text?('My projects'), 'Found text - My projects'
19 assert page.has_link?("Log in to #{Rails.configuration.site_name}"), 'Not found text - log in to'
20 elsif user['is_active']
21 if profile_config && !has_profile
22 assert page.has_text?('Save profile'), 'No text - Save profile'
24 assert page.has_text?('My projects'), 'Not found text - My projects'
25 assert page.has_text?('Projects shared with me'), 'Not found text - Project shared with me'
28 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 . . .'
30 assert page.has_text?('Your account is inactive'), 'Not found text - Your account is inactive'
33 within('.navbar-fixed-top') do
35 assert page.has_link?('Log in'), 'Not found link - Log in'
38 assert page.has_link?("#{user['email']}"), 'Not found link - email'
39 find('a', text: "#{user['email']}").click
40 within('.dropdown-menu') do
42 assert page.has_no_link?('Not active'), 'Found link - Not active'
43 assert page.has_no_link?('Sign agreements'), 'Found link - Sign agreements'
45 assert page.has_link?('Manage account'), 'No link - Manage account'
48 assert page.has_link?('Manage profile'), 'No link - Manage profile'
50 assert page.has_no_link?('Manage profile'), 'Found link - Manage profile'
53 assert page.has_no_link?('Manage account'), 'Found link - Manage account'
54 assert page.has_no_link?('Manage profile'), 'Found link - Manage profile'
56 assert page.has_link?('Log out'), 'No link - Log out'
64 within('.navbar-fixed-top') do
65 page.find("#arv-help").click
66 within('.dropdown-menu') do
67 assert page.has_link?('Tutorials and User guide'), 'No link - Tutorials and User guide'
68 assert page.has_link?('API Reference'), 'No link - API Reference'
69 assert page.has_link?('SDK Reference'), 'No link - SDK Reference'
70 assert page.has_link?('Show version / debugging info ...'), 'No link - Show version / debugging info'
71 assert page.has_link?('Report a problem ...'), 'No link - Report a problem'
72 # Version info and Report a problem are tested in "report_issue_test.rb"
77 def verify_system_menu user
78 if user && user['is_admin']
79 assert page.has_link?('system-menu'), 'No link - system menu'
80 within('.navbar-fixed-top') do
81 page.find("#system-menu").click
82 within('.dropdown-menu') do
83 assert page.has_text?('Groups'), 'No text - Groups'
84 assert page.has_link?('Repositories'), 'No link - Repositories'
85 assert page.has_link?('Virtual machines'), 'No link - Virtual machines'
86 assert page.has_link?('SSH keys'), 'No link - SSH keys'
87 assert page.has_link?('API tokens'), 'No link - API tokens'
88 find('a', text: 'Users').click
91 assert page.has_text? 'Add a new user'
93 assert page.has_no_link?('system-menu'), 'Found link - system menu'
98 [nil, nil, false, false],
99 ['inactive', api_fixture('users')['inactive'], true, false],
100 ['inactive_uninvited', api_fixture('users')['inactive_uninvited'], false, false],
101 ['active', api_fixture('users')['active'], true, true],
102 ['admin', api_fixture('users')['admin'], true, true],
103 ['active_no_prefs', api_fixture('users')['active_no_prefs'], true, false],
104 ['active_no_prefs_profile', api_fixture('users')['active_no_prefs_profile'], true, false],
105 ].each do |token, user, invited, has_profile|
107 test "visit home page for user #{token}" do
111 visit page_with_token(token)
114 verify_homepage user, invited, has_profile
117 test "check help for user #{token}" do
121 visit page_with_token(token)
127 test "test system menu for user #{token}" do
131 visit page_with_token(token)
134 verify_system_menu user