Commit 0fea04b8 authored by Chloe Liu's avatar Chloe Liu

Add e2e tests for CI minutes purchase

parent f3915fd9
...@@ -10,7 +10,9 @@ module Gitlab ...@@ -10,7 +10,9 @@ module Gitlab
link :buy_ci_minutes, text: 'Buy additional minutes' link :buy_ci_minutes, text: 'Buy additional minutes'
link :buy_storage, text: /Purchase more storage/ link :buy_storage, text: /Purchase more storage/
strong :additional_minutes, text: 'Additional minutes' strong :additional_minutes, text: 'Additional minutes'
strong :plan_minutes, text: 'Current period usage'
div :purchased_usage, 'data-testid': 'purchased-usage' div :purchased_usage, 'data-testid': 'purchased-usage'
div(:plan_minutes_usage) { plan_minutes_element.following_sibling.span }
div(:additional_minutes_usage) { additional_minutes_element.following_sibling.span } div(:additional_minutes_usage) { additional_minutes_element.following_sibling.span }
div :ci_purchase_successful_alert, text: /You have successfully purchased CI minutes/ div :ci_purchase_successful_alert, text: /You have successfully purchased CI minutes/
div :storage_purchase_successful_alert, text: /You have successfully purchased a storage/ div :storage_purchase_successful_alert, text: /You have successfully purchased a storage/
......
...@@ -38,51 +38,125 @@ module QA ...@@ -38,51 +38,125 @@ 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
context 'without active subscription' do
after do
group.remove_via_api!
end end
it 'adds additional minutes to group namespace', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/2260' do it 'adds additional minutes to group namespace', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/2260' do
Page::Group::Menu.perform(&:go_to_usage_quotas) purchase_ci_minutes
Gitlab::Page::Group::Settings::UsageQuotas.perform do |usage_quota| Gitlab::Page::Group::Settings::UsageQuotas.perform do |usage_quota|
usage_quota.pipeline_tab expected_minutes = CI_MINUTES[:ci_minutes] * purchase_quantity
usage_quota.buy_ci_minutes
expect { usage_quota.ci_purchase_successful_alert? }.to eventually_be_truthy.within(max_duration: 60, max_attempts: 30)
expect { usage_quota.additional_minutes? }.to eventually_be_truthy.within(max_duration: 120, max_attempts: 60, reload_page: page)
expect(usage_quota.additional_limits).to eq(expected_minutes.to_s)
end
end
end end
Gitlab::Page::Subscriptions::New.perform do |ci_minutes| context 'with an active subscription' do
ci_minutes.quantity = purchase_quantity before do
ci_minutes.continue_to_billing Page::Group::Menu.perform(&:go_to_billing)
Gitlab::Page::Group::Settings::Billing.perform(&:upgrade_to_ultimate)
ci_minutes.country = user_billing_info[:country] Gitlab::Page::Subscriptions::New.perform do |new_subscription|
ci_minutes.street_address_1 = user_billing_info[:address_1] new_subscription.continue_to_billing
ci_minutes.street_address_2 = user_billing_info[:address_2]
ci_minutes.city = user_billing_info[:city]
ci_minutes.state = user_billing_info[:state]
ci_minutes.zip_code = user_billing_info[:zip]
ci_minutes.continue_to_payment
ci_minutes.name_on_card = credit_card_info[:name]
ci_minutes.card_number = credit_card_info[:number]
ci_minutes.expiration_month = credit_card_info[:month]
ci_minutes.expiration_year = credit_card_info[:year]
ci_minutes.cvv = credit_card_info[:cvv]
ci_minutes.review_your_order
ci_minutes.confirm_purchase 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/quality/testcases/-/quality/test_cases/2430' do
purchase_ci_minutes
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
plan_limits = ULTIMATE[:ci_minutes]
expect { usage_quota.ci_purchase_successful_alert? }.to eventually_be_truthy.within(max_duration: 60, max_attempts: 30) expect { usage_quota.ci_purchase_successful_alert? }.to eventually_be_truthy.within(max_duration: 60, max_attempts: 30)
expect { usage_quota.additional_minutes? }.to eventually_be_truthy.within(max_duration: 120, max_attempts: 60, reload_page: page) expect { usage_quota.additional_minutes? }.to eventually_be_truthy.within(max_duration: 120, max_attempts: 60, reload_page: page)
aggregate_failures do
expect(usage_quota.additional_limits).to eq(expected_minutes.to_s) expect(usage_quota.additional_limits).to eq(expected_minutes.to_s)
expect(usage_quota.plan_minutes_limits).to eq(plan_limits.to_s)
end
end
end
end
context 'with existing CI minutes packs' do
before do
purchase_ci_minutes
end
after do
group.remove_via_api!
end
it 'adds additional minutes to group namespace', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/2431' do
purchase_ci_minutes
Gitlab::Page::Group::Settings::UsageQuotas.perform do |usage_quota|
expected_minutes = CI_MINUTES[:ci_minutes] * purchase_quantity * 2
expect { usage_quota.ci_purchase_successful_alert? }.to eventually_be_truthy.within(max_duration: 60, max_attempts: 30)
expect { usage_quota.additional_minutes? }.to eventually_be_truthy.within(max_duration: 120, max_attempts: 60, reload_page: page)
expect(usage_quota.additional_limits).to eq(expected_minutes.to_s)
end
end end
end end
private 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 def credit_card_info
{ {
name: 'QA Test', name: 'QA Test',
......
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