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")
|
2016-11-29 14:07:38 -05:00
|
|
|
node = find("#{parent} h#{level} a#user-content-#{id}")
|
2017-04-20 19:27:03 -04:00
|
|
|
expect(node[:href]).to end_with "##{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
|
2017-05-25 06:11:30 -04:00
|
|
|
expect(first('.gfm-form')).to have_link('Write', 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
|
2017-03-24 20:10:57 -04:00
|
|
|
expect(find('.js-md-preview')).to have_css('gl-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
|
2017-05-25 06:11:30 -04:00
|
|
|
page.within(first('.gfm-form')) do
|
2014-10-15 03:21:21 -04:00
|
|
|
fill_in 'Description', with: 'Bug fixed :smile:'
|
2017-05-25 06:11:30 -04:00
|
|
|
click_link 'Preview'
|
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
|