chore: Update conversations API to include unattended conversations. (#4708)
* Update conversations API to include unattended conversations.
This commit is contained in:
@@ -15,6 +15,8 @@ RSpec.describe 'Conversations API', type: :request do
|
||||
context 'when it is an authenticated user' do
|
||||
let(:agent) { create(:user, account: account, role: :agent) }
|
||||
let(:conversation) { create(:conversation, account: account) }
|
||||
let(:attended_conversation) { create(:conversation, account: account, first_reply_created_at: Time.now.utc) }
|
||||
let(:unattended_conversation) { create(:conversation, account: account, first_reply_created_at: nil) }
|
||||
|
||||
before do
|
||||
create(:inbox_member, user: agent, inbox: conversation.inbox)
|
||||
@@ -43,6 +45,22 @@ RSpec.describe 'Conversations API', type: :request do
|
||||
expect(body[:data][:meta][:all_count]).to eq(1)
|
||||
expect(body[:data][:payload].first[:messages]).to eq([])
|
||||
end
|
||||
|
||||
it 'returns unattended conversations' do
|
||||
agent_1 = create(:user, account: account, role: :agent)
|
||||
create(:inbox_member, user: agent_1, inbox: attended_conversation.inbox)
|
||||
create(:inbox_member, user: agent_1, inbox: unattended_conversation.inbox)
|
||||
|
||||
get "/api/v1/accounts/#{account.id}/conversations",
|
||||
headers: agent_1.create_new_auth_token,
|
||||
params: { reply_status: 'unattended' },
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
body = JSON.parse(response.body, symbolize_names: true)
|
||||
expect(body[:data][:meta][:all_count]).to eq(1)
|
||||
expect(body[:data][:payload].count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user