|
|
@ -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 |