Commit 7725a707 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Reduce duplication in QA page elements-related code

parent 65615776
......@@ -41,7 +41,7 @@ module QA
end
def click_element(name)
find("qa-#{name.tr('_', '-')}").click
find(Page::Element.new(name).selector).click
end
def self.path
......
......@@ -5,7 +5,11 @@ module QA
def initialize(name, pattern = nil)
@name = name
@pattern = pattern || "qa-#{@name.to_s.tr('_', '-')}"
@pattern = pattern || selector
end
def selector
"qa-#{@name.to_s.tr('_', '-')}"
end
def expression
......
......@@ -17,7 +17,7 @@ module QA
STDERR.puts <<~EOS
GitLab QA sanity selectors validation test detected problems
your merge request!
with your merge request!
The purpose of this test is to make sure that GitLab QA tests,
that are entirely black-box, click-driven scenarios, do match
......
describe QA::Page::Element do
describe '#selector' do
it 'transform element name into QA-specific selector' do
expect(described_class.new(:sign_in_button).selector)
.to eq 'qa-sign-in-button'
end
end
context 'when pattern is an expression' do
subject { described_class.new(:something, /button 'Sign in'/) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment