2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-11-21 11:11:45 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Blob shortcuts', :js do
|
2017-11-21 11:11:45 -05:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :public, :repository) }
|
|
|
|
let(:issue) { create(:issue, project: project, author: user) }
|
|
|
|
let(:merge_request) { create(:merge_request, source_project: project) }
|
|
|
|
let(:note_text) { 'I got this!' }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
2018-06-21 08:22:40 -04:00
|
|
|
shared_examples "quotes the selected text" do
|
2022-03-23 11:08:38 -04:00
|
|
|
it 'quotes the selected text in main comment form', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/356388' do
|
|
|
|
select_element('#notes-list .note:first-child .note-text')
|
2018-06-21 08:22:40 -04:00
|
|
|
find('body').native.send_key('r')
|
|
|
|
|
|
|
|
expect(find('.js-main-target-form .js-vue-comment-form').value).to include(note_text)
|
|
|
|
end
|
2022-03-23 11:08:38 -04:00
|
|
|
|
|
|
|
it 'quotes the selected text in the discussion reply form', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/356388' do
|
|
|
|
find('#notes-list .note:first-child .js-reply-button').click
|
|
|
|
select_element('#notes-list .note:first-child .note-text')
|
|
|
|
find('body').native.send_key('r')
|
|
|
|
|
|
|
|
expect(find('#notes-list .note:first-child .js-vue-markdown-field .js-gfm-input').value).to include(note_text)
|
|
|
|
end
|
2018-06-21 08:22:40 -04:00
|
|
|
end
|
|
|
|
|
2017-11-21 11:11:45 -05:00
|
|
|
describe 'pressing "r"' do
|
|
|
|
describe 'On an Issue' do
|
|
|
|
before do
|
|
|
|
create(:note, noteable: issue, project: project, note: note_text)
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
2018-06-21 08:22:40 -04:00
|
|
|
include_examples 'quotes the selected text'
|
2017-11-21 11:11:45 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'On a Merge Request' do
|
|
|
|
before do
|
|
|
|
create(:note, noteable: merge_request, project: project, note: note_text)
|
|
|
|
visit project_merge_request_path(project, merge_request)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
2018-06-21 08:22:40 -04:00
|
|
|
include_examples 'quotes the selected text'
|
2017-11-21 11:11:45 -05:00
|
|
|
end
|
|
|
|
end
|
2021-12-09 19:13:05 -05:00
|
|
|
|
|
|
|
shared_examples "opens assignee dropdown for editing" do
|
|
|
|
it "opens assignee dropdown for editing" do
|
|
|
|
find('body').native.send_key('a')
|
|
|
|
|
|
|
|
expect(find('.block.assignee')).to have_selector('.js-sidebar-assignee-data')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'pressing "a"' do
|
|
|
|
describe 'On an Issue' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(issue_assignees_widget: false)
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'opens assignee dropdown for editing'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'On a Merge Request' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(issue_assignees_widget: false)
|
|
|
|
visit project_merge_request_path(project, merge_request)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'opens assignee dropdown for editing'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples "opens milestones dropdown for editing" do
|
|
|
|
it "opens milestones dropdown for editing" do
|
|
|
|
find('body').native.send_key('m')
|
|
|
|
|
|
|
|
expect(find('[data-testid="milestone-edit"]')).to have_selector('.gl-new-dropdown-inner')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'pressing "m"' do
|
|
|
|
describe 'On an Issue' do
|
|
|
|
before do
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'opens milestones dropdown for editing'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'On a Merge Request' do
|
|
|
|
before do
|
|
|
|
visit project_merge_request_path(project, merge_request)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'opens milestones dropdown for editing'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples "opens labels dropdown for editing" do
|
|
|
|
it "opens labels dropdown for editing" do
|
|
|
|
find('body').native.send_key('l')
|
|
|
|
|
|
|
|
expect(find('.js-labels-block')).to have_selector('[data-testid="labels-select-dropdown-contents"]')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'pressing "l"' do
|
|
|
|
describe 'On an Issue' do
|
|
|
|
before do
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'opens labels dropdown for editing'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'On a Merge Request' do
|
|
|
|
before do
|
|
|
|
visit project_merge_request_path(project, merge_request)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'opens labels dropdown for editing'
|
|
|
|
end
|
|
|
|
end
|
2017-11-21 11:11:45 -05:00
|
|
|
end
|