diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-09 09:10:17 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-09 09:10:17 +0000 |
commit | ad0265eead72a624ce7a020847db4f0f0c877e57 (patch) | |
tree | 206e0564b02aa9530e3c95f70eb10a77e074bdf0 /qa/spec | |
parent | 4dfc8711171fe0c04bc6b8b224687603026dea46 (diff) | |
download | gitlab-ce-ad0265eead72a624ce7a020847db4f0f0c877e57.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa/spec')
-rw-r--r-- | qa/spec/page/base_spec.rb | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/qa/spec/page/base_spec.rb b/qa/spec/page/base_spec.rb index f6080bcad49..0cbb0a2b12e 100644 --- a/qa/spec/page/base_spec.rb +++ b/qa/spec/page/base_spec.rb @@ -107,4 +107,76 @@ describe QA::Page::Base do end end end + + context 'elements' do + subject do + Class.new(described_class) do + view 'path/to/some/view.html.haml' do + element :something, required: true + element :something_else + end + end + end + + describe '#elements' do + it 'returns all elements' do + expect(subject.elements.size).to eq(2) + end + end + + describe '#required_elements' do + it 'returns only required elements' do + expect(subject.required_elements.size).to eq(1) + end + end + + describe '#visible?', 'Page is currently visible' do + let(:page) { subject.new } + + 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 + + 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) + end + + 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 + subject do + Class.new(described_class) do + view 'path/to/some/view.html.haml' do + element :something + element :something_else + end + end + end + + let(:page) { subject.new } + + it 'raises error if page has no required elements' do + expect { page.visible? }.to raise_error(described_class::NoRequiredElementsError) + end + end + end + end end |