Voice calling is now a capability on the existing TwilioSms rather than a separate Voice model. A single Twilio phone number handles both SMS and voice calls through one inbox. Fixes https://linear.app/chatwoot/issue/CW-6683/add-voice-calling-as-a-capability-on-twilio-sms-channel and https://linear.app/chatwoot/issue/PLA-120/add-the-support-for-sms **What changed** - Replaced Channel::Voice with voice_enabled flag on Channel::TwilioSms - Added voice_enabled, twiml_app_sid, api_key_secret columns to channel_twilio_sms table - Dropped channel_voice table (no production data) - All voice logic lives in Enterprise layer via prepend_mod_with('Channel::TwilioSms') - Added Voice settings tab on Twilio SMS inbox settings to enable/disable voice - Validates Twilio number voice capability before provisioning - Teardown service cleans up TwiML app and credentials when voice is disabled - Frontend voice detection uses isVoiceCallEnabled() / getVoiceCallProvider() helpers — extensible to future providers - Gated by channel_voice feature flag **How to test** 1. Enable feature flag: Account.find(<id>).enable_features('channel_voice') 2. Create voice inbox: Inboxes → Voice tile → enter Twilio credentials → verify incoming/outgoing calls and SMS work 3. Enable voice on existing SMS inbox: Inboxes → select Twilio SMS inbox → Voice tab → toggle on → provide API key credentials → verify calls work 4. Disable voice: Voice tab → toggle off → verify TwiML app is deleted, credentials cleared, SMS still works 5. Re-enable voice: Toggle on again → must provide api_key_secret again → new TwiML app provisioned --------- Co-authored-by: Muhsin <12408980+muhsin-k@users.noreply.github.com>
146 lines
4.7 KiB
JavaScript
146 lines
4.7 KiB
JavaScript
import { useChannelIcon } from '../provider';
|
|
|
|
describe('useChannelIcon', () => {
|
|
it('returns correct icon for API channel', () => {
|
|
const inbox = { channel_type: 'Channel::Api' };
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-api');
|
|
});
|
|
|
|
it('returns correct icon for Facebook channel', () => {
|
|
const inbox = { channel_type: 'Channel::FacebookPage' };
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-messenger');
|
|
});
|
|
|
|
it('returns correct icon for WhatsApp channel', () => {
|
|
const inbox = { channel_type: 'Channel::Whatsapp' };
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-whatsapp');
|
|
});
|
|
|
|
it('returns correct icon for voice-enabled Twilio channel', () => {
|
|
const inbox = {
|
|
channel_type: 'Channel::TwilioSms',
|
|
voice_enabled: true,
|
|
};
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-voice');
|
|
});
|
|
|
|
it('returns correct icon for Line channel', () => {
|
|
const inbox = { channel_type: 'Channel::Line' };
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-line');
|
|
});
|
|
|
|
it('returns correct icon for SMS channel', () => {
|
|
const inbox = { channel_type: 'Channel::Sms' };
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-sms');
|
|
});
|
|
|
|
it('returns correct icon for Telegram channel', () => {
|
|
const inbox = { channel_type: 'Channel::Telegram' };
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-telegram');
|
|
});
|
|
|
|
it('returns correct icon for Twitter channel', () => {
|
|
const inbox = { channel_type: 'Channel::TwitterProfile' };
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-x');
|
|
});
|
|
|
|
it('returns correct icon for WebWidget channel', () => {
|
|
const inbox = { channel_type: 'Channel::WebWidget' };
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-website');
|
|
});
|
|
|
|
it('returns correct icon for Instagram channel', () => {
|
|
const inbox = { channel_type: 'Channel::Instagram' };
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-instagram');
|
|
});
|
|
|
|
it('returns correct icon for TikTok channel', () => {
|
|
const inbox = { channel_type: 'Channel::Tiktok' };
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-tiktok');
|
|
});
|
|
|
|
describe('TwilioSms channel', () => {
|
|
it('returns chat icon for regular Twilio SMS channel', () => {
|
|
const inbox = { channel_type: 'Channel::TwilioSms' };
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-sms');
|
|
});
|
|
|
|
it('returns WhatsApp icon for Twilio SMS with WhatsApp medium', () => {
|
|
const inbox = {
|
|
channel_type: 'Channel::TwilioSms',
|
|
medium: 'whatsapp',
|
|
};
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-whatsapp');
|
|
});
|
|
|
|
it('returns chat icon for Twilio SMS with non-WhatsApp medium', () => {
|
|
const inbox = {
|
|
channel_type: 'Channel::TwilioSms',
|
|
medium: 'sms',
|
|
};
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-sms');
|
|
});
|
|
|
|
it('returns chat icon for Twilio SMS with undefined medium', () => {
|
|
const inbox = {
|
|
channel_type: 'Channel::TwilioSms',
|
|
medium: undefined,
|
|
};
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-sms');
|
|
});
|
|
});
|
|
|
|
describe('Email channel', () => {
|
|
it('returns mail icon for generic email channel', () => {
|
|
const inbox = { channel_type: 'Channel::Email' };
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-mail');
|
|
});
|
|
|
|
it('returns Microsoft icon for Microsoft email provider', () => {
|
|
const inbox = {
|
|
channel_type: 'Channel::Email',
|
|
provider: 'microsoft',
|
|
};
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-outlook');
|
|
});
|
|
|
|
it('returns Google icon for Google email provider', () => {
|
|
const inbox = {
|
|
channel_type: 'Channel::Email',
|
|
provider: 'google',
|
|
};
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-woot-gmail');
|
|
});
|
|
});
|
|
|
|
it('returns default icon for unknown channel type', () => {
|
|
const inbox = { channel_type: 'Channel::Unknown' };
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-ri-global-fill');
|
|
});
|
|
|
|
it('returns default icon when channel type is undefined', () => {
|
|
const inbox = {};
|
|
const { value: icon } = useChannelIcon(inbox);
|
|
expect(icon).toBe('i-ri-global-fill');
|
|
});
|
|
});
|