From 0ec8259d63f696f648134134a3be7c7378742f08 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Wed, 7 May 2014 12:01:50 +0200 Subject: [PATCH 1/9] Update capybara to 2.2.1 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5cec0bc45a..db3cb1b6b5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -72,7 +72,7 @@ GEM byebug (2.7.0) columnize (~> 0.3) debugger-linecache (~> 1.2) - capybara (2.1.0) + capybara (2.2.1) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) From f56e5db58c56a0a424d7200b7e9ad649366a3e23 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Thu, 8 May 2014 14:02:49 +0200 Subject: [PATCH 2/9] Rename support file --- .../{toggable_fieldsets_spec.rb => toggable_fieldsets.rb} | 0 .../accessibility/work_packages/index_toggable_fieldsets_spec.rb | 1 + 2 files changed, 1 insertion(+) rename spec/features/accessibility/support/{toggable_fieldsets_spec.rb => toggable_fieldsets.rb} (100%) diff --git a/spec/features/accessibility/support/toggable_fieldsets_spec.rb b/spec/features/accessibility/support/toggable_fieldsets.rb similarity index 100% rename from spec/features/accessibility/support/toggable_fieldsets_spec.rb rename to spec/features/accessibility/support/toggable_fieldsets.rb diff --git a/spec/features/accessibility/work_packages/index_toggable_fieldsets_spec.rb b/spec/features/accessibility/work_packages/index_toggable_fieldsets_spec.rb index 51a7ef043c..2ea77a1f59 100644 --- a/spec/features/accessibility/work_packages/index_toggable_fieldsets_spec.rb +++ b/spec/features/accessibility/work_packages/index_toggable_fieldsets_spec.rb @@ -27,6 +27,7 @@ #++ require 'spec_helper' +require 'features/accessibility/support/toggable_fieldsets' require 'features/work_packages/work_packages_page' describe 'Work package index' do From 5266ea26bb53ef78ae51359fb273fb607427590c Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Thu, 8 May 2014 14:03:10 +0200 Subject: [PATCH 3/9] Don't use let for find expressions --- .../support/toggable_fieldsets.rb | 20 +++++++++---------- .../work_packages/work_package_query_spec.rb | 9 ++++----- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/spec/features/accessibility/support/toggable_fieldsets.rb b/spec/features/accessibility/support/toggable_fieldsets.rb index e90dffe793..636af1aadc 100644 --- a/spec/features/accessibility/support/toggable_fieldsets.rb +++ b/spec/features/accessibility/support/toggable_fieldsets.rb @@ -30,15 +30,13 @@ require 'spec_helper' require 'features/work_packages/work_packages_page' shared_context 'find legend with text' do - let(:legend_text) { find('legend a span', text: fieldset_name) } - let(:fieldset) { legend_text.find(:xpath, '../../..') } + let(:fieldset) { } end shared_context 'find toggle label' do - let(:link) { legend_text.find(:xpath, '..') } - let(:toggle_state_label) { link.find("span.hidden-for-sighted", visible: false) } + let(:link) { find('legend a span', text: fieldset_name).find(:xpath, '..') } - it { expect(toggle_state_label).not_to be_nil } + it { expect(link.find("span.hidden-for-sighted", visible: false)).not_to be_nil } end shared_context 'Toggable fieldset examples' do @@ -53,7 +51,7 @@ shared_context 'Toggable fieldset examples' do describe 'after click' do include_context 'find legend with text' - before { legend_text.click } + before { find('legend a span', text: fieldset_name).click } it_behaves_like 'expanded fieldset' end @@ -70,7 +68,7 @@ shared_context 'Toggable fieldset examples' do describe 'after click' do include_context 'find legend with text' - before { legend_text.click } + before { find('legend a span', text: fieldset_name).click } it_behaves_like 'collapsed fieldset' end @@ -80,14 +78,14 @@ shared_context 'Toggable fieldset examples' do include_context 'find legend with text' include_context 'find toggle label' - it { expect(toggle_state_label.text(:all)).to include(I18n.t('js.label_collapsed')) } + it { expect(link.find("span.hidden-for-sighted", visible: false).text(:all)).to include(I18n.t('js.label_collapsed')) } end shared_examples_for 'toggle state set expanded' do include_context 'find legend with text' include_context 'find toggle label' - it { expect(toggle_state_label.text(:all)).to include(I18n.t('js.label_expanded')) } + it { expect(link.find("span.hidden-for-sighted", visible: false).text(:all)).to include(I18n.t('js.label_expanded')) } end shared_context 'collapsed CSS' do @@ -98,13 +96,13 @@ shared_context 'Toggable fieldset examples' do include_context 'collapsed CSS' include_context 'find legend with text' - it { expect(fieldset[:class]).to include(collapsed_class_name) } + it { expect(find('legend a span', text: fieldset_name).find(:xpath, '../../..')[:class]).to include(collapsed_class_name) } end shared_examples_for 'expanded fieldset' do include_context 'collapsed CSS' include_context 'find legend with text' - it { expect(fieldset[:class]).not_to include(collapsed_class_name) } + it { expect(find('legend a span', text: fieldset_name).find(:xpath, '../../..')[:class]).not_to include(collapsed_class_name) } end end diff --git a/spec/features/accessibility/work_packages/work_package_query_spec.rb b/spec/features/accessibility/work_packages/work_package_query_spec.rb index 5965768aa3..8568b6216d 100644 --- a/spec/features/accessibility/work_packages/work_package_query_spec.rb +++ b/spec/features/accessibility/work_packages/work_package_query_spec.rb @@ -43,15 +43,14 @@ describe 'Work package index accessibility' do end describe 'Select all link' do - let(:select_all_link) { find('table.list.issues th.checkbox a') } - let(:description_for_blind) { select_all_link.find(:xpath, 'span/span[@class="hidden-for-sighted"]') } + #let(:description_for_blind) { find('table.list.issues th.checkbox a').find(:xpath, 'span/span[@class="hidden-for-sighted"]') } describe 'Initial state', js: true do - it { expect(select_all_link).not_to be_nil } + it { expect(find('table.list.issues th.checkbox a')).not_to be_nil } - it { expect(select_all_link[:title]).to eq(I18n.t(:button_check_all)) } + it { expect(find('table.list.issues th.checkbox a')[:title]).to eq(I18n.t(:button_check_all)) } - it { expect(select_all_link[:alt]).to eq(I18n.t(:button_check_all)) } + it { expect(find('table.list.issues th.checkbox a')[:alt]).to eq(I18n.t(:button_check_all)) } # TODO: This test is failing because of what seems to be a bug in selenium. # The hidden-for-sighted elements cannot be found using because they are styled with From 9cd1d592b84725c135dddf7d57e77bc60dde29a6 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Thu, 8 May 2014 16:02:22 +0200 Subject: [PATCH 4/9] Refactor toggable support spec --- .../support/toggable_fieldsets.rb | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/spec/features/accessibility/support/toggable_fieldsets.rb b/spec/features/accessibility/support/toggable_fieldsets.rb index 636af1aadc..afc578e551 100644 --- a/spec/features/accessibility/support/toggable_fieldsets.rb +++ b/spec/features/accessibility/support/toggable_fieldsets.rb @@ -29,29 +29,25 @@ require 'spec_helper' require 'features/work_packages/work_packages_page' -shared_context 'find legend with text' do - let(:fieldset) { } -end +shared_context 'Toggable fieldset examples' do + let(:toggable_title_selector) { 'legend a span' } + let(:toggable_content_selector) { 'span.hidden-for-sighted' } -shared_context 'find toggle label' do - let(:link) { find('legend a span', text: fieldset_name).find(:xpath, '..') } + shared_context 'find toggle label' do + let(:link) { find(toggable_title_selector, text: fieldset_name).find(:xpath, '..') } - it { expect(link.find("span.hidden-for-sighted", visible: false)).not_to be_nil } -end + it { expect(link.find(toggable_content_selector, visible: false)).not_to be_nil } + end -shared_context 'Toggable fieldset examples' do shared_examples_for 'toggable fieldset initially collapsed' do it_behaves_like 'collapsed fieldset' describe 'initial state' do - include_context 'find legend with text' it_behaves_like 'toggle state set collapsed' end describe 'after click' do - include_context 'find legend with text' - - before { find('legend a span', text: fieldset_name).click } + before { find(toggable_title_selector, text: fieldset_name).click } it_behaves_like 'expanded fieldset' end @@ -61,31 +57,26 @@ shared_context 'Toggable fieldset examples' do it_behaves_like 'expanded fieldset' describe 'initial state' do - include_context 'find legend with text' it_behaves_like 'toggle state set expanded' end describe 'after click' do - include_context 'find legend with text' - - before { find('legend a span', text: fieldset_name).click } + before { find(toggable_title_selector, text: fieldset_name).click } it_behaves_like 'collapsed fieldset' end end shared_examples_for 'toggle state set collapsed' do - include_context 'find legend with text' include_context 'find toggle label' - it { expect(link.find("span.hidden-for-sighted", visible: false).text(:all)).to include(I18n.t('js.label_collapsed')) } + it { expect(link.find(toggable_content_selector, visible: false).text(:all)).to include(I18n.t('js.label_collapsed')) } end shared_examples_for 'toggle state set expanded' do - include_context 'find legend with text' include_context 'find toggle label' - it { expect(link.find("span.hidden-for-sighted", visible: false).text(:all)).to include(I18n.t('js.label_expanded')) } + it { expect(link.find(toggable_content_selector, visible: false).text(:all)).to include(I18n.t('js.label_expanded')) } end shared_context 'collapsed CSS' do @@ -94,15 +85,13 @@ shared_context 'Toggable fieldset examples' do shared_examples_for 'collapsed fieldset' do include_context 'collapsed CSS' - include_context 'find legend with text' - it { expect(find('legend a span', text: fieldset_name).find(:xpath, '../../..')[:class]).to include(collapsed_class_name) } + it { expect(find(toggable_title_selector, text: fieldset_name).find(:xpath, '../../..')[:class]).to include(collapsed_class_name) } end shared_examples_for 'expanded fieldset' do include_context 'collapsed CSS' - include_context 'find legend with text' - it { expect(find('legend a span', text: fieldset_name).find(:xpath, '../../..')[:class]).not_to include(collapsed_class_name) } + it { expect(find(toggable_title_selector, text: fieldset_name).find(:xpath, '../../..')[:class]).not_to include(collapsed_class_name) } end end From ea67e95499d517b70ddacfc099362a9b7acc0519 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Thu, 8 May 2014 16:17:32 +0200 Subject: [PATCH 5/9] Refactor select all link specs --- .../accessibility/work_packages/work_package_query_spec.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/features/accessibility/work_packages/work_package_query_spec.rb b/spec/features/accessibility/work_packages/work_package_query_spec.rb index 8568b6216d..5b97c5154d 100644 --- a/spec/features/accessibility/work_packages/work_package_query_spec.rb +++ b/spec/features/accessibility/work_packages/work_package_query_spec.rb @@ -43,14 +43,15 @@ describe 'Work package index accessibility' do end describe 'Select all link' do + let(:select_all_checkbox_selector) { 'table.list.issues th.checkbox a' } #let(:description_for_blind) { find('table.list.issues th.checkbox a').find(:xpath, 'span/span[@class="hidden-for-sighted"]') } describe 'Initial state', js: true do - it { expect(find('table.list.issues th.checkbox a')).not_to be_nil } + it { expect(find(select_all_checkbox_selector)).not_to be_nil } - it { expect(find('table.list.issues th.checkbox a')[:title]).to eq(I18n.t(:button_check_all)) } + it { expect(find(select_all_checkbox_selector)[:title]).to eq(I18n.t(:button_check_all)) } - it { expect(find('table.list.issues th.checkbox a')[:alt]).to eq(I18n.t(:button_check_all)) } + it { expect(find(select_all_checkbox_selector)[:alt]).to eq(I18n.t(:button_check_all)) } # TODO: This test is failing because of what seems to be a bug in selenium. # The hidden-for-sighted elements cannot be found using because they are styled with From 753e8848f7c05c614baf59972ae32b96d73e951b Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Fri, 9 May 2014 11:50:49 +0200 Subject: [PATCH 6/9] Expect sort header before accessing the title --- .../accessibility/work_packages/work_package_query_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/features/accessibility/work_packages/work_package_query_spec.rb b/spec/features/accessibility/work_packages/work_package_query_spec.rb index 5b97c5154d..595750381c 100644 --- a/spec/features/accessibility/work_packages/work_package_query_spec.rb +++ b/spec/features/accessibility/work_packages/work_package_query_spec.rb @@ -67,7 +67,10 @@ describe 'Work package index accessibility' do describe 'Sort link', js: true do shared_examples_for 'sort column' do - it { expect(find(sort_header_selector).find("span")[:title]).to eq(sort_text) } + it do + expect(find(sort_header_selector)).not_to be_nil + expect(find(sort_header_selector).find("span")[:title]).to eq(sort_text) + end end shared_examples_for 'unsorted column' do From c7a28c569ce3858e37537c3e83a5149a6ff593e0 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Mon, 12 May 2014 13:36:10 +0200 Subject: [PATCH 7/9] Make commented spec a pending one --- .../work_packages/work_package_query_spec.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/spec/features/accessibility/work_packages/work_package_query_spec.rb b/spec/features/accessibility/work_packages/work_package_query_spec.rb index 595750381c..870ee6f5b6 100644 --- a/spec/features/accessibility/work_packages/work_package_query_spec.rb +++ b/spec/features/accessibility/work_packages/work_package_query_spec.rb @@ -44,7 +44,7 @@ describe 'Work package index accessibility' do describe 'Select all link' do let(:select_all_checkbox_selector) { 'table.list.issues th.checkbox a' } - #let(:description_for_blind) { find('table.list.issues th.checkbox a').find(:xpath, 'span/span[@class="hidden-for-sighted"]') } + let(:checkbox_link) { 'table.list.issues th.checkbox a' } describe 'Initial state', js: true do it { expect(find(select_all_checkbox_selector)).not_to be_nil } @@ -53,11 +53,14 @@ describe 'Work package index accessibility' do it { expect(find(select_all_checkbox_selector)[:alt]).to eq(I18n.t(:button_check_all)) } - # TODO: This test is failing because of what seems to be a bug in selenium. - # The hidden-for-sighted elements cannot be found using because they are styled with - # absolute positioning and have an x index off the side of the page. If you remove - # the x coord then it will find them but that doesn't seem like a satisfactory solution. - # it { expect(description_for_blind.text).to eq(I18n.t(:button_check_all)) } + it do + pending("This test is failing because of what seems to be a bug in selenium. " \ + "The hidden-for-sighted elements cannot be found using because they are styled with " \ + "absolute positioning and have an x index off the side of the page. If you remove " \ + "the x coord then it will find them but that doesn't seem like a satisfactory solution.") + expect(find(checkbox_link)).not_to be_nil + expect(find(checkbox_link).find(:xpath, 'span/span[@class="hidden-for-sighted"]').text).to eq(I18n.t(:button_check_all)) + end end describe 'Change state', js: true do From 57e433c69a8c169af495db6fcd137b1c3b3a907a Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Mon, 12 May 2014 14:30:30 +0200 Subject: [PATCH 8/9] Extract find calls to methods --- .../support/toggable_fieldsets.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/spec/features/accessibility/support/toggable_fieldsets.rb b/spec/features/accessibility/support/toggable_fieldsets.rb index afc578e551..70e2840879 100644 --- a/spec/features/accessibility/support/toggable_fieldsets.rb +++ b/spec/features/accessibility/support/toggable_fieldsets.rb @@ -32,11 +32,13 @@ require 'features/work_packages/work_packages_page' shared_context 'Toggable fieldset examples' do let(:toggable_title_selector) { 'legend a span' } let(:toggable_content_selector) { 'span.hidden-for-sighted' } + let(:find_toggable_title_selector) { lambda { find(toggable_title_selector, text: fieldset_name) } } + let(:find_toggable_content_selector) { lambda { |link| link.find(toggable_content_selector, visible: false) } } shared_context 'find toggle label' do - let(:link) { find(toggable_title_selector, text: fieldset_name).find(:xpath, '..') } + let(:link) { find_toggable_title_selector.call.find(:xpath, '..') } - it { expect(link.find(toggable_content_selector, visible: false)).not_to be_nil } + it { expect(find_toggable_content_selector.call(link)).not_to be_nil } end shared_examples_for 'toggable fieldset initially collapsed' do @@ -47,7 +49,7 @@ shared_context 'Toggable fieldset examples' do end describe 'after click' do - before { find(toggable_title_selector, text: fieldset_name).click } + before { find_toggable_title_selector.call.click } it_behaves_like 'expanded fieldset' end @@ -61,7 +63,7 @@ shared_context 'Toggable fieldset examples' do end describe 'after click' do - before { find(toggable_title_selector, text: fieldset_name).click } + before { find_toggable_title_selector.call.click } it_behaves_like 'collapsed fieldset' end @@ -70,13 +72,13 @@ shared_context 'Toggable fieldset examples' do shared_examples_for 'toggle state set collapsed' do include_context 'find toggle label' - it { expect(link.find(toggable_content_selector, visible: false).text(:all)).to include(I18n.t('js.label_collapsed')) } + it { expect(find_toggable_content_selector.call(link).text(:all)).to include(I18n.t('js.label_collapsed')) } end shared_examples_for 'toggle state set expanded' do include_context 'find toggle label' - it { expect(link.find(toggable_content_selector, visible: false).text(:all)).to include(I18n.t('js.label_expanded')) } + it { expect(find_toggable_content_selector.call(link).text(:all)).to include(I18n.t('js.label_expanded')) } end shared_context 'collapsed CSS' do @@ -86,12 +88,12 @@ shared_context 'Toggable fieldset examples' do shared_examples_for 'collapsed fieldset' do include_context 'collapsed CSS' - it { expect(find(toggable_title_selector, text: fieldset_name).find(:xpath, '../../..')[:class]).to include(collapsed_class_name) } + it { expect(find_toggable_title_selector.call.find(:xpath, '../../..')[:class]).to include(collapsed_class_name) } end shared_examples_for 'expanded fieldset' do include_context 'collapsed CSS' - it { expect(find(toggable_title_selector, text: fieldset_name).find(:xpath, '../../..')[:class]).not_to include(collapsed_class_name) } + it { expect(find_toggable_title_selector.call.find(:xpath, '../../..')[:class]).not_to include(collapsed_class_name) } end end From 86bd08a1f3a4861612167eac7705da2e8310a237 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Mon, 12 May 2014 19:22:33 +0100 Subject: [PATCH 9/9] Use methods instead of let for fresh results. --- .../support/toggable_fieldsets.rb | 28 +++++++------- .../work_packages/work_package_query_spec.rb | 38 ++++++++++++------- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/spec/features/accessibility/support/toggable_fieldsets.rb b/spec/features/accessibility/support/toggable_fieldsets.rb index 70e2840879..9c1a8de291 100644 --- a/spec/features/accessibility/support/toggable_fieldsets.rb +++ b/spec/features/accessibility/support/toggable_fieldsets.rb @@ -30,15 +30,17 @@ require 'spec_helper' require 'features/work_packages/work_packages_page' shared_context 'Toggable fieldset examples' do - let(:toggable_title_selector) { 'legend a span' } - let(:toggable_content_selector) { 'span.hidden-for-sighted' } - let(:find_toggable_title_selector) { lambda { find(toggable_title_selector, text: fieldset_name) } } - let(:find_toggable_content_selector) { lambda { |link| link.find(toggable_content_selector, visible: false) } } + def toggable_title + find('legend a span', text: fieldset_name) + end - shared_context 'find toggle label' do - let(:link) { find_toggable_title_selector.call.find(:xpath, '..') } + def toggable_content + link = toggable_title.find(:xpath, '..') + link.find('span.hidden-for-sighted', visible: false) + end - it { expect(find_toggable_content_selector.call(link)).not_to be_nil } + shared_context 'find toggle label' do + it { expect(toggable_content).not_to be_nil } end shared_examples_for 'toggable fieldset initially collapsed' do @@ -49,7 +51,7 @@ shared_context 'Toggable fieldset examples' do end describe 'after click' do - before { find_toggable_title_selector.call.click } + before { toggable_title.click } it_behaves_like 'expanded fieldset' end @@ -63,7 +65,7 @@ shared_context 'Toggable fieldset examples' do end describe 'after click' do - before { find_toggable_title_selector.call.click } + before { toggable_title.click } it_behaves_like 'collapsed fieldset' end @@ -72,13 +74,13 @@ shared_context 'Toggable fieldset examples' do shared_examples_for 'toggle state set collapsed' do include_context 'find toggle label' - it { expect(find_toggable_content_selector.call(link).text(:all)).to include(I18n.t('js.label_collapsed')) } + it { expect(toggable_content.text(:all)).to include(I18n.t('js.label_collapsed')) } end shared_examples_for 'toggle state set expanded' do include_context 'find toggle label' - it { expect(find_toggable_content_selector.call(link).text(:all)).to include(I18n.t('js.label_expanded')) } + it { expect(toggable_content.text(:all)).to include(I18n.t('js.label_expanded')) } end shared_context 'collapsed CSS' do @@ -88,12 +90,12 @@ shared_context 'Toggable fieldset examples' do shared_examples_for 'collapsed fieldset' do include_context 'collapsed CSS' - it { expect(find_toggable_title_selector.call.find(:xpath, '../../..')[:class]).to include(collapsed_class_name) } + it { expect(toggable_title.find(:xpath, '../../..')[:class]).to include(collapsed_class_name) } end shared_examples_for 'expanded fieldset' do include_context 'collapsed CSS' - it { expect(find_toggable_title_selector.call.find(:xpath, '../../..')[:class]).not_to include(collapsed_class_name) } + it { expect(toggable_title.find(:xpath, '../../..')[:class]).not_to include(collapsed_class_name) } end end diff --git a/spec/features/accessibility/work_packages/work_package_query_spec.rb b/spec/features/accessibility/work_packages/work_package_query_spec.rb index 870ee6f5b6..5dbe663d1c 100644 --- a/spec/features/accessibility/work_packages/work_package_query_spec.rb +++ b/spec/features/accessibility/work_packages/work_package_query_spec.rb @@ -43,23 +43,27 @@ describe 'Work package index accessibility' do end describe 'Select all link' do - let(:select_all_checkbox_selector) { 'table.list.issues th.checkbox a' } - let(:checkbox_link) { 'table.list.issues th.checkbox a' } + def select_all_link + find('table.list.issues th.checkbox a') + end + + def description_for_blind + select_all_link.find(:xpath, 'span/span[@class="hidden-for-sighted"]') + end describe 'Initial state', js: true do - it { expect(find(select_all_checkbox_selector)).not_to be_nil } + it { expect(select_all_link).not_to be_nil } - it { expect(find(select_all_checkbox_selector)[:title]).to eq(I18n.t(:button_check_all)) } + it { expect(select_all_link[:title]).to eq(I18n.t(:button_check_all)) } - it { expect(find(select_all_checkbox_selector)[:alt]).to eq(I18n.t(:button_check_all)) } + it { expect(select_all_link[:alt]).to eq(I18n.t(:button_check_all)) } it do pending("This test is failing because of what seems to be a bug in selenium. " \ "The hidden-for-sighted elements cannot be found using because they are styled with " \ "absolute positioning and have an x index off the side of the page. If you remove " \ "the x coord then it will find them but that doesn't seem like a satisfactory solution.") - expect(find(checkbox_link)).not_to be_nil - expect(find(checkbox_link).find(:xpath, 'span/span[@class="hidden-for-sighted"]').text).to eq(I18n.t(:button_check_all)) + expect(description_for_blind.text).to eq(I18n.t(:button_check_all)) end end @@ -69,10 +73,18 @@ describe 'Work package index accessibility' do end describe 'Sort link', js: true do + def sort_link + find(sort_link_selector) + end + shared_examples_for 'sort column' do + def sort_header + find(sort_header_selector) + end + it do - expect(find(sort_header_selector)).not_to be_nil - expect(find(sort_header_selector).find("span")[:title]).to eq(sort_text) + expect(sort_header).not_to be_nil + expect(sort_header.find("span")[:title]).to eq(sort_text) end end @@ -96,12 +108,12 @@ describe 'Work package index accessibility' do shared_examples_for 'descending sortable first' do describe 'one click' do - before { find(sort_link_selector).click } + before { sort_link.click } it_behaves_like 'descending sorted column' describe 'two clicks' do - before { find(sort_link_selector).click } + before { sort_link.click } it_behaves_like 'ascending sorted column' end @@ -110,12 +122,12 @@ describe 'Work package index accessibility' do shared_examples_for 'ascending sortable first' do describe 'one click' do - before { find(sort_link_selector).click } + before { sort_link.click } it_behaves_like 'ascending sorted column' describe 'two clicks' do - before { find(sort_link_selector).click } + before { sort_link.click } it_behaves_like 'descending sorted column' end