Commit 443cfc57 authored by Dan Davison's avatar Dan Davison

Merge branch 'e2e-cloud-activation' into 'master'

Add e2e tests for cloud activation

See merge request gitlab-org/gitlab!77997
parents 0ad368f9 58e1fc7b
......@@ -156,6 +156,7 @@ export default {
v-model.trim="form.fields.activationCode.value"
v-validation:[form.showValidation]
class="gl-mb-4"
data-qa-selector="activation_code"
:disabled="isLoading"
:placeholder="$options.i18n.pasteActivationCode"
:state="form.fields.activationCode.state"
......@@ -197,6 +198,7 @@ export default {
category="primary"
class="gl-mt-6 js-no-auto-disable"
data-testid="activate-button"
data-qa-selector="activate"
type="submit"
variant="confirm"
>
......
......@@ -179,6 +179,7 @@ export default {
:subscription="subscription"
:sync-did-fail="syncDidFail"
data-testid="subscription-details"
data-qa-selector="subscription_details"
>
<template v-if="shouldShowFooter" #footer>
<div class="gl-display-flex gl-flex-wrap gl-align-items-flex-start">
......
......@@ -6,6 +6,10 @@ module Gitlab
class Subscription < Chemlab::Page
path '/admin/subscription'
div :subscription_details
text_field :activation_code
button :activate
label :terms_of_services, text: /I agree that/
p :plan
p :started
p :name
......@@ -16,6 +20,33 @@ module Gitlab
h2 :users_in_subscription
h2 :users_over_subscription
table :subscription_history
def accept_terms
terms_of_services_element.click # workaround for hidden checkbox
end
# 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 has_subscription_record?(plan, users_in_license, license_type)
# find any records that have a matching plan and seats and type
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
......
......@@ -4,6 +4,112 @@ module Gitlab
module Page
module Admin
module Subscription
# @note Defined as +h6 :subscription_details+
# @return [String] The text content or value of +subscription_details+
def subscription_details
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription.subscription_details_element).to exist
# end
# @return [Watir::H6] The raw +H6+ element
def subscription_details_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_details
# end
# @return [Boolean] true if the +subscription_details+ element is present on the page
def subscription_details?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +text_field :activation_code+
# @return [String] The text content or value of +activation_code+
def activation_code
# This is a stub, used for indexing. The method is dynamically generated.
end
# Set the value of activation_code
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# subscription.activation_code = 'value'
# end
# @param value [String] The value to set.
def activation_code=(value)
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription.activation_code_element).to exist
# end
# @return [Watir::TextField] The raw +TextField+ element
def activation_code_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_activation_code
# end
# @return [Boolean] true if the +activation_code+ element is present on the page
def activation_code?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +label :terms_of_services+
# @return [String] The text content or value of +terms_of_services+
def terms_of_services
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription.terms_of_services_element).to exist
# end
# @return [Watir::Label] The raw +Label+ element
def terms_of_services_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_terms_of_services
# end
# @return [Boolean] true if the +terms_of_services+ element is present on the page
def terms_of_services?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +button :activate+
# Clicks +activate+
def activate
# This is a stub, used for indexing. The method is dynamically generated.
end
# @example
# Gitlab::Page::Admin::Subscription.perform do |subscription|
# expect(subscription.activate_element).to exist
# end
# @return [Watir::Button] The raw +Button+ element
def activate_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_activate
# end
# @return [Boolean] true if the +activate+ element is present on the page
def activate?
# This is a stub, used for indexing. The method is dynamically generated.
end
# @note Defined as +p :plan+
# @return [String] The text content or value of +plan+
def plan
......
......@@ -434,6 +434,10 @@ module QA
ENV.fetch('QA_TEST_RESOURCES_CREATED_FILEPATH', File.join(Path.qa_root, 'tmp', file_name))
end
def ee_activation_code
ENV['QA_EE_ACTIVATION_CODE']
end
private
def remote_grid_credentials
......
# frozen_string_literal: true
module QA
include QA::Support::Helpers::Plan
RSpec.describe 'Fulfillment', :requires_admin, :orchestrated, :cloud_activation do
let(:user) { 'GitLab QA' }
let(:company) { 'QA User' }
let(:user_count) { 10_000 }
let(:plan) { ULTIMATE_SELF_MANAGED }
context 'Cloud activation code' do
before do
Flow::Login.sign_in_as_admin
Gitlab::Page::Admin::Subscription.perform(&:visit)
end
it 'activates instance with correct subscription details', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/350294' do
Gitlab::Page::Admin::Subscription.perform do |subscription|
subscription.activation_code = Runtime::Env.ee_activation_code
subscription.accept_terms
subscription.activate
aggregate_failures do
expect { subscription.subscription_details?}.to eventually_be_truthy.within(max_duration: 60)
expect(subscription.name).to eq(user)
expect(subscription.company).to include(company)
expect(subscription.plan).to eq(plan[:name].capitalize)
expect(subscription.users_in_subscription).to eq(user_count.to_s)
expect(subscription).to have_subscription_record(plan, user_count, LICENSE_TYPE[:cloud_license])
end
end
end
end
end
end
......@@ -7,7 +7,7 @@ module QA
let(:user) { 'GitLab QA' }
let(:user_email) { 'gitlab-qa@gitlab.com' }
let(:company) { 'GitLab' }
let(:user_count) { 10000 }
let(:user_count) { 10_000 }
let(:plan) { ULTIMATE_SELF_MANAGED }
context 'Active license details' do
......@@ -24,34 +24,7 @@ module QA
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
expect(subscription).to have_subscription_record(plan, user_count, LICENSE_TYPE[:license_file])
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