feat: Add i18n on whatsapp list button (#10852)
Fixes #10862 --------- Co-authored-by: Pranav <pranav@chatwoot.com>
This commit is contained in:
committed by
GitHub
parent
0d05a07aa7
commit
d52f4267ba
@@ -51,16 +51,15 @@ describe Whatsapp::Providers::Whatsapp360DialogService do
|
||||
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: [
|
||||
{ title: 'Burito', value: 'Burito' },
|
||||
{ title: 'Pasta', value: 'Pasta' },
|
||||
{ title: 'Sushi', value: 'Sushi' },
|
||||
{ title: 'Salad', value: 'Salad' }
|
||||
]
|
||||
})
|
||||
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: {
|
||||
@@ -70,9 +69,9 @@ describe Whatsapp::Providers::Whatsapp360DialogService do
|
||||
body: {
|
||||
text: 'test'
|
||||
},
|
||||
action: '{"button":"Choose an item","sections":[{"rows":[{"id":"Burito","title":"Burito"},' \
|
||||
'{"id":"Pasta","title":"Pasta"},{"id":"Sushi","title":"Sushi"},{"id":"Salad","title":"Salad"}]}]}'
|
||||
}, type: 'interactive'
|
||||
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'
|
||||
|
||||
@@ -124,16 +124,15 @@ describe Whatsapp::Providers::WhatsappCloudService do
|
||||
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: [
|
||||
{ title: 'Burito', value: 'Burito' },
|
||||
{ title: 'Pasta', value: 'Pasta' },
|
||||
{ title: 'Sushi', value: 'Sushi' },
|
||||
{ title: 'Salad', value: 'Salad' }
|
||||
]
|
||||
})
|
||||
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://graph.facebook.com/v13.0/123456789/messages')
|
||||
.with(
|
||||
body: {
|
||||
@@ -143,9 +142,9 @@ describe Whatsapp::Providers::WhatsappCloudService do
|
||||
body: {
|
||||
text: 'test'
|
||||
},
|
||||
action: '{"button":"Choose an item","sections":[{"rows":[{"id":"Burito","title":"Burito"},' \
|
||||
'{"id":"Pasta","title":"Pasta"},{"id":"Sushi","title":"Sushi"},{"id":"Salad","title":"Salad"}]}]}'
|
||||
}, type: 'interactive'
|
||||
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'
|
||||
|
||||
Reference in New Issue
Block a user