1 require 'integration_helper'
2 require 'selenium-webdriver'
5 class UserManageAccountTest < ActionDispatch::IntegrationTest
7 headless = Headless.new
9 Capybara.current_driver = :selenium
12 # test manage_account page
13 def verify_manage_account user
15 within('.navbar-fixed-top') do
16 find('a', text: "#{user['email']}").click
17 within('.dropdown-menu') do
18 find('a', text: 'Manage account').click
22 # now in manage account page
23 assert page.has_text?('Virtual Machines'), 'No text - Virtual Machines'
24 assert page.has_text?('Repositories'), 'No text - Repositories'
25 assert page.has_text?('SSH Keys'), 'No text - SSH Keys'
26 assert page.has_text?('Current Token'), 'No text - Current Token'
27 assert page.has_text?('The Arvados API token is a secret key that enables the Arvados SDKs to access Arvados'), 'No text - Arvados API token'
28 add_and_verify_ssh_key
30 within('.navbar-fixed-top') do
31 find('a', text: "#{user['email']}").click
32 within('.dropdown-menu') do
33 assert page.has_no_link?('Manage profile'), 'Found link - Manage profile'
39 def add_and_verify_ssh_key
40 click_link 'Add new SSH key'
42 within '.modal-content' do
43 assert page.has_text?('Public Key'), 'No text - Public Key'
44 assert page.has_button?('Cancel'), 'No button - Cancel'
45 assert page.has_button?('Submit'), 'No button - Submit'
47 page.find_field('public_key').set 'first test with an incorrect ssh key value'
49 assert page.has_text?('Public key does not appear to be a valid ssh-rsa or dsa public key'), 'No text - Public key does not appear to be a valid'
51 public_key_str = api_fixture('authorized_keys')['active']['public_key']
52 page.find_field('public_key').set public_key_str
53 page.find_field('name').set 'added_in_test'
55 assert page.has_text?('Public key already exists in the database, use a different key.'), 'No text - Public key already exists'
57 new_key = SSHKey.generate
58 page.find_field('public_key').set new_key.ssh_public_key
59 page.find_field('name').set 'added_in_test'
63 # key must be added. look for it in the refreshed page
64 assert page.has_text?('added_in_test'), 'No text - added_in_test'
68 ['inactive', api_fixture('users')['inactive']],
69 ['inactive_uninvited', api_fixture('users')['inactive_uninvited']],
70 ['active', api_fixture('users')['active']],
71 ['admin', api_fixture('users')['admin']],
72 ].each do |token, user|
73 test "test manage account for user #{token}" do
74 visit page_with_token(token)
75 verify_manage_account user
80 ['inactive_but_signed_user_agreement', true],
82 ].each do |user, notifications|
83 test "test manage account for #{user} with notifications #{notifications}" do
84 visit page_with_token(user)
85 click_link 'notifications-menu'
87 assert_selector('a', text: 'Click here to set up an SSH public key for use with Arvados')
88 assert_selector('a', text: 'Click here to learn how to run an Arvados Crunch pipeline')
89 click_link('Click here to set up an SSH public key for use with Arvados')
90 assert_selector('a', text: 'Add new SSH key')
92 add_and_verify_ssh_key
94 # No more SSH notification
95 click_link 'notifications-menu'
96 assert_no_selector('a', text: 'Click here to set up an SSH public key for use with Arvados')
97 assert_selector('a', text: 'Click here to learn how to run an Arvados Crunch pipeline')
99 assert_no_selector('a', text: 'Click here to set up an SSH public key for use with Arvados')
100 assert_no_selector('a', text: 'Click here to learn how to run an Arvados Crunch pipeline')