|
|
|
@ -29,31 +29,29 @@ |
|
|
|
|
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, '../../..') } |
|
|
|
|
end |
|
|
|
|
shared_context 'Toggable fieldset examples' do |
|
|
|
|
def toggable_title |
|
|
|
|
find('legend a span', text: fieldset_name) |
|
|
|
|
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) } |
|
|
|
|
def toggable_content |
|
|
|
|
link = toggable_title.find(:xpath, '..') |
|
|
|
|
link.find('span.hidden-for-sighted', visible: false) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it { expect(toggle_state_label).not_to be_nil } |
|
|
|
|
end |
|
|
|
|
shared_context 'find toggle label' do |
|
|
|
|
it { expect(toggable_content).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 { legend_text.click } |
|
|
|
|
before { toggable_title.click } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'expanded fieldset' |
|
|
|
|
end |
|
|
|
@ -63,31 +61,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 { legend_text.click } |
|
|
|
|
before { toggable_title.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(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 |
|
|
|
|
|
|
|
|
|
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(toggable_content.text(:all)).to include(I18n.t('js.label_expanded')) } |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
shared_context 'collapsed CSS' do |
|
|
|
@ -96,15 +89,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(fieldset[: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' |
|
|
|
|
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 |