Commit c235a1b3 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'qa-refactor-selector-patterns-browserui-manage-login' into 'master'

[QA] consolidate selector patterns (1_manage/login)

See merge request gitlab-org/gitlab-ce!21711
parents d83c1559 c59fd889
......@@ -7,12 +7,12 @@
= f.hidden_field :reset_password_token
.form-group
= f.label 'New password', for: "user_password"
= f.password_field :password, class: "form-control top", required: true, title: 'This field is required'
= f.password_field :password, class: "form-control top qa-password-field", required: true, title: 'This field is required'
.form-group
= f.label 'Confirm new password', for: "user_password_confirmation"
= f.password_field :password_confirmation, class: "form-control bottom", title: 'This field is required', required: true
= f.password_field :password_confirmation, class: "form-control bottom qa-password-confirmation", title: 'This field is required', required: true
.clearfix
= f.submit "Change your password", class: "btn btn-primary"
= f.submit "Change your password", class: "btn btn-primary qa-change-password-button"
.clearfix.prepend-top-20
%p
......
= form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: 'new_user gl-show-field-errors', 'aria-live' => 'assertive'}) do |f|
.form-group
= f.label "Username or email", for: "user_login", class: 'label-bold'
= f.text_field :login, class: "form-control top", autofocus: "autofocus", autocapitalize: "off", autocorrect: "off", required: true, title: "This field is required."
= f.text_field :login, class: "form-control top qa-login-field", autofocus: "autofocus", autocapitalize: "off", autocorrect: "off", required: true, title: "This field is required."
.form-group
= f.label :password, class: 'label-bold'
= f.password_field :password, class: "form-control bottom", required: true, title: "This field is required."
= f.password_field :password, class: "form-control bottom qa-password-field", required: true, title: "This field is required."
- if devise_mapping.rememberable?
.remember-me
%label{ for: "user_remember_me" }
......@@ -17,4 +17,4 @@
= recaptcha_tags
.submit-container.move-submit-down
= f.submit "Sign in", class: "btn btn-save"
= f.submit "Sign in", class: "btn btn-save qa-sign-in-button"
= form_tag(omniauth_callback_path(:user, server['provider_name']), id: 'new_ldap_user', class: "gl-show-field-errors") do
.form-group
= label_tag :username, "#{server['label']} Username"
= text_field_tag :username, nil, { class: "form-control top", title: "This field is required.", autofocus: "autofocus", required: true }
= text_field_tag :username, nil, { class: "form-control top qa-username-field", title: "This field is required.", autofocus: "autofocus", required: true }
.form-group
= label_tag :password
= password_field_tag :password, nil, { class: "form-control bottom", title: "This field is required.", required: true }
= password_field_tag :password, nil, { class: "form-control bottom qa-password-field", title: "This field is required.", required: true }
- if devise_mapping.rememberable?
.remember-me
%label{ for: "remember_me" }
= check_box_tag :remember_me, '1', false, id: 'remember_me'
%span Remember me
= submit_tag "Sign in", class: "btn-save btn"
= submit_tag "Sign in", class: "btn-save btn qa-sign-in-button"
......@@ -4,10 +4,10 @@
= link_to "Crowd", "#crowd", class: 'nav-link active', 'data-toggle' => 'tab'
- @ldap_servers.each_with_index do |server, i|
%li.nav-item
= link_to server['label'], "##{server['provider_name']}", class: "nav-link #{active_when(i.zero? && !crowd_enabled?)}", 'data-toggle' => 'tab'
= link_to server['label'], "##{server['provider_name']}", class: "nav-link #{active_when(i.zero? && !crowd_enabled?)} qa-ldap-tab", 'data-toggle' => 'tab'
- if password_authentication_enabled_for_web?
%li.nav-item
= link_to 'Standard', '#login-pane', class: 'nav-link', 'data-toggle' => 'tab'
= link_to 'Standard', '#login-pane', class: 'nav-link qa-standard-tab', 'data-toggle' => 'tab'
- if allow_signup?
%li.nav-item
= link_to 'Register', '#register-pane', class: 'nav-link', 'data-toggle' => 'tab'
%ul.nav-links.new-session-tabs.nav-tabs.nav{ role: 'tablist' }
%li.nav-item{ role: 'presentation' }
%a.nav-link.active{ href: '#login-pane', data: { toggle: 'tab' }, role: 'tab' } Sign in
%a.nav-link.qa-sign-in-tab.active{ href: '#login-pane', data: { toggle: 'tab' }, role: 'tab' } Sign in
- if allow_signup?
%li.nav-item{ role: 'presentation' }
%a.nav-link{ href: '#register-pane', data: { toggle: 'tab' }, role: 'tab' } Register
%a.nav-link.qa-register-tab{ href: '#register-pane', data: { toggle: 'tab' }, role: 'tab' } Register
......@@ -3,31 +3,31 @@ module QA
module Main
class Login < Page::Base
view 'app/views/devise/passwords/edit.html.haml' do
element :password_field, 'password_field :password'
element :password_confirmation, 'password_field :password_confirmation'
element :change_password_button, 'submit "Change your password"'
element :password_field
element :password_confirmation
element :change_password_button
end
view 'app/views/devise/sessions/_new_base.html.haml' do
element :login_field, 'text_field :login'
element :password_field, 'password_field :password'
element :sign_in_button, 'submit "Sign in"'
element :login_field
element :password_field
element :sign_in_button
end
view 'app/views/devise/sessions/_new_ldap.html.haml' do
element :username_field, 'text_field_tag :username'
element :password_field, 'password_field_tag :password'
element :sign_in_button, 'submit_tag "Sign in"'
element :username_field
element :password_field
element :sign_in_button
end
view 'app/views/devise/shared/_tabs_ldap.html.haml' do
element :ldap_tab, "link_to server['label']"
element :standard_tab, "link_to 'Standard'"
element :ldap_tab
element :standard_tab
end
view 'app/views/devise/shared/_tabs_normal.html.haml' do
element :sign_in_tab, /nav-link.*login-pane.*Sign in/
element :register_tab, /nav-link.*register-pane.*Register/
element :sign_in_tab
element :register_tab
end
def initialize
......@@ -87,19 +87,19 @@ module QA
end
def switch_to_sign_in_tab
click_on 'Sign in'
click_element :sign_in_tab
end
def switch_to_register_tab
click_on 'Register'
click_element :register_tab
end
def switch_to_ldap_tab
click_on 'LDAP'
click_element :ldap_tab
end
def switch_to_standard_tab
click_on 'Standard'
click_element :standard_tab
end
private
......@@ -107,26 +107,26 @@ module QA
def sign_in_using_ldap_credentials
switch_to_ldap_tab
fill_in :username, with: Runtime::User.ldap_username
fill_in :password, with: Runtime::User.ldap_password
click_button 'Sign in'
fill_element :username_field, Runtime::User.ldap_username
fill_element :password_field, Runtime::User.ldap_password
click_element :sign_in_button
end
def sign_in_using_gitlab_credentials(user)
switch_to_sign_in_tab unless sign_in_tab?
switch_to_standard_tab if ldap_tab?
fill_in :user_login, with: user.username
fill_in :user_password, with: user.password
click_button 'Sign in'
fill_element :login_field, user.username
fill_element :password_field, user.password
click_element :sign_in_button
end
def set_initial_password_if_present
return unless page.has_content?('Change your password')
fill_in :user_password, with: Runtime::User.password
fill_in :user_password_confirmation, with: Runtime::User.password
click_button 'Change your password'
fill_element :password_field, Runtime::User.password
fill_element :password_confirmation, Runtime::User.password
click_element :change_password_button
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