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

42 lines
1.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'spec_helper'
2016-12-19 15:26:10 +00:00
RSpec.describe 'Issue markdown toolbar', :js do
let(:project) { create(:project, :public) }
2016-12-19 15:26:10 +00:00
let(:issue) { create(:issue, project: project) }
let(:user) { create(:user) }
2016-12-19 15:26:10 +00:00
before do
sign_in(user)
2016-12-19 15:26:10 +00:00
visit project_issue_path(project, issue)
2016-12-19 15:26:10 +00:00
end
it "doesn't include first new line when adding bold" do
find('#note-body').native.send_keys('test')
find('#note-body').native.send_key(:enter)
find('#note-body').native.send_keys('bold')
2016-12-19 15:26:10 +00:00
find('.js-main-target-form #note-body')
page.evaluate_script('document.querySelectorAll(".js-main-target-form #note-body")[0].setSelectionRange(4, 9)')
2016-12-19 15:26:10 +00:00
first('.toolbar-btn').click
expect(find('#note-body')[:value]).to eq("test\n**bold**\n")
2016-12-19 15:26:10 +00:00
end
it "doesn't include first new line when adding underline" do
find('#note-body').native.send_keys('test')
find('#note-body').native.send_key(:enter)
find('#note-body').native.send_keys('underline')
2016-12-19 15:26:10 +00:00
find('.js-main-target-form #note-body')
page.evaluate_script('document.querySelectorAll(".js-main-target-form #note-body")[0].setSelectionRange(4, 50)')
2016-12-19 15:26:10 +00:00
all('.toolbar-btn')[1].click
2016-12-19 15:26:10 +00:00
expect(find('#note-body')[:value]).to eq("test\n*underline*\n")
2016-12-19 15:26:10 +00:00
end
end