Commit 37c593c8 authored by Sanad Liaquat's avatar Sanad Liaquat Committed by Andrew Fontaine

Fix user registration and user_registration_billing_spec e2e specs

parent 5dd91446
......@@ -22,7 +22,7 @@
.row
.form-group.col-sm-12
= f.label :role, _('Role'), class: 'label-bold'
= f.select :role, ::User.roles.keys.map { |role| [role.titleize, role] }, { include_blank: _('Select a role') }, class: 'form-control js-user-role-dropdown', autofocus: true, required: true
= f.select :role, ::User.roles.keys.map { |role| [role.titleize, role] }, { include_blank: _('Select a role') }, class: 'form-control js-user-role-dropdown', autofocus: true, required: true, data: { qa_selector: 'role_dropdown' }
- if Feature.enabled?(:user_other_role_details)
.row
.form-group.col-sm-12.js-other-role-group.hidden
......
......@@ -8,7 +8,7 @@
= f.label :setup_for_company, setup_for_company_label_text, class: 'label-bold'
.gl-display-flex.gl-flex-direction-column.gl-lg-flex-direction-row
.gl-flex-grow-1
= f.radio_button :setup_for_company, true, class: 'js-setup-for-company', required: true
= f.radio_button :setup_for_company, true, class: 'js-setup-for-company', required: true, data: { qa_selector: 'setup_for_company_radio' }
= f.label :setup_for_company, _('My company or team'), class: 'normal', value: 'true'
.gl-flex-grow-1
= f.radio_button :setup_for_company, false, class: 'js-setup-for-me', required: true
......
# frozen_string_literal: true
module Gitlab
module Page
module Main
class Welcome < Chemlab::Page
path '/users/sign_up/welcome'
button :get_started_button
end
end
end
end
# frozen_string_literal: true
module Gitlab
module Page
module Main
module Welcome
# @note Defined as +button :get_started_button+
# Clicks +get_started_button+
def get_started_button
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::Welcome.perform do |welcome|
# expect(welcome.get_started_button_element).to exist
# end
# @return [Watir::Button] The raw +Button+ element
def get_started_button_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::Welcome.perform do |welcome|
# expect(welcome).to be_get_started_button
# end
# @return [Boolean] true if the +get_started_button+ element is present on the page
def get_started_button?
# This is a stub, used for indexing. The method is dynamically generated.
end
end
end
end
end
......@@ -7,13 +7,24 @@ module QA
module Welcome
extend QA::Page::PageConcern
def self.included(base)
def self.prepended(base)
super
base.view 'ee/app/views/registrations/welcome/_button.html.haml' do
element :get_started_button
base.class_eval do
view 'ee/app/views/registrations/welcome/_button.html.haml' do
element :get_started_button
end
view 'ee/app/views/registrations/welcome/_setup_for_company.html.haml' do
element :setup_for_company_radio
end
end
end
# setup_for_company_radio is only shown in development environment and .com
def choose_setup_for_company_if_available
choose_element(:setup_for_company_radio) if QA::Runtime::Env.running_on_dev_or_dot_com?
end
end
end
end
......
......@@ -26,9 +26,12 @@ module QA
sign_up.click_new_user_register_button
end
Page::Registration::Welcome.perform(&:click_get_started_button_if_available)
Flow::UserOnboarding.onboard_user
success = if user.expect_fabrication_success
# In development env and .com the user is asked to create a group and a project which can be skipped for
# the purpose of signing up
Runtime::Browser.visit(:gitlab, Page::Dashboard::Welcome)
Page::Main::Menu.perform(&:has_personal_area?)
else
Page::Main::Menu.perform(&:not_signed_in?)
......
# frozen_string_literal: true
module QA
module Flow
module UserOnboarding
module_function
def onboard_user
Page::Registration::Welcome.perform do |welcome_page|
if welcome_page.has_get_started_button?
welcome_page.select_role('Other')
welcome_page.choose_setup_for_company_if_available
welcome_page.click_get_started_button
end
end
end
end
end
end
......@@ -11,6 +11,10 @@ module QA
def has_welcome_title?(text)
has_element?(:welcome_title_content, text: text)
end
def self.path
'/'
end
end
end
end
......
......@@ -16,10 +16,6 @@ module QA
element :new_user_username_field
end
view 'app/views/registrations/welcome/show.html.haml' do
element :get_started_button
end
def fill_new_user_first_name_field(first_name)
fill_element :new_user_first_name_field, first_name
end
......
......@@ -6,14 +6,25 @@ module QA
class Welcome < Page::Base
view 'app/views/registrations/welcome/show.html.haml' do
element :get_started_button
element :role_dropdown
end
def click_get_started_button_if_available
if has_element?(:get_started_button)
Support::Retrier.retry_until do
click_element :get_started_button
has_no_element?(:get_started_button)
end
def has_get_started_button?
has_element?(:get_started_button)
end
def select_role(role)
select_element(:role_dropdown, role)
end
def choose_setup_for_company_if_available
# Only implemented in EE
end
def click_get_started_button
Support::Retrier.retry_until do
click_element :get_started_button
has_no_element?(:get_started_button)
end
end
end
......
......@@ -90,6 +90,20 @@ module QA
enabled?(ENV['ACCEPT_INSECURE_CERTS'])
end
def running_on_dot_com?
uri = URI.parse(Runtime::Scenario.gitlab_address)
uri.host.include?('.com')
end
def running_on_dev?
uri = URI.parse(Runtime::Scenario.gitlab_address)
uri.port != 80 && uri.port != 443
end
def running_on_dev_or_dot_com?
running_on_dev? || running_on_dot_com?
end
def running_in_ci?
ENV['CI'] || ENV['CI_SERVER']
end
......
......@@ -118,11 +118,12 @@ module QA
Flow::Login.sign_in(as: @user, skip_page_validation: true)
Page::Registration::Welcome.perform(&:click_get_started_button_if_available)
Flow::UserOnboarding.onboard_user
Page::Main::Menu.perform do |menu|
expect(menu).to have_personal_area
end
# In development env and .com the user is asked to create a group and a project which can be skipped for
# the purpose of this test
Runtime::Browser.visit(:gitlab, Page::Dashboard::Welcome)
Page::Main::Menu.perform(&:has_personal_area?)
end
after do
......
......@@ -20,6 +20,7 @@ module QA
before do
# Enable sign-ups
Runtime::ApplicationSettings.set_application_settings(signup_enabled: true)
Runtime::ApplicationSettings.set_application_settings(require_admin_approval_after_user_signup: true)
# Register the new user through the registration page
Gitlab::Page::Main::SignUp.perform do |sign_up|
......@@ -27,10 +28,7 @@ module QA
sign_up.register_user(user)
end
# Click the Get Started button on the welcome page if it presents itself
Gitlab::Page::Main::Welcome.perform do |welcome|
welcome.get_started_button if welcome.get_started_button?
end
Flow::UserOnboarding.onboard_user
end
after do
......
......@@ -83,6 +83,46 @@ RSpec.describe QA::Runtime::Env do
end
end
describe '.running_on_dot_com?' do
using RSpec::Parameterized::TableSyntax
where(:url, :result) do
'https://www.gitlab.com' | true
'https://staging.gitlab.com' | true
'http://www.gitlab.com' | true
'http://localhost:3000' | false
'http://localhost' | false
'http://gdk.test:3000' | false
end
with_them do
before do
QA::Runtime::Scenario.define(:gitlab_address, url)
end
it { expect(described_class.running_on_dot_com?).to eq result }
end
end
describe '.running_on_dev?' do
using RSpec::Parameterized::TableSyntax
where(:url, :result) do
'https://www.gitlab.com' | false
'http://localhost:3000' | true
'http://localhost' | false
'http://gdk.test:3000' | true
end
with_them do
before do
QA::Runtime::Scenario.define(:gitlab_address, url)
end
it { expect(described_class.running_on_dev?).to eq result }
end
end
describe '.personal_access_token' do
around do |example|
described_class.instance_variable_set(:@personal_access_token, nil)
......
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