diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /qa/spec/page | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) | |
download | gitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'qa/spec/page')
-rw-r--r-- | qa/spec/page/base_spec.rb | 43 | ||||
-rw-r--r-- | qa/spec/page/logging_spec.rb | 32 |
2 files changed, 43 insertions, 32 deletions
diff --git a/qa/spec/page/base_spec.rb b/qa/spec/page/base_spec.rb index 52345876149..146e71da933 100644 --- a/qa/spec/page/base_spec.rb +++ b/qa/spec/page/base_spec.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +# rubocop:disable QA/ElementWithPattern RSpec.describe QA::Page::Base do describe 'page helpers' do it 'exposes helpful page helpers' do @@ -11,12 +12,12 @@ RSpec.describe QA::Page::Base do subject do Class.new(described_class) do view 'path/to/some/view.html.haml' do - element :something, 'string pattern' # rubocop:disable QA/ElementWithPattern - element :something_else, /regexp pattern/ # rubocop:disable QA/ElementWithPattern + element :something, 'string pattern' + element :something_else, /regexp pattern/ end view 'path/to/some/_partial.html.haml' do - element :another_element, 'string pattern' # rubocop:disable QA/ElementWithPattern + element :another_element, 'string pattern' end end end @@ -95,6 +96,7 @@ RSpec.describe QA::Page::Base do describe '#all_elements' do before do allow(subject).to receive(:all) + allow(subject).to receive(:wait_for_requests) end it 'raises an error if count or minimum are not specified' do @@ -108,7 +110,7 @@ RSpec.describe QA::Page::Base do end end - context 'elements' do + describe 'elements' do subject do Class.new(described_class) do view 'path/to/some/view.html.haml' do @@ -133,35 +135,37 @@ RSpec.describe QA::Page::Base do describe '#visible?', 'Page is currently visible' do let(:page) { subject.new } + before do + allow(page).to receive(:wait_for_requests) + end + context 'with elements' do - context 'on the page' do - before do - # required elements not there, meaning not on page - allow(page).to receive(:has_no_element?).and_return(false) - end + before do + allow(page).to receive(:has_no_element?).and_return(has_no_element) + end + + context 'with element on the page' do + let(:has_no_element) { false } it 'is visible' do expect(page).to be_visible end - end - context 'not on the page' do - before do - # required elements are not on the page - allow(page).to receive(:has_no_element?).and_return(true) + it 'does not raise error if page has elements' do + expect { page.visible? }.not_to raise_error end + end + + context 'with element not on the page' do + let(:has_no_element) { true } it 'is not visible' do expect(page).not_to be_visible end end - - it 'does not raise error if page has elements' do - expect { page.visible? }.not_to raise_error - end end - context 'no elements' do + context 'with no elements' do subject do Class.new(described_class) do view 'path/to/some/view.html.haml' do @@ -180,3 +184,4 @@ RSpec.describe QA::Page::Base do end end end +# rubocop:enable QA/ElementWithPattern diff --git a/qa/spec/page/logging_spec.rb b/qa/spec/page/logging_spec.rb index 054332eea29..93a08108787 100644 --- a/qa/spec/page/logging_spec.rb +++ b/qa/spec/page/logging_spec.rb @@ -72,41 +72,47 @@ RSpec.describe QA::Support::Page::Logging do end it 'logs has_element?' do - expect { subject.has_element?(:element) } - .to output(/has_element\? :element \(wait: #{QA::Runtime::Browser::CAPYBARA_MAX_WAIT_TIME}\) returned: true/o).to_stdout_from_any_process + expect { subject.has_element?(:element) }.to output( + /has_element\? :element \(wait: #{Capybara.default_max_wait_time}\) returned: true/o + ).to_stdout_from_any_process end it 'logs has_element? with text' do - expect { subject.has_element?(:element, text: "some text") } - .to output(/has_element\? :element with text "some text" \(wait: #{QA::Runtime::Browser::CAPYBARA_MAX_WAIT_TIME}\) returned: true/o).to_stdout_from_any_process + expect { subject.has_element?(:element, text: "some text") }.to output( + /has_element\? :element with text "some text" \(wait: #{Capybara.default_max_wait_time}\) returned: true/o + ).to_stdout_from_any_process end it 'logs has_no_element?' do allow(page).to receive(:has_no_css?).and_return(true) - expect { subject.has_no_element?(:element) } - .to output(/has_no_element\? :element \(wait: #{QA::Runtime::Browser::CAPYBARA_MAX_WAIT_TIME}\) returned: true/o).to_stdout_from_any_process + expect { subject.has_no_element?(:element) }.to output( + /has_no_element\? :element \(wait: #{Capybara.default_max_wait_time}\) returned: true/o + ).to_stdout_from_any_process end it 'logs has_no_element? with text' do allow(page).to receive(:has_no_css?).and_return(true) - expect { subject.has_no_element?(:element, text: "more text") } - .to output(/has_no_element\? :element with text "more text" \(wait: #{QA::Runtime::Browser::CAPYBARA_MAX_WAIT_TIME}\) returned: true/o).to_stdout_from_any_process + expect { subject.has_no_element?(:element, text: "more text") }.to output( + /has_no_element\? :element with text "more text" \(wait: #{Capybara.default_max_wait_time}\) returned: true/o + ).to_stdout_from_any_process end it 'logs has_text?' do allow(page).to receive(:has_text?).and_return(true) - expect { subject.has_text? 'foo' } - .to output(/has_text\?\('foo', wait: #{QA::Runtime::Browser::CAPYBARA_MAX_WAIT_TIME}\) returned true/o).to_stdout_from_any_process + expect { subject.has_text? 'foo' }.to output( + /has_text\?\('foo', wait: #{Capybara.default_max_wait_time}\) returned true/o + ).to_stdout_from_any_process end it 'logs has_no_text?' do allow(page).to receive(:has_no_text?).with('foo', any_args).and_return(true) - expect { subject.has_no_text? 'foo' } - .to output(/has_no_text\?\('foo', wait: #{QA::Runtime::Browser::CAPYBARA_MAX_WAIT_TIME}\) returned true/o).to_stdout_from_any_process + expect { subject.has_no_text? 'foo' }.to output( + /has_no_text\?\('foo', wait: #{Capybara.default_max_wait_time}\) returned true/o + ).to_stdout_from_any_process end it 'logs finished_loading?' do @@ -123,7 +129,7 @@ RSpec.describe QA::Support::Page::Logging do .to output(/end within element :element/).to_stdout_from_any_process end - context 'all_elements' do + context 'with all_elements' do it 'logs the number of elements found' do allow(page).to receive(:all).and_return([1, 2]) |