diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-05-03 10:48:01 +0200 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-05-05 15:45:49 +0200 |
commit | e4f7b87ddb4ba83456871eb83b841192b1b56799 (patch) | |
tree | cf79d159784d2c5573acf8a56a8ea09bccaf2d81 /spec/features/snippets | |
parent | 729c006ff82fcb87afe8eb3e6a21254892f43afd (diff) | |
download | gitlab-ce-e4f7b87ddb4ba83456871eb83b841192b1b56799.tar.gz |
Support comments for personal snippets
Diffstat (limited to 'spec/features/snippets')
-rw-r--r-- | spec/features/snippets/notes_on_personal_snippets_spec.rb | 64 |
1 files changed, 62 insertions, 2 deletions
diff --git a/spec/features/snippets/notes_on_personal_snippets_spec.rb b/spec/features/snippets/notes_on_personal_snippets_spec.rb index c646039e0b1..957baac02eb 100644 --- a/spec/features/snippets/notes_on_personal_snippets_spec.rb +++ b/spec/features/snippets/notes_on_personal_snippets_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Comments on personal snippets', feature: true do +describe 'Comments on personal snippets', :js, feature: true do let!(:user) { create(:user) } let!(:snippet) { create(:personal_snippet, :public) } let!(:snippet_notes) do @@ -18,7 +18,7 @@ describe 'Comments on personal snippets', feature: true do subject { page } - context 'viewing the snippet detail page' do + context 'when viewing the snippet detail page' do it 'contains notes for a snippet with correct action icons' do expect(page).to have_selector('#notes-list li', count: 2) @@ -36,4 +36,64 @@ describe 'Comments on personal snippets', feature: true do end end end + + context 'when submitting a note' do + it 'shows a valid form' do + is_expected.to have_css('.js-main-target-form', visible: true, count: 1) + expect(find('.js-main-target-form .js-comment-button').value). + to eq('Comment') + + page.within('.js-main-target-form') do + expect(page).not_to have_link('Cancel') + end + end + + it 'previews a note' do + fill_in 'note[note]', with: 'This is **awesome**!' + find('.js-md-preview-button').click + + page.within('.new-note .md-preview') do + expect(page).to have_content('This is awesome!') + expect(page).to have_selector('strong') + end + end + + it 'creates a note' do + fill_in 'note[note]', with: 'This is **awesome**!' + click_button 'Comment' + + expect(find('div#notes')).to have_content('This is awesome!') + end + end + + context 'when editing a note' do + it 'changes the text' do + page.within("#notes-list li#note_#{snippet_notes[0].id}") do + click_on 'Edit comment' + end + + page.within('.current-note-edit-form') do + fill_in 'note[note]', with: 'new content' + find('.btn-save').click + end + + page.within("#notes-list li#note_#{snippet_notes[0].id}") do + expect(page).to have_css('.note_edited_ago') + expect(page).to have_content('new content') + expect(find('.note_edited_ago').text).to match(/less than a minute ago/) + end + end + end + + context 'when deleting a note' do + it 'removes the note from the snippet detail page' do + page.within("#notes-list li#note_#{snippet_notes[0].id}") do + click_on 'Remove comment' + end + + wait_for_ajax + + expect(page).not_to have_selector("#notes-list li#note_#{snippet_notes[0].id}") + end + end end |