Commit f8a9ae9a authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'qa-shl-add-spec-for-account-recreation' into 'master'

Add e2e spec to test recreating user after removal

Closes gitlab-org/quality/testcases#851

See merge request gitlab-org/gitlab!36959
parents 12a419dc 518eb3f6
...@@ -100,6 +100,7 @@ Once you confirm %{deleteAccount}, it cannot be undone or recovered.`), ...@@ -100,6 +100,7 @@ Once you confirm %{deleteAccount}, it cannot be undone or recovered.`),
name="password" name="password"
class="form-control" class="form-control"
type="password" type="password"
data-qa-selector="password_confirmation_field"
aria-labelledby="input-label" aria-labelledby="input-label"
/> />
<input <input
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
%strong.fly-out-top-item-name %strong.fly-out-top-item-name
= _('Profile') = _('Profile')
= nav_link(controller: [:accounts, :two_factor_auths]) do = nav_link(controller: [:accounts, :two_factor_auths]) do
= link_to profile_account_path do = link_to profile_account_path, data: { qa_selector: 'profile_account_link' } do
.nav-icon-container .nav-icon-container
= sprite_icon('account') = sprite_icon('account')
%span.nav-item-name %span.nav-item-name
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
= render 'users/deletion_guidance', user: current_user = render 'users/deletion_guidance', user: current_user
%button#delete-account-button.btn.btn-danger.disabled{ data: { toggle: 'modal', %button#delete-account-button.btn.btn-danger.disabled{ data: { toggle: 'modal',
target: '#delete-account-modal' } } target: '#delete-account-modal', qa_selector: 'delete_account_button' } }
= s_('Profiles|Delete account') = s_('Profiles|Delete account')
#delete-account-modal{ data: { action_url: user_registration_path, #delete-account-modal{ data: { action_url: user_registration_path,
......
...@@ -376,6 +376,10 @@ module QA ...@@ -376,6 +376,10 @@ module QA
autoload :Emails, 'qa/page/profile/emails' autoload :Emails, 'qa/page/profile/emails'
autoload :Password, 'qa/page/profile/password' autoload :Password, 'qa/page/profile/password'
autoload :TwoFactorAuth, 'qa/page/profile/two_factor_auth' autoload :TwoFactorAuth, 'qa/page/profile/two_factor_auth'
module Accounts
autoload :Show, 'qa/page/profile/accounts/show'
end
end end
module Issuable module Issuable
......
# frozen_string_literal: true
module QA
module Page
module Profile
module Accounts
class Show < Page::Base
view 'app/views/profiles/accounts/show.html.haml' do
element :delete_account_button, required: true
end
view 'app/assets/javascripts/profile/account/components/delete_account_modal.vue' do
element :password_confirmation_field
end
view 'app/assets/javascripts/vue_shared/components/deprecated_modal.vue' do
element :save_changes_button
end
def delete_account(password)
click_element(:delete_account_button)
find_element(:password_confirmation_field).set password
click_element(:save_changes_button)
end
end
end
end
end
end
...@@ -11,6 +11,7 @@ module QA ...@@ -11,6 +11,7 @@ module QA
element :ssh_keys, 'SSH Keys' # rubocop:disable QA/ElementWithPattern element :ssh_keys, 'SSH Keys' # rubocop:disable QA/ElementWithPattern
element :profile_emails_link element :profile_emails_link
element :profile_password_link element :profile_password_link
element :profile_account_link
end end
def click_access_tokens def click_access_tokens
...@@ -25,6 +26,12 @@ module QA ...@@ -25,6 +26,12 @@ module QA
end end
end end
def click_account
within_sidebar do
click_element(:profile_account_link)
end
end
def click_emails def click_emails
within_sidebar do within_sidebar do
click_element(:profile_emails_link) click_element(:profile_emails_link)
......
...@@ -87,6 +87,8 @@ module QA ...@@ -87,6 +87,8 @@ module QA
def api_delete_path def api_delete_path
"/users/#{id}" "/users/#{id}"
rescue NoValueError
"/users/#{fetch_id(username)}"
end end
def api_get_path def api_get_path
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module QA module QA
RSpec.shared_examples 'registration and login' do RSpec.shared_examples 'registration and login' do
it 'user registers and logs in' do it 'allows the user to registers and login' do
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
Resource::User.fabricate_via_browser_ui! Resource::User.fabricate_via_browser_ui!
...@@ -16,6 +16,50 @@ module QA ...@@ -16,6 +16,50 @@ module QA
RSpec.describe 'Manage', :skip_signup_disabled do RSpec.describe 'Manage', :skip_signup_disabled do
describe 'standard' do describe 'standard' do
it_behaves_like 'registration and login' it_behaves_like 'registration and login'
context 'when user account is deleted', :requires_admin do
let(:user) do
Resource::User.fabricate_via_api! do |resource|
resource.api_client = admin_api_client
end
end
before do
# Use the UI instead of API to delete the account since
# this is the only test that exercise this UI.
# Other tests should use the API for this purpose.
Flow::Login.sign_in(as: user)
Page::Main::Menu.perform(&:click_settings_link)
Page::Profile::Menu.perform(&:click_account)
Page::Profile::Accounts::Show.perform do |show|
show.delete_account(user.password)
end
end
it 'allows recreating with same credentials' do
expect(Page::Main::Menu.perform(&:signed_in?)).to be_falsy
Flow::Login.sign_in(as: user, skip_page_validation: true)
expect(page).to have_text("Invalid Login or password")
@recreated_user = Resource::User.fabricate_via_browser_ui! do |resource|
resource.name = user.name
resource.username = user.username
resource.email = user.email
end
expect(Page::Main::Menu.perform(&:signed_in?)).to be_truthy
end
after do
@recreated_user.remove_via_api!
end
def admin_api_client
@admin_api_client ||= Runtime::API::Client.as_admin
end
end
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