2014-02-04 02:48:33 -05:00
|
|
|
module SharedMarkdown
|
|
|
|
include Spinach::DSL
|
|
|
|
|
|
|
|
def header_should_have_correct_id_and_link(level, text, id, parent = ".wiki")
|
2015-04-28 15:37:04 -04:00
|
|
|
node = find("#{parent} h#{level} a##{id}")
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(node[:href]).to eq "##{id}"
|
2015-04-28 15:37:04 -04:00
|
|
|
|
|
|
|
# Work around a weird Capybara behavior where calling `parent` on a node
|
|
|
|
# returns the whole document, not the node's actual parent element
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(find(:xpath, "#{node.path}/..").text).to eq text
|
2014-02-04 02:48:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'Header "Description header" should have correct id and link' do
|
|
|
|
header_should_have_correct_id_and_link(1, 'Description header', 'description-header')
|
|
|
|
end
|
2014-10-06 02:59:03 -04:00
|
|
|
|
2014-10-15 03:21:21 -04:00
|
|
|
step 'I should not see the Markdown preview' do
|
2014-10-20 22:53:17 -04:00
|
|
|
expect(find('.gfm-form .js-md-preview')).not_to be_visible
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
|
2014-10-17 00:36:52 -04:00
|
|
|
step 'The Markdown preview tab should say there is nothing to do' do
|
2015-06-12 01:36:00 -04:00
|
|
|
page.within('.gfm-form') do
|
2014-10-17 00:36:52 -04:00
|
|
|
find('.js-md-preview-button').click
|
|
|
|
expect(find('.js-md-preview')).to have_content('Nothing to preview.')
|
|
|
|
end
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should not see the Markdown text field' do
|
2014-10-20 22:53:17 -04:00
|
|
|
expect(find('.gfm-form textarea')).not_to be_visible
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
|
2014-10-17 00:36:52 -04:00
|
|
|
step 'I should see the Markdown write tab' do
|
2014-10-20 22:53:17 -04:00
|
|
|
expect(find('.gfm-form')).to have_css('.js-md-write-button', visible: true)
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should see the Markdown preview' do
|
2014-10-20 22:53:17 -04:00
|
|
|
expect(find('.gfm-form')).to have_css('.js-md-preview', visible: true)
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
|
2014-10-17 00:36:52 -04:00
|
|
|
step 'The Markdown preview tab should display rendered Markdown' do
|
2015-06-12 01:36:00 -04:00
|
|
|
page.within('.gfm-form') do
|
2014-10-17 00:36:52 -04:00
|
|
|
find('.js-md-preview-button').click
|
2014-10-20 22:53:17 -04:00
|
|
|
expect(find('.js-md-preview')).to have_css('img.emoji', visible: true)
|
2014-10-17 00:36:52 -04:00
|
|
|
end
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
|
2014-10-17 00:36:52 -04:00
|
|
|
step 'I write a description like ":+1: Nice"' do
|
|
|
|
find('.gfm-form').fill_in 'Description', with: ':+1: Nice'
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I preview a description text like "Bug fixed :smile:"' do
|
2015-06-12 01:36:00 -04:00
|
|
|
page.within('.gfm-form') do
|
2014-10-15 03:21:21 -04:00
|
|
|
fill_in 'Description', with: 'Bug fixed :smile:'
|
2014-10-18 19:24:12 -04:00
|
|
|
find('.js-md-preview-button').click
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I haven\'t written any description text' do
|
|
|
|
find('.gfm-form').fill_in 'Description', with: ''
|
|
|
|
end
|
2014-02-04 02:48:33 -05:00
|
|
|
end
|