X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/78a0505d03f79f667926eff41954f5212bf57c2c..5e9787f914dd1a2f762ae7a653fe8dda36f8f555:/apps/workbench/test/integration/user_profile_test.rb diff --git a/apps/workbench/test/integration/user_profile_test.rb b/apps/workbench/test/integration/user_profile_test.rb index 59a1203051..30d4943c62 100644 --- a/apps/workbench/test/integration/user_profile_test.rb +++ b/apps/workbench/test/integration/user_profile_test.rb @@ -1,26 +1,30 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + require 'integration_helper' class UserProfileTest < ActionDispatch::IntegrationTest setup do need_javascript - @user_profile_form_fields = Rails.configuration.user_profile_form_fields + @user_profile_form_fields = Rails.configuration.Workbench.UserProfileFormFields end teardown do - Rails.configuration.user_profile_form_fields = @user_profile_form_fields + Rails.configuration.Workbench.UserProfileFormFields = @user_profile_form_fields end def verify_homepage_with_profile user, invited, has_profile - profile_config = Rails.configuration.user_profile_form_fields + profile_config = Rails.configuration.Workbench.UserProfileFormFields if !user assert_text('Please log in') elsif user['is_active'] - if profile_config && !has_profile + if !profile_config.empty? && !has_profile assert_text('Save profile') add_profile user else - assert_text('Recent pipelines and processes') + assert_text('Recent processes') assert_no_text('Save profile') end elsif invited @@ -58,7 +62,7 @@ class UserProfileTest < ActionDispatch::IntegrationTest assert_selector('a', text: 'Current token') assert_selector('a', text: 'SSH keys') - if profile_config + if !profile_config.empty? assert_selector('a', text: 'Manage profile') else assert_no_selector('a', text: 'Manage profile') @@ -92,14 +96,15 @@ class UserProfileTest < ActionDispatch::IntegrationTest assert_text('Save profile') # This time fill in required field and then save. Expect to go to requested page after that. - profile_message = Rails.configuration.user_profile_form_message + profile_message = Rails.configuration.Workbench.UserProfileFormMessage required_field_title = '' required_field_key = '' - profile_config = Rails.configuration.user_profile_form_fields - profile_config.andand.each do |entry| - if entry['required'] - required_field_key = entry['key'] - required_field_title = entry['form_field_title'] + profile_config = Rails.configuration.Workbench.UserProfileFormFields + profile_config.each do |k, entry| + if entry['Required'] + required_field_key = k.to_s + required_field_title = entry['FormFieldTitle'] + break end end @@ -111,6 +116,9 @@ class UserProfileTest < ActionDispatch::IntegrationTest click_button "Save profile" # profile saved and in profile page now with success assert_text('Thank you for filling in your profile') + assert_selector('input' + + '[name="user[prefs][profile]['+required_field_key+']"]' + + '[value="value to fill required field"]') if user['prefs']['getting_started_shown'] click_link 'Back to work!' else @@ -118,7 +126,7 @@ class UserProfileTest < ActionDispatch::IntegrationTest end # profile saved and in home page now - assert_text('Recent pipelines and processes') + assert_text('Recent processes') end [ @@ -134,11 +142,11 @@ class UserProfileTest < ActionDispatch::IntegrationTest [true, false].each do |profile_required| test "visit #{token} home page when profile is #{'not ' if !profile_required}configured" do if !profile_required - Rails.configuration.user_profile_form_fields = false + Rails.configuration.Workbench.UserProfileFormFields = [] else # Our test config enabled profile by default. So, no need to update config end - Rails.configuration.enable_getting_started_popup = true + Rails.configuration.Workbench.EnableGettingStartedPopup = true if !token visit ('/')