Merge branch 'ml-qa-skip-signup-disabled' into 'master'

QA: Allow the registration e2e test to be skipped

See merge request gitlab-org/gitlab-ce!22205
This commit is contained in:
Rémy Coutable 2018-10-09 07:00:42 +00:00
commit e04291117d
5 changed files with 55 additions and 19 deletions

View file

@ -5,13 +5,17 @@ module QA
# set to 'false' to have Chrome run visibly instead of headless
def chrome_headless?
(ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i) != 0
enabled?(ENV['CHROME_HEADLESS'])
end
def running_in_ci?
ENV['CI'] || ENV['CI_SERVER']
end
def signup_disabled?
enabled?(ENV['SIGNUP_DISABLED'], default: false)
end
# specifies token that can be used for the api
def personal_access_token
ENV['PERSONAL_ACCESS_TOKEN']
@ -83,6 +87,14 @@ module QA
raise ArgumentError, "Please provide GITHUB_ACCESS_TOKEN"
end
private
def enabled?(value, default: true)
return default if value.nil?
(value =~ /^(false|no|0)$/i) != 0
end
end
end
end

View file

@ -16,13 +16,13 @@ module QA
end
end
context :manage do
context :manage, :skip_signup_disabled do
describe 'standard' do
it_behaves_like 'registration and login'
end
end
context :manage, :orchestrated, :ldap do
context :manage, :orchestrated, :ldap, :skip_signup_disabled do
describe 'while LDAP is enabled' do
it_behaves_like 'registration and login'
end

View file

@ -23,6 +23,8 @@ module QA
args.push(%w[--tag ~orchestrated]) unless (%w[-t --tag] & options).any?
end
args.push(%w[--tag ~skip_signup_disabled]) if QA::Runtime::Env.signup_disabled?
args.push(options)
args.push(DEFAULT_TEST_PATH_ARGS) unless options.any? { |opt| opt =~ %r{/features/} }

View file

@ -1,39 +1,47 @@
describe QA::Runtime::Env do
include Support::StubENV
describe '.chrome_headless?' do
shared_examples 'boolean method' do |method, env_key, default|
context 'when there is an env variable set' do
it 'returns false when falsey values specified' do
stub_env('CHROME_HEADLESS', 'false')
expect(described_class.chrome_headless?).to be_falsey
stub_env(env_key, 'false')
expect(described_class.public_send(method)).to be_falsey
stub_env('CHROME_HEADLESS', 'no')
expect(described_class.chrome_headless?).to be_falsey
stub_env(env_key, 'no')
expect(described_class.public_send(method)).to be_falsey
stub_env('CHROME_HEADLESS', '0')
expect(described_class.chrome_headless?).to be_falsey
stub_env(env_key, '0')
expect(described_class.public_send(method)).to be_falsey
end
it 'returns true when anything else specified' do
stub_env('CHROME_HEADLESS', 'true')
expect(described_class.chrome_headless?).to be_truthy
stub_env(env_key, 'true')
expect(described_class.public_send(method)).to be_truthy
stub_env('CHROME_HEADLESS', '1')
expect(described_class.chrome_headless?).to be_truthy
stub_env(env_key, '1')
expect(described_class.public_send(method)).to be_truthy
stub_env('CHROME_HEADLESS', 'anything')
expect(described_class.chrome_headless?).to be_truthy
stub_env(env_key, 'anything')
expect(described_class.public_send(method)).to be_truthy
end
end
context 'when there is no env variable set' do
it 'returns the default, true' do
stub_env('CHROME_HEADLESS', nil)
expect(described_class.chrome_headless?).to be_truthy
it "returns the default, #{default}" do
stub_env(env_key, nil)
expect(described_class.public_send(method)).to be(default)
end
end
end
describe '.signup_disabled?' do
it_behaves_like 'boolean method', :signup_disabled?, 'SIGNUP_DISABLED', false
end
describe '.chrome_headless?' do
it_behaves_like 'boolean method', :chrome_headless?, 'CHROME_HEADLESS', true
end
describe '.running_in_ci?' do
context 'when there is an env variable set' do
it 'returns true if CI' do

View file

@ -62,6 +62,20 @@ describe QA::Specs::Runner do
end
end
context 'when SIGNUP_DISABLED is true' do
before do
allow(QA::Runtime::Env).to receive(:signup_disabled?).and_return(true)
end
subject { described_class.new }
it 'it includes default args and excludes the skip_signup_disabled tag' do
expect_rspec_runner_arguments(['--tag', '~orchestrated', '--tag', '~skip_signup_disabled', *described_class::DEFAULT_TEST_PATH_ARGS])
subject.perform
end
end
def expect_rspec_runner_arguments(arguments)
expect(RSpec::Core::Runner).to receive(:run)
.with(arguments, $stderr, $stdout)