28 lines
1.4 KiB
Ruby
28 lines
1.4 KiB
Ruby
|
require 'rails_helper'
|
||
|
|
||
|
RSpec.describe '/api/v1/widget/conversations/toggle_typing', type: :request do
|
||
|
let(:account) { create(:account) }
|
||
|
let(:web_widget) { create(:channel_widget, account: account) }
|
||
|
let(:contact) { create(:contact, account: account, email: nil) }
|
||
|
let(:contact_inbox) { create(:contact_inbox, contact: contact, inbox: web_widget.inbox) }
|
||
|
let!(:conversation) { create(:conversation, contact: contact, account: account, inbox: web_widget.inbox, contact_inbox: contact_inbox) }
|
||
|
let(:payload) { { source_id: contact_inbox.source_id, inbox_id: web_widget.inbox.id } }
|
||
|
let(:token) { ::Widget::TokenService.new(payload: payload).generate_token }
|
||
|
|
||
|
describe 'POST /api/v1/widget/conversations/toggle_typing' do
|
||
|
context 'with a conversation' do
|
||
|
it 'dispatches the correct typing status' do
|
||
|
allow(Rails.configuration.dispatcher).to receive(:dispatch)
|
||
|
post '/api/v1/widget/conversations/toggle_typing',
|
||
|
headers: { 'X-Auth-Token' => token },
|
||
|
params: { typing_status: 'on', website_token: web_widget.website_token },
|
||
|
as: :json
|
||
|
|
||
|
expect(response).to have_http_status(:success)
|
||
|
expect(Rails.configuration.dispatcher).to have_received(:dispatch)
|
||
|
.with(Conversation::CONVERSATION_TYPING_ON, kind_of(Time), { conversation: conversation, user: contact })
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|