feat: Add live agent load report api (#4297)
This change allows the admin user to fetch conversation metrics for an account, agents, and filter conversation metrics for a specific agent. Fixes #4305
This commit is contained in:
@@ -57,6 +57,68 @@ RSpec.describe 'Reports API', type: :request do
|
||||
expect(current_day_metric.length).to eq(1)
|
||||
expect(current_day_metric[0]['value']).to eq(10)
|
||||
end
|
||||
|
||||
it 'return conversation metrics in account level' do
|
||||
unassigned_conversation = create(:conversation, account: account, inbox: inbox,
|
||||
assignee: nil, created_at: Time.zone.today)
|
||||
unassigned_conversation.save!
|
||||
|
||||
get "/api/v2/accounts/#{account.id}/reports/conversations",
|
||||
params: {
|
||||
type: :account
|
||||
},
|
||||
headers: admin.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
json_response = JSON.parse(response.body)
|
||||
|
||||
expect(json_response['open']).to eq(11)
|
||||
expect(json_response['unattended']).to eq(11)
|
||||
expect(json_response['unassigned']).to eq(1)
|
||||
end
|
||||
|
||||
it 'return conversation metrics for user in account level' do
|
||||
create_list(:conversation, 2, account: account, inbox: inbox,
|
||||
assignee: admin, created_at: Time.zone.today)
|
||||
|
||||
get "/api/v2/accounts/#{account.id}/reports/conversations",
|
||||
params: {
|
||||
type: :agent
|
||||
},
|
||||
headers: admin.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response.blank?).to be false
|
||||
user_metrics = json_response.find { |item| item['user']['name'] == admin[:name] }
|
||||
expect(user_metrics.present?).to be true
|
||||
|
||||
expect(user_metrics['metric']['open']).to eq(2)
|
||||
expect(user_metrics['metric']['unattended']).to eq(2)
|
||||
end
|
||||
|
||||
it 'return conversation metrics for specific user in account level' do
|
||||
create_list(:conversation, 2, account: account, inbox: inbox,
|
||||
assignee: admin, created_at: Time.zone.today)
|
||||
|
||||
get "/api/v2/accounts/#{account.id}/reports/conversations",
|
||||
params: {
|
||||
type: :agent,
|
||||
user_id: user.id
|
||||
},
|
||||
headers: admin.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response.blank?).to be false
|
||||
expect(json_response[0]['metric']['open']).to eq(10)
|
||||
expect(json_response[0]['metric']['unattended']).to eq(10)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user