Commit 49d117be authored by Ramya Authappan's avatar Ramya Authappan

Merge branch 'dj-gitlab-chemlab-and-upgrade-group-spec' into 'master'

Add upgrade_group_spec.rb

See merge request gitlab-org/gitlab!66954
parents 308a3a85 25fa866d
...@@ -72,4 +72,4 @@ ...@@ -72,4 +72,4 @@
- if show_contact_sales_button - if show_contact_sales_button
= link_to s_('BillingPlan|Contact sales'), "#{contact_sales_url}?test=inappcontactsales#{plan.code}", class: ["btn gl-button", show_upgrade_button ? "btn-success-secondary" : "btn-success"], data: { **experiment_tracking_data_for_button_click('contact_sales') } = link_to s_('BillingPlan|Contact sales'), "#{contact_sales_url}?test=inappcontactsales#{plan.code}", class: ["btn gl-button", show_upgrade_button ? "btn-success-secondary" : "btn-success"], data: { **experiment_tracking_data_for_button_click('contact_sales') }
- if show_upgrade_button - if show_upgrade_button
= link_to upgrade_button_text, plan_purchase_or_upgrade_url(namespace, plan), class: "#{upgrade_button_classes} billing-cta-purchase#{cta_class} gl-ml-3", data: { **experiment_tracking_data_for_button_click('upgrade') } = link_to upgrade_button_text, plan_purchase_or_upgrade_url(namespace, plan), class: "#{upgrade_button_classes} billing-cta-purchase#{cta_class} gl-ml-3", data: { **experiment_tracking_data_for_button_click('upgrade'), qa_selector: "upgrade_to_#{plan.code}" }
# frozen_string_literal: true
$:.unshift(File.expand_path('lib', __dir__))
Gem::Specification.new do |spec|
spec.name = 'chemlab-library-gitlab'
spec.version = '0.1.1'
spec.authors = ['GitLab Quality']
spec.email = ['quality@gitlab.com']
spec.required_ruby_version = '>= 2.5' # rubocop:disable Gemspec/RequiredRubyVersion
spec.summary = 'Chemlab Page Libraries for GitLab'
spec.homepage = 'https://gitlab.com/'
spec.license = 'MIT'
spec.files = `git ls-files -- lib/*`.split("\n")
spec.require_paths = ['lib']
spec.add_runtime_dependency 'chemlab', '~> 0.7'
end
# frozen_string_literal: true
# Chemlab Page Libraries for GitLab
module Gitlab
module Page
module Main
autoload :Login, 'gitlab/page/main/login'
end
module Subscriptions
autoload :New, 'gitlab/page/subscriptions/new'
end
module Group
module Settings
autoload :Billing, 'gitlab/page/group/settings/billing'
end
end
end
end
# frozen_string_literal: true # frozen_string_literal: true
module QA module Gitlab
module Page module Page
module Group module Group
module Settings module Settings
class Billing < Chemlab::Page class Billing < Chemlab::Page
# TODO: Supplant with data-qa-selectors
h4 :billing_plan_header, css: 'div.billing-plan-header h4'
link :start_your_free_trial link :start_your_free_trial
link :upgrade_to_premium, css: '[data-testid="plan-card-premium"] a.billing-cta-purchase-new'
link :upgrade_to_ultimate, css: '[data-testid="plan-card-ultimate"] a.billing-cta-purchase-new'
end end
end end
end end
......
# frozen_string_literal: true
module Gitlab
module Page
module Group
module Settings
module Billing
# @note Defined as +h4 :billing_plan_header+
# @return [String] The text content or value of +billing_plan_header+
def billing_plan_header
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Group::Settings::Billing.perform do |billing|
# expect(billing.billing_plan_header_element).to exist
# end
# @return [Watir::H4] The raw +H4+ element
def billing_plan_header_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Group::Settings::Billing.perform do |billing|
# expect(billing).to be_billing_plan_header
# end
# @return [Boolean] true if the +billing_plan_header+ element is present on the page
def billing_plan_header?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +link :start_your_free_trial+
# Clicks +start_your_free_trial+
def start_your_free_trial
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Group::Settings::Billing.perform do |billing|
# expect(billing.start_your_free_trial_element).to exist
# end
# @return [Watir::Link] The raw +Link+ element
def start_your_free_trial_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Group::Settings::Billing.perform do |billing|
# expect(billing).to be_start_your_free_trial
# end
# @return [Boolean] true if the +start_your_free_trial+ element is present on the page
def start_your_free_trial?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +link :upgrade_to_premium+
# Clicks +upgrade_to_premium+
def upgrade_to_premium
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Group::Settings::Billing.perform do |billing|
# expect(billing.upgrade_to_premium_element).to exist
# end
# @return [Watir::Link] The raw +Link+ element
def upgrade_to_premium_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Group::Settings::Billing.perform do |billing|
# expect(billing).to be_upgrade_to_premium
# end
# @return [Boolean] true if the +upgrade_to_premium+ element is present on the page
def upgrade_to_premium?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +link :upgrade_to_ultimate+
# Clicks +upgrade_to_ultimate+
def upgrade_to_ultimate
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Group::Settings::Billing.perform do |billing|
# expect(billing.upgrade_to_ultimate_element).to exist
# end
# @return [Watir::Link] The raw +Link+ element
def upgrade_to_ultimate_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Group::Settings::Billing.perform do |billing|
# expect(billing).to be_upgrade_to_ultimate
# end
# @return [Boolean] true if the +upgrade_to_ultimate+ element is present on the page
def upgrade_to_ultimate?
# This is a stub, used for indexing. The method is dynamically generated.
end
end
end
end
end
end
# frozen_string_literal: true
module Gitlab
module Page
module Main
class Login < Chemlab::Page
path '/users/sign_in'
text_field :login_field
text_field :password_field
button :sign_in_button
def sign_in_as(username:, password:)
self.login_field = username
self.password_field = password
sign_in_button
end
end
end
end
end
# frozen_string_literal: true
module Gitlab
module Page
module Main
module Login
# @note Defined as +text_field :login_field+
# @return [String] The text content or value of +login_field+
def login_field
# This is a stub, used for indexing. The method is dynamically generated.
end
# Set the value of login_field
# @example
# Gitlab::Page::Main::Login.perform do |login|
# login.login_field = 'value'
# end
# @param value [String] The value to set.
def login_field=(value)
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::Login.perform do |login|
# expect(login.login_field_element).to exist
# end
# @return [Watir::TextField] The raw +TextField+ element
def login_field_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::Login.perform do |login|
# expect(login).to be_login_field
# end
# @return [Boolean] true if the +login_field+ element is present on the page
def login_field?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +text_field :password_field+
# @return [String] The text content or value of +password_field+
def password_field
# This is a stub, used for indexing. The method is dynamically generated.
end
# Set the value of password_field
# @example
# Gitlab::Page::Main::Login.perform do |login|
# login.password_field = 'value'
# end
# @param value [String] The value to set.
def password_field=(value)
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::Login.perform do |login|
# expect(login.password_field_element).to exist
# end
# @return [Watir::TextField] The raw +TextField+ element
def password_field_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::Login.perform do |login|
# expect(login).to be_password_field
# end
# @return [Boolean] true if the +password_field+ element is present on the page
def password_field?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +button :sign_in_button+
# Clicks +sign_in_button+
def sign_in_button
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::Login.perform do |login|
# expect(login.sign_in_button_element).to exist
# end
# @return [Watir::Button] The raw +Button+ element
def sign_in_button_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Main::Login.perform do |login|
# expect(login).to be_sign_in_button
# end
# @return [Boolean] true if the +sign_in_button+ element is present on the page
def sign_in_button?
# This is a stub, used for indexing. The method is dynamically generated.
end
end
end
end
end
# frozen_string_literal: true
module Gitlab
module Page
module Subscriptions
class New < Chemlab::Page
path '/subscriptions/new'
# Subscription Details
select :plan_name
select :group_name
text_field :number_of_users
button :continue_to_billing, text: /Continue to billing/
# Billing address
select :country
text_field :street_address_1
text_field :street_address_2
text_field :city
select :state
text_field :zip_code
button :continue_to_payment, text: /Continue to payment/
# Payment method
# TODO: Revisit when https://gitlab.com/gitlab-org/quality/chemlab/-/issues/6 is closed
iframe :payment_form, id: 'z_hppm_iframe'
text_field(:name_on_card) { payment_form_element.text_field(id: 'input-creditCardHolderName') }
text_field(:card_number) { payment_form_element.text_field(id: 'input-creditCardNumber') }
select(:expiration_month) { payment_form_element.select(id: 'input-creditCardExpirationMonth') }
select(:expiration_year) { payment_form_element.select(id: 'input-creditCardExpirationYear') }
text_field(:cvv) { payment_form_element.text_field(id: 'input-cardSecurityCode') }
link(:review_your_order) { payment_form_element.link(text: /Review your order/) }
# ENDTODO
# Confirmation
button :confirm_purchase, text: /Confirm purchase/
end
end
end
end
This diff is collapsed.
...@@ -8,6 +8,8 @@ require_relative '../lib/gitlab' ...@@ -8,6 +8,8 @@ require_relative '../lib/gitlab'
require_relative '../lib/gitlab/utils' require_relative '../lib/gitlab/utils'
require_relative '../config/initializers/0_inject_enterprise_edition_module' require_relative '../config/initializers/0_inject_enterprise_edition_module'
require_relative 'lib/gitlab'
require 'chemlab' require 'chemlab'
module QA module QA
......
# frozen_string_literal: true
module QA
RSpec.describe 'Fulfillment', :requires_admin, only: { subdomain: :staging } do
describe 'Purchase' do
describe 'group plan' do
let(:hash) { SecureRandom.hex(4) }
let(:user) do
Resource::User.fabricate_via_api! do |user|
user.email = "gitlab-qa+#{hash}@gitlab.com"
user.api_client = Runtime::API::Client.as_admin
user.hard_delete_on_api_removal = true
end
end
# Normally we would delete the group, however we cannot remove this group
# after the test runs since GitLab will not allow deletion of a group
# that has a Subscription attached
let(:group) do
Resource::Sandbox.fabricate_via_api! do |sandbox|
sandbox.path = "gitlab-qa-group-#{hash}"
sandbox.api_client = Runtime::API::Client.as_admin
end
end
before do
Runtime::Feature.enable(:top_level_group_creation_enabled)
group.add_member(user, Resource::Members::AccessLevel::OWNER)
Flow::Login.sign_in(as: user)
group.visit!
end
after do
user.remove_via_api!
Runtime::Feature.disable(:top_level_group_creation_enabled)
end
it 'upgrades from free to ultimate', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1863' 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|
# Subscription details
new_subscription.continue_to_billing
# Billing information
new_subscription.country = 'United States of America'
new_subscription.street_address_1 = 'QA Test Address 1'
new_subscription.city = 'San Francisco'
new_subscription.state = 'California'
new_subscription.zip_code = '94102'
new_subscription.continue_to_payment
# Payment method
new_subscription.name_on_card = 'QA Test User'
new_subscription.card_number = '4111 1111 1111 1111'
new_subscription.expiration_month = '01'
new_subscription.expiration_year = '2030'
new_subscription.cvv = '789'
new_subscription.review_your_order
# Confirm
new_subscription.confirm_purchase
end
Page::Group::Menu.perform(&:go_to_billing)
Gitlab::Page::Group::Settings::Billing.perform do |billing|
expect do
billing.billing_plan_header
end.to eventually_include("#{group.name} is currently using the Ultimate SaaS Plan").within(duration: 120, attempts: 60, reload_page: page)
end
end
end
end
end
end
...@@ -25,6 +25,7 @@ module Matchers ...@@ -25,6 +25,7 @@ module Matchers
@duration = options[:duration] @duration = options[:duration]
@attempts = options[:attempts] @attempts = options[:attempts]
@interval = options[:interval] @interval = options[:interval]
@reload_page = options[:reload_page]
end end
def supports_block_expectations? def supports_block_expectations?
...@@ -59,7 +60,8 @@ module Matchers ...@@ -59,7 +60,8 @@ module Matchers
QA::Support::Retrier.retry_until( QA::Support::Retrier.retry_until(
max_attempts: @attempts, max_attempts: @attempts,
max_duration: @duration, max_duration: @duration,
sleep_interval: @interval || 0.5 sleep_interval: @interval || 0.5,
reload_page: @reload_page
) do ) do
QA::Runtime::Logger.debug("evaluating expectation, attempt: #{attempt += 1}") QA::Runtime::Logger.debug("evaluating expectation, attempt: #{attempt += 1}")
......
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