Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
84 lines
3.4 KiB
Ruby
84 lines
3.4 KiB
Ruby
require 'rails_helper'
|
|
|
|
describe Integrations::Facebook::DeliveryStatus do
|
|
subject(:message_builder) { described_class.new(message_deliveries, facebook_channel.inbox).perform }
|
|
|
|
before do
|
|
stub_request(:post, /graph\.facebook\.com/)
|
|
end
|
|
|
|
let!(:account) { create(:account) }
|
|
let!(:facebook_channel) { create(:channel_facebook_page, page_id: '117172741761305') }
|
|
let!(:message_delivery_object) { build(:message_deliveries).to_json }
|
|
let!(:message_deliveries) { Integrations::Facebook::MessageParser.new(message_delivery_object) }
|
|
|
|
let!(:contact) { create(:contact, account: account) }
|
|
let(:contact_inbox) { create(:contact_inbox, contact: contact, inbox: facebook_channel.inbox, source_id: '3383290475046708') }
|
|
let!(:conversation) { create(:conversation, inbox: facebook_channel.inbox, contact: contact, contact_inbox: contact_inbox) }
|
|
|
|
let!(:message_read_object) { build(:message_reads).to_json }
|
|
let!(:message_reads) { Integrations::Facebook::MessageParser.new(message_read_object) }
|
|
let!(:message1) do
|
|
create(:message, content: 'facebook message', message_type: 'outgoing', inbox: facebook_channel.inbox, conversation: conversation)
|
|
end
|
|
let!(:message2) do
|
|
create(:message, content: 'facebook message', message_type: 'incoming', inbox: facebook_channel.inbox, conversation: conversation)
|
|
end
|
|
|
|
describe '#perform' do
|
|
context 'when message_deliveries callback fires' do
|
|
before do
|
|
allow(Conversations::UpdateMessageStatusJob).to receive(:perform_later)
|
|
end
|
|
|
|
it 'updates all messages if the status is delivered' do
|
|
described_class.new(params: message_deliveries).perform
|
|
expect(Conversations::UpdateMessageStatusJob).to have_received(:perform_later).with(
|
|
message1.conversation.id,
|
|
Time.zone.at(message_deliveries.delivery['watermark'].to_i).to_datetime,
|
|
:delivered
|
|
)
|
|
end
|
|
|
|
it 'does not update the message status if the message is incoming' do
|
|
described_class.new(params: message_deliveries).perform
|
|
expect(message2.reload.status).to eq('sent')
|
|
end
|
|
|
|
it 'does not update the message status if the message was created after the watermark' do
|
|
message1.update(created_at: 1.day.from_now)
|
|
message_deliveries.delivery['watermark'] = 1.day.ago.to_i
|
|
described_class.new(params: message_deliveries).perform
|
|
expect(message1.reload.status).to eq('sent')
|
|
end
|
|
end
|
|
|
|
context 'when message_reads callback fires' do
|
|
before do
|
|
allow(Conversations::UpdateMessageStatusJob).to receive(:perform_later)
|
|
end
|
|
|
|
it 'updates all messages if the status is read' do
|
|
described_class.new(params: message_reads).perform
|
|
expect(Conversations::UpdateMessageStatusJob).to have_received(:perform_later).with(
|
|
message1.conversation.id,
|
|
Time.zone.at(message_reads.read['watermark'].to_i).to_datetime,
|
|
:read
|
|
)
|
|
end
|
|
|
|
it 'does not update the message status if the message is incoming' do
|
|
described_class.new(params: message_reads).perform
|
|
expect(message2.reload.status).to eq('sent')
|
|
end
|
|
|
|
it 'does not update the message status if the message was created after the watermark' do
|
|
message1.update(created_at: 1.day.from_now)
|
|
message_reads.read['watermark'] = 1.day.ago.to_i
|
|
described_class.new(params: message_reads).perform
|
|
expect(message1.reload.status).to eq('sent')
|
|
end
|
|
end
|
|
end
|
|
end
|