From b4c289fcfef2d57d24a8f2f7d8cc4875f0a4860d Mon Sep 17 00:00:00 2001 From: ddavison Date: Tue, 27 Aug 2019 13:32:09 -0700 Subject: Add extensible data-qa-* selection mechanisms Primarily this will prevent the necessity to match on text. By providing this mechanism, we add the ability to match on dynamic content --- qa/spec/page/element_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'qa/spec/page') diff --git a/qa/spec/page/element_spec.rb b/qa/spec/page/element_spec.rb index 20d4a00c020..5a61c3ad453 100644 --- a/qa/spec/page/element_spec.rb +++ b/qa/spec/page/element_spec.rb @@ -113,8 +113,23 @@ describe QA::Page::Element do describe 'data-qa selectors' do subject { described_class.new(:my_element) } + it 'properly translates to a data-qa-selector' do expect(subject.selector_css).to include(%q([data-qa-selector="my_element"])) end + + context 'additional selectors' do + let(:element) { described_class.new(:my_element, index: 3) } + let(:required_element) { described_class.new(:my_element, required: true, index: 3) } + + it 'matches on additional data-qa properties' do + expect(element.selector_css).to include(%q([data-qa-selector="my_element"][data-qa-index="3"])) + end + + it 'doesnt conflict with element requirement' do + expect(required_element).to be_required + expect(required_element.selector_css).not_to include(%q(data-qa-required)) + end + end end end -- cgit v1.2.1