2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
require "spec_helper"
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
RSpec.describe "User comments on issue", :js, feature_category: :team_planning do
|
2023-06-20 00:43:36 +05:30
|
|
|
include Features::NotesHelpers
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
let_it_be(:project) { create(:project, :public) }
|
|
|
|
let_it_be(:issue) { create(:issue, project: project) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_guest(user)
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit(project_issue_path(project, issue))
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when adding comments" do
|
|
|
|
it "adds comment" do
|
|
|
|
content = "XML attached"
|
|
|
|
target_form = ".js-main-target-form"
|
|
|
|
|
|
|
|
add_note(content)
|
|
|
|
|
|
|
|
page.within(".note") do
|
|
|
|
expect(page).to have_content(content)
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within(target_form) do
|
|
|
|
find(".error-alert", visible: false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it_behaves_like 'edits content using the content editor'
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
it "adds comment with code block" do
|
2018-11-08 19:23:39 +05:30
|
|
|
code_block_content = "Command [1]: /usr/local/bin/git , see [text](doc/text)"
|
|
|
|
comment = "```\n#{code_block_content}\n```"
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
add_note(comment)
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(page.find('pre code').text).to eq code_block_content
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
2018-11-29 20:51:05 +05:30
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
it 'opens autocomplete menu for quick actions and have `/label` first choice' do
|
|
|
|
project.add_maintainer(user)
|
|
|
|
create(:label, project: project, title: 'label')
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
fill_in 'Comment', with: '/l'
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(find_highlighted_autocomplete_item).to have_content('/label')
|
2019-12-04 20:38:33 +05:30
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context "when editing comments" do
|
|
|
|
it "edits comment" do
|
|
|
|
add_note("# Comment with a header")
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
page.within(".note-body .note-text") do
|
2018-05-09 12:01:36 +05:30
|
|
|
expect(page).to have_content("Comment with a header").and have_no_css("#comment-with-a-header")
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within(".main-notes-list") do
|
|
|
|
note = find(".note")
|
|
|
|
|
|
|
|
note.hover
|
|
|
|
note.find(".js-note-edit").click
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_css(".current-note-edit-form textarea")
|
|
|
|
|
|
|
|
comment = "+1 Awesome!"
|
|
|
|
|
|
|
|
page.within(".current-note-edit-form") do
|
|
|
|
fill_in("note[note]", with: comment)
|
2018-11-08 19:23:39 +05:30
|
|
|
find('textarea').send_keys [:control, :shift, 'p']
|
|
|
|
expect(page).to have_selector('.current-note-edit-form .md-preview-holder')
|
|
|
|
expect(page.find('.current-note-edit-form .md-preview-holder p')).to have_content(comment)
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_selector('.new-note .note-textarea')
|
|
|
|
|
|
|
|
page.within(".current-note-edit-form") do
|
2018-05-09 12:01:36 +05:30
|
|
|
click_button("Save comment")
|
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
page.within(".note") do
|
|
|
|
expect(page).to have_content(comment)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def find_highlighted_autocomplete_item
|
|
|
|
find('.atwho-view li.cur', visible: true)
|
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|