Reduce duplication in QA page elements-related code
This commit is contained in:
parent
65615776eb
commit
7725a7071d
|
@ -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
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
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'/) }
|
||||
|
||||
|
|
Loading…
Reference in New Issue