Merge pull request #1271 from opf/feature/update_capybara_to_2-2-1

[Feature] 7198 Intermittent database deadlock in Work package Capybara spec
pull/1275/merge
Alex Coles 11 years ago
commit f72683f990
  1. 2
      Gemfile.lock
  2. 43
      spec/features/accessibility/support/toggable_fieldsets.rb
  3. 1
      spec/features/accessibility/work_packages/index_toggable_fieldsets_spec.rb
  4. 42
      spec/features/accessibility/work_packages/work_package_query_spec.rb

@ -72,7 +72,7 @@ GEM
byebug (2.7.0) byebug (2.7.0)
columnize (~> 0.3) columnize (~> 0.3)
debugger-linecache (~> 1.2) debugger-linecache (~> 1.2)
capybara (2.1.0) capybara (2.2.1)
mime-types (>= 1.16) mime-types (>= 1.16)
nokogiri (>= 1.3.3) nokogiri (>= 1.3.3)
rack (>= 1.0.0) rack (>= 1.0.0)

@ -29,31 +29,29 @@
require 'spec_helper' require 'spec_helper'
require 'features/work_packages/work_packages_page' require 'features/work_packages/work_packages_page'
shared_context 'find legend with text' do shared_context 'Toggable fieldset examples' do
let(:legend_text) { find('legend a span', text: fieldset_name) } def toggable_title
let(:fieldset) { legend_text.find(:xpath, '../../..') } find('legend a span', text: fieldset_name)
end end
shared_context 'find toggle label' do def toggable_content
let(:link) { legend_text.find(:xpath, '..') } link = toggable_title.find(:xpath, '..')
let(:toggle_state_label) { link.find("span.hidden-for-sighted", visible: false) } link.find('span.hidden-for-sighted', visible: false)
end
it { expect(toggle_state_label).not_to be_nil } shared_context 'find toggle label' do
end it { expect(toggable_content).not_to be_nil }
end
shared_context 'Toggable fieldset examples' do
shared_examples_for 'toggable fieldset initially collapsed' do shared_examples_for 'toggable fieldset initially collapsed' do
it_behaves_like 'collapsed fieldset' it_behaves_like 'collapsed fieldset'
describe 'initial state' do describe 'initial state' do
include_context 'find legend with text'
it_behaves_like 'toggle state set collapsed' it_behaves_like 'toggle state set collapsed'
end end
describe 'after click' do describe 'after click' do
include_context 'find legend with text' before { toggable_title.click }
before { legend_text.click }
it_behaves_like 'expanded fieldset' it_behaves_like 'expanded fieldset'
end end
@ -63,31 +61,26 @@ shared_context 'Toggable fieldset examples' do
it_behaves_like 'expanded fieldset' it_behaves_like 'expanded fieldset'
describe 'initial state' do describe 'initial state' do
include_context 'find legend with text'
it_behaves_like 'toggle state set expanded' it_behaves_like 'toggle state set expanded'
end end
describe 'after click' do describe 'after click' do
include_context 'find legend with text' before { toggable_title.click }
before { legend_text.click }
it_behaves_like 'collapsed fieldset' it_behaves_like 'collapsed fieldset'
end end
end end
shared_examples_for 'toggle state set collapsed' do shared_examples_for 'toggle state set collapsed' do
include_context 'find legend with text'
include_context 'find toggle label' include_context 'find toggle label'
it { expect(toggle_state_label.text(:all)).to include(I18n.t('js.label_collapsed')) } it { expect(toggable_content.text(:all)).to include(I18n.t('js.label_collapsed')) }
end end
shared_examples_for 'toggle state set expanded' do shared_examples_for 'toggle state set expanded' do
include_context 'find legend with text'
include_context 'find toggle label' include_context 'find toggle label'
it { expect(toggle_state_label.text(:all)).to include(I18n.t('js.label_expanded')) } it { expect(toggable_content.text(:all)).to include(I18n.t('js.label_expanded')) }
end end
shared_context 'collapsed CSS' do shared_context 'collapsed CSS' do
@ -96,15 +89,13 @@ shared_context 'Toggable fieldset examples' do
shared_examples_for 'collapsed fieldset' do shared_examples_for 'collapsed fieldset' do
include_context 'collapsed CSS' include_context 'collapsed CSS'
include_context 'find legend with text'
it { expect(fieldset[:class]).to include(collapsed_class_name) } it { expect(toggable_title.find(:xpath, '../../..')[:class]).to include(collapsed_class_name) }
end end
shared_examples_for 'expanded fieldset' do shared_examples_for 'expanded fieldset' do
include_context 'collapsed CSS' include_context 'collapsed CSS'
include_context 'find legend with text'
it { expect(fieldset[:class]).not_to include(collapsed_class_name) } it { expect(toggable_title.find(:xpath, '../../..')[:class]).not_to include(collapsed_class_name) }
end end
end end

@ -27,6 +27,7 @@
#++ #++
require 'spec_helper' require 'spec_helper'
require 'features/accessibility/support/toggable_fieldsets'
require 'features/work_packages/work_packages_page' require 'features/work_packages/work_packages_page'
describe 'Work package index' do describe 'Work package index' do

@ -43,8 +43,13 @@ describe 'Work package index accessibility' do
end end
describe 'Select all link' do describe 'Select all link' do
let(:select_all_link) { find('table.list.issues th.checkbox a') } def select_all_link
let(:description_for_blind) { select_all_link.find(:xpath, 'span/span[@class="hidden-for-sighted"]') } 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 describe 'Initial state', js: true do
it { expect(select_all_link).not_to be_nil } it { expect(select_all_link).not_to be_nil }
@ -53,11 +58,13 @@ describe 'Work package index accessibility' do
it { expect(select_all_link[:alt]).to eq(I18n.t(:button_check_all)) } it { expect(select_all_link[:alt]).to eq(I18n.t(:button_check_all)) }
# TODO: This test is failing because of what seems to be a bug in selenium. it do
# The hidden-for-sighted elements cannot be found using because they are styled with pending("This test is failing because of what seems to be a bug in selenium. " \
# absolute positioning and have an x index off the side of the page. If you remove "The hidden-for-sighted elements cannot be found using because they are styled with " \
# the x coord then it will find them but that doesn't seem like a satisfactory solution. "absolute positioning and have an x index off the side of the page. If you remove " \
# it { expect(description_for_blind.text).to eq(I18n.t(:button_check_all)) } "the x coord then it will find them but that doesn't seem like a satisfactory solution.")
expect(description_for_blind.text).to eq(I18n.t(:button_check_all))
end
end end
describe 'Change state', js: true do describe 'Change state', js: true do
@ -66,8 +73,19 @@ describe 'Work package index accessibility' do
end end
describe 'Sort link', js: true do describe 'Sort link', js: true do
def sort_link
find(sort_link_selector)
end
shared_examples_for 'sort column' do shared_examples_for 'sort column' do
it { expect(find(sort_header_selector).find("span")[:title]).to eq(sort_text) } def sort_header
find(sort_header_selector)
end
it do
expect(sort_header).not_to be_nil
expect(sort_header.find("span")[:title]).to eq(sort_text)
end
end end
shared_examples_for 'unsorted column' do shared_examples_for 'unsorted column' do
@ -90,12 +108,12 @@ describe 'Work package index accessibility' do
shared_examples_for 'descending sortable first' do shared_examples_for 'descending sortable first' do
describe 'one click' do describe 'one click' do
before { find(sort_link_selector).click } before { sort_link.click }
it_behaves_like 'descending sorted column' it_behaves_like 'descending sorted column'
describe 'two clicks' do describe 'two clicks' do
before { find(sort_link_selector).click } before { sort_link.click }
it_behaves_like 'ascending sorted column' it_behaves_like 'ascending sorted column'
end end
@ -104,12 +122,12 @@ describe 'Work package index accessibility' do
shared_examples_for 'ascending sortable first' do shared_examples_for 'ascending sortable first' do
describe 'one click' do describe 'one click' do
before { find(sort_link_selector).click } before { sort_link.click }
it_behaves_like 'ascending sorted column' it_behaves_like 'ascending sorted column'
describe 'two clicks' do describe 'two clicks' do
before { find(sort_link_selector).click } before { sort_link.click }
it_behaves_like 'descending sorted column' it_behaves_like 'descending sorted column'
end end

Loading…
Cancel
Save