2017-08-01 14:03:07 -04:00
|
|
|
require 'rails_helper'
|
2017-04-12 11:02:53 -04:00
|
|
|
|
2017-08-01 14:03:07 -04:00
|
|
|
describe 'Merge request > User posts notes', :js do
|
2017-06-07 14:33:50 -04:00
|
|
|
include NoteInteractionHelpers
|
|
|
|
|
2017-07-26 17:52:10 -04:00
|
|
|
let(:project) { create(:project, :repository) }
|
2017-08-01 14:03:07 -04:00
|
|
|
let(:user) { project.creator }
|
2017-04-12 11:02:53 -04:00
|
|
|
let(:merge_request) do
|
|
|
|
create(:merge_request, source_project: project, target_project: project)
|
|
|
|
end
|
|
|
|
let!(:note) do
|
|
|
|
create(:note_on_merge_request, :with_attachment, noteable: merge_request,
|
|
|
|
project: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2017-08-01 14:03:07 -04:00
|
|
|
sign_in(user)
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2017-04-12 11:02:53 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
subject { page }
|
|
|
|
|
|
|
|
describe 'the note form' do
|
|
|
|
it 'is valid' do
|
|
|
|
is_expected.to have_css('.js-main-target-form', visible: true, count: 1)
|
2018-06-21 08:22:40 -04:00
|
|
|
expect(find('.js-main-target-form')).to have_selector('button', text: 'Comment')
|
2017-04-12 11:02:53 -04:00
|
|
|
page.within('.js-main-target-form') do
|
2018-06-21 08:22:40 -04:00
|
|
|
expect(page).not_to have_button('Cancel')
|
2017-04-12 11:02:53 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'with text' do
|
|
|
|
before do
|
|
|
|
page.within('.js-main-target-form') do
|
|
|
|
fill_in 'note[note]', with: 'This is awesome'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has enable submit button and preview button' do
|
|
|
|
page.within('.js-main-target-form') do
|
|
|
|
expect(page).not_to have_css('.js-comment-button[disabled]')
|
|
|
|
expect(page).to have_css('.js-md-preview-button', visible: true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'when posting a note' do
|
|
|
|
before do
|
|
|
|
page.within('.js-main-target-form') do
|
|
|
|
fill_in 'note[note]', with: 'This is awesome!'
|
|
|
|
find('.js-md-preview-button').click
|
|
|
|
click_button 'Comment'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is added and form reset' do
|
|
|
|
is_expected.to have_content('This is awesome!')
|
|
|
|
page.within('.js-main-target-form') do
|
|
|
|
expect(page).to have_no_field('note[note]', with: 'This is awesome!')
|
2018-06-21 08:22:40 -04:00
|
|
|
expect(page).to have_css('.js-vue-md-preview', visible: :hidden)
|
2017-04-12 11:02:53 -04:00
|
|
|
end
|
2018-06-21 08:22:40 -04:00
|
|
|
wait_for_requests
|
2017-04-12 11:02:53 -04:00
|
|
|
page.within('.js-main-target-form') do
|
|
|
|
is_expected.to have_css('.js-note-text', visible: true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-12-20 14:29:44 -05:00
|
|
|
describe 'when previewing a note' do
|
|
|
|
it 'shows the toolbar buttons when editing a note' do
|
|
|
|
page.within('.js-main-target-form') do
|
|
|
|
expect(page).to have_css('.md-header-toolbar.active')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'hides the toolbar buttons when previewing a note' do
|
2018-06-21 08:22:40 -04:00
|
|
|
wait_for_requests
|
2017-12-20 14:29:44 -05:00
|
|
|
find('.js-md-preview-button').click
|
|
|
|
page.within('.js-main-target-form') do
|
|
|
|
expect(page).not_to have_css('.md-header-toolbar.active')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-04-12 11:02:53 -04:00
|
|
|
describe 'when editing a note' do
|
|
|
|
describe 'editing the note' do
|
|
|
|
before do
|
|
|
|
find('.note').hover
|
2017-06-07 14:33:50 -04:00
|
|
|
|
2017-04-12 11:02:53 -04:00
|
|
|
find('.js-note-edit').click
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the note edit form and hide the note body' do
|
|
|
|
page.within("#note_#{note.id}") do
|
|
|
|
expect(find('.current-note-edit-form', visible: true)).to be_visible
|
|
|
|
expect(find('.note-edit-form', visible: true)).to be_visible
|
|
|
|
expect(find(:css, '.note-body > .note-text', visible: false)).not_to be_visible
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'resets the edit note form textarea with the original content of the note if cancelled' do
|
|
|
|
within('.current-note-edit-form') do
|
|
|
|
fill_in 'note[note]', with: 'Some new content'
|
|
|
|
find('.btn-cancel').click
|
|
|
|
end
|
2018-06-21 08:22:40 -04:00
|
|
|
expect(find('.js-note-text').text).to eq ''
|
2017-04-12 11:02:53 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows using markdown buttons after saving a note and then trying to edit it again' do
|
|
|
|
page.within('.current-note-edit-form') do
|
|
|
|
fill_in 'note[note]', with: 'This is the new content'
|
|
|
|
find('.btn-save').click
|
|
|
|
end
|
|
|
|
|
|
|
|
find('.note').hover
|
2018-06-21 08:22:40 -04:00
|
|
|
wait_for_requests
|
2017-06-07 14:33:50 -04:00
|
|
|
|
2017-04-12 11:02:53 -04:00
|
|
|
find('.js-note-edit').click
|
|
|
|
|
|
|
|
page.within('.current-note-edit-form') do
|
|
|
|
expect(find('#note_note').value).to eq('This is the new content')
|
|
|
|
find('.js-md:first-child').click
|
|
|
|
expect(find('#note_note').value).to eq('This is the new content****')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'appends the edited at time to the note' do
|
|
|
|
page.within('.current-note-edit-form') do
|
|
|
|
fill_in 'note[note]', with: 'Some new content'
|
|
|
|
find('.btn-save').click
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within("#note_#{note.id}") do
|
|
|
|
is_expected.to have_css('.note_edited_ago')
|
2017-06-21 09:48:12 -04:00
|
|
|
expect(find('.note_edited_ago').text)
|
2018-06-03 10:45:26 -04:00
|
|
|
.to match(/just now/)
|
2017-04-12 11:02:53 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-27 19:10:43 -05:00
|
|
|
describe 'deleting attachment on legacy diff note' do
|
2017-04-12 11:02:53 -04:00
|
|
|
before do
|
|
|
|
find('.note').hover
|
2017-06-07 14:33:50 -04:00
|
|
|
|
2017-04-12 11:02:53 -04:00
|
|
|
find('.js-note-edit').click
|
|
|
|
end
|
|
|
|
|
2018-06-21 08:22:40 -04:00
|
|
|
# TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034
|
|
|
|
xit 'shows the delete link' do
|
2017-04-12 11:02:53 -04:00
|
|
|
page.within('.note-attachment') do
|
|
|
|
is_expected.to have_css('.js-note-attachment-delete')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-06-21 08:22:40 -04:00
|
|
|
# TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034
|
|
|
|
xit 'removes the attachment div and resets the edit form' do
|
2017-09-27 08:46:48 -04:00
|
|
|
accept_confirm { find('.js-note-attachment-delete').click }
|
2017-04-12 11:02:53 -04:00
|
|
|
is_expected.not_to have_css('.note-attachment')
|
|
|
|
is_expected.not_to have_css('.current-note-edit-form')
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-04-12 11:02:53 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|