Fixes #3825 - Reply all: Duplicate email on changing recipient and cc in a certain way

This commit is contained in:
Mantas Masalskis 2021-11-12 14:35:39 +01:00
parent 939ffa445b
commit 6a6b19b4e6
2 changed files with 34 additions and 0 deletions

View file

@ -654,6 +654,11 @@
var tokensBefore = this.getTokensList()
this.setTokens( this.$input.val(), true )
// remove token text was cleared while editing
if (this.$input.data( 'edit' ) && !this.$input.val()) {
this.$element.val( this.getTokensList() )
}
if (tokensBefore == this.getTokensList() && this.$input.val().length)
return false // No tokens were added, do nothing (prevent form submit)

View file

@ -833,4 +833,33 @@ RSpec.describe 'Ticket Create', type: :system do
expect(page.all('select[name=owner_id] option').count).to eq(1)
end
end
# https://github.com/zammad/zammad/issues/3825
describe 'CC token field' do
before do
visit 'ticket/create'
find('[data-type=email-out]').click
end
it 'can be cleared by cutting out text' do
add_email 'asd@example.com'
add_email 'def@example.com'
find('.token', text: 'def@example.com').double_click
meta_key = Gem::Platform.local.os == 'darwin' ? :command : :control
send_keys([meta_key, 'x'])
find('.token').click # trigger blur
expect(find('[name="cc"]', visible: :all).value).to eq 'asd@example.com'
end
def add_email(input)
fill_in 'Cc', with: input
send_keys(:enter) # trigger blur
find '.token', text: input # wait for email to tokenize
end
end
end