Merge branch 'master' into 9352-many-nodes-make-workbench-faster
[arvados.git] / apps / workbench / test / integration / user_profile_test.rb
index e79a132cc2656d02497e20ea8eafa23494785b75..a98fa3542d859be996225e082db21b38c2a6ece2 100644 (file)
@@ -1,15 +1,8 @@
 require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
 
 class UserProfileTest < ActionDispatch::IntegrationTest
-  reset_api_fixtures :after_suite
-
   setup do
-    headless = Headless.new
-    headless.start
-    Capybara.current_driver = :selenium
-
+    need_javascript
     @user_profile_form_fields = Rails.configuration.user_profile_form_fields
   end
 
@@ -27,30 +20,44 @@ class UserProfileTest < ActionDispatch::IntegrationTest
         assert page.has_text?('Save profile'), 'No text - Save profile'
         add_profile user
       else
-        assert page.has_text?('Active pipelines'), 'Not found text - Active pipelines'
+        assert page.has_text?('Recent pipelines and processes'), 'Not found text - Recent pipelines and processes'
         assert page.has_no_text?('Save profile'), 'Found text - Save profile'
       end
     elsif invited
-      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 . . .'
+      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 . . .'
       assert page.has_no_text?('Save profile'), 'Found text - Save profile'
     else
       assert page.has_text?('Your account is inactive'), 'Not found text - Your account is inactive'
       assert page.has_no_text?('Save profile'), 'Found text - Save profile'
     end
 
+    # If the user has not already seen getting_started modal, it will be shown on first visit.
+    if user and user['is_active'] and !user['prefs']['getting_started_shown']
+      within '.modal-content' do
+        assert_text 'Getting Started'
+        assert_selector 'button', text: 'Next'
+        assert_selector 'button', text: 'Prev'
+        first('button', text: 'x').click
+      end
+    end
+
     within('.navbar-fixed-top') do
       if !user
         assert page.has_link?('Log in'), 'Not found link - Log in'
       else
         # my account menu
-        assert page.has_link?("#{user['email']}"), 'Not found link - email'
-        find('a', text: "#{user['email']}").click
+        assert(page.has_link?("notifications-menu"), 'no user menu')
+        page.find("#notifications-menu").click
         within('.dropdown-menu') do
           if user['is_active']
             assert page.has_no_link?('Not active'), 'Found link - Not active'
             assert page.has_no_link?('Sign agreements'), 'Found link - Sign agreements'
 
-            assert page.has_link?('Manage account'), 'No link - Manage account'
+            assert page.has_link?('Virtual machines'), 'No link - Virtual machines'
+            assert page.has_link?('Repositories'), 'No link - Repositories'
+            assert page.has_link?('Current token'), 'No link - Current token'
+            assert page.has_link?('SSH keys'), 'No link - SSH Keys'
 
             if profile_config
               assert page.has_link?('Manage profile'), 'No link - Manage profile'
@@ -70,10 +77,10 @@ class UserProfileTest < ActionDispatch::IntegrationTest
     assert page.has_no_text?('Projects shared with me'), 'Found text - Projects shared with me'
 
     assert page.has_text?('Profile'), 'No text - Profile'
-    assert page.has_text?('First name'), 'No text - First name'
-    assert page.has_text?('Last name'), 'No text - Last name'
+    assert page.has_text?('First Name'), 'No text - First Name'
+    assert page.has_text?('Last Name'), 'No text - Last Name'
     assert page.has_text?('Identity URL'), 'No text - Identity URL'
-    assert page.has_text?('Email'), 'No text - Email'
+    assert page.has_text?('E-mail'), 'No text - E-mail'
     assert page.has_text?(user['email']), 'No text - user email'
 
     # Using the default profile which has message and one required field
@@ -81,8 +88,8 @@ class UserProfileTest < ActionDispatch::IntegrationTest
     # Save profile without filling in the required field. Expect to be back in this profile page again
     click_button "Save profile"
     assert page.has_text?('Profile'), 'No text - Profile'
-    assert page.has_text?('First name'), 'No text - First name'
-    assert page.has_text?('Last name'), 'No text - Last name'
+    assert page.has_text?('First Name'), 'No text - First Name'
+    assert page.has_text?('Last Name'), 'No text - Last Name'
     assert page.has_text?('Save profile'), 'No text - Save profile'
 
     # This time fill in required field and then save. Expect to go to requested page after that.
@@ -105,10 +112,14 @@ class UserProfileTest < ActionDispatch::IntegrationTest
     click_button "Save profile"
     # profile saved and in profile page now with success
     assert page.has_text?('Thank you for filling in your profile'), 'No text - Thank you for filling'
-    click_link 'Back to work!'
+    if user['prefs']['getting_started_shown']
+      click_link 'Back to work!'
+    else
+      click_link 'Get started'
+    end
 
     # profile saved and in home page now
-    assert page.has_text?('Active pipelines'), 'No text - Active pipelines'
+    assert page.has_text?('Recent pipelines and processes'), 'No text - Recent pipelines and processes'
   end
 
   [
@@ -118,11 +129,16 @@ class UserProfileTest < ActionDispatch::IntegrationTest
     ['active', api_fixture('users')['active'], true, true],
     ['admin', api_fixture('users')['admin'], true, true],
     ['active_no_prefs', api_fixture('users')['active_no_prefs'], true, false],
-    ['active_no_prefs_profile', api_fixture('users')['active_no_prefs_profile'], true, false],
+    ['active_no_prefs_profile_no_getting_started_shown',
+      api_fixture('users')['active_no_prefs_profile_no_getting_started_shown'], true, false],
+    ['active_no_prefs_profile_with_getting_started_shown',
+      api_fixture('users')['active_no_prefs_profile_with_getting_started_shown'], true, false],
   ].each do |token, user, invited, has_profile|
 
     test "visit home page when profile is configured for user #{token}" do
       # Our test config enabled profile by default. So, no need to update config
+      Rails.configuration.enable_getting_started_popup = true
+
       if !token
         visit ('/')
       else
@@ -134,6 +150,7 @@ class UserProfileTest < ActionDispatch::IntegrationTest
 
     test "visit home page when profile not configured for user #{token}" do
       Rails.configuration.user_profile_form_fields = false
+      Rails.configuration.enable_getting_started_popup = true
 
       if !token
         visit ('/')