From 2e6b415826675d86d1ef80ee6f5e3b3febe53e54 Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma Date: Thu, 7 May 2026 16:27:46 +0700 Subject: [PATCH] test(voice): align WhatsApp call specs with current voice_enabled gate and connect semantics - Enable channel_voice and set provider_config['source'] = 'embedded_signup' in the before block so Channel::Whatsapp#voice_enabled? actually returns true; otherwise the service short-circuits before any handling runs. - Outbound `connect` only stores the SDP answer and broadcasts voice_call.outbound_connected; the in_progress / started_at transition has moved to the separate status=ACCEPTED webhook. Update the existing-call spec to expect status: 'ringing' and started_at: nil instead. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../services/whatsapp/incoming_call_service_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/enterprise/services/whatsapp/incoming_call_service_spec.rb b/spec/enterprise/services/whatsapp/incoming_call_service_spec.rb index 5dacff6f2..d52adc041 100644 --- a/spec/enterprise/services/whatsapp/incoming_call_service_spec.rb +++ b/spec/enterprise/services/whatsapp/incoming_call_service_spec.rb @@ -11,7 +11,8 @@ describe Whatsapp::IncomingCallService do let(:provider_call_id) { 'wacid_abc' } before do - channel.provider_config = channel.provider_config.merge('calling_enabled' => true) + account.enable_features!('channel_voice') + channel.provider_config = channel.provider_config.merge('source' => 'embedded_signup', 'calling_enabled' => true) channel.save! end @@ -57,14 +58,15 @@ describe Whatsapp::IncomingCallService do provider: :whatsapp, direction: :outgoing, status: 'ringing', provider_call_id: provider_call_id) end - it 'transitions the call to in_progress and broadcasts voice_call.outbound_connected with the SDP answer' do + it 'stores the SDP answer and broadcasts voice_call.outbound_connected without flipping to in_progress' do allow(ActionCable.server).to receive(:broadcast) sdp_answer = "v=0\r\na=setup:actpass\r\n" params = call_payload(event: 'connect', session: { sdp: sdp_answer, sdp_type: 'answer' }) described_class.new(inbox: inbox, params: params).perform - expect(call.reload).to have_attributes(status: 'in_progress', started_at: be_present) + # connect only completes the SDP handshake; pickup is reported separately as status=ACCEPTED. + expect(call.reload).to have_attributes(status: 'ringing', started_at: nil) expect(call.meta['sdp_answer']).to include('a=setup:active') expect(ActionCable.server).to have_received(:broadcast).with( "account_#{account.id}", @@ -116,7 +118,6 @@ describe Whatsapp::IncomingCallService do describe 'terminate with no local row yet' do it 'logs and skips instead of materialising an inbound missed-call row' do - allow(inbox.channel).to receive(:voice_enabled?).and_return(true) allow(Rails.logger).to receive(:warn) allow(ActionCable.server).to receive(:broadcast) @@ -131,7 +132,6 @@ describe Whatsapp::IncomingCallService do describe 'outbound connect with no local row yet' do it 'does not mint an inbound call when sdp_type is answer' do - allow(inbox.channel).to receive(:voice_enabled?).and_return(true) allow(Rails.logger).to receive(:warn) allow(ActionCable.server).to receive(:broadcast)