chore: Change the conversation bot status to pending (#2677)

fixes: #2649
This commit is contained in:
Sojan Jose
2021-07-21 22:02:43 +05:30
committed by GitHub
parent a0886d37bc
commit a7ca55c080
22 changed files with 87 additions and 54 deletions

View File

@@ -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