Commit a8802520 authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'e2e-add-storage-spec' into 'master'

Add e2e tests for purchase storage with new route

See merge request gitlab-org/gitlab!75397
parents 6727ccad 7bf72abd
......@@ -10,8 +10,11 @@ module Gitlab
link :buy_ci_minutes, text: 'Buy additional minutes'
link :buy_storage, text: /Purchase more storage/
strong :additional_minutes, text: 'Additional minutes'
div :purchased_usage, 'data-testid': 'purchased-usage'
div(:additional_minutes_usage) { additional_minutes_element.following_sibling.span }
div :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/
h4 :storage_available_alert, text: /purchased storage is available/
def plan_minutes_limits
plan_minutes_usage[%r{([^/ ]+)$}]
......@@ -20,6 +23,23 @@ module Gitlab
def additional_limits
additional_minutes_usage[%r{([^/ ]+)$}]
end
# Waits and Checks if storage available alert presents on the page
#
# @return [Boolean] True if the alert presents, false if not after 5 second wait
def purchased_storage_available?
storage_available_alert_element.wait_until(timeout: 5, &:present?)
rescue Watir::Wait::TimeoutError
false
end
# Returns total purchased storage value once it's ready on page
#
# @return [Float] Total purchased storage value in GiB
def total_purchased_storage
storage_available_alert_element.wait_until(&:present?)
purchased_usage_element.p.spans[3].text.to_f
end
end
end
end
......
# frozen_string_literal: true
module QA
include QA::Support::Helpers::Plan
RSpec.describe 'Fulfillment', :requires_admin, only: { subdomain: :staging } do
context 'Purchase CI minutes' do
# the quantity of products to purchase
......@@ -71,9 +73,9 @@ module QA
end
Gitlab::Page::Group::Settings::UsageQuotas.perform do |usage_quota|
expected_minutes = ci_product[:minutes] * purchase_quantity
expected_minutes = CI_MINUTES[:ci_minutes] * purchase_quantity
expect { usage_quota.purchase_successful_alert? }.to eventually_be_truthy.within(max_duration: 120, max_attempts: 60)
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
......@@ -81,16 +83,6 @@ module QA
private
# Hash presentation of CI minutes addon
# @return [Hash] CI Minutes addon
def ci_product
{
name: 'CI Minutes', # the name as it appears to purchase in GitLab
price: 10, # unit price in USD
minutes: 1000 # additional CI minutes per pack
}.freeze
end
def credit_card_info
{
name: 'QA Test',
......
# frozen_string_literal: true
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
end
let(:group) do
Resource::Sandbox.fabricate! do |sandbox|
sandbox.path = "gitlab-qa-group-#{hash}"
sandbox.api_client = Runtime::API::Client.as_admin
end
end
before do
Runtime::Feature.enable(:new_route_storage_purchase)
group.add_member(user, Resource::Members::AccessLevel::OWNER)
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
Flow::Login.sign_in(as: user)
group.visit!
end
after do |example|
Runtime::Feature.disable(:new_route_storage_purchase)
user.remove_via_api!
group.remove_via_api! unless example.exception
end
it 'adds additional storage to group namespace', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/2424' 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
end
private
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
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