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

Add e2e test for validating active subscription details

Add plan helper class
parent 0aa1b867
......@@ -41,7 +41,7 @@ GEM
capybara-screenshot (1.0.23)
capybara (>= 1.0, < 4)
launchy
chemlab (0.9.1)
chemlab (0.9.2)
colorize (~> 0.8)
i18n (~> 1.8)
rake (>= 12, < 14)
......
......@@ -6,7 +6,16 @@ module Gitlab
class Subscription < Chemlab::Page
path '/admin/subscription'
p :plan
p :started
p :name
p :company
p :email
h2 :billable_users
h2 :maximum_users
h2 :users_in_subscription
h2 :users_over_subscription
table :subscription_history
end
end
end
......
......@@ -4,6 +4,174 @@ module Gitlab
module Page
module Admin
module Subscription
# @note Defined as +p :plan+
# @return [String] The text content or value of +plan+
def plan
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription.plan_element).to exist
# end
# @return [Watir::P] The raw +P+ element
def plan_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription).to be_plan
# end
# @return [Boolean] true if the +plan+ element is present on the page
def plan?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +p :started+
# @return [String] The text content or value of +started+
def started
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription.started_element).to exist
# end
# @return [Watir::P] The raw +P+ element
def started_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription).to be_started
# end
# @return [Boolean] true if the +started+ element is present on the page
def started?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +p :name+
# @return [String] The text content or value of +name+
def name
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription.name_element).to exist
# end
# @return [Watir::P] The raw +P+ element
def name_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription).to be_name
# end
# @return [Boolean] true if the +name+ element is present on the page
def name?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +p :company+
# @return [String] The text content or value of +company+
def company
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription.company_element).to exist
# end
# @return [Watir::P] The raw +P+ element
def company_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription).to be_company
# end
# @return [Boolean] true if the +company+ element is present on the page
def company?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +p :email+
# @return [String] The text content or value of +email+
def email
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription.email_element).to exist
# end
# @return [Watir::P] The raw +P+ element
def email_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription).to be_email
# end
# @return [Boolean] true if the +email+ element is present on the page
def email?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +h2 :billable_users+
# @return [String] The text content or value of +billable_users+
def billable_users
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription.billable_users_element).to exist
# end
# @return [Watir::H2] The raw +H2+ element
def billable_users_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription).to be_billable_users
# end
# @return [Boolean] true if the +billable_users+ element is present on the page
def billable_users?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +h2 :maximum_users+
# @return [String] The text content or value of +maximum_users+
def maximum_users
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription.maximum_users_element).to exist
# end
# @return [Watir::H2] The raw +H2+ element
def maximum_users_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription).to be_maximum_users
# end
# @return [Boolean] true if the +maximum_users+ element is present on the page
def maximum_users?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +h2 :users_in_subscription+
# @return [String] The text content or value of +users_in_subscription+
def users_in_subscription
......@@ -27,6 +195,54 @@ module Gitlab
def users_in_subscription?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +h2 :users_over_subscription+
# @return [String] The text content or value of +users_over_subscription+
def users_over_subscription
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription.users_over_subscription_element).to exist
# end
# @return [Watir::H2] The raw +H2+ element
def users_over_subscription_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription).to be_users_over_subscription
# end
# @return [Boolean] true if the +users_over_subscription+ element is present on the page
def users_over_subscription?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +table :subscription_history+
# @return [String] The text content or value of +subscription_history+
def subscription_history
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription.subscription_history_element).to exist
# end
# @return [Watir::Table] The raw +Table+ element
def subscription_history_element
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription).to be_subscription_history
# end
# @return [Boolean] true if the +subscription_history+ element is present on the page
def subscription_history?
# This is a stub, used for indexing. The method is dynamically generated.
end
end
end
end
......
# frozen_string_literal: true
module QA
include QA::Support::Helpers::Plan
RSpec.describe 'Fulfillment', :requires_admin, :skip_live_env, except: { job: 'review-qa-*' } do
let(:user) { 'GitLab QA' }
let(:user_email) { 'gitlab-qa@gitlab.com' }
let(:company) { 'GitLab' }
let(:user_count) { 10000 }
let(:plan) { ULTIMATE_SELF_MANAGED }
context 'Active license details' do
before do
Flow::Login.sign_in_as_admin
Gitlab::Page::Admin::Subscription.perform(&:visit)
end
it 'shows up in subscription page', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/2341' do
Gitlab::Page::Admin::Subscription.perform do |subscription|
aggregate_failures do
expect { subscription.name }.to eventually_eq(user).within(max_duration: 30)
expect(subscription.email).to eq(user_email)
expect(subscription.company).to eq(company)
expect(subscription.plan).to eq(plan[:name].capitalize)
expect(subscription.users_in_subscription).to eq(user_count.to_s)
expect(subscription_record_exists(plan, user_count, LICENSE_TYPE[:license_file])).to be(true)
end
end
end
private
# Checks if a subscription record exists in subscription history table
#
# @param plan [Hash] Name of the plan
# @option plan [Hash] Support::Helpers::FREE
# @option plan [Hash] Support::Helpers::PREMIUM
# @option plan [Hash] Support::Helpers::PREMIUM_SELF_MANAGED
# @option plan [Hash] Support::Helpers::ULTIMATE
# @option plan [Hash] Support::Helpers::ULTIMATE_SELF_MANAGED
# @option plan [Hash] Support::Helpers::CI_MINUTES
# @option plan [Hash] Support::Helpers::STORAGE
# @param users_in_license [Integer] Number of users in license
# @param license_type [Hash] Type of the license
# @option license_type [String] 'license file'
# @option license_type [String] 'cloud license'
# @return [Boolean] True if record exsists, false if not
def subscription_record_exists(plan, users_in_license, license_type)
Gitlab::Page::Admin::Subscription.perform do |subscription|
# find any records that have a matching plan and seats and type
subscription.subscription_history_element.hashes.any? do |record|
record['Plan'] == plan[:name].capitalize && record['Seats'] == users_in_license.to_s && \
record['Type'].strip.downcase == license_type
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module Support
module Helpers
module Plan
FREE = { name: 'free', price: 0, yearly_price: 0, ci_minutes: 400 }.freeze
PREMIUM = {
plan_id: '2c92a00d76f0d5060176f2fb0a5029ff',
rate_charge_id: '2c92a00d76f0d5060176f2fb0a672a02',
name: 'premium',
price: 19,
yearly_price: 228,
ci_minutes: 10000
}.freeze
PREMIUM_SELF_MANAGED = {
plan_id: '2c92a01176f0d50a0176f3043c4d4a53',
rate_charge_id: '2c92a01176f0d50a0176f3043c6a4a58',
name: 'premium',
price: 19,
yearly_price: 228
}.freeze
ULTIMATE = {
plan_id: '2c92a0ff76f0d5250176f2f8c86f305a',
rate_charge_id: '2c92a0ff76f0d5250176f2f8c896305c',
name: 'ultimate',
price: 99,
yearly_price: 1188,
ci_minutes: 50000
}.freeze
ULTIMATE_SELF_MANAGED = {
plan_id: '2c92a00c76f0c6c20176f2f9328b33c9',
rate_charge_id: '2c92a00c76f0c6c20176f2fcbb645b5f',
name: 'ultimate',
price: 99,
yearly_price: 1188
}.freeze
CI_MINUTES = {
plan_id: '2c92a0086a07f4a8016a2c0a1f7b4b4c',
rate_charge_id: '2c92a0fd6a07f4c6016a2c0af07c3f21',
name: 'ci_minutes',
price: 10,
ci_minutes: 1000
}.freeze
STORAGE = {
plan_id: '2c92a00f7279a6f5017279d299d01cf9',
rate_charge_id: '2c92a0ff7279a74f017279d5bea71fc5',
name: 'storage',
price: 60,
storage: 10
}.freeze
LICENSE_TYPE = {
license_file: 'license file',
cloud_license: 'cloud license'
}.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