fix: Agent typing indicator for website widget (#4495)
When we migrated the pubsub tokens from contact to contact inboxes, we missed out on doing this update for the typing indicator events. Hence the agent typing events weren't visible on the widget side. This change fixes that and removes the necessary column contact pubsub token from the model. fixes: #4476
This commit is contained in:
@@ -17,8 +17,5 @@ RSpec.describe DataImportJob, type: :job do
|
||||
expect(data_import.account.contacts.count).to eq(csv_length)
|
||||
expect(data_import.reload.total_records).to eq(csv_length)
|
||||
expect(data_import.reload.processed_records).to eq(csv_length)
|
||||
|
||||
# should generate pubsub tokens for contacts
|
||||
expect(data_import.account.contacts.last.pubsub_token).present?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,7 +61,7 @@ describe ActionCableListener do
|
||||
expect(conversation.inbox.reload.inbox_members.count).to eq(1)
|
||||
expect(ActionCableBroadcastJob).to receive(:perform_later).with(
|
||||
a_collection_containing_exactly(
|
||||
admin.pubsub_token, conversation.contact.pubsub_token
|
||||
admin.pubsub_token, conversation.contact_inbox.pubsub_token
|
||||
),
|
||||
'conversation.typing_on', conversation: conversation.push_event_data,
|
||||
user: agent.push_event_data,
|
||||
@@ -72,6 +72,26 @@ describe ActionCableListener do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#typing_on with contact' do
|
||||
let(:event_name) { :'conversation.typing_on' }
|
||||
let!(:event) { Events::Base.new(event_name, Time.zone.now, conversation: conversation, user: conversation.contact, is_private: false) }
|
||||
|
||||
it 'sends message to account admins, inbox agents and the contact' do
|
||||
# HACK: to reload conversation inbox members
|
||||
expect(conversation.inbox.reload.inbox_members.count).to eq(1)
|
||||
expect(ActionCableBroadcastJob).to receive(:perform_later).with(
|
||||
a_collection_containing_exactly(
|
||||
admin.pubsub_token, agent.pubsub_token
|
||||
),
|
||||
'conversation.typing_on', conversation: conversation.push_event_data,
|
||||
user: conversation.contact.push_event_data,
|
||||
account_id: account.id,
|
||||
is_private: false
|
||||
)
|
||||
listener.conversation_typing_on(event)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#typing_off' do
|
||||
let(:event_name) { :'conversation.typing_off' }
|
||||
let!(:event) { Events::Base.new(event_name, Time.zone.now, conversation: conversation, user: agent, is_private: false) }
|
||||
@@ -81,7 +101,7 @@ describe ActionCableListener do
|
||||
expect(conversation.inbox.reload.inbox_members.count).to eq(1)
|
||||
expect(ActionCableBroadcastJob).to receive(:perform_later).with(
|
||||
a_collection_containing_exactly(
|
||||
admin.pubsub_token, conversation.contact.pubsub_token
|
||||
admin.pubsub_token, conversation.contact_inbox.pubsub_token
|
||||
),
|
||||
'conversation.typing_off', conversation: conversation.push_event_data,
|
||||
user: agent.push_event_data,
|
||||
|
||||
Reference in New Issue
Block a user