2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
require 'spec_helper'
|
2016-12-19 10:26:10 -05:00
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Issue markdown toolbar', :js do
|
2021-03-18 11:09:04 -04:00
|
|
|
let_it_be(:project) { create(:project, :public) }
|
|
|
|
let_it_be(:issue) { create(:issue, project: project) }
|
|
|
|
let_it_be(: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
|
2021-03-18 11:09:04 -04:00
|
|
|
fill_in 'Comment', with: "test\nbold"
|
2016-12-19 10:26:10 -05:00
|
|
|
|
2021-03-18 11:09:04 -04:00
|
|
|
page.evaluate_script('document.getElementById("note-body").setSelectionRange(4, 9)')
|
2016-12-19 10:26:10 -05:00
|
|
|
|
2021-03-18 11:09:04 -04:00
|
|
|
click_button 'Add bold text'
|
2016-12-19 10:26:10 -05:00
|
|
|
|
2021-03-18 11:09:04 -04:00
|
|
|
expect(find_field('Comment').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
|
2021-03-18 11:09:04 -04:00
|
|
|
fill_in 'Comment', with: "test\nunderline"
|
2016-12-19 10:26:10 -05:00
|
|
|
|
2021-03-18 11:09:04 -04:00
|
|
|
page.evaluate_script('document.getElementById("note-body").setSelectionRange(4, 50)')
|
2016-12-19 10:26:10 -05:00
|
|
|
|
2021-03-18 11:09:04 -04:00
|
|
|
click_button 'Add italic text'
|
2016-12-19 10:26:10 -05:00
|
|
|
|
2021-03-18 11:09:04 -04:00
|
|
|
expect(find_field('Comment').value).to eq("test\n_underline_\n")
|
2016-12-19 10:26:10 -05:00
|
|
|
end
|
|
|
|
end
|