chore: Change the conversation bot status to pending (#2677)
fixes: #2649
This commit is contained in:
@@ -32,7 +32,7 @@ RSpec.describe 'API Base', type: :request do
|
||||
describe 'request with api_access_token for bot' do
|
||||
let!(:agent_bot) { create(:agent_bot) }
|
||||
let!(:inbox) { create(:inbox, account: account) }
|
||||
let!(:conversation) { create(:conversation, account: account, inbox: inbox, assignee: user, status: 'bot') }
|
||||
let!(:conversation) { create(:conversation, account: account, inbox: inbox, assignee: user, status: 'pending') }
|
||||
|
||||
context 'when it is an unauthorized url' do
|
||||
it 'returns unauthorized' do
|
||||
|
||||
@@ -200,6 +200,20 @@ RSpec.describe 'Conversations API', type: :request do
|
||||
end
|
||||
|
||||
it 'creates a conversation in specificed status' do
|
||||
allow(Rails.configuration.dispatcher).to receive(:dispatch)
|
||||
post "/api/v1/accounts/#{account.id}/conversations",
|
||||
headers: agent.create_new_auth_token,
|
||||
params: { source_id: contact_inbox.source_id, status: 'pending' },
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
response_data = JSON.parse(response.body, symbolize_names: true)
|
||||
expect(response_data[:status]).to eq('pending')
|
||||
end
|
||||
|
||||
# TODO: remove this spec when we remove the condition check in controller
|
||||
# Added for backwards compatibility for bot status
|
||||
it 'creates a conversation as pending if status is specified as bot' do
|
||||
allow(Rails.configuration.dispatcher).to receive(:dispatch)
|
||||
post "/api/v1/accounts/#{account.id}/conversations",
|
||||
headers: agent.create_new_auth_token,
|
||||
@@ -208,7 +222,7 @@ RSpec.describe 'Conversations API', type: :request do
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
response_data = JSON.parse(response.body, symbolize_names: true)
|
||||
expect(response_data[:status]).to eq('bot')
|
||||
expect(response_data[:status]).to eq('pending')
|
||||
end
|
||||
|
||||
it 'creates a new conversation with message when message is passed' do
|
||||
@@ -269,8 +283,8 @@ RSpec.describe 'Conversations API', type: :request do
|
||||
expect(conversation.reload.status).to eq('resolved')
|
||||
end
|
||||
|
||||
it 'toggles the conversation status to open from bot' do
|
||||
conversation.update!(status: 'bot')
|
||||
it 'toggles the conversation status to open from pending' do
|
||||
conversation.update!(status: 'pending')
|
||||
|
||||
post "/api/v1/accounts/#{account.id}/conversations/#{conversation.display_id}/toggle_status",
|
||||
headers: agent.create_new_auth_token,
|
||||
@@ -283,13 +297,27 @@ RSpec.describe 'Conversations API', type: :request do
|
||||
it 'toggles the conversation status to specific status when parameter is passed' do
|
||||
expect(conversation.status).to eq('open')
|
||||
|
||||
post "/api/v1/accounts/#{account.id}/conversations/#{conversation.display_id}/toggle_status",
|
||||
headers: agent.create_new_auth_token,
|
||||
params: { status: 'pending' },
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(conversation.reload.status).to eq('pending')
|
||||
end
|
||||
|
||||
# TODO: remove this spec when we remove the condition check in controller
|
||||
# Added for backwards compatibility for bot status
|
||||
it 'toggles the conversation status to pending status when parameter bot is passed' do
|
||||
expect(conversation.status).to eq('open')
|
||||
|
||||
post "/api/v1/accounts/#{account.id}/conversations/#{conversation.display_id}/toggle_status",
|
||||
headers: agent.create_new_auth_token,
|
||||
params: { status: 'bot' },
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(conversation.reload.status).to eq('bot')
|
||||
expect(conversation.reload.status).to eq('pending')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user