feat: Add native support for CSML in agent_bot API (#4913)

This commit is contained in:
Pranav Raj S
2022-06-23 19:17:46 +05:30
committed by GitHub
parent f71980bd95
commit b7606e4dd2
26 changed files with 722 additions and 80 deletions

View File

@@ -0,0 +1,19 @@
require 'rails_helper'
RSpec.describe AgentBots::CsmlJob, type: :job do
it 'runs csml processor service' do
event = 'message.created'
message = create(:message)
agent_bot = create(:agent_bot)
processor = double
allow(Integrations::Csml::ProcessorService).to receive(:new).and_return(processor)
allow(processor).to receive(:perform)
described_class.perform_now(event, agent_bot, message)
expect(Integrations::Csml::ProcessorService)
.to have_received(:new)
.with(event_name: event, agent_bot: agent_bot, event_data: { message: message })
end
end

View File

@@ -1,6 +1,8 @@
require 'rails_helper'
RSpec.describe AgentBotJob, type: :job do
RSpec.describe AgentBots::WebhookJob, type: :job do
include ActiveJob::TestHelper
subject(:job) { described_class.perform_later(url, payload) }
let(:url) { 'https://test.com' }
@@ -11,4 +13,9 @@ RSpec.describe AgentBotJob, type: :job do
.with(url, payload)
.on_queue('bots')
end
it 'executes perform' do
expect(Webhooks::Trigger).to receive(:execute).with(url, payload)
perform_enqueued_jobs { job }
end
end

View File

@@ -1,9 +1,11 @@
require 'rails_helper'
RSpec.describe WebhookJob, type: :job do
include ActiveJob::TestHelper
subject(:job) { described_class.perform_later(url, payload) }
let(:url) { 'https://test.com' }
let(:url) { 'https://test.chatwoot.com' }
let(:payload) { { name: 'test' } }
it 'queues the job' do
@@ -11,4 +13,9 @@ RSpec.describe WebhookJob, type: :job do
.with(url, payload)
.on_queue('webhooks')
end
it 'executes perform' do
expect(Webhooks::Trigger).to receive(:execute).with(url, payload)
perform_enqueued_jobs { job }
end
end