feat: Mark the messages as failed if the API channel webhooks fail for any reason. (#8277)
This commit is contained in:
@@ -3,19 +3,20 @@ require 'rails_helper'
|
||||
RSpec.describe AgentBots::WebhookJob do
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
subject(:job) { described_class.perform_later(url, payload) }
|
||||
subject(:job) { described_class.perform_later(url, payload, webhook_type) }
|
||||
|
||||
let(:url) { 'https://test.com' }
|
||||
let(:payload) { { name: 'test' } }
|
||||
let(:webhook_type) { :agent_bot_webhook }
|
||||
|
||||
it 'queues the job' do
|
||||
expect { job }.to have_enqueued_job(described_class)
|
||||
.with(url, payload)
|
||||
.with(url, payload, webhook_type)
|
||||
.on_queue('high')
|
||||
end
|
||||
|
||||
it 'executes perform' do
|
||||
expect(Webhooks::Trigger).to receive(:execute).with(url, payload)
|
||||
expect(Webhooks::Trigger).to receive(:execute).with(url, payload, webhook_type)
|
||||
perform_enqueued_jobs { job }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,19 +3,29 @@ require 'rails_helper'
|
||||
RSpec.describe WebhookJob do
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
subject(:job) { described_class.perform_later(url, payload) }
|
||||
subject(:job) { described_class.perform_later(url, payload, webhook_type) }
|
||||
|
||||
let(:url) { 'https://test.chatwoot.com' }
|
||||
let(:payload) { { name: 'test' } }
|
||||
let(:webhook_type) { :account_webhook }
|
||||
|
||||
it 'queues the job' do
|
||||
expect { job }.to have_enqueued_job(described_class)
|
||||
.with(url, payload)
|
||||
.with(url, payload, webhook_type)
|
||||
.on_queue('medium')
|
||||
end
|
||||
|
||||
it 'executes perform' do
|
||||
expect(Webhooks::Trigger).to receive(:execute).with(url, payload)
|
||||
it 'executes perform with default webhook type' do
|
||||
expect(Webhooks::Trigger).to receive(:execute).with(url, payload, webhook_type)
|
||||
perform_enqueued_jobs { job }
|
||||
end
|
||||
|
||||
context 'with custom webhook type' do
|
||||
let(:webhook_type) { :api_inbox_webhook }
|
||||
|
||||
it 'executes perform with inbox webhook type' do
|
||||
expect(Webhooks::Trigger).to receive(:execute).with(url, payload, webhook_type)
|
||||
perform_enqueued_jobs { job }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user