blob: 32c4f469207d0d6993f28842711de677102dc01d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# frozen_string_literal: true
module QA
module Flow
module Purchase
include QA::Support::Helpers::Plan
extend self
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.pipelines_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.purchase_more_storage
end
# Purchase checkout opens a new tab but buying additional storage does not
session = Chemlab.configuration.browser.session.engine
session.switch_window if session.windows.size == 2
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::Flow::Purchase.prepend_mod_with('Flow::Purchase', namespace: QA)
|