Newer
Older
require 'spec_helper'
describe 'On a merge request', js: true, feature: true do
let!(:merge_request) { create(:merge_request) }
let!(:project) { merge_request.source_project }
let!(:note) do
create(:note_on_merge_request, :with_attachment, project: project)
end
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
is_expected.to have_css('.js-main-target-form', visible: true, count: 1)
expect(find('.js-main-target-form input[type=submit]').value).
to eq('Add Comment')
within('.js-main-target-form') do
expect(page).not_to have_link('Cancel')
end
within('.js-main-target-form') do
fill_in 'note[note]', with: 'This is awesome'
end
end
it 'should have enable submit button and preview button' do
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)
within('.js-main-target-form') do
fill_in 'note[note]', with: 'This is awsome!'
is_expected.to have_content('This is awsome!')
within('.js-main-target-form') do
expect(page).to have_no_field('note[note]', with: 'This is awesome!')
expect(page).to have_css('.js-md-preview', visible: :hidden)
within('.js-main-target-form') do
is_expected.to have_css('.js-note-text', visible: true)
end
describe 'when editing a note', js: true do
it 'should contain the hidden edit form' do
within("#note_#{note.id}") do
is_expected.to have_css('.note-edit-form', visible: false)
end
before do
find('.note').hover
find(".js-note-edit").click
it 'should show the note edit form and hide the note body' do
expect(find('.current-note-edit-form', visible: true)).to be_visible
expect(find('.note-edit-form', visible: true)).to be_visible
Douwe Maan
committed
expect(find(:css, '.note-body > .note-text', visible: false)).not_to be_visible
# TODO: fix after 7.7 release
#it "should reset 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
#expect(find(".js-note-text", visible: false).text).to eq note.note
#end
#end
it 'appends the edited at time to the note' do
within('.current-note-edit-form') do
fill_in 'note[note]', with: 'Some new content'
find('.btn-save').click
is_expected.to have_css('.note_edited_ago')
expect(find('.note_edited_ago').text).
to match(/less than a minute ago/)
it 'shows the delete link' do
within('.note-attachment') do
is_expected.to have_css('.js-note-attachment-delete')
it 'removes the attachment div and resets the edit form' do
find('.js-note-attachment-delete').click
is_expected.not_to have_css('.note-attachment')
expect(find('.current-note-edit-form', visible: false)).
not_to be_visible
describe 'On a merge request diff', js: true, feature: true do
let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.source_project }
visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request)
describe 'the notes holder' do
it { is_expected.to have_css('.js-temp-notes-holder') }
it 'has .new_note css class' do
within('.js-temp-notes-holder') do
expect(subject).to have_css('.new_note')
end
end
is_expected.
to have_css("tr[id='#{line_code}'] + .js-temp-notes-holder form",
count: 1)
find('.js-close-discussion-note-form').trigger('click')
is_expected.to have_no_css('.js-temp-notes-holder')
end
end
end
click_diff_line
click_diff_line(line_code_2)
it { is_expected.to have_css('.js-temp-notes-holder', count: 2) }
before do
# add two separate texts and trigger previews on both
within("tr[id='#{line_code}'] + .js-temp-notes-holder") do
fill_in 'note[note]', with: 'One comment on line 7'
end
within("tr[id='#{line_code_2}'] + .js-temp-notes-holder") do
fill_in 'note[note]', with: 'Another comment on line 10'
before do
within("tr[id='#{line_code_2}'] + .js-temp-notes-holder") do
fill_in 'note[note]', with: 'Another comment on line 10'
click_button('Add Comment')
end
end
it 'should be added as discussion' do
is_expected.to have_content('Another comment on line 10')
is_expected.to have_css('.notes_holder')
is_expected.to have_css('.notes_holder .note', count: 1)
is_expected.to have_button('Reply')
def line_code
sample_compare.changes.first[:line_code]
end
def line_code_2
sample_compare.changes.last[:line_code]
end
def click_diff_line(data = nil)
data ||= line_code
find("button[data-line-code=\"#{data}\"]").click
end