Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
82 lines
3.6 KiB
Ruby
82 lines
3.6 KiB
Ruby
## the older specs are covered in send in spec/services/whatsapp/send_on_whatsapp_service_spec.rb
|
|
require 'rails_helper'
|
|
|
|
describe Whatsapp::Providers::Whatsapp360DialogService do
|
|
subject(:service) { described_class.new(whatsapp_channel: whatsapp_channel) }
|
|
|
|
let!(:whatsapp_channel) { create(:channel_whatsapp, sync_templates: false, validate_provider_config: false) }
|
|
let(:response_headers) { { 'Content-Type' => 'application/json' } }
|
|
let(:whatsapp_response) { { messages: [{ id: 'message_id' }] } }
|
|
|
|
describe '#sync_templates' do
|
|
context 'when called' do
|
|
it 'updates message_templates_last_updated even when template request fails' do
|
|
stub_request(:get, 'https://waba.360dialog.io/v1/configs/templates')
|
|
.to_return(status: 401)
|
|
|
|
timstamp = whatsapp_channel.reload.message_templates_last_updated
|
|
subject.sync_templates
|
|
expect(whatsapp_channel.reload.message_templates_last_updated).not_to eq(timstamp)
|
|
end
|
|
end
|
|
end
|
|
|
|
describe '#send_interactive message' do
|
|
context 'when called' do
|
|
it 'calls message endpoints with button payload when number of items is less than or equal to 3' do
|
|
message = create(:message, message_type: :outgoing, content: 'test',
|
|
inbox: whatsapp_channel.inbox, content_type: 'input_select',
|
|
content_attributes: {
|
|
items: [
|
|
{ title: 'Burito', value: 'Burito' },
|
|
{ title: 'Pasta', value: 'Pasta' },
|
|
{ title: 'Sushi', value: 'Sushi' }
|
|
]
|
|
})
|
|
stub_request(:post, 'https://waba.360dialog.io/v1/messages')
|
|
.with(
|
|
body: {
|
|
to: '+123456789',
|
|
interactive: {
|
|
type: 'button',
|
|
body: {
|
|
text: 'test'
|
|
},
|
|
action: '{"buttons":[{"type":"reply","reply":{"id":"Burito","title":"Burito"}},{"type":"reply",' \
|
|
'"reply":{"id":"Pasta","title":"Pasta"}},{"type":"reply","reply":{"id":"Sushi","title":"Sushi"}}]}'
|
|
}, type: 'interactive'
|
|
}.to_json
|
|
).to_return(status: 200, body: whatsapp_response.to_json, headers: response_headers)
|
|
expect(service.send_message('+123456789', message)).to eq 'message_id'
|
|
end
|
|
|
|
it 'calls message endpoints with list payload when number of items is greater than 3' do
|
|
items = %w[Burito Pasta Sushi Salad].map { |i| { title: i, value: i } }
|
|
message = create(:message, message_type: :outgoing, content: 'test', inbox: whatsapp_channel.inbox,
|
|
content_type: 'input_select', content_attributes: { items: items })
|
|
|
|
expected_action = {
|
|
button: I18n.t('conversations.messages.whatsapp.list_button_label'),
|
|
sections: [{ rows: %w[Burito Pasta Sushi Salad].map { |i| { id: i, title: i } } }]
|
|
}.to_json
|
|
|
|
stub_request(:post, 'https://waba.360dialog.io/v1/messages')
|
|
.with(
|
|
body: {
|
|
to: '+123456789',
|
|
interactive: {
|
|
type: 'list',
|
|
body: {
|
|
text: 'test'
|
|
},
|
|
action: expected_action
|
|
},
|
|
type: 'interactive'
|
|
}.to_json
|
|
).to_return(status: 200, body: whatsapp_response.to_json, headers: response_headers)
|
|
expect(service.send_message('+123456789', message)).to eq 'message_id'
|
|
end
|
|
end
|
|
end
|
|
end
|