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

170 lines
4.2 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
module SharedNote
include Spinach::DSL
2017-09-10 17:25:29 +05:30
include WaitForRequests
2014-09-02 18:07:02 +05:30
2017-08-17 22:00:37 +05:30
after do
2017-09-10 17:25:29 +05:30
wait_for_requests if javascript_test?
2017-08-17 22:00:37 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I delete a comment' do
2016-06-02 11:05:42 +05:30
page.within('.main-notes-list') do
2017-09-10 17:25:29 +05:30
note = find('.note')
note.hover
find('.more-actions').click
find('.more-actions .dropdown-menu li', match: :first)
2018-03-17 18:26:18 +05:30
accept_confirm { find(".js-note-delete").click }
2015-09-11 14:41:01 +05:30
end
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I haven\'t written any comment text' do
2015-09-11 14:41:01 +05:30
page.within(".js-main-target-form") do
2014-09-02 18:07:02 +05:30
fill_in "note[note]", with: ""
end
end
2015-04-26 12:48:37 +05:30
step 'I leave a comment like "XML attached"' do
2015-09-11 14:41:01 +05:30
page.within(".js-main-target-form") do
2014-09-02 18:07:02 +05:30
fill_in "note[note]", with: "XML attached"
2016-06-02 11:05:42 +05:30
click_button "Comment"
2014-09-02 18:07:02 +05:30
end
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
wait_for_requests
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I preview a comment text like "Bug fixed :smile:"' do
2015-09-11 14:41:01 +05:30
page.within(".js-main-target-form") do
2014-09-02 18:07:02 +05:30
fill_in "note[note]", with: "Bug fixed :smile:"
2015-04-26 12:48:37 +05:30
find('.js-md-preview-button').click
2014-09-02 18:07:02 +05:30
end
end
2015-04-26 12:48:37 +05:30
step 'I submit the comment' do
2015-09-11 14:41:01 +05:30
page.within(".js-main-target-form") do
2016-06-02 11:05:42 +05:30
click_button "Comment"
2014-09-02 18:07:02 +05:30
end
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
wait_for_requests
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I write a comment like ":+1: Nice"' do
2015-09-11 14:41:01 +05:30
page.within(".js-main-target-form") do
2015-04-26 12:48:37 +05:30
fill_in 'note[note]', with: ':+1: Nice'
2014-09-02 18:07:02 +05:30
end
end
2015-04-26 12:48:37 +05:30
step 'I should not see a comment saying "XML attached"' do
2015-09-11 14:41:01 +05:30
expect(page).not_to have_css(".note")
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I should not see the cancel comment button' do
2015-09-11 14:41:01 +05:30
page.within(".js-main-target-form") do
2014-09-02 18:07:02 +05:30
should_not have_link("Cancel")
end
end
2015-04-26 12:48:37 +05:30
step 'I should not see the comment preview' do
2015-09-11 14:41:01 +05:30
page.within(".js-main-target-form") do
2015-04-26 12:48:37 +05:30
expect(find('.js-md-preview')).not_to be_visible
2014-09-02 18:07:02 +05:30
end
end
2015-04-26 12:48:37 +05:30
step 'The comment preview tab should say there is nothing to do' do
2015-09-11 14:41:01 +05:30
page.within(".js-main-target-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.')
2014-09-02 18:07:02 +05:30
end
end
2015-04-26 12:48:37 +05:30
step 'I should not see the comment text field' do
2015-09-11 14:41:01 +05:30
page.within(".js-main-target-form") do
2015-04-26 12:48:37 +05:30
expect(find('.js-note-text')).not_to be_visible
2014-09-02 18:07:02 +05:30
end
end
2015-04-26 12:48:37 +05:30
step 'I should see a comment saying "XML attached"' do
2015-09-11 14:41:01 +05:30
page.within(".note") do
expect(page).to have_content("XML attached")
2014-09-02 18:07:02 +05:30
end
end
2015-04-26 12:48:37 +05:30
step 'I should see an empty comment text field' do
2015-09-11 14:41:01 +05:30
page.within(".js-main-target-form") do
expect(page).to have_field("note[note]", with: "")
2014-09-02 18:07:02 +05:30
end
end
2015-04-26 12:48:37 +05:30
step 'I should see the comment write tab' do
2015-09-11 14:41:01 +05:30
page.within(".js-main-target-form") do
2015-04-26 12:48:37 +05:30
expect(page).to have_css('.js-md-write-button', visible: true)
2014-09-02 18:07:02 +05:30
end
end
2015-04-26 12:48:37 +05:30
step 'The comment preview tab should be display rendered Markdown' do
2015-09-11 14:41:01 +05:30
page.within(".js-main-target-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)
2014-09-02 18:07:02 +05:30
end
end
2015-04-26 12:48:37 +05:30
step 'I should see the comment preview' do
2015-09-11 14:41:01 +05:30
page.within(".js-main-target-form") do
2015-04-26 12:48:37 +05:30
expect(page).to have_css('.js-md-preview', visible: true)
2014-09-02 18:07:02 +05:30
end
end
2015-04-26 12:48:37 +05:30
step 'I should see comment "XML attached"' do
2015-09-11 14:41:01 +05:30
page.within(".note") do
expect(page).to have_content("XML attached")
2014-09-02 18:07:02 +05:30
end
end
step 'I should see no notes at all' do
expect(page).not_to have_css('.note')
end
2014-09-02 18:07:02 +05:30
# Markdown
step 'I leave a comment with a header containing "Comment with a header"' do
2015-09-11 14:41:01 +05:30
page.within(".js-main-target-form") do
2014-09-02 18:07:02 +05:30
fill_in "note[note]", with: "# Comment with a header"
2016-06-02 11:05:42 +05:30
click_button "Comment"
2014-09-02 18:07:02 +05:30
end
2016-11-03 12:29:30 +05:30
2017-09-10 17:25:29 +05:30
wait_for_requests
2014-09-02 18:07:02 +05:30
end
step 'The comment with the header should not have an ID' do
2015-09-11 14:41:01 +05:30
page.within(".note-body > .note-text") do
2018-03-17 18:26:18 +05:30
expect(page).to have_content("Comment with a header")
2015-09-11 14:41:01 +05:30
expect(page).not_to have_css("#comment-with-a-header")
2015-04-26 12:48:37 +05:30
end
end
step 'I edit the last comment with a +1' do
2016-06-02 11:05:42 +05:30
page.within(".main-notes-list") do
2017-09-10 17:25:29 +05:30
note = find('.note')
note.hover
note.find('.js-note-edit').click
2015-09-11 14:41:01 +05:30
end
2015-04-26 12:48:37 +05:30
2018-03-17 18:26:18 +05:30
page.find('.current-note-edit-form textarea')
2015-09-11 14:41:01 +05:30
page.within(".current-note-edit-form") do
2015-04-26 12:48:37 +05:30
fill_in 'note[note]', with: '+1 Awesome!'
2017-08-17 22:00:37 +05:30
click_button 'Save comment'
2015-04-26 12:48:37 +05:30
end
2018-03-17 18:26:18 +05:30
wait_for_requests
2015-04-26 12:48:37 +05:30
end
step 'I should see +1 in the description' do
2015-09-11 14:41:01 +05:30
page.within(".note") do
expect(page).to have_content("+1 Awesome!")
2015-04-26 12:48:37 +05:30
end
2018-03-17 18:26:18 +05:30
wait_for_requests
2015-04-26 12:48:37 +05:30
end
2014-09-02 18:07:02 +05:30
end