1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Issue markdown toolbar', :js, feature_category: :text_editors do
let_it_be(:project) { create(:project, :public) }
let_it_be(:issue) { create(:issue, project: project) }
let_it_be(:user) { create(:user) }
before do
sign_in(user)
visit project_issue_path(project, issue)
end
it "doesn't include first new line when adding bold" do
fill_in 'Comment', with: "test\nbold"
page.evaluate_script('document.getElementById("note-body").setSelectionRange(4, 9)')
click_button 'Add bold text'
expect(find_field('Comment').value).to eq("test\n**bold**\n")
end
it "doesn't include first new line when adding underline" do
fill_in 'Comment', with: "test\nunderline"
page.evaluate_script('document.getElementById("note-body").setSelectionRange(4, 50)')
click_button 'Add italic text'
expect(find_field('Comment').value).to eq("test\n_underline_\n")
end
it "makes sure bold works fine after preview" do
fill_in 'Comment', with: "test"
click_button 'Preview'
click_button 'Continue editing'
page.evaluate_script('document.getElementById("note-body").setSelectionRange(0, 4)')
click_button 'Add bold text'
expect(find_field('Comment').value).to eq("**test**")
end
end
|