summaryrefslogtreecommitdiff
path: root/qa/spec
diff options
context:
space:
mode:
authorddavison <ddavison@gitlab.com>2019-08-27 13:32:09 -0700
committerddavison <ddavison@gitlab.com>2019-08-27 13:32:09 -0700
commitb4c289fcfef2d57d24a8f2f7d8cc4875f0a4860d (patch)
tree979482ab517d06de370898ab22bdb6ec6c209ab0 /qa/spec
parentde385eee8507a35f1c01ca784ba9aab9bc38e11d (diff)
downloadgitlab-ce-qa-extensible-data-qa-selectors.tar.gz
Add extensible data-qa-* selection mechanismsqa-extensible-data-qa-selectors
Primarily this will prevent the necessity to match on text. By providing this mechanism, we add the ability to match on dynamic content
Diffstat (limited to 'qa/spec')
-rw-r--r--qa/spec/page/element_spec.rb15
1 files changed, 15 insertions, 0 deletions
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