Files
assistant-storefront/spec/jobs/webhooks/facebook_events_job_spec.rb
Liang XJ 092fb2e083
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
Initial commit: Add logistics and order_detail message types
- 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>
2026-01-26 11:16:56 +08:00

52 lines
2.0 KiB
Ruby

require 'rails_helper'
RSpec.describe Webhooks::FacebookEventsJob do
subject(:job) { described_class.perform_later(params) }
let(:params) { { test: 'test' } }
let(:parsed_response) { instance_double(Integrations::Facebook::MessageParser) }
let(:lock_key_format) { Redis::Alfred::FACEBOOK_MESSAGE_MUTEX }
let(:lock_key) { format(lock_key_format, sender_id: 'sender_id', recipient_id: 'recipient_id') } # Use real format if different
before do
allow(Integrations::Facebook::MessageParser).to receive(:new).and_return(parsed_response)
allow(parsed_response).to receive(:sender_id).and_return('sender_id')
allow(parsed_response).to receive(:recipient_id).and_return('recipient_id')
end
it 'enqueues the job' do
expect { job }.to have_enqueued_job(described_class)
.with(params)
.on_queue('default')
end
describe 'job execution' do
let(:message_creator) { instance_double(Integrations::Facebook::MessageCreator) }
before do
allow(Integrations::Facebook::MessageParser).to receive(:new).and_return(parsed_response)
allow(Integrations::Facebook::MessageCreator).to receive(:new).with(parsed_response).and_return(message_creator)
allow(message_creator).to receive(:perform)
end
# ensures that the response is built
it 'invokes the message parser and creator' do
expect(Integrations::Facebook::MessageParser).to receive(:new).with(params)
expect(Integrations::Facebook::MessageCreator).to receive(:new).with(parsed_response)
expect(message_creator).to receive(:perform)
described_class.perform_now(params)
end
# this test ensures that the process message function is indeed called
it 'attempts to acquire a lock and then processes the message' do
job_instance = described_class.new
allow(job_instance).to receive(:process_message).with(parsed_response)
job_instance.perform(params)
expect(job_instance).to have_received(:process_message).with(parsed_response)
end
end
end