diff --git a/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json b/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json index ebe919be1..c0389e2d9 100644 --- a/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json +++ b/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json @@ -123,7 +123,6 @@ }, "TWILIO": { "TITLE": "Twilio SMS/WhatsApp Channel", - "DESC": "Integrate Twilio and start supporting your customers via SMS or WhatsApp. Chatwoot automatically configures the required callback URLs for you.", "ACCOUNT_SID": { "LABEL": "Account SID", "PLACEHOLDER": "Please enter your Twilio Account SID", diff --git a/spec/controllers/api/v1/accounts/channels/twilio_channels_controller_spec.rb b/spec/controllers/api/v1/accounts/channels/twilio_channels_controller_spec.rb index 8e3e45fed..502687379 100644 --- a/spec/controllers/api/v1/accounts/channels/twilio_channels_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/channels/twilio_channels_controller_spec.rb @@ -38,6 +38,8 @@ RSpec.describe '/api/v1/accounts/{account.id}/channels/twilio_channel', type: :r context 'when user is logged in' do context 'with user as administrator' do it 'creates inbox and returns inbox object' do + expect(Twilio::WebhookSetupService).to receive(:new).and_return(twilio_webhook_setup_service) + expect(twilio_webhook_setup_service).to receive(:perform) allow(twilio_client).to receive(:messages).and_return(message_double) allow(message_double).to receive(:list).and_return([]) @@ -131,6 +133,8 @@ RSpec.describe '/api/v1/accounts/{account.id}/channels/twilio_channel', type: :r end it 'return error if Twilio tokens are incorrect' do + expect(twilio_webhook_setup_service).not_to receive(:perform) + expect(Twilio::WebhookSetupService).not_to receive(:new) allow(twilio_client).to receive(:messages).and_return(message_double) allow(message_double).to receive(:list).and_raise(Twilio::REST::TwilioError) diff --git a/spec/services/twilio/webhook_setup_service_spec.rb b/spec/services/twilio/webhook_setup_service_spec.rb index fbbc11a60..e10bca5cd 100644 --- a/spec/services/twilio/webhook_setup_service_spec.rb +++ b/spec/services/twilio/webhook_setup_service_spec.rb @@ -60,6 +60,26 @@ describe Twilio::WebhookSetupService do sms_url: twilio_callback_index_url ) end + + it 'strips whatsapp prefix before looking up phone number' do + phone_channel = create( + :channel_twilio_sms, + :with_phone_number, + :whatsapp, + phone_number: 'whatsapp:+1234567890', + messaging_service_sid: nil + ) + + allow(twilio_client).to receive(:incoming_phone_numbers).and_return(phone_double) + allow(phone_double).to receive(:list).and_return([phone_record_double]) + allow(phone_record_double).to receive(:sid).and_return('1234') + + described_class.new(inbox: phone_channel.inbox).perform + + expect(phone_double).to have_received(:list).with( + phone_number: '+1234567890' + ) + end end end end