Maintenance: Improve RSpec 'text modules group dependency examples'
This commit is contained in:
parent
fae194918e
commit
77d0b2d5c9
2 changed files with 12 additions and 19 deletions
|
@ -19,3 +19,7 @@ end
|
||||||
Capybara.add_selector(:richtext) do
|
Capybara.add_selector(:richtext) do
|
||||||
css { |name| "div[data-name=#{name || 'body'}]" }
|
css { |name| "div[data-name=#{name || 'body'}]" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Capybara.add_selector(:text_module) do
|
||||||
|
css { |id| %(.shortcut > ul > li[data-id="#{id}"]) }
|
||||||
|
end
|
||||||
|
|
|
@ -22,30 +22,19 @@ RSpec.shared_examples 'group-dependent text modules' do |path:|
|
||||||
visit path
|
visit path
|
||||||
|
|
||||||
within(:active_content) do
|
within(:active_content) do
|
||||||
|
find('select[name="group_id"]').select(group1.name)
|
||||||
selector_group_select = 'select[name="group_id"]'
|
|
||||||
selector_text_module_selection = '.shortcut'
|
|
||||||
selector_text_module_item = ".shortcut > ul > li[data-id='%s']"
|
|
||||||
|
|
||||||
# exercise
|
|
||||||
find(selector_group_select).find(:option, group1.name).select_option
|
|
||||||
find(:richtext).send_keys('::')
|
find(:richtext).send_keys('::')
|
||||||
|
|
||||||
# expectations
|
expect(page).to have_selector(:text_module, text_module_without_group.id)
|
||||||
expect(page).to have_css(selector_text_module_selection, wait: 3)
|
expect(page).to have_selector(:text_module, text_module_group1.id)
|
||||||
expect(page).to have_css(format(selector_text_module_item, text_module_without_group.id))
|
expect(page).to have_no_selector(:text_module, text_module_group2.id)
|
||||||
expect(page).to have_css(format(selector_text_module_item, text_module_group1.id))
|
|
||||||
expect(page).to have_no_css(format(selector_text_module_item, text_module_group2.id))
|
|
||||||
|
|
||||||
# exercise
|
find('select[name="group_id"]').select(group2.name)
|
||||||
find(selector_group_select).find(:option, group2.name).select_option
|
|
||||||
find(:richtext).send_keys('::')
|
find(:richtext).send_keys('::')
|
||||||
|
|
||||||
# expectations
|
expect(page).to have_selector(:text_module, text_module_without_group.id)
|
||||||
expect(page).to have_css(selector_text_module_selection, wait: 3)
|
expect(page).to have_no_selector(:text_module, text_module_group1.id)
|
||||||
expect(page).to have_css(format(selector_text_module_item, text_module_without_group.id))
|
expect(page).to have_selector(:text_module, text_module_group2.id)
|
||||||
expect(page).to have_no_css(format(selector_text_module_item, text_module_group1.id))
|
|
||||||
expect(page).to have_css(format(selector_text_module_item, text_module_group2.id))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue