chore: Auto resolution job for captain (#9898)
- Add a conversation auto-resolution job for the captain integration
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ResponseBot::InboxPendingConversationsResolutionJob, type: :job do
|
||||
RSpec.describe Captain::InboxPendingConversationsResolutionJob, type: :job do
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
let!(:inbox) { create(:inbox) }
|
||||
@@ -7,23 +7,47 @@ RSpec.describe Account::ConversationsResolutionSchedulerJob, type: :job do
|
||||
let!(:inbox_without_bot) { create(:inbox, account: account_without_bot) }
|
||||
let(:response_source) { create(:response_source, account: account_with_bot) }
|
||||
|
||||
before do
|
||||
skip_unless_response_bot_enabled_test_environment
|
||||
account_with_bot.enable_features!(:response_bot)
|
||||
create(:inbox_response_source, inbox: inbox_with_bot, response_source: response_source)
|
||||
end
|
||||
describe '#perform - response bot resolutions' do
|
||||
before do
|
||||
skip_unless_response_bot_enabled_test_environment
|
||||
account_with_bot.enable_features!(:response_bot)
|
||||
create(:inbox_response_source, inbox: inbox_with_bot, response_source: response_source)
|
||||
end
|
||||
|
||||
describe '#perform' do
|
||||
it 'enqueues resolution jobs only for inboxes with response bot enabled' do
|
||||
expect do
|
||||
described_class.perform_now
|
||||
end.to have_enqueued_job(ResponseBot::InboxPendingConversationsResolutionJob).with(inbox_with_bot).and have_enqueued_job.exactly(:once)
|
||||
end.to have_enqueued_job(Captain::InboxPendingConversationsResolutionJob).with(inbox_with_bot).and have_enqueued_job.exactly(:once)
|
||||
end
|
||||
|
||||
it 'does not enqueue resolution jobs for inboxes without response bot enabled' do
|
||||
expect do
|
||||
described_class.perform_now
|
||||
end.not_to have_enqueued_job(ResponseBot::InboxPendingConversationsResolutionJob).with(inbox_without_bot)
|
||||
end.not_to have_enqueued_job(Captain::InboxPendingConversationsResolutionJob).with(inbox_without_bot)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#perform - captain resolutions' do
|
||||
before do
|
||||
create(:integrations_hook, app_id: 'captain', account: account_with_bot, settings: {
|
||||
inbox_ids: inbox_with_bot.id.to_s,
|
||||
access_token: SecureRandom.hex,
|
||||
account_id: Faker::Alphanumeric.alpha(number: 10),
|
||||
account_email: Faker::Internet.email,
|
||||
assistant_id: Faker::Alphanumeric.alpha(number: 10)
|
||||
})
|
||||
end
|
||||
|
||||
it 'enqueues resolution jobs only for inboxes with captain enabled' do
|
||||
expect do
|
||||
described_class.perform_now
|
||||
end.to have_enqueued_job(Captain::InboxPendingConversationsResolutionJob).with(inbox_with_bot).and have_enqueued_job.exactly(:once)
|
||||
end
|
||||
|
||||
it 'does not enqueue resolution jobs for inboxes without captain enabled' do
|
||||
expect do
|
||||
described_class.perform_now
|
||||
end.not_to have_enqueued_job(Captain::InboxPendingConversationsResolutionJob).with(inbox_without_bot)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user