Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f4c2eee3
Commit
f4c2eee3
authored
Oct 07, 2021
by
Dan Davison
Committed by
Anastasia McDonald
Oct 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add user registration billing spec
parent
52d11faf
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
483 additions
and
0 deletions
+483
-0
qa/lib/gitlab.rb
qa/lib/gitlab.rb
+6
-0
qa/lib/gitlab/page/admin/dashboard.rb
qa/lib/gitlab/page/admin/dashboard.rb
+15
-0
qa/lib/gitlab/page/admin/dashboard.stub.rb
qa/lib/gitlab/page/admin/dashboard.stub.rb
+81
-0
qa/lib/gitlab/page/admin/subscription.rb
qa/lib/gitlab/page/admin/subscription.rb
+13
-0
qa/lib/gitlab/page/admin/subscription.stub.rb
qa/lib/gitlab/page/admin/subscription.stub.rb
+33
-0
qa/lib/gitlab/page/main/sign_up.rb
qa/lib/gitlab/page/main/sign_up.rb
+36
-0
qa/lib/gitlab/page/main/sign_up.stub.rb
qa/lib/gitlab/page/main/sign_up.stub.rb
+203
-0
qa/qa/resource/user.rb
qa/qa/resource/user.rb
+11
-0
qa/qa/specs/features/ee/browser_ui/fulfillment/purchase/user_registration_billing_spec.rb
...ui/fulfillment/purchase/user_registration_billing_spec.rb
+85
-0
No files found.
qa/lib/gitlab.rb
View file @
f4c2eee3
...
...
@@ -9,12 +9,18 @@ module Gitlab
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'
...
...
qa/lib/gitlab/page/admin/dashboard.rb
0 → 100644
View file @
f4c2eee3
# frozen_string_literal: true
module
Gitlab
module
Page
module
Admin
class
Dashboard
<
Chemlab
::
Page
path
'/admin'
h2
:users_in_license
h2
:billable_users
h3
:number_of_users
end
end
end
end
qa/lib/gitlab/page/admin/dashboard.stub.rb
0 → 100644
View file @
f4c2eee3
# frozen_string_literal: true
module
Gitlab
module
Page
module
Admin
module
Dashboard
# @note Defined as +h2 :users_in_license+
# @return [String] The text content or value of +users_in_license+
def
users_in_license
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Dashboard.perform do |dashboard|
# expect(dashboard.users_in_license_element).to exist
# end
# @return [Watir::H2] The raw +H2+ element
def
users_in_license_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Dashboard.perform do |dashboard|
# expect(dashboard).to be_users_in_license
# end
# @return [Boolean] true if the +users_in_license+ element is present on the page
def
users_in_license?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +h2 :billable_users+
# @return [String] The text content or value of +billable_users+
def
billable_users
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Dashboard.perform do |dashboard|
# expect(dashboard.billable_users_element).to exist
# end
# @return [Watir::H2] The raw +H2+ element
def
billable_users_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Dashboard.perform do |dashboard|
# expect(dashboard).to be_billable_users
# end
# @return [Boolean] true if the +billable_users+ element is present on the page
def
billable_users?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +h3 :number_of_users+
# @return [String] The text content or value of +number_of_users+
def
number_of_users
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Dashboard.perform do |dashboard|
# expect(dashboard.number_of_users_element).to exist
# end
# @return [Watir::H3] The raw +H3+ element
def
number_of_users_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Dashboard.perform do |dashboard|
# expect(dashboard).to be_number_of_users
# end
# @return [Boolean] true if the +number_of_users+ element is present on the page
def
number_of_users?
# This is a stub, used for indexing. The method is dynamically generated.
end
end
end
end
end
qa/lib/gitlab/page/admin/subscription.rb
0 → 100644
View file @
f4c2eee3
# frozen_string_literal: true
module
Gitlab
module
Page
module
Admin
class
Subscription
<
Chemlab
::
Page
path
'/admin/subscription'
h2
:users_in_subscription
end
end
end
end
qa/lib/gitlab/page/admin/subscription.stub.rb
0 → 100644
View file @
f4c2eee3
# frozen_string_literal: true
module
Gitlab
module
Page
module
Admin
module
Subscription
# @note Defined as +h2 :users_in_subscription+
# @return [String] The text content or value of +users_in_subscription+
def
users_in_subscription
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription.users_in_subscription_element).to exist
# end
# @return [Watir::H2] The raw +H2+ element
def
users_in_subscription_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription).to be_users_in_subscription
# end
# @return [Boolean] true if the +users_in_subscription+ element is present on the page
def
users_in_subscription?
# This is a stub, used for indexing. The method is dynamically generated.
end
end
end
end
end
qa/lib/gitlab/page/main/sign_up.rb
0 → 100644
View file @
f4c2eee3
# frozen_string_literal: true
module
Gitlab
module
Page
module
Main
class
SignUp
<
Chemlab
::
Page
path
'/users/sign_up'
# TODO: Refactor data-qa-selectors to be more terse
text_field
:first_name
,
'data-qa-selector'
:
'new_user_first_name_field'
text_field
:last_name
,
'data-qa-selector'
:
'new_user_last_name_field'
text_field
:username
,
'data-qa-selector'
:
'new_user_username_field'
text_field
:email
,
'data-qa-selector'
:
'new_user_email_field'
text_field
:password
,
'data-qa-selector'
:
'new_user_password_field'
button
:register
,
'data-qa-selector'
:
'new_user_register_button'
# Register a user
# @param [Resource::User] user the user to register
def
register_user
(
user
)
raise
ArgumentError
,
'User must be of type Resource::User'
unless
user
.
is_a?
::
QA
::
Resource
::
User
self
.
first_name
=
user
.
first_name
self
.
last_name
=
user
.
last_name
self
.
username
=
user
.
username
self
.
email
=
user
.
email
self
.
password
=
user
.
password
self
.
register
end
end
end
end
end
qa/lib/gitlab/page/main/sign_up.stub.rb
0 → 100644
View file @
f4c2eee3
# frozen_string_literal: true
module
Gitlab
module
Page
module
Main
module
SignUp
# @note Defined as +text_field :first_name+
# @return [String] The text content or value of +first_name+
def
first_name
# This is a stub, used for indexing. The method is dynamically generated.
end
# Set the value of first_name
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# sign_up.first_name = 'value'
# end
# @param value [String] The value to set.
def
first_name
=
(
value
)
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# expect(sign_up.first_name_element).to exist
# end
# @return [Watir::TextField] The raw +TextField+ element
def
first_name_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# expect(sign_up).to be_first_name
# end
# @return [Boolean] true if the +first_name+ element is present on the page
def
first_name?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +text_field :last_name+
# @return [String] The text content or value of +last_name+
def
last_name
# This is a stub, used for indexing. The method is dynamically generated.
end
# Set the value of last_name
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# sign_up.last_name = 'value'
# end
# @param value [String] The value to set.
def
last_name
=
(
value
)
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# expect(sign_up.last_name_element).to exist
# end
# @return [Watir::TextField] The raw +TextField+ element
def
last_name_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# expect(sign_up).to be_last_name
# end
# @return [Boolean] true if the +last_name+ element is present on the page
def
last_name?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +text_field :username+
# @return [String] The text content or value of +username+
def
username
# This is a stub, used for indexing. The method is dynamically generated.
end
# Set the value of username
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# sign_up.username = 'value'
# end
# @param value [String] The value to set.
def
username
=
(
value
)
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# expect(sign_up.username_element).to exist
# end
# @return [Watir::TextField] The raw +TextField+ element
def
username_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# expect(sign_up).to be_username
# end
# @return [Boolean] true if the +username+ element is present on the page
def
username?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +text_field :email+
# @return [String] The text content or value of +email+
def
email
# This is a stub, used for indexing. The method is dynamically generated.
end
# Set the value of email
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# sign_up.email = 'value'
# end
# @param value [String] The value to set.
def
email
=
(
value
)
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# expect(sign_up.email_element).to exist
# end
# @return [Watir::TextField] The raw +TextField+ element
def
email_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# expect(sign_up).to be_email
# end
# @return [Boolean] true if the +email+ element is present on the page
def
email?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +text_field :password+
# @return [String] The text content or value of +password+
def
password
# This is a stub, used for indexing. The method is dynamically generated.
end
# Set the value of password
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# sign_up.password = 'value'
# end
# @param value [String] The value to set.
def
password
=
(
value
)
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# expect(sign_up.password_element).to exist
# end
# @return [Watir::TextField] The raw +TextField+ element
def
password_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# expect(sign_up).to be_password
# end
# @return [Boolean] true if the +password+ element is present on the page
def
password?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +button :register+
# Clicks +register+
def
register
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# expect(sign_up.register_element).to exist
# end
# @return [Watir::Button] The raw +Button+ element
def
register_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::SignUp.perform do |sign_up|
# expect(sign_up).to be_register
# end
# @return [Boolean] true if the +register+ element is present on the page
def
register?
# This is a stub, used for indexing. The method is dynamically generated.
end
end
end
end
end
qa/qa/resource/user.rb
View file @
f4c2eee3
...
...
@@ -123,6 +123,10 @@ module QA
"/users/
#{
id
}
/block"
end
def
api_approve_path
"/users/
#{
id
}
/approve"
end
def
api_post_body
{
admin:
admin
,
...
...
@@ -148,6 +152,13 @@ module QA
end
end
def
approve!
response
=
post
(
Runtime
::
API
::
Request
.
new
(
api_client
,
api_approve_path
).
url
,
nil
)
return
if
response
.
code
==
201
raise
ResourceUpdateFailedError
,
"Failed to approve user. Request returned (
#{
response
.
code
}
): `
#{
response
}
`"
end
def
block!
response
=
post
(
Runtime
::
API
::
Request
.
new
(
api_client
,
api_block_path
).
url
,
nil
)
return
if
response
.
code
==
HTTP_STATUS_CREATED
...
...
qa/qa/specs/features/ee/browser_ui/fulfillment/purchase/user_registration_billing_spec.rb
0 → 100644
View file @
f4c2eee3
# frozen_string_literal: true
module
QA
RSpec
.
describe
'Fulfillment'
,
:requires_admin
,
:skip_live_env
,
except:
{
job:
'review-qa-*'
}
do
describe
'Purchase'
do
describe
'User Registration'
do
let
(
:group
)
do
Resource
::
Group
.
fabricate_via_api!
end
let
(
:user
)
do
Resource
::
User
.
init
do
|
user
|
user
.
first_name
=
'QA'
user
.
last_name
=
'Test'
user
.
username
=
"qa-test-
#{
SecureRandom
.
hex
(
3
)
}
"
user
.
hard_delete_on_api_removal
=
true
end
end
before
do
# 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
end
after
do
user
.
remove_via_api!
group
.
remove_via_api!
rescue
Resource
::
ApiFabricator
::
ResourceNotDeletedError
# ignore and leave for other cleanup tasks.
# sometimes `group.remove_api!` fails with error:
# could not be deleted (400): `{"message":"Group has been already marked for deletion"}`
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'
do
Flow
::
Login
.
sign_in_as_admin
# Save the number of users as stated by the license
users_in_subscription
=
Gitlab
::
Page
::
Admin
::
Subscription
.
perform
do
|
subscription
|
subscription
.
visit
subscription
.
users_in_subscription
end
.
tr
(
','
,
''
)
# sanitize the value when returned as 10,000
# Save the number of users active on the instance as reported by GitLab
users_in_license
=
Gitlab
::
Page
::
Admin
::
Dashboard
.
perform
do
|
users
|
users
.
visit
users
.
users_in_license
end
.
tr
(
','
,
''
)
# sanitize the value when returned as 10,000
expect
(
users_in_subscription
).
to
eq
(
users_in_license
)
billable_users
=
Gitlab
::
Page
::
Admin
::
Dashboard
.
perform
(
&
:billable_users
)
# Activate the new user
user
.
reload!
&&
user
.
approve!
# first reload the API resource to fetch the ID, then approve
Gitlab
::
Page
::
Admin
::
Dashboard
.
perform
do
|
dashboard
|
dashboard
.
visit
# Validate billable users has not changed after approval
expect
(
dashboard
.
billable_users
).
to
eq
(
billable_users
)
group
.
add_member
(
user
)
# add the user to the group
dashboard
.
visit
# reload
# Validate billable users incremented by 1
expect
(
dashboard
.
billable_users
.
to_i
).
to
eq
(
billable_users
.
to_i
+
1
)
group
.
remove_member
(
user
)
# remove the user from the group
dashboard
.
visit
# reload
# Validate billable users equals the original amount
expect
(
dashboard
.
billable_users
).
to
eq
(
billable_users
)
end
end
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment