Commit 155c5649 authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'e2e-storage-tests' into 'master'

Add purchase storage e2e tests

See merge request gitlab-org/gitlab!76562
parents ab8f4466 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
...@@ -48,7 +48,7 @@ module QA ...@@ -48,7 +48,7 @@ module QA
end end
it 'adds additional minutes to group namespace', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347622' do 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| Gitlab::Page::Group::Settings::UsageQuotas.perform do |usage_quota|
expected_minutes = CI_MINUTES[:ci_minutes] * purchase_quantity expected_minutes = CI_MINUTES[:ci_minutes] * purchase_quantity
...@@ -62,21 +62,11 @@ module QA ...@@ -62,21 +62,11 @@ module QA
context 'with an active subscription' do context 'with an active subscription' do
before do before do
Page::Group::Menu.perform(&:go_to_billing) Flow::Purchase.upgrade_subscription(plan: ULTIMATE)
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
end end
it 'adds additional minutes to group namespace', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347569' do 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| Gitlab::Page::Group::Settings::UsageQuotas.perform do |usage_quota|
expected_minutes = CI_MINUTES[:ci_minutes] * purchase_quantity expected_minutes = CI_MINUTES[:ci_minutes] * purchase_quantity
...@@ -94,7 +84,7 @@ module QA ...@@ -94,7 +84,7 @@ module QA
context 'with existing CI minutes packs' do context 'with existing CI minutes packs' do
before do before do
purchase_ci_minutes Flow::Purchase.purchase_ci_minutes(quantity: purchase_quantity)
end end
after do after do
...@@ -102,7 +92,7 @@ module QA ...@@ -102,7 +92,7 @@ module QA
end end
it 'adds additional minutes to group namespace', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347568' do 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| Gitlab::Page::Group::Settings::UsageQuotas.perform do |usage_quota|
expected_minutes = CI_MINUTES[:ci_minutes] * purchase_quantity * 2 expected_minutes = CI_MINUTES[:ci_minutes] * purchase_quantity * 2
...@@ -113,70 +103,6 @@ module QA ...@@ -113,70 +103,6 @@ module QA
end end
end 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 end
end end
...@@ -3,10 +3,21 @@ ...@@ -3,10 +3,21 @@
module QA module QA
include QA::Support::Helpers::Plan include QA::Support::Helpers::Plan
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
RSpec.describe 'Fulfillment', :requires_admin, only: { subdomain: :staging } do 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(:hash) { SecureRandom.hex(4) }
let(:user) do let(:user) do
Resource::User.fabricate_via_api! do |user| Resource::User.fabricate_via_api! do |user|
...@@ -37,71 +48,36 @@ module QA ...@@ -37,71 +48,36 @@ module QA
group.visit! group.visit!
end end
after do |example| after do
user.remove_via_api! user.remove_via_api!
group.remove_via_api! unless example.exception
end end
it 'adds additional storage to group namespace', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347571' do context 'purchase storage without active subscription', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347571' do
Page::Group::Menu.perform(&:go_to_usage_quotas) after do
Gitlab::Page::Group::Settings::UsageQuotas.perform do |usage_quota| group.remove_via_api!
usage_quota.storage_tab
usage_quota.buy_storage
end end
Gitlab::Page::Subscriptions::New.perform do |storage| it_behaves_like 'Purchase storage', 5
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 end
Gitlab::Page::Group::Settings::UsageQuotas.perform do |usage_quota| context 'purchase storage with an active subscription', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348472' do
expected_storage = STORAGE[:storage] * purchase_quantity before do
Flow::Purchase.upgrade_subscription(plan: PREMIUM)
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
private it_behaves_like 'Purchase storage', 20
end
def credit_card_info context 'purchase storage with existing CI minutes packs', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348470' do
{ before do
name: 'QA Test', Flow::Purchase.purchase_ci_minutes(quantity: 5)
number: '4111111111111111',
month: '01',
year: '2025',
cvv: '232'
}.freeze
end end
def user_billing_info after do
{ group.remove_via_api!
country: 'United States of America',
address_1: 'Address 1',
address_2: 'Address 2',
city: 'San Francisco',
state: 'California',
zip: '94102'
}.freeze
end end
it_behaves_like 'Purchase storage', 10
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