chore: Sync pre-chat fields after custom attribute update (#4692)

This commit is contained in:
Muhsin Keloth
2022-06-20 14:16:49 +05:30
committed by GitHub
parent 6c6df8661b
commit a8c6cd729b
4 changed files with 57 additions and 1 deletions

View File

@@ -15,7 +15,7 @@ RSpec.describe Inboxes::SyncWidgetPreChatCustomFieldsJob, type: :job do
end
context 'when called' do
it 'reopens snoozed conversations whose snooze until has passed' do
it 'sync pre chat fields if custom attribute deleted' do
described_class.perform_now(account, 'developer_id')
expect(web_widget.reload.pre_chat_form_options['pre_chat_fields']).to eq [{
'label' => 'Full Name',

View File

@@ -0,0 +1,30 @@
require 'rails_helper'
RSpec.describe Inboxes::UpdateWidgetPreChatCustomFieldsJob, type: :job do
pre_chat_fields = [{
'label' => 'Developer Id',
'name' => 'developer_id'
}, {
'label' => 'Full Name',
'name' => 'full_name'
}]
pre_chat_message = 'Share your queries here.'
custom_attribute = {
'attribute_key' => 'developer_id',
'attribute_display_name' => 'Developer Number'
}
let!(:account) { create(:account) }
let!(:web_widget) do
create(:channel_widget, account: account, pre_chat_form_options: { pre_chat_message: pre_chat_message, pre_chat_fields: pre_chat_fields })
end
context 'when called' do
it 'sync pre chat fields if custom attribute updated' do
described_class.perform_now(account, custom_attribute)
expect(web_widget.reload.pre_chat_form_options['pre_chat_fields']).to eq [
{ 'label' => 'Developer Number', 'name' => 'developer_id', 'placeholder' => 'Developer Number',
'values' => nil }, { 'label' => 'Full Name', 'name' => 'full_name' }
]
end
end
end