chore: Message API improvements (#2396)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
@@ -31,6 +31,23 @@ RSpec.describe 'Conversation Messages API', type: :request do
|
||||
expect(conversation.messages.first.content).to eq(params[:content])
|
||||
end
|
||||
|
||||
it 'creates an outgoing message with a specific bot sender' do
|
||||
agent_bot = create(:agent_bot)
|
||||
time_stamp = Time.now.utc.to_s
|
||||
params = { content: 'test-message', external_created_at: time_stamp, sender_type: 'AgentBot', sender_id: agent_bot.id }
|
||||
|
||||
post api_v1_account_conversation_messages_url(account_id: account.id, conversation_id: conversation.display_id),
|
||||
params: params,
|
||||
headers: agent.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
response_data = JSON.parse(response.body)
|
||||
expect(response_data['content_attributes']['external_created_at']).to eq time_stamp
|
||||
expect(conversation.messages.count).to eq(1)
|
||||
expect(conversation.messages.last.sender_id).to eq(agent_bot.id)
|
||||
end
|
||||
|
||||
it 'creates a new outgoing message with attachment' do
|
||||
file = fixture_file_upload(Rails.root.join('spec/assets/avatar.png'), 'image/png')
|
||||
params = { content: 'test-message', attachments: [file] }
|
||||
|
||||
Reference in New Issue
Block a user