Merge branch 'dj-fix-user_registration_billing_spec' into 'master'

Enable signup before test start

See merge request gitlab-org/gitlab!72234
This commit is contained in:
Dan Davison 2021-11-10 16:31:57 +00:00
commit f257915e02
5 changed files with 66 additions and 25 deletions

View file

@ -19,4 +19,5 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']
spec.add_runtime_dependency 'chemlab', '~> 0.9'
spec.add_runtime_dependency 'zeitwerk', '~> 2.4'
end

View file

@ -1,31 +1,14 @@
# frozen_string_literal: true
require 'chemlab/library'
require 'zeitwerk'
loader = Zeitwerk::Loader.new
loader.push_dir(__dir__)
loader.ignore("#{__dir__}/gitlab/**/*.stub.rb") # ignore page stubs
loader.setup
# Chemlab Page Libraries for GitLab
module Gitlab
include Chemlab::Library
module Page
module Main
autoload :Login, 'gitlab/page/main/login'
autoload :SignUp, 'gitlab/page/main/sign_up'
end
module Subscriptions
autoload :New, 'gitlab/page/subscriptions/new'
end
module Admin
autoload :Dashboard, 'gitlab/page/admin/dashboard'
autoload :Subscription, 'gitlab/page/admin/subscription'
end
module Group
module Settings
autoload :Billing, 'gitlab/page/group/settings/billing'
autoload :UsageQuotas, 'gitlab/page/group/settings/usage_quotas'
end
end
end
end

View file

@ -0,0 +1,13 @@
# 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

View file

@ -0,0 +1,33 @@
# 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

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
module QA
RSpec.describe 'Fulfillment', :requires_admin, :skip_live_env, except: { job: 'review-qa-*' } do
RSpec.describe 'Fulfillment', :requires_admin, :skip_live_env do
describe 'Purchase' do
describe 'User Registration' do
let(:group) do
@ -18,14 +18,25 @@ module QA
end
before do
# Enable sign-ups
Runtime::ApplicationSettings.set_application_settings(signup_enabled: true)
# Register the new user through the registration page
Gitlab::Page::Main::SignUp.perform do |sign_up|
sign_up.visit
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
end
after do
# Restore what the signup_enabled setting was before this test was run
Runtime::ApplicationSettings.restore_application_settings(:signup_enabled)
user.remove_via_api!
group.remove_via_api!
rescue Resource::ApiFabricator::ResourceNotDeletedError
@ -35,7 +46,7 @@ module QA
end
context 'when adding and removing a group member' do
it 'consumes a seat on the license', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/2268', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/342675', type: :investigating } do
it 'consumes a seat on the license', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/2268' do
Flow::Login.sign_in_as_admin
# Save the number of users as stated by the license