Add status reopen activity message for api channel (#6839)
This commit is contained in:
@@ -80,6 +80,32 @@ RSpec.describe 'Conversation Messages API', type: :request do
|
||||
expect(conversation.messages.last.attachments.first.file.present?).to be(true)
|
||||
expect(conversation.messages.last.attachments.first.file_type).to eq('image')
|
||||
end
|
||||
|
||||
context 'when api inbox' do
|
||||
let(:api_channel) { create(:channel_api, account: account) }
|
||||
let(:api_inbox) { create(:inbox, channel: api_channel, account: account) }
|
||||
let(:inbox_member) { create(:inbox_member, user: agent, inbox: api_inbox) }
|
||||
let(:conversation) { create(:conversation, inbox: api_inbox, account: account) }
|
||||
|
||||
it 'reopens the conversation with new incoming message' do
|
||||
create(:message, conversation: conversation, account: account)
|
||||
conversation.resolved!
|
||||
|
||||
params = { content: 'test-message', private: false, message_type: 'incoming' }
|
||||
|
||||
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)
|
||||
expect(conversation.reload.status).to eq('open')
|
||||
expect(Conversations::ActivityMessageJob)
|
||||
.to(have_been_enqueued.at_least(:once)
|
||||
.with(conversation, { account_id: conversation.account_id, inbox_id: conversation.inbox_id, message_type: :activity,
|
||||
content: 'System reopened the conversation due to a new incoming message.' }))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when it is an authenticated agent bot' do
|
||||
|
||||
Reference in New Issue
Block a user