Feature: Send chat transcript via email (#1152)

Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
Sojan Jose
2020-08-17 11:25:13 +05:30
committed by GitHub
parent 4b70e4e3d6
commit 22880df429
31 changed files with 559 additions and 59 deletions

View File

@@ -212,4 +212,32 @@ RSpec.describe 'Conversations API', type: :request do
end
end
end
describe 'POST /api/v1/accounts/{account.id}/conversations/:id/transcript' do
let(:conversation) { create(:conversation, account: account) }
context 'when it is an unauthenticated user' do
it 'returns unauthorized' do
post "/api/v1/accounts/#{account.id}/conversations/#{conversation.display_id}/transcript"
expect(response).to have_http_status(:unauthorized)
end
end
context 'when it is an authenticated user' do
let(:agent) { create(:user, account: account, role: :agent) }
let(:params) { { email: 'test@test.com' } }
it 'mutes conversation' do
allow(ConversationReplyMailer).to receive(:conversation_transcript)
post "/api/v1/accounts/#{account.id}/conversations/#{conversation.display_id}/transcript",
headers: agent.create_new_auth_token,
params: params,
as: :json
expect(response).to have_http_status(:success)
expect(ConversationReplyMailer).to have_received(:conversation_transcript).with(conversation, 'test@test.com')
end
end
end
end

View File

@@ -60,4 +60,20 @@ RSpec.describe '/api/v1/widget/conversations/toggle_typing', type: :request do
end
end
end
describe 'POST /api/v1/widget/conversations/transcript' do
context 'with a conversation' do
it 'sends transcript email' do
allow(ConversationReplyMailer).to receive(:conversation_transcript)
post '/api/v1/widget/conversations/transcript',
headers: { 'X-Auth-Token' => token },
params: { website_token: web_widget.website_token, email: 'test@test.com' },
as: :json
expect(response).to have_http_status(:success)
expect(ConversationReplyMailer).to have_received(:conversation_transcript).with(conversation, 'test@test.com')
end
end
end
end