mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 11:37:58 +00:00
fix: Set message sender to macros excution (#5769)
This commit is contained in:
@@ -247,21 +247,55 @@ RSpec.describe 'Api::V1::Accounts::MacrosController', type: :request do
|
||||
end
|
||||
|
||||
context 'when it is an authenticated user' do
|
||||
it 'execute the macro' do
|
||||
expect(conversation.messages).to be_empty
|
||||
expect(conversation.assignee).to be_nil
|
||||
expect(conversation.labels).to be_empty
|
||||
context 'when execute the macro' do
|
||||
it 'send the message with sender' do
|
||||
expect(conversation.messages).to be_empty
|
||||
|
||||
perform_enqueued_jobs do
|
||||
post "/api/v1/accounts/#{account.id}/macros/#{macro.id}/execute",
|
||||
params: { conversation_ids: [conversation.display_id] },
|
||||
headers: administrator.create_new_auth_token
|
||||
perform_enqueued_jobs do
|
||||
post "/api/v1/accounts/#{account.id}/macros/#{macro.id}/execute",
|
||||
params: { conversation_ids: [conversation.display_id] },
|
||||
headers: administrator.create_new_auth_token
|
||||
end
|
||||
|
||||
expect(conversation.messages.chat.last.content).to eq('Send this message.')
|
||||
expect(conversation.messages.chat.last.sender).to eq(administrator)
|
||||
end
|
||||
|
||||
expect(conversation.reload.status).to eql('snoozed')
|
||||
expect(conversation.messages.chat.last.content).to eq('Send this message.')
|
||||
expect(conversation.label_list).to match_array(%w[support priority_customer])
|
||||
expect(conversation.messages.activity.last.content).to eq("Assigned to #{user_1.name} by #{administrator.name}")
|
||||
it 'Assign the agent' do
|
||||
expect(conversation.assignee).to be_nil
|
||||
|
||||
perform_enqueued_jobs do
|
||||
post "/api/v1/accounts/#{account.id}/macros/#{macro.id}/execute",
|
||||
params: { conversation_ids: [conversation.display_id] },
|
||||
headers: administrator.create_new_auth_token
|
||||
end
|
||||
|
||||
expect(conversation.messages.activity.last.content).to eq("Assigned to #{user_1.name} by #{administrator.name}")
|
||||
end
|
||||
|
||||
it 'Assign the labels' do
|
||||
expect(conversation.labels).to be_empty
|
||||
|
||||
perform_enqueued_jobs do
|
||||
post "/api/v1/accounts/#{account.id}/macros/#{macro.id}/execute",
|
||||
params: { conversation_ids: [conversation.display_id] },
|
||||
headers: administrator.create_new_auth_token
|
||||
end
|
||||
|
||||
expect(conversation.reload.label_list).to match_array(%w[support priority_customer])
|
||||
end
|
||||
|
||||
it 'Update the status' do
|
||||
expect(conversation.reload.status).to eql('open')
|
||||
|
||||
perform_enqueued_jobs do
|
||||
post "/api/v1/accounts/#{account.id}/macros/#{macro.id}/execute",
|
||||
params: { conversation_ids: [conversation.display_id] },
|
||||
headers: administrator.create_new_auth_token
|
||||
end
|
||||
|
||||
expect(conversation.reload.status).to eql('snoozed')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user