fix: Automation Bugs and minor enhancements (#3936)

This commit is contained in:
Fayaz Ahmed
2022-02-15 23:36:29 +05:30
committed by GitHub
parent e345a4486d
commit 5ad6db07b4
17 changed files with 203 additions and 129 deletions

View File

@@ -70,6 +70,53 @@ describe AutomationRuleListener do
end
end
describe '#conversation_updated' do
before do
automation_rule.update!(
event_name: 'conversation_updated',
name: 'Call actions conversation updated',
description: 'Add labels, assign team after conversation updated'
)
end
let!(:event) do
Events::Base.new('conversation_updated', Time.zone.now, { conversation: conversation })
end
context 'when rule matches' do
it 'triggers automation rule to assign team' do
expect(conversation.team_id).not_to eq(team.id)
automation_rule
listener.conversation_updated(event)
conversation.reload
expect(conversation.team_id).to eq(team.id)
end
it 'triggers automation rule to add label' do
expect(conversation.labels).to eq([])
automation_rule
listener.conversation_updated(event)
conversation.reload
expect(conversation.labels.pluck(:name)).to eq(%w[support priority_customer])
end
it 'triggers automation rule to assign best agents' do
expect(conversation.assignee).to be_nil
automation_rule
listener.conversation_updated(event)
conversation.reload
expect(conversation.assignee).to eq(user_1)
end
end
end
describe '#message_created' do
before do
automation_rule.update!(