feat: Enable Capacity Config UI (#5164)

- Enables Capacity Config in UI
- Rewrite auto assignment Logic to consider only online agents

fixes: #4990
This commit is contained in:
Sojan Jose
2022-08-16 16:58:23 +05:30
committed by GitHub
parent 287f0a6de0
commit 2ecb2ca0f0
20 changed files with 225 additions and 216 deletions

View File

@@ -6,7 +6,7 @@ shared_examples_for 'assignment_handler' do
describe '#update_team' do
let(:conversation) { create(:conversation, assignee: create(:user)) }
let(:agent) do
create(:user, email: 'agent@example.com', account: conversation.account, role: :agent)
create(:user, email: 'agent@example.com', account: conversation.account, role: :agent, auto_offline: false)
end
let(:team) do
create(:team, account: conversation.account, allow_auto_assign: false)

View File

@@ -2,10 +2,10 @@
require 'rails_helper'
shared_examples_for 'round_robin_handler' do
describe '#round robin' do
shared_examples_for 'auto_assignment_handler' do
describe '#auto assignment' do
let(:account) { create(:account) }
let(:agent) { create(:user, email: 'agent1@example.com', account: account) }
let(:agent) { create(:user, email: 'agent1@example.com', account: account, auto_offline: false) }
let(:inbox) { create(:inbox, account: account) }
let(:conversation) do
create(
@@ -23,14 +23,12 @@ shared_examples_for 'round_robin_handler' do
end
it 'runs round robin on after_save callbacks' do
# run_round_robin
expect(conversation.reload.assignee).to eq(agent)
end
it 'will not auto assign agent if enable_auto_assignment is false' do
inbox.update(enable_auto_assignment: false)
# run_round_robin
expect(conversation.reload.assignee).to be_nil
end
@@ -44,7 +42,6 @@ shared_examples_for 'round_robin_handler' do
assignee: nil
)
# run_round_robin
expect(conversation.reload.assignee).to be_nil
end
@@ -55,7 +52,7 @@ shared_examples_for 'round_robin_handler' do
inbox.inbox_members.where(user_id: agent.id).first.destroy!
# round robin changes assignee in this case since agent doesn't have access to inbox
agent2 = create(:user, email: 'agent2@example.com', account: account)
agent2 = create(:user, email: 'agent2@example.com', account: account, auto_offline: false)
create(:inbox_member, inbox: inbox, user: agent2)
allow(Redis::Alfred).to receive(:rpoplpush).and_return(agent2.id)
conversation.status = 'open'