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
50c00356
Commit
50c00356
authored
Dec 08, 2021
by
Chloe Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add purchase storage e2e tests
Add purchase flow to e2e tests
parent
0fd270ff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
171 additions
and
162 deletions
+171
-162
qa/qa/flow/purchase.rb
qa/qa/flow/purchase.rb
+107
-0
qa/qa/specs/features/ee/browser_ui/11_fulfillment/purchase/purchase_ci_spec.rb
...ee/browser_ui/11_fulfillment/purchase/purchase_ci_spec.rb
+5
-79
qa/qa/specs/features/ee/browser_ui/11_fulfillment/purchase/purchase_storage_spec.rb
...owser_ui/11_fulfillment/purchase/purchase_storage_spec.rb
+59
-83
No files found.
qa/qa/flow/purchase.rb
0 → 100644
View file @
50c00356
# frozen_string_literal: true
module
QA
module
Flow
module
Purchase
include
QA
::
Support
::
Helpers
::
Plan
module_function
def
upgrade_subscription
(
plan:
PREMIUM
)
Page
::
Group
::
Menu
.
perform
(
&
:go_to_billing
)
Gitlab
::
Page
::
Group
::
Settings
::
Billing
.
perform
do
|
billing
|
billing
.
send
(
"upgrade_to_
#{
plan
[
:name
].
downcase
}
"
)
end
Gitlab
::
Page
::
Subscriptions
::
New
.
perform
do
|
new_subscription
|
new_subscription
.
continue_to_billing
fill_in_customer_info
fill_in_payment_info
new_subscription
.
confirm_purchase
end
end
def
purchase_ci_minutes
(
quantity:
1
)
Page
::
Group
::
Menu
.
perform
(
&
:go_to_usage_quotas
)
Gitlab
::
Page
::
Group
::
Settings
::
UsageQuotas
.
perform
do
|
usage_quota
|
usage_quota
.
pipeline_tab
usage_quota
.
buy_ci_minutes
end
Gitlab
::
Page
::
Subscriptions
::
New
.
perform
do
|
ci_minutes
|
ci_minutes
.
quantity
=
quantity
ci_minutes
.
continue_to_billing
fill_in_customer_info
fill_in_payment_info
ci_minutes
.
confirm_purchase
end
end
def
purchase_storage
(
quantity:
1
)
Page
::
Group
::
Menu
.
perform
(
&
:go_to_usage_quotas
)
Gitlab
::
Page
::
Group
::
Settings
::
UsageQuotas
.
perform
do
|
usage_quota
|
usage_quota
.
storage_tab
usage_quota
.
buy_storage
end
Gitlab
::
Page
::
Subscriptions
::
New
.
perform
do
|
storage
|
storage
.
quantity
=
quantity
storage
.
continue_to_billing
fill_in_customer_info
fill_in_payment_info
storage
.
confirm_purchase
end
end
def
fill_in_customer_info
Gitlab
::
Page
::
Subscriptions
::
New
.
perform
do
|
subscription
|
subscription
.
country
=
user_billing_info
[
:country
]
subscription
.
street_address_1
=
user_billing_info
[
:address_1
]
subscription
.
street_address_2
=
user_billing_info
[
:address_2
]
subscription
.
city
=
user_billing_info
[
:city
]
subscription
.
state
=
user_billing_info
[
:state
]
subscription
.
zip_code
=
user_billing_info
[
:zip
]
subscription
.
continue_to_payment
end
end
def
fill_in_payment_info
Gitlab
::
Page
::
Subscriptions
::
New
.
perform
do
|
subscription
|
subscription
.
name_on_card
=
credit_card_info
[
:name
]
subscription
.
card_number
=
credit_card_info
[
:number
]
subscription
.
expiration_month
=
credit_card_info
[
:month
]
subscription
.
expiration_year
=
credit_card_info
[
:year
]
subscription
.
cvv
=
credit_card_info
[
:cvv
]
subscription
.
review_your_order
end
end
def
credit_card_info
{
name:
'QA Test'
,
number:
'4111111111111111'
,
month:
'01'
,
year:
'2025'
,
cvv:
'232'
}.
freeze
end
def
user_billing_info
{
country:
'United States of America'
,
address_1:
'Address 1'
,
address_2:
'Address 2'
,
city:
'San Francisco'
,
state:
'California'
,
zip:
'94102'
}.
freeze
end
end
end
end
qa/qa/specs/features/ee/browser_ui/11_fulfillment/purchase/purchase_ci_spec.rb
View file @
50c00356
...
...
@@ -48,7 +48,7 @@ module QA
end
it
'adds additional minutes to group namespace'
,
testcase:
'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347622'
do
purchase_ci_minutes
Flow
::
Purchase
.
purchase_ci_minutes
(
quantity:
purchase_quantity
)
Gitlab
::
Page
::
Group
::
Settings
::
UsageQuotas
.
perform
do
|
usage_quota
|
expected_minutes
=
CI_MINUTES
[
:ci_minutes
]
*
purchase_quantity
...
...
@@ -62,21 +62,11 @@ module QA
context
'with an active subscription'
do
before
do
Page
::
Group
::
Menu
.
perform
(
&
:go_to_billing
)
Gitlab
::
Page
::
Group
::
Settings
::
Billing
.
perform
(
&
:upgrade_to_ultimate
)
Gitlab
::
Page
::
Subscriptions
::
New
.
perform
do
|
new_subscription
|
new_subscription
.
continue_to_billing
fill_in_customer_info
fill_in_payment_info
new_subscription
.
confirm_purchase
end
Flow
::
Purchase
.
upgrade_subscription
(
plan:
ULTIMATE
)
end
it
'adds additional minutes to group namespace'
,
testcase:
'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347569'
do
purchase_ci_minutes
Flow
::
Purchase
.
purchase_ci_minutes
(
quantity:
purchase_quantity
)
Gitlab
::
Page
::
Group
::
Settings
::
UsageQuotas
.
perform
do
|
usage_quota
|
expected_minutes
=
CI_MINUTES
[
:ci_minutes
]
*
purchase_quantity
...
...
@@ -94,7 +84,7 @@ module QA
context
'with existing CI minutes packs'
do
before
do
purchase_ci_minutes
Flow
::
Purchase
.
purchase_ci_minutes
(
quantity:
purchase_quantity
)
end
after
do
...
...
@@ -102,7 +92,7 @@ module QA
end
it
'adds additional minutes to group namespace'
,
testcase:
'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347568'
do
purchase_ci_minutes
Flow
::
Purchase
.
purchase_ci_minutes
(
quantity:
purchase_quantity
)
Gitlab
::
Page
::
Group
::
Settings
::
UsageQuotas
.
perform
do
|
usage_quota
|
expected_minutes
=
CI_MINUTES
[
:ci_minutes
]
*
purchase_quantity
*
2
...
...
@@ -113,70 +103,6 @@ module QA
end
end
end
private
def
purchase_ci_minutes
Page
::
Group
::
Menu
.
perform
(
&
:go_to_usage_quotas
)
Gitlab
::
Page
::
Group
::
Settings
::
UsageQuotas
.
perform
do
|
usage_quota
|
usage_quota
.
pipeline_tab
usage_quota
.
buy_ci_minutes
end
Gitlab
::
Page
::
Subscriptions
::
New
.
perform
do
|
ci_minutes
|
ci_minutes
.
quantity
=
purchase_quantity
ci_minutes
.
continue_to_billing
fill_in_customer_info
fill_in_payment_info
ci_minutes
.
confirm_purchase
end
end
def
fill_in_customer_info
Gitlab
::
Page
::
Subscriptions
::
New
.
perform
do
|
subscription
|
subscription
.
country
=
user_billing_info
[
:country
]
subscription
.
street_address_1
=
user_billing_info
[
:address_1
]
subscription
.
street_address_2
=
user_billing_info
[
:address_2
]
subscription
.
city
=
user_billing_info
[
:city
]
subscription
.
state
=
user_billing_info
[
:state
]
subscription
.
zip_code
=
user_billing_info
[
:zip
]
subscription
.
continue_to_payment
end
end
def
fill_in_payment_info
Gitlab
::
Page
::
Subscriptions
::
New
.
perform
do
|
subscription
|
subscription
.
name_on_card
=
credit_card_info
[
:name
]
subscription
.
card_number
=
credit_card_info
[
:number
]
subscription
.
expiration_month
=
credit_card_info
[
:month
]
subscription
.
expiration_year
=
credit_card_info
[
:year
]
subscription
.
cvv
=
credit_card_info
[
:cvv
]
subscription
.
review_your_order
end
end
def
credit_card_info
{
name:
'QA Test'
,
number:
'4111111111111111'
,
month:
'01'
,
year:
'2025'
,
cvv:
'232'
}.
freeze
end
def
user_billing_info
{
country:
'United States of America'
,
address_1:
'Address 1'
,
address_2:
'Address 2'
,
city:
'San Francisco'
,
state:
'California'
,
zip:
'94102'
}.
freeze
end
end
end
end
qa/qa/specs/features/ee/browser_ui/11_fulfillment/purchase/purchase_storage_spec.rb
View file @
50c00356
...
...
@@ -3,105 +3,81 @@
module
QA
include
QA
::
Support
::
Helpers
::
Plan
RSpec
.
describe
'Fulfillment'
,
:requires_admin
,
only:
{
subdomain: :staging
}
do
context
'Purchase Storage'
do
# the quantity of products to purchase
let
(
:purchase_quantity
)
{
5
}
let
(
:hash
)
{
SecureRandom
.
hex
(
4
)
}
let
(
:user
)
do
Resource
::
User
.
fabricate_via_api!
do
|
user
|
user
.
email
=
"test-user-
#{
hash
}
@gitlab.com"
user
.
api_client
=
Runtime
::
API
::
Client
.
as_admin
user
.
hard_delete_on_api_removal
=
true
end
RSpec
.
shared_examples
'Purchase storage'
do
|
purchase_quantity
|
it
'adds additional storage to group namespace'
do
Flow
::
Purchase
.
purchase_storage
(
quantity:
purchase_quantity
)
Gitlab
::
Page
::
Group
::
Settings
::
UsageQuotas
.
perform
do
|
usage_quota
|
expected_storage
=
STORAGE
[
:storage
]
*
purchase_quantity
expect
{
usage_quota
.
storage_purchase_successful_alert?
}.
to
eventually_be_truthy
.
within
(
max_duration:
60
,
max_attempts:
30
)
expect
{
usage_quota
.
purchased_storage_available?
}.
to
eventually_be_truthy
.
within
(
max_duration:
120
,
max_attempts:
60
,
reload_page:
page
)
expect
{
usage_quota
.
total_purchased_storage
}.
to
eventually_eq
(
expected_storage
.
to_f
).
within
(
max_duration:
120
,
max_attempts:
60
,
reload_page:
page
)
end
end
end
let
(
:group
)
do
Resource
::
Sandbox
.
fabricate!
do
|
sandbox
|
sandbox
.
path
=
"gitlab-qa-group-
#{
hash
}
"
sandbox
.
api_client
=
Runtime
::
API
::
Client
.
as_admin
end
RSpec
.
describe
'Fulfillment'
,
:requires_admin
,
only:
{
subdomain: :staging
}
do
let
(
:hash
)
{
SecureRandom
.
hex
(
4
)
}
let
(
:user
)
do
Resource
::
User
.
fabricate_via_api!
do
|
user
|
user
.
email
=
"test-user-
#{
hash
}
@gitlab.com"
user
.
api_client
=
Runtime
::
API
::
Client
.
as_admin
user
.
hard_delete_on_api_removal
=
true
end
end
before
do
group
.
add_member
(
user
,
Resource
::
Members
::
AccessLevel
::
OWNER
)
let
(
:group
)
do
Resource
::
Sandbox
.
fabricate!
do
|
sandbox
|
sandbox
.
path
=
"gitlab-qa-group-
#{
hash
}
"
sandbox
.
api_client
=
Runtime
::
API
::
Client
.
as_admin
end
end
Resource
::
Project
.
fabricate_via_api!
do
|
project
|
project
.
name
=
'storage'
project
.
group
=
group
project
.
initialize_with_readme
=
true
project
.
api_client
=
Runtime
::
API
::
Client
.
as_admin
end
before
do
group
.
add_member
(
user
,
Resource
::
Members
::
AccessLevel
::
OWNER
)
Flow
::
Login
.
sign_in
(
as:
user
)
group
.
visit!
Resource
::
Project
.
fabricate_via_api!
do
|
project
|
project
.
name
=
'storage'
project
.
group
=
group
project
.
initialize_with_readme
=
true
project
.
api_client
=
Runtime
::
API
::
Client
.
as_admin
end
after
do
|
example
|
user
.
remove_via_api!
group
.
remove_via_api!
unless
example
.
exception
Flow
::
Login
.
sign_in
(
as:
user
)
group
.
visit!
end
after
do
user
.
remove_via_api!
end
context
'purchase storage without active subscription'
,
testcase:
'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347571'
do
after
do
group
.
remove_via_api!
end
it
'adds additional storage to group namespace'
,
testcase:
'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347571'
do
Page
::
Group
::
Menu
.
perform
(
&
:go_to_usage_quotas
)
Gitlab
::
Page
::
Group
::
Settings
::
UsageQuotas
.
perform
do
|
usage_quota
|
usage_quota
.
storage_tab
usage_quota
.
buy_storage
end
Gitlab
::
Page
::
Subscriptions
::
New
.
perform
do
|
storage
|
storage
.
quantity
=
purchase_quantity
storage
.
continue_to_billing
storage
.
country
=
user_billing_info
[
:country
]
storage
.
street_address_1
=
user_billing_info
[
:address_1
]
storage
.
street_address_2
=
user_billing_info
[
:address_2
]
storage
.
city
=
user_billing_info
[
:city
]
storage
.
state
=
user_billing_info
[
:state
]
storage
.
zip_code
=
user_billing_info
[
:zip
]
storage
.
continue_to_payment
storage
.
name_on_card
=
credit_card_info
[
:name
]
storage
.
card_number
=
credit_card_info
[
:number
]
storage
.
expiration_month
=
credit_card_info
[
:month
]
storage
.
expiration_year
=
credit_card_info
[
:year
]
storage
.
cvv
=
credit_card_info
[
:cvv
]
storage
.
review_your_order
storage
.
confirm_purchase
end
Gitlab
::
Page
::
Group
::
Settings
::
UsageQuotas
.
perform
do
|
usage_quota
|
expected_storage
=
STORAGE
[
:storage
]
*
purchase_quantity
expect
{
usage_quota
.
storage_purchase_successful_alert?
}.
to
eventually_be_truthy
.
within
(
max_duration:
60
,
max_attempts:
30
)
expect
{
usage_quota
.
purchased_storage_available?
}.
to
eventually_be_truthy
.
within
(
max_duration:
120
,
max_attempts:
60
,
reload_page:
page
)
expect
{
usage_quota
.
total_purchased_storage
}.
to
eventually_eq
(
expected_storage
.
to_f
).
within
(
max_duration:
120
,
max_attempts:
60
,
reload_page:
page
)
end
it_behaves_like
'Purchase storage'
,
5
end
context
'purchase storage with an active subscription'
,
testcase:
'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348472'
do
before
do
Flow
::
Purchase
.
upgrade_subscription
(
plan:
PREMIUM
)
end
private
it_behaves_like
'Purchase storage'
,
20
end
def
credit_card_info
{
name:
'QA Test'
,
number:
'4111111111111111'
,
month:
'01'
,
year:
'2025'
,
cvv:
'232'
}.
freeze
context
'purchase storage with existing CI minutes packs'
,
testcase:
'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348470'
do
before
do
Flow
::
Purchase
.
purchase_ci_minutes
(
quantity:
5
)
end
def
user_billing_info
{
country:
'United States of America'
,
address_1:
'Address 1'
,
address_2:
'Address 2'
,
city:
'San Francisco'
,
state:
'California'
,
zip:
'94102'
}.
freeze
after
do
group
.
remove_via_api!
end
it_behaves_like
'Purchase storage'
,
10
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