Commit 6edf99aa authored by Mike Greiling's avatar Mike Greiling

Merge branch 'fix-set-new-password' into 'master'

Update set up new password handling in e2e tests

See merge request gitlab-org/gitlab!60344
parents 946783b7 1ff7ee6c
......@@ -16,16 +16,16 @@
.col-sm-2.col-form-label
= f.label :current_password, _('Current password')
.col-sm-10
= f.password_field :current_password, required: true, class: 'form-control gl-form-input'
= f.password_field :current_password, required: true, class: 'form-control gl-form-input', data: { qa_selector: 'current_password_field' }
.form-group.row
.col-sm-2.col-form-label
= f.label :password, _('New password')
.col-sm-10
= f.password_field :password, required: true, class: 'form-control gl-form-input'
= f.password_field :password, required: true, class: 'form-control gl-form-input', data: { qa_selector: 'new_password_field' }
.form-group.row
.col-sm-2.col-form-label
= f.label :password_confirmation, _('Password confirmation')
.col-sm-10
= f.password_field :password_confirmation, required: true, class: 'form-control gl-form-input'
= f.password_field :password_confirmation, required: true, class: 'form-control gl-form-input', data: { qa_selector: 'confirm_password_field' }
.form-actions
= f.submit _('Set new password'), class: 'gl-button btn btn-confirm'
= f.submit _('Set new password'), class: 'gl-button btn btn-confirm', data: { qa_selector: 'set_new_password_button' }
......@@ -50,15 +50,17 @@ module QA
return if Page::Main::Menu.perform(&:signed_in?)
using_wait_time 0 do
set_initial_password_if_present
raise 'If an LDAP user is provided, it must be used for sign-in', QA::Resource::User::InvalidUserError if Runtime::User.ldap_user? && user && user.username != Runtime::User.ldap_username
if Runtime::User.ldap_user? && user && user.username != Runtime::User.ldap_username
raise 'If an LDAP user is provided, it must be used for sign-in', QA::Resource::User::InvalidUserError
end
if Runtime::User.ldap_user?
sign_in_using_ldap_credentials(user: user || Runtime::User)
else
sign_in_using_gitlab_credentials(user: user || Runtime::User, skip_page_validation: skip_page_validation)
end
set_initial_password_if_present
end
end
......@@ -69,8 +71,6 @@ module QA
end
using_wait_time 0 do
set_initial_password_if_present
sign_in_using_gitlab_credentials(user: admin)
end
......@@ -81,8 +81,6 @@ module QA
Page::Main::Menu.perform(&:sign_out_if_signed_in)
using_wait_time 0 do
set_initial_password_if_present
switch_to_ldap_tab
fill_element :username_field, user.ldap_username
......@@ -169,11 +167,11 @@ module QA
end
def set_initial_password_if_present
return unless has_content?('Change your password')
return unless has_content?('Set up new password')
fill_element :password_field, Runtime::User.password
fill_element :password_confirmation_field, Runtime::User.password
click_element :change_password_button
Profile::Password.perform do |new_password_page|
new_password_page.set_new_password(Runtime::User.password, Runtime::User.password)
end
end
end
end
......
......@@ -11,12 +11,26 @@ module QA
element :save_password_button
end
view 'app/views/profiles/passwords/new.html.haml' do
element :current_password_field
element :new_password_field
element :confirm_password_field
element :set_new_password_button
end
def update_password(new_password, current_password)
find_element(:current_password_field).set current_password
find_element(:new_password_field).set new_password
find_element(:confirm_password_field).set new_password
click_element(:save_password_button)
end
def set_new_password(new_password, current_password)
fill_element :current_password_field, current_password
fill_element :new_password_field, new_password
fill_element :confirm_password_field, new_password
click_element :set_new_password_button
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment