debian-mirror-gitlab/features/steps/shared/markdown.rb

62 lines
2 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
module SharedMarkdown
include Spinach::DSL
def header_should_have_correct_id_and_link(level, text, id, parent = ".wiki")
2017-08-17 22:00:37 +05:30
node = find("#{parent} h#{level} a#user-content-#{id}")
expect(node[:href]).to end_with "##{id}"
2015-04-26 12:48:37 +05:30
2015-09-11 14:41:01 +05:30
# Work around a weird Capybara behavior where calling `parent` on a node
# returns the whole document, not the node's actual parent element
expect(find(:xpath, "#{node.path}/..").text).to eq text
2014-09-02 18:07:02 +05:30
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
2015-04-26 12:48:37 +05:30
step 'I should not see the Markdown preview' do
expect(find('.gfm-form .js-md-preview')).not_to be_visible
end
step 'The Markdown preview tab should say there is nothing to do' do
2015-09-11 14:41:01 +05:30
page.within('.gfm-form') do
2015-04-26 12:48:37 +05:30
find('.js-md-preview-button').click
expect(find('.js-md-preview')).to have_content('Nothing to preview.')
end
end
step 'I should not see the Markdown text field' do
expect(find('.gfm-form textarea')).not_to be_visible
end
step 'I should see the Markdown write tab' do
2017-09-10 17:25:29 +05:30
expect(first('.gfm-form')).to have_link('Write', visible: true)
2015-04-26 12:48:37 +05:30
end
step 'I should see the Markdown preview' do
expect(find('.gfm-form')).to have_css('.js-md-preview', visible: true)
end
step 'The Markdown preview tab should display rendered Markdown' do
2015-09-11 14:41:01 +05:30
page.within('.gfm-form') do
2015-04-26 12:48:37 +05:30
find('.js-md-preview-button').click
2017-08-17 22:00:37 +05:30
expect(find('.js-md-preview')).to have_css('gl-emoji', visible: true)
2015-04-26 12:48:37 +05:30
end
end
step 'I write a description like ":+1: Nice"' do
find('.gfm-form').fill_in 'Description', with: ':+1: Nice'
end
step 'I preview a description text like "Bug fixed :smile:"' do
2017-09-10 17:25:29 +05:30
page.within(first('.gfm-form')) do
2015-04-26 12:48:37 +05:30
fill_in 'Description', with: 'Bug fixed :smile:'
2017-09-10 17:25:29 +05:30
click_link 'Preview'
2015-04-26 12:48:37 +05:30
end
end
step 'I haven\'t written any description text' do
find('.gfm-form').fill_in 'Description', with: ''
end
2014-09-02 18:07:02 +05:30
end