Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/qa/spec
diff options
context:
space:
mode:
Diffstat (limited to 'qa/spec')
-rw-r--r--qa/spec/git/repository_spec.rb2
-rw-r--r--qa/spec/resource/base_spec.rb12
-rw-r--r--qa/spec/runtime/env_spec.rb21
-rw-r--r--qa/spec/runtime/feature_spec.rb73
-rw-r--r--qa/spec/runtime/logger_spec.rb2
-rw-r--r--qa/spec/service/shellout_spec.rb58
-rw-r--r--qa/spec/specs/helpers/feature_flag_spec.rb22
-rw-r--r--qa/spec/specs/runner_spec.rb52
-rw-r--r--qa/spec/support/page_error_checker_spec.rb68
-rw-r--r--qa/spec/support/wait_for_requests_spec.rb16
10 files changed, 244 insertions, 82 deletions
diff --git a/qa/spec/git/repository_spec.rb b/qa/spec/git/repository_spec.rb
index a6a49f5907a..1b88cba2ba5 100644
--- a/qa/spec/git/repository_spec.rb
+++ b/qa/spec/git/repository_spec.rb
@@ -4,6 +4,7 @@ RSpec.describe QA::Git::Repository do
include QA::Support::Helpers::StubEnv
shared_context 'unresolvable git directory' do
+ let(:logger) { instance_double(Logger, info: nil, debug: nil) }
let(:repo_uri) { 'http://foo/bar.git' }
let(:repo_uri_with_credentials) { 'http://root@foo/bar.git' }
let(:env_vars) { [%q{HOME="temp"}] }
@@ -22,6 +23,7 @@ RSpec.describe QA::Git::Repository do
before do
stub_env('GITLAB_USERNAME', 'root')
allow(repository).to receive(:tmp_home_dir).and_return(tmp_netrc_dir)
+ allow(QA::Runtime::Logger).to receive(:logger).and_return(logger)
end
around do |example|
diff --git a/qa/spec/resource/base_spec.rb b/qa/spec/resource/base_spec.rb
index 6dac8e0e3ee..f23f4aa728b 100644
--- a/qa/spec/resource/base_spec.rb
+++ b/qa/spec/resource/base_spec.rb
@@ -112,18 +112,16 @@ RSpec.describe QA::Resource::Base do
let(:method) { 'api' }
before do
- allow(QA::Runtime::Logger).to receive(:debug)
+ allow(QA::Runtime::Logger).to receive(:info)
allow(resource).to receive(:api_support?).and_return(true)
allow(resource).to receive(:fabricate_via_api!)
allow(resource).to receive(:api_client) { api_client }
end
it 'logs the resource and build method' do
- stub_env('QA_DEBUG', 'true')
-
subject.fabricate_via_api!('something', resource: resource, parents: [])
- expect(QA::Runtime::Logger).to have_received(:debug) do |&msg|
+ expect(QA::Runtime::Logger).to have_received(:info) do |&msg|
expect(msg.call).to match_regex(log_regex)
end
end
@@ -155,15 +153,13 @@ RSpec.describe QA::Resource::Base do
let(:method) { 'browser_ui' }
before do
- allow(QA::Runtime::Logger).to receive(:debug)
+ allow(QA::Runtime::Logger).to receive(:info)
end
it 'logs the resource and build method' do
- stub_env('QA_DEBUG', 'true')
-
subject.fabricate_via_browser_ui!('something', resource: resource, parents: [])
- expect(QA::Runtime::Logger).to have_received(:debug) do |&msg|
+ expect(QA::Runtime::Logger).to have_received(:info) do |&msg|
expect(msg.call).to match_regex(log_regex)
end
end
diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb
index 22603497019..a41d7385c41 100644
--- a/qa/spec/runtime/env_spec.rb
+++ b/qa/spec/runtime/env_spec.rb
@@ -47,13 +47,6 @@ RSpec.describe QA::Runtime::Env do
default: false
end
- describe '.debug?' do
- it_behaves_like 'boolean method',
- method: :debug?,
- env_key: 'QA_DEBUG',
- default: false
- end
-
describe '.webdriver_headless?' do
it_behaves_like 'boolean method',
method: :webdriver_headless?,
@@ -264,20 +257,6 @@ RSpec.describe QA::Runtime::Env do
end
end
- describe '.log_destination' do
- it 'returns $stdout if QA_LOG_PATH is not defined' do
- stub_env('QA_LOG_PATH', nil)
-
- expect(described_class.log_destination).to eq($stdout)
- end
-
- it 'returns the path if QA_LOG_PATH is defined' do
- stub_env('QA_LOG_PATH', 'path/to_file')
-
- expect(described_class.log_destination).to eq('path/to_file')
- end
- end
-
describe '.can_test?' do
it_behaves_like 'boolean method with parameter',
method: :can_test?,
diff --git a/qa/spec/runtime/feature_spec.rb b/qa/spec/runtime/feature_spec.rb
index 88f5cd5be93..72ba915d99b 100644
--- a/qa/spec/runtime/feature_spec.rb
+++ b/qa/spec/runtime/feature_spec.rb
@@ -61,7 +61,7 @@ RSpec.describe QA::Runtime::Feature do
.to receive(:get)
.and_return(Struct.new(:code, :body).new(200, %Q([{ "name": "a_flag", "state": "conditional", "gates": #{gates} }])))
- expect(described_class.enabled?(feature_flag, scope => actor)).to be_truthy
+ expect(described_class.enabled?(feature_flag, scope => actor)).to be true
end
end
end
@@ -172,7 +172,7 @@ RSpec.describe QA::Runtime::Feature do
.to receive(:get)
.and_return(Struct.new(:code, :body).new(200, '[{ "name": "a_flag", "state": "on" }]'))
- expect(described_class.enabled?(feature_flag)).to be_truthy
+ expect(described_class.enabled?(feature_flag)).to be true
end
it 'raises an error when the scope is unknown' do
@@ -224,6 +224,75 @@ RSpec.describe QA::Runtime::Feature do
let(:gates) { %q([{"key": "groups", "value": ["foo"]}]) }
end
end
+
+ context 'when a feature flag is not found via the API and there is no definition file' do
+ before do
+ allow(QA::Runtime::API::Request)
+ .to receive(:new)
+ .with(api_client, "/features")
+ .and_return(request)
+ allow(described_class)
+ .to receive(:get)
+ .and_return(Struct.new(:code, :body).new(200, '[]'))
+ allow(Dir).to receive(:glob).and_return([])
+ end
+
+ it 'raises an error' do
+ expect { described_class.enabled?(feature_flag) }
+ .to raise_error(QA::Runtime::Feature::UnknownFeatureFlagError)
+ end
+ end
+
+ context 'with definition files' do
+ context 'when no features are found via the API' do
+ before do
+ allow(QA::Runtime::API::Request)
+ .to receive(:new)
+ .with(api_client, "/features")
+ .and_return(request)
+ allow(described_class)
+ .to receive(:get)
+ .and_return(Struct.new(:code, :body).new(200, '[]'))
+ allow(Dir).to receive(:glob).and_return(['file_path'])
+ allow(File).to receive(:read).and_return(definition)
+ end
+
+ context 'with a default enabled defintion' do
+ let(:definition) { 'default_enabled: true' }
+
+ it 'returns a default enabled flag' do
+ expect(described_class.enabled?(feature_flag)).to be true
+ end
+ end
+
+ context 'with a default disabled defintion' do
+ let(:definition) { 'default_enabled: false' }
+
+ it 'returns a default disabled flag' do
+ expect(described_class.enabled?(feature_flag)).to be false
+ end
+ end
+ end
+
+ context 'when the feature is found via the API' do
+ before do
+ allow(QA::Runtime::API::Request)
+ .to receive(:new)
+ .with(api_client, "/features")
+ .and_return(request)
+ allow(described_class)
+ .to receive(:get)
+ .and_return(Struct.new(:code, :body).new(200, '[{ "name": "a_flag", "state": "on" }]'))
+ end
+
+ it 'returns the value from the API not the definition file' do
+ expect(Dir).not_to receive(:glob)
+ expect(File).not_to receive(:read)
+
+ expect(described_class.enabled?(feature_flag)).to be true
+ end
+ end
+ end
end
end
diff --git a/qa/spec/runtime/logger_spec.rb b/qa/spec/runtime/logger_spec.rb
index f0fcfa0564e..652037a7041 100644
--- a/qa/spec/runtime/logger_spec.rb
+++ b/qa/spec/runtime/logger_spec.rb
@@ -2,6 +2,6 @@
RSpec.describe QA::Runtime::Logger do
it 'returns logger instance' do
- expect(described_class.logger).to be_an_instance_of(::Logger)
+ expect(described_class.logger).to be_an_instance_of(ActiveSupport::Logger)
end
end
diff --git a/qa/spec/service/shellout_spec.rb b/qa/spec/service/shellout_spec.rb
new file mode 100644
index 00000000000..9d7adeb0e94
--- /dev/null
+++ b/qa/spec/service/shellout_spec.rb
@@ -0,0 +1,58 @@
+# frozen_string_literal: true
+
+module QA
+ RSpec.describe Service::Shellout do
+ let(:wait_thread) { instance_double('Thread') }
+ let(:errored_wait) { instance_double('Process::Status', exited?: true, exitstatus: 1) }
+ let(:non_errored_wait) { instance_double('Process::Status', exited?: true, exitstatus: 0) }
+ let(:stdin) { StringIO.new }
+ let(:stdout) { [+'logged in as user with password secret'] }
+
+ context 'when masking secrets' do
+ before do
+ allow(Open3).to receive(:popen2e).and_yield(stdin, stdout, wait_thread)
+ end
+
+ it 'masks command secrets on CommandError' do
+ expect(wait_thread).to receive(:value).twice.and_return(errored_wait)
+
+ expect { subject.shell('docker login -u user -p secret', mask_secrets: %w[secret user]) }
+ .to raise_error(Service::Shellout::CommandError) do |error|
+ expect(error.to_s).to include('Command: `docker login -u **** -p ****` failed')
+ end
+ end
+
+ it 'masking secrets is optional' do
+ expect(wait_thread).to receive(:value).twice.and_return(errored_wait)
+
+ expect { subject.shell('docker pull ruby:3') }.to raise_error(Service::Shellout::CommandError) do |error|
+ expect(error.to_s).to include('Command: `docker pull ruby:3` failed')
+ end
+ end
+
+ it 'masks secrets when yielding output' do
+ expect(wait_thread).to receive(:value).twice.and_return(non_errored_wait)
+
+ subject.shell('docker login -u user -p secret', mask_secrets: %w[secret user]) do |output|
+ expect(output).not_to be(nil)
+ expect(output).to eql('logged in as **** with password ****')
+ end
+ end
+
+ it 'masks secrets in debug logs' do
+ expect(Runtime::Logger).to receive(:debug).with(/logged in as \*\*\*\* with password \*\*\*\*/)
+ expect(wait_thread).to receive(:value).twice.and_return(non_errored_wait)
+
+ subject.shell('docker login -u user -p secret', mask_secrets: %w[secret user])
+ end
+
+ it 'masks secrets in error logs' do
+ expect(Runtime::Logger).to receive(:error).with(/logged in as \*\*\*\* with password \*\*\*\*/)
+ expect(wait_thread).to receive(:value).twice.and_return(errored_wait)
+
+ expect { subject.shell('docker login -u user -p secret', mask_secrets: %w[secret user]) }
+ .to raise_error(Service::Shellout::CommandError)
+ end
+ end
+ end
+end
diff --git a/qa/spec/specs/helpers/feature_flag_spec.rb b/qa/spec/specs/helpers/feature_flag_spec.rb
index a1300ecf073..491fc22f026 100644
--- a/qa/spec/specs/helpers/feature_flag_spec.rb
+++ b/qa/spec/specs/helpers/feature_flag_spec.rb
@@ -147,6 +147,28 @@ RSpec.describe QA::Specs::Helpers::FeatureFlag do
it_behaves_like 'skips with given feature flag metadata', { name: 'global_ff', scope: :global }
end
+ context 'when run on pre' do
+ before(:context) do
+ QA::Runtime::Scenario.define(:gitlab_address, 'https://pre.gitlab.com')
+ end
+
+ context 'for only one test in the example group' do
+ it 'only skips specified test and runs all others' do
+ group = describe_successfully 'Feature flag set for one test' do
+ it('is skipped', feature_flag: { name: 'single_test_ff', scope: :group }) {}
+ it('passes') {}
+ end
+
+ expect(group.examples[0].execution_result.status).to eq(:pending)
+ expect(group.examples[1].execution_result.status).to eq(:passed)
+ end
+ end
+
+ it_behaves_like 'skips with given feature flag metadata', { name: 'actor_ff', scope: :project }
+
+ it_behaves_like 'skips with given feature flag metadata', { name: 'global_ff', scope: :global }
+ end
+
# The nightly package job, for example, does not run against a live environment with
# a defined gitlab_address. In this case, feature_flag tag logic can be safely ignored
context 'when run without a gitlab address specified' do
diff --git a/qa/spec/specs/runner_spec.rb b/qa/spec/specs/runner_spec.rb
index d5e442acfe7..dd013497367 100644
--- a/qa/spec/specs/runner_spec.rb
+++ b/qa/spec/specs/runner_spec.rb
@@ -1,14 +1,18 @@
# frozen_string_literal: true
RSpec.describe QA::Specs::Runner do
- shared_examples 'excludes orchestrated, transient, and geo' do
- it 'excludes the orchestrated, transient, and geo tags, and includes default args' do
- expect_rspec_runner_arguments(['--tag', '~orchestrated', '--tag', '~transient', '--tag', '~geo', *described_class::DEFAULT_TEST_PATH_ARGS])
+ shared_examples 'excludes default skipped, and geo' do
+ it 'excludes the default skipped and geo tags, and includes default args' do
+ expect_rspec_runner_arguments(DEFAULT_SKIPPED_TAGS + ['--tag', '~geo', *described_class::DEFAULT_TEST_PATH_ARGS])
subject.perform
end
end
+ before do
+ stub_const('DEFAULT_SKIPPED_TAGS', %w[--tag ~orchestrated --tag ~transient --tag ~sanity_feature_flags].freeze)
+ end
+
describe '#perform' do
before do
allow(QA::Runtime::Browser).to receive(:configure!)
@@ -17,13 +21,15 @@ RSpec.describe QA::Specs::Runner do
QA::Runtime::Scenario.define(:klass, "QA::Scenario::Test::Instance::All")
end
- it_behaves_like 'excludes orchestrated, transient, and geo'
+ it_behaves_like 'excludes default skipped, and geo'
context 'when tty is set' do
subject { described_class.new.tap { |runner| runner.tty = true } }
it 'sets the `--tty` flag' do
- expect_rspec_runner_arguments(['--tty', '--tag', '~orchestrated', '--tag', '~transient', '--tag', '~geo', *described_class::DEFAULT_TEST_PATH_ARGS])
+ expect_rspec_runner_arguments(
+ ['--tty'] + DEFAULT_SKIPPED_TAGS + ['--tag', '~geo', *described_class::DEFAULT_TEST_PATH_ARGS]
+ )
subject.perform
end
@@ -39,7 +45,10 @@ RSpec.describe QA::Specs::Runner do
end
it 'sets the `--dry-run` flag' do
- expect_rspec_runner_arguments(['--dry-run', '--tag', '~orchestrated', '--tag', '~transient', '--tag', '~geo', *described_class::DEFAULT_TEST_PATH_ARGS], [$stderr, anything])
+ expect_rspec_runner_arguments(
+ ['--dry-run'] + DEFAULT_SKIPPED_TAGS + ['--tag', '~geo', *described_class::DEFAULT_TEST_PATH_ARGS],
+ [$stderr, anything]
+ )
subject.perform
end
@@ -73,7 +82,10 @@ RSpec.describe QA::Specs::Runner do
subject { described_class.new.tap { |runner| runner.options = %w[--tag actioncable] } }
it 'includes the option value in the file name' do
- expect_rspec_runner_arguments(['--dry-run', '--tag', '~geo', '--tag', 'actioncable', *described_class::DEFAULT_TEST_PATH_ARGS], [$stderr, anything])
+ expect_rspec_runner_arguments(
+ ['--dry-run', '--tag', '~geo', '--tag', 'actioncable', *described_class::DEFAULT_TEST_PATH_ARGS],
+ [$stderr, anything]
+ )
expect(File).to receive(:open).with('no_of_examples/test_instance_all_actioncable.txt', 'w') { '22' }
@@ -98,7 +110,10 @@ RSpec.describe QA::Specs::Runner do
end
it 'sets the `--dry-run` flag' do
- expect_rspec_runner_arguments(['--dry-run', '--tag', '~orchestrated', '--tag', '~transient', '--tag', '~geo', *described_class::DEFAULT_TEST_PATH_ARGS], [$stderr, anything])
+ expect_rspec_runner_arguments(
+ ['--dry-run'] + DEFAULT_SKIPPED_TAGS + ['--tag', '~geo', *described_class::DEFAULT_TEST_PATH_ARGS],
+ [$stderr, anything]
+ )
subject.perform
end
@@ -125,7 +140,9 @@ RSpec.describe QA::Specs::Runner do
subject { described_class.new.tap { |runner| runner.tags = %i[orchestrated github] } }
it 'focuses on the given tags' do
- expect_rspec_runner_arguments(['--tag', 'orchestrated', '--tag', 'github', '--tag', '~geo', *described_class::DEFAULT_TEST_PATH_ARGS])
+ expect_rspec_runner_arguments(
+ ['--tag', 'orchestrated', '--tag', 'github', '--tag', '~geo', *described_class::DEFAULT_TEST_PATH_ARGS]
+ )
subject.perform
end
@@ -144,8 +161,8 @@ RSpec.describe QA::Specs::Runner do
context 'when "qa/specs/features/foo" is set as options' do
subject { described_class.new.tap { |runner| runner.options = %w[qa/specs/features/foo] } }
- it 'passes the given tests path and excludes the orchestrated, transient, and geo tags' do
- expect_rspec_runner_arguments(['--tag', '~orchestrated', '--tag', '~transient', '--tag', '~geo', 'qa/specs/features/foo'])
+ it 'passes the given tests path and excludes the default skipped, and geo tags' do
+ expect_rspec_runner_arguments(DEFAULT_SKIPPED_TAGS + ['--tag', '~geo', 'qa/specs/features/foo'])
subject.perform
end
@@ -167,7 +184,7 @@ RSpec.describe QA::Specs::Runner do
end
it 'includes default args and excludes the skip_signup_disabled tag' do
- expect_rspec_runner_arguments(['--tag', '~orchestrated', '--tag', '~transient', '--tag', '~geo', '--tag', '~skip_signup_disabled', *described_class::DEFAULT_TEST_PATH_ARGS])
+ expect_rspec_runner_arguments(DEFAULT_SKIPPED_TAGS + ['--tag', '~geo', '--tag', '~skip_signup_disabled', *described_class::DEFAULT_TEST_PATH_ARGS])
subject.perform
end
@@ -179,7 +196,7 @@ RSpec.describe QA::Specs::Runner do
end
it 'includes default args and excludes the skip_live_env tag' do
- expect_rspec_runner_arguments(['--tag', '~orchestrated', '--tag', '~transient', '--tag', '~geo', '--tag', '~skip_live_env', *described_class::DEFAULT_TEST_PATH_ARGS])
+ expect_rspec_runner_arguments(DEFAULT_SKIPPED_TAGS + ['--tag', '~geo', '--tag', '~skip_live_env', *described_class::DEFAULT_TEST_PATH_ARGS])
subject.perform
end
end
@@ -212,7 +229,10 @@ RSpec.describe QA::Specs::Runner do
end
it 'includes default args and excludes all unsupported tags' do
- expect_rspec_runner_arguments(['--tag', '~orchestrated', '--tag', '~transient', '--tag', '~geo', *excluded_feature_tags_except(feature), *described_class::DEFAULT_TEST_PATH_ARGS])
+ expect_rspec_runner_arguments(
+ DEFAULT_SKIPPED_TAGS + ['--tag', '~geo', *excluded_feature_tags_except(feature),
+ *described_class::DEFAULT_TEST_PATH_ARGS]
+ )
subject.perform
end
@@ -237,11 +257,11 @@ RSpec.describe QA::Specs::Runner do
end
end
- it_behaves_like 'excludes orchestrated, transient, and geo'
+ it_behaves_like 'excludes default skipped, and geo'
end
context 'when features are not specified' do
- it_behaves_like 'excludes orchestrated, transient, and geo'
+ it_behaves_like 'excludes default skipped, and geo'
end
end
diff --git a/qa/spec/support/page_error_checker_spec.rb b/qa/spec/support/page_error_checker_spec.rb
index 7c8aaeb182a..ab7014f4677 100644
--- a/qa/spec/support/page_error_checker_spec.rb
+++ b/qa/spec/support/page_error_checker_spec.rb
@@ -8,23 +8,37 @@ RSpec.describe QA::Support::PageErrorChecker do
describe '.report!' do
context 'reports errors' do
let(:expected_chrome_error) do
- "Error Code 500\n\n"\
- "chrome errors\n\n"\
- "Path: #{test_path}\n\n"\
- "Logging: foo123"
+ <<~MSG
+ Error Code: 500
+
+ chrome errors
+
+ Path: #{test_path}
+
+ Logging: foo123
+ MSG
end
let(:expected_basic_error) do
- "Error Code 500\n\n"\
- "foo status\n\n"\
- "Path: #{test_path}\n\n"\
- "Logging: foo123"
+ <<~MSG
+ Error Code: 500
+
+ foo status
+
+ Path: #{test_path}
+
+ Logging: foo123
+ MSG
end
let(:expected_basic_404) do
- "Error Code 404\n\n"\
- "foo status\n\n"\
- "Path: #{test_path}"
+ <<~MSG
+ Error Code: 404
+
+ foo status
+
+ Path: #{test_path}
+ MSG
end
it 'reports error message on chrome browser' do
@@ -34,7 +48,10 @@ RSpec.describe QA::Support::PageErrorChecker do
allow(page).to receive(:current_path).and_return(test_path)
allow(QA::Runtime::Env).to receive(:browser).and_return(:chrome)
- expect { QA::Support::PageErrorChecker.report!(page, 500) }.to raise_error(RuntimeError, expected_chrome_error)
+ expect { QA::Support::PageErrorChecker.report!(page, 500) }.to raise_error(
+ QA::Support::PageErrorChecker::PageError,
+ expected_chrome_error
+ )
end
it 'reports basic message on non-chrome browser' do
@@ -44,7 +61,10 @@ RSpec.describe QA::Support::PageErrorChecker do
allow(page).to receive(:current_path).and_return(test_path)
allow(QA::Runtime::Env).to receive(:browser).and_return(:firefox)
- expect { QA::Support::PageErrorChecker.report!(page, 500) }.to raise_error(RuntimeError, expected_basic_error)
+ expect { QA::Support::PageErrorChecker.report!(page, 500) }.to raise_error(
+ QA::Support::PageErrorChecker::PageError,
+ expected_basic_error
+ )
end
it 'does not report failure metadata on non 500 error' do
@@ -56,7 +76,10 @@ RSpec.describe QA::Support::PageErrorChecker do
allow(page).to receive(:current_path).and_return(test_path)
allow(QA::Runtime::Env).to receive(:browser).and_return(:firefox)
- expect { QA::Support::PageErrorChecker.report!(page, 404) }.to raise_error(RuntimeError, expected_basic_404)
+ expect { QA::Support::PageErrorChecker.report!(page, 404) }.to raise_error(
+ QA::Support::PageErrorChecker::PageError,
+ expected_basic_404
+ )
end
end
end
@@ -182,9 +205,10 @@ RSpec.describe QA::Support::PageErrorChecker do
"</div>"
end
- let(:error_500_str) { "<h1> 500 </h1>"}
- let(:backtrace_str) {"<body><section class=\"backtrace\">foo</section></body>"}
- let(:no_error_str) {"<body>no 404 or 500 or backtrace</body>"}
+ let(:error_500_str) { "<head><title>Something went wrong (500)</title></head><body><h1> 500 </h1></body>" }
+ let(:project_name_500_str) { "<head><title>Project</title></head><h1 class=\"home-panel-title gl-mt-3 gl-mb-2\" itemprop=\"name\">qa-test-2022-05-25-12-12-16-d4500c2e79c37289</h1>" }
+ let(:backtrace_str) { "<head><title>Error::Backtrace</title></head><body><section class=\"backtrace\">foo</section></body>" }
+ let(:no_error_str) { "<head><title>Nothing wrong here</title></head><body>no 404 or 500 or backtrace</body>" }
it 'calls report with 404 if 404 found' do
allow(page).to receive(:html).and_return(error_404_str)
@@ -207,6 +231,13 @@ RSpec.describe QA::Support::PageErrorChecker do
expect(QA::Support::PageErrorChecker).to receive(:report!).with(page, 500)
QA::Support::PageErrorChecker.check_page_for_error_code(page)
end
+ it 'does not call report if 500 found in project name' do
+ allow(page).to receive(:html).and_return(project_name_500_str)
+ allow(Nokogiri::HTML).to receive(:parse).with(project_name_500_str).and_return(NokogiriParse.parse(project_name_500_str))
+
+ expect(QA::Support::PageErrorChecker).not_to receive(:report!)
+ QA::Support::PageErrorChecker.check_page_for_error_code(page)
+ end
it 'does not call report if no 404, 500 or backtrace found' do
allow(page).to receive(:html).and_return(no_error_str)
allow(Nokogiri::HTML).to receive(:parse).with(no_error_str).and_return(NokogiriParse.parse(no_error_str))
@@ -234,7 +265,7 @@ RSpec.describe QA::Support::PageErrorChecker do
it 'returns error report array of log messages' do
expect(QA::Support::PageErrorChecker.error_report_for([LogOne, LogTwo]))
- .to eq(%W(foo\n bar))
+ .to eq(%W[foo\n bar])
end
end
@@ -246,6 +277,7 @@ RSpec.describe QA::Support::PageErrorChecker do
before do
allow(Capybara).to receive(:current_session).and_return(session)
+ allow(QA::Runtime::Env).to receive(:can_intercept?).and_return(true)
end
it 'logs from the error cache' do
diff --git a/qa/spec/support/wait_for_requests_spec.rb b/qa/spec/support/wait_for_requests_spec.rb
index 221d61ea2b4..3204333fc0e 100644
--- a/qa/spec/support/wait_for_requests_spec.rb
+++ b/qa/spec/support/wait_for_requests_spec.rb
@@ -16,22 +16,6 @@ RSpec.describe QA::Support::WaitForRequests do
end
end
- context 'when skip_finished_loading_check is true' do
- it 'does not call finished_loading?' do
- subject.wait_for_requests(skip_finished_loading_check: true)
-
- expect(subject).not_to have_received(:finished_loading?)
- end
- end
-
- context 'when skip_resp_code_check is defaulted to false' do
- it 'call report' do
- subject.wait_for_requests
-
- expect(QA::Support::PageErrorChecker).to have_received(:check_page_for_error_code).with(Capybara.page)
- end
- end
-
context 'when skip_resp_code_check is true' do
it 'does not parse for an error code' do
subject.wait_for_requests(skip_resp_code_check: true)