feat: Add message support for input_select type in LINE (#11628)

# Pull Request Template

## Description

Added input_select message type support for LINE

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality not to work as expected)
- [ ] This change requires a documentation update

## How Has This Been Tested?

add testcase. and test manually by myself


## Checklist:

- [X] My code follows the style guidelines of this project
- [X] I have performed a self-review of my code
- [ ] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules

---------

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
mix5003
2025-06-10 16:40:51 +07:00
committed by GitHub
parent 3e73c1b4bc
commit cf1d0de294
3 changed files with 111 additions and 1 deletions

View File

@@ -93,6 +93,69 @@ describe Line::SendOnLineService do
end
end
context 'with message input_select' do
let(:success_response) do
{
'message' => 'ok'
}.to_json
end
let(:expect_message) do
{
type: 'flex',
altText: 'test',
contents: {
type: 'bubble',
body: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'test'
},
{
type: 'button',
style: 'link',
height: 'sm',
action: {
type: 'message',
label: 'text 1',
text: 'value 1'
}
},
{
type: 'button',
style: 'link',
height: 'sm',
action: {
type: 'message',
label: 'text 2',
text: 'value 2'
}
}
]
}
}
}
end
it 'sends the message with input_select' do
message = create(
:message, message_type: :outgoing, content: 'test', content_type: 'input_select',
content_attributes: { 'items' => [{ 'title' => 'text 1', 'value' => 'value 1' }, { 'title' => 'text 2', 'value' => 'value 2' }] },
conversation: create(:conversation, inbox: line_channel.inbox)
)
expect(line_client).to receive(:push_message).with(
message.conversation.contact_inbox.source_id,
expect_message
).and_return(OpenStruct.new(code: '200', body: success_response))
described_class.new(message: message).perform
end
end
context 'with message attachments' do
it 'sends the message with text and attachments' do
attachment = message.attachments.new(account_id: message.account_id, file_type: :image)