2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-08-18 07:49:45 +00:00
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'Ticket > Update > Email Reply', current_user_id: -> { current_user.id }, type: :system, time_zone: 'Europe/London' do
|
|
|
|
let(:group) { Group.find_by(name: 'Users') }
|
|
|
|
let(:ticket) { create(:ticket, group: group) }
|
|
|
|
let(:ticket_article) { create(:ticket_article, ticket: ticket, from: 'Example Name <asdf1@example.com>') }
|
|
|
|
let(:customer) { create(:customer) }
|
|
|
|
let(:current_user) { customer }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit "ticket/zoom/#{ticket_article.ticket.id}"
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when TO field is being edited' do
|
|
|
|
|
|
|
|
it 'shows error dialog when updated value is an invalid email' do
|
|
|
|
within(:active_content) do
|
2021-10-28 09:33:02 +00:00
|
|
|
click_email_reply
|
2021-08-18 07:49:45 +00:00
|
|
|
|
|
|
|
find('.token').double_click
|
|
|
|
find('.js-to', visible: false).sibling('.token-input').set('test')
|
|
|
|
find('.js-textarea').set('welcome to the community')
|
|
|
|
find('.js-submitDropdown button.js-submit').click
|
|
|
|
|
2022-01-18 12:52:57 +00:00
|
|
|
expect(page).to have_text 'Need recipient in "TO" or "CC".'
|
2021-08-18 07:49:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates article when updated value is a valid email' do
|
|
|
|
within(:active_content) do
|
2021-10-28 09:33:02 +00:00
|
|
|
click_email_reply
|
2021-08-18 07:49:45 +00:00
|
|
|
|
|
|
|
find('.token').double_click
|
|
|
|
find('.js-to', visible: false).sibling('.token-input').set('user@test.com')
|
|
|
|
find('.js-textarea').set('welcome to the community')
|
|
|
|
find('.js-submitDropdown button.js-submit').click
|
|
|
|
|
|
|
|
expect(page).to have_text 'welcome to the community'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2021-10-28 09:33:02 +00:00
|
|
|
context 'when a new recipient is added in email reply' do
|
|
|
|
it 'shows both name and email in token' do
|
|
|
|
click_email_reply
|
|
|
|
|
|
|
|
find('.js-to', visible: false).sibling('.token-input').set(customer.email)
|
|
|
|
find('ul.ui-autocomplete li:first-child', visible: false).click
|
|
|
|
|
|
|
|
within all('.token-label')[1] do
|
|
|
|
expect(page).to have_text("#{customer.firstname} #{customer.lastname} <#{customer.email}>")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def click_email_reply
|
2021-08-18 07:49:45 +00:00
|
|
|
click '.js-ArticleAction[data-type=emailReply]'
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|