gitlab-org--gitlab-foss/spec/features/issues/markdown_toolbar_spec.rb

38 lines
1.2 KiB
Ruby
Raw Normal View History

2016-12-19 10:26:10 -05:00
require 'rails_helper'
feature 'Issue markdown toolbar', feature: true, js: true do
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project) }
let(:user) { create(:user) }
before do
login_as(user)
visit namespace_project_issue_path(project.namespace, project, issue)
end
it "doesn't include first new line when adding bold" do
find('#note_note').native.send_keys('test')
find('#note_note').native.send_key(:enter)
find('#note_note').native.send_keys('bold')
2017-01-06 05:02:16 -05:00
page.evaluate_script('document.querySelectorAll(".js-main-target-form #note_note")[0].setSelectionRange(4, 9)')
2016-12-19 10:26:10 -05:00
first('.toolbar-btn').click
expect(find('#note_note')[:value]).to eq("test\n**bold**\n")
end
it "doesn't include first new line when adding underline" do
find('#note_note').native.send_keys('test')
find('#note_note').native.send_key(:enter)
find('#note_note').native.send_keys('underline')
2017-01-06 05:02:16 -05:00
page.evaluate_script('document.querySelectorAll(".js-main-target-form #note_note")[0].setSelectionRange(4, 50)')
2016-12-19 10:26:10 -05:00
find('.toolbar-btn:nth-child(2)').click
expect(find('#note_note')[:value]).to eq("test\n*underline*\n")
end
end