debian-mirror-gitlab/spec/features/issues/markdown_toolbar_spec.rb

42 lines
1.2 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'rails_helper'
2018-11-08 19:23:39 +05:30
describe 'Issue markdown toolbar', :js do
2017-08-17 22:00:37 +05:30
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project) }
2017-09-10 17:25:29 +05:30
let(:user) { create(:user) }
2017-08-17 22:00:37 +05:30
before do
2017-09-10 17:25:29 +05:30
sign_in(user)
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
visit project_issue_path(project, issue)
2017-08-17 22:00:37 +05:30
end
it "doesn't include first new line when adding bold" do
2018-03-17 18:26:18 +05:30
find('#note-body').native.send_keys('test')
find('#note-body').native.send_key(:enter)
find('#note-body').native.send_keys('bold')
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
find('.js-main-target-form #note-body')
page.evaluate_script('document.querySelectorAll(".js-main-target-form #note-body")[0].setSelectionRange(4, 9)')
2017-08-17 22:00:37 +05:30
first('.toolbar-btn').click
2018-03-17 18:26:18 +05:30
expect(find('#note-body')[:value]).to eq("test\n**bold**\n")
2017-08-17 22:00:37 +05:30
end
it "doesn't include first new line when adding underline" do
2018-03-17 18:26:18 +05:30
find('#note-body').native.send_keys('test')
find('#note-body').native.send_key(:enter)
find('#note-body').native.send_keys('underline')
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
find('.js-main-target-form #note-body')
page.evaluate_script('document.querySelectorAll(".js-main-target-form #note-body")[0].setSelectionRange(4, 50)')
2017-08-17 22:00:37 +05:30
2019-09-04 21:01:54 +05:30
all('.toolbar-btn')[1].click
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
expect(find('#note-body')[:value]).to eq("test\n*underline*\n")
2017-08-17 22:00:37 +05:30
end
end