Files
assistant-storefront/spec/jobs/crm/setup_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

86 lines
2.8 KiB
Ruby

require 'rails_helper'
RSpec.describe Crm::SetupJob do
subject(:job) { described_class.perform_later(hook.id) }
let(:account) { create(:account) }
let(:hook) do
create(:integrations_hook,
account: account,
app_id: 'leadsquared',
settings: {
access_key: 'test_key',
secret_key: 'test_token',
endpoint_url: 'https://api.leadsquared.com'
})
end
before do
account.enable_features('crm_integration')
end
it 'enqueues the job' do
expect { job }.to have_enqueued_job(described_class)
.with(hook.id)
.on_queue('default')
end
describe '#perform' do
context 'when hook is not found' do
it 'returns without processing' do
allow(Integrations::Hook).to receive(:find_by).and_return(nil)
expect(described_class.new.perform(0)).to be_nil
end
end
context 'when hook is disabled' do
it 'returns without processing' do
disabled_hook = create(:integrations_hook,
account: account,
app_id: 'leadsquared',
status: 'disabled',
settings: {
access_key: 'test_key',
secret_key: 'test_token',
endpoint_url: 'https://api.leadsquared.com'
})
expect(described_class.new.perform(disabled_hook.id)).to be_nil
end
end
context 'when hook is not a CRM integration' do
it 'returns without processing' do
non_crm_hook = create(:integrations_hook,
account: account,
app_id: 'slack',
settings: { webhook_url: 'https://slack.com/webhook' })
expect(described_class.new.perform(non_crm_hook.id)).to be_nil
end
end
context 'when hook is valid' do
let(:setup_service) { instance_double(Crm::Leadsquared::SetupService) }
before do
allow(Crm::Leadsquared::SetupService).to receive(:new).with(hook).and_return(setup_service)
end
context 'when setup raises an error' do
it 'captures exception and logs error' do
error = StandardError.new('Test error')
allow(setup_service).to receive(:setup).and_raise(error)
allow(Rails.logger).to receive(:error)
allow(ChatwootExceptionTracker).to receive(:new)
.with(error, account: hook.account)
.and_return(instance_double(ChatwootExceptionTracker, capture_exception: true))
described_class.new.perform(hook.id)
expect(Rails.logger).to have_received(:error)
.with("Error in CRM setup for hook ##{hook.id} (#{hook.app_id}): Test error")
end
end
end
end
end