summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
Diffstat (limited to 'qa')
-rw-r--r--qa/qa/page/base.rb4
-rw-r--r--qa/qa/page/validator.rb10
-rw-r--r--qa/qa/scenario/test/sanity/selectors.rb11
-rw-r--r--qa/spec/page/base_spec.rb25
-rw-r--r--qa/spec/page/validator_spec.rb8
5 files changed, 40 insertions, 18 deletions
diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb
index 9064c78b792..ba1323eb215 100644
--- a/qa/qa/page/base.rb
+++ b/qa/qa/page/base.rb
@@ -49,6 +49,10 @@ module QA
end
def self.errors
+ if views.empty?
+ return ["#{name} class does not have views / elements defined!"]
+ end
+
@errors ||= views.map(&:errors).flatten
end
diff --git a/qa/qa/page/validator.rb b/qa/qa/page/validator.rb
index cf4e57db0f0..88d083f5d97 100644
--- a/qa/qa/page/validator.rb
+++ b/qa/qa/page/validator.rb
@@ -31,8 +31,8 @@ module QA
@errors ||= Array.new.tap do |errors|
descendants.each do |page|
page.views.each do |view|
- view.errors.each do |error|
- errors.push(Error.new(page, view, error))
+ view.errors.each do |message|
+ errors.push(Error.new(page.name, view.path, message))
end
end
end
@@ -40,11 +40,9 @@ module QA
end
def validate!
- message = <<~EOS
- We found validation errors!
- EOS
+ return if errors.none?
- raise ValidationError, message if errors.any?
+ raise ValidationError, 'Page views / elements validation error!'
end
end
end
diff --git a/qa/qa/scenario/test/sanity/selectors.rb b/qa/qa/scenario/test/sanity/selectors.rb
index 892bb2966c7..c6ede07680a 100644
--- a/qa/qa/scenario/test/sanity/selectors.rb
+++ b/qa/qa/scenario/test/sanity/selectors.rb
@@ -5,7 +5,18 @@ module QA
class Selectors < Scenario::Template
include Scenario::Bootable
+ PAGE_MODULES = [QA::Page]
+
def perform(*)
+ validators = PAGE_MODULES.map do |pages|
+ Page::Validator.new(pages)
+ end
+
+ validators.map(&:errors).flatten.tap do |errors|
+
+ end
+
+ validators.each(&:validate!)
end
end
end
diff --git a/qa/spec/page/base_spec.rb b/qa/spec/page/base_spec.rb
index 63445d8f7bf..29b62cf758c 100644
--- a/qa/spec/page/base_spec.rb
+++ b/qa/spec/page/base_spec.rb
@@ -36,15 +36,28 @@ describe QA::Page::Base do
describe '.errors' do
let(:view) { double('view') }
- before do
- allow(described_class).to receive(:views)
- .and_return([view])
+ context 'when page has views and elements defined' do
+ before do
+ allow(described_class).to receive(:views)
+ .and_return([view])
- allow(view).to receive(:errors).and_return(['some error'])
+ allow(view).to receive(:errors).and_return(['some error'])
+ end
+
+ it 'iterates views composite and returns errors' do
+ expect(described_class.errors).to eq ['some error']
+ end
end
- it 'iterates views composite and returns errors' do
- expect(described_class.errors).to eq ['some error']
+ context 'when page has no views and elements defined' do
+ before do
+ allow(described_class).to receive(:views).and_return([])
+ end
+
+ it 'appends an error about missing views / elements block' do
+ expect(described_class.errors)
+ .to include 'QA::Page::Base class does not have views / elements defined!'
+ end
end
end
end
diff --git a/qa/spec/page/validator_spec.rb b/qa/spec/page/validator_spec.rb
index abee137f4a1..e13fb1eae5b 100644
--- a/qa/spec/page/validator_spec.rb
+++ b/qa/spec/page/validator_spec.rb
@@ -69,13 +69,9 @@ describe QA::Page::Validator do
end
describe '#validate!' do
- it 'does raises an error with descriptive message' do
- message = <<~EOS
- We found validation errors!
- EOS
-
+ it 'raises validation error' do
expect { subject.validate! }
- .to raise_error described_class::ValidationError, message
+ .to raise_error described_class::ValidationError
end
end
end