2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-19 10:26:10 -05:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'Issue markdown toolbar', :js do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, :public) }
|
2016-12-19 10:26:10 -05:00
|
|
|
let(:issue) { create(:issue, project: project) }
|
2017-07-26 17:49:06 -04:00
|
|
|
let(:user) { create(:user) }
|
2016-12-19 10:26:10 -05:00
|
|
|
|
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2016-12-19 10:26:10 -05:00
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_issue_path(project, issue)
|
2016-12-19 10:26:10 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't include first new line when adding bold" do
|
2017-07-20 13:16:13 -04:00
|
|
|
find('#note-body').native.send_keys('test')
|
|
|
|
find('#note-body').native.send_key(:enter)
|
|
|
|
find('#note-body').native.send_keys('bold')
|
2016-12-19 10:26:10 -05:00
|
|
|
|
2017-10-16 13:37:52 -04:00
|
|
|
find('.js-main-target-form #note-body')
|
2017-07-20 13:16:13 -04:00
|
|
|
page.evaluate_script('document.querySelectorAll(".js-main-target-form #note-body")[0].setSelectionRange(4, 9)')
|
2016-12-19 10:26:10 -05:00
|
|
|
|
|
|
|
first('.toolbar-btn').click
|
|
|
|
|
2017-07-20 13:16:13 -04:00
|
|
|
expect(find('#note-body')[:value]).to eq("test\n**bold**\n")
|
2016-12-19 10:26:10 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't include first new line when adding underline" do
|
2017-07-20 13:16:13 -04:00
|
|
|
find('#note-body').native.send_keys('test')
|
|
|
|
find('#note-body').native.send_key(:enter)
|
|
|
|
find('#note-body').native.send_keys('underline')
|
2016-12-19 10:26:10 -05:00
|
|
|
|
2017-10-16 13:37:52 -04:00
|
|
|
find('.js-main-target-form #note-body')
|
2017-07-20 13:16:13 -04:00
|
|
|
page.evaluate_script('document.querySelectorAll(".js-main-target-form #note-body")[0].setSelectionRange(4, 50)')
|
2016-12-19 10:26:10 -05:00
|
|
|
|
2019-06-14 09:01:24 -04:00
|
|
|
all('.toolbar-btn')[1].click
|
2016-12-19 10:26:10 -05:00
|
|
|
|
2017-07-20 13:16:13 -04:00
|
|
|
expect(find('#note-body')[:value]).to eq("test\n*underline*\n")
|
2016-12-19 10:26:10 -05:00
|
|
|
end
|
|
|
|
end
|