2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2020-02-19 11:56:27 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2021-07-22 14:03:33 +00:00
|
|
|
RSpec.describe 'Knowledge Base Locale Answer Edit', type: :system do
|
2020-02-19 11:56:27 +00:00
|
|
|
include_context 'basic Knowledge Base'
|
|
|
|
|
|
|
|
before do
|
|
|
|
published_answer && draft_answer && internal_answer
|
|
|
|
end
|
|
|
|
|
2020-02-19 17:07:52 +00:00
|
|
|
it 'wraps long texts' do
|
2020-02-19 11:56:27 +00:00
|
|
|
long_string = '3KKFA9DAWE9VJYNNnpYRRtMwfa168O1yvpD2t9QXsfb3cppGV6KZ12q0UUJIy5r4Exfk18GnWPR0A3SoDsjxIHz1Gcu4aCEVzenilSOu4gAfxnB6k3mSBUOGIfdgChEBYhcHGgiCmV2EoXu4gG7GAJxKJhM2d4NUiL5RZttGtMXYYFr2Jsg7MV7xXGcygnsLMYqnwzOJxBK0vH3fzhdIZd6YrqR3fggaY0RyKtVigOBZ2SETC8s238Z9eDL4gfUW'
|
|
|
|
|
|
|
|
visit "#knowledge_base/#{knowledge_base.id}/locale/#{primary_locale.system_locale.locale}/answer/#{draft_answer.id}/edit"
|
|
|
|
|
|
|
|
within(:active_content) do
|
|
|
|
find('.richtext-content').send_keys long_string
|
|
|
|
|
|
|
|
expect(page).to have_css('.js-submit') { |elem| !elem.obscured? }
|
|
|
|
expect(page).to have_css('.page-header-title') { |elem| !elem.obscured? }
|
|
|
|
end
|
|
|
|
end
|
2020-02-19 17:07:52 +00:00
|
|
|
|
2021-02-02 05:57:11 +00:00
|
|
|
context 'add weblink' do
|
|
|
|
def open_editor_and_add_link(input)
|
|
|
|
visit "#knowledge_base/#{knowledge_base.id}/locale/#{primary_locale.system_locale.locale}/answer/#{draft_answer.id}/edit"
|
|
|
|
|
|
|
|
sleep 3 # wait for popover killer to pass
|
|
|
|
|
|
|
|
find('a[data-action="link"]').click
|
|
|
|
|
|
|
|
within('.popover-content') do
|
|
|
|
find('input').fill_in with: input
|
|
|
|
find('[type=submit]').click
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows mailto links' do
|
|
|
|
open_editor_and_add_link 'mailto:test@example.com'
|
|
|
|
|
|
|
|
expect(page).to have_selector('a[href="mailto:test@example.com"]')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows link with a protocol' do
|
|
|
|
open_editor_and_add_link 'protocol://example.org'
|
|
|
|
|
|
|
|
expect(page).to have_selector('a[href="protocol://example.org"]')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows relative link' do
|
|
|
|
open_editor_and_add_link '/path'
|
|
|
|
|
|
|
|
expect(page).to have_selector('a[href="/path"]')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows non-protocol URL and prepends default protocol' do
|
|
|
|
open_editor_and_add_link 'example.com'
|
|
|
|
|
|
|
|
expect(page).to have_selector('a[href="http://example.com"]')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-02-19 17:07:52 +00:00
|
|
|
context 'embedded video' do
|
|
|
|
|
|
|
|
it 'has adding functionality' do
|
|
|
|
visit "#knowledge_base/#{knowledge_base.id}/locale/#{primary_locale.system_locale.locale}/answer/#{published_answer.id}/edit"
|
|
|
|
|
|
|
|
sleep 3 # wait for popover killer to pass
|
|
|
|
|
|
|
|
find('a[data-action="embed_video"]').click
|
|
|
|
|
|
|
|
within('.popover-content') do
|
|
|
|
find('input').fill_in with: 'https://www.youtube.com/watch?v=vTTzwJsHpU8'
|
|
|
|
find('[type=submit]').click
|
|
|
|
end
|
|
|
|
|
|
|
|
within('.richtext-content') do
|
|
|
|
expect(page).to have_text('( widget: video, provider: youtube, id: vTTzwJsHpU8 )')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'loads stored' do
|
|
|
|
visit "#knowledge_base/#{knowledge_base.id}/locale/#{primary_locale.system_locale.locale}/answer/#{published_answer_with_video.id}"
|
|
|
|
|
|
|
|
iframe = find('iframe')
|
2020-03-06 08:27:42 +00:00
|
|
|
expect(iframe['src']).to start_with('https://www.youtube.com/embed/')
|
2020-02-19 17:07:52 +00:00
|
|
|
end
|
|
|
|
end
|
2020-02-19 11:56:27 +00:00
|
|
|
end
|