fix: Assign agent action changes (#5827)

This commit is contained in:
Tejaswini Chile
2022-11-15 13:15:27 +05:30
committed by GitHub
parent 38ab3c36db
commit 826a735cdb
11 changed files with 35 additions and 15 deletions

View File

@@ -263,12 +263,13 @@ RSpec.describe 'Api::V1::Accounts::MacrosController', type: :request do
before do
create(:team_member, user: user_1, team: team)
create(:account_user, user: user_1, account: account)
create(:inbox_member, user: user_1, inbox: inbox)
macro.update!(actions:
[
{ 'action_name' => 'assign_team', 'action_params' => [team.id] },
{ 'action_name' => 'add_label', 'action_params' => %w[support priority_customer] },
{ 'action_name' => 'snooze_conversation' },
{ 'action_name' => 'assign_best_agent', 'action_params' => [user_1.id] },
{ 'action_name' => 'assign_agent', 'action_params' => [user_1.id] },
{ 'action_name' => 'send_message', 'action_params' => ['Send this message.'] },
{ 'action_name' => 'add_private_note', 'action_params': ['We are sending greeting message to customer.'] }
])
@@ -297,7 +298,7 @@ RSpec.describe 'Api::V1::Accounts::MacrosController', type: :request do
expect(conversation.messages.chat.last.sender).to eq(administrator)
end
it 'Assign the agent' do
it 'Assign the agent when he is inbox member' do
expect(conversation.assignee).to be_nil
perform_enqueued_jobs do
@@ -309,6 +310,20 @@ RSpec.describe 'Api::V1::Accounts::MacrosController', type: :request do
expect(conversation.messages.activity.last.content).to eq("Assigned to #{user_1.name} by #{administrator.name}")
end
it 'Assign the agent when he is not inbox member' do
InboxMember.last.destroy
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).not_to eq("Assigned to #{user_1.name} by #{administrator.name}")
end
it 'Assign the labels' do
expect(conversation.labels).to be_empty