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
- 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>
85 lines
2.9 KiB
Ruby
85 lines
2.9 KiB
Ruby
require 'rails_helper'
|
|
|
|
describe ConversationBuilder do
|
|
let(:account) { create(:account) }
|
|
let!(:sms_channel) { create(:channel_sms, account: account) }
|
|
let!(:api_channel) { create(:channel_api, account: account) }
|
|
let!(:sms_inbox) { create(:inbox, channel: sms_channel, account: account) }
|
|
let!(:api_inbox) { create(:inbox, channel: api_channel, account: account) }
|
|
let(:contact) { create(:contact, account: account) }
|
|
let(:contact_sms_inbox) { create(:contact_inbox, contact: contact, inbox: sms_inbox) }
|
|
let(:contact_api_inbox) { create(:contact_inbox, contact: contact, inbox: api_inbox) }
|
|
|
|
describe '#perform' do
|
|
it 'creates sms conversation' do
|
|
conversation = described_class.new(
|
|
contact_inbox: contact_sms_inbox,
|
|
params: {}
|
|
).perform
|
|
|
|
expect(conversation.contact_inbox_id).to eq(contact_sms_inbox.id)
|
|
end
|
|
|
|
it 'creates api conversation' do
|
|
conversation = described_class.new(
|
|
contact_inbox: contact_api_inbox,
|
|
params: {}
|
|
).perform
|
|
|
|
expect(conversation.contact_inbox_id).to eq(contact_api_inbox.id)
|
|
end
|
|
|
|
context 'when lock_to_single_conversation is true for sms inbox' do
|
|
before do
|
|
sms_inbox.update!(lock_to_single_conversation: true)
|
|
end
|
|
|
|
it 'creates sms conversation when existing conversation is not present' do
|
|
conversation = described_class.new(
|
|
contact_inbox: contact_sms_inbox,
|
|
params: {}
|
|
).perform
|
|
|
|
expect(conversation.contact_inbox_id).to eq(contact_sms_inbox.id)
|
|
end
|
|
|
|
it 'returns last from existing sms conversations when existing conversation is not present' do
|
|
create(:conversation, contact_inbox: contact_sms_inbox)
|
|
existing_conversation = create(:conversation, contact_inbox: contact_sms_inbox)
|
|
conversation = described_class.new(
|
|
contact_inbox: contact_sms_inbox,
|
|
params: {}
|
|
).perform
|
|
|
|
expect(conversation.id).to eq(existing_conversation.id)
|
|
end
|
|
end
|
|
|
|
context 'when lock_to_single_conversation is true for api inbox' do
|
|
before do
|
|
api_inbox.update!(lock_to_single_conversation: true)
|
|
end
|
|
|
|
it 'creates conversation when existing api conversation is not present' do
|
|
conversation = described_class.new(
|
|
contact_inbox: contact_api_inbox,
|
|
params: {}
|
|
).perform
|
|
|
|
expect(conversation.contact_inbox_id).to eq(contact_api_inbox.id)
|
|
end
|
|
|
|
it 'returns last from existing api conversations when existing conversation is not present' do
|
|
create(:conversation, contact_inbox: contact_api_inbox)
|
|
existing_conversation = create(:conversation, contact_inbox: contact_api_inbox)
|
|
conversation = described_class.new(
|
|
contact_inbox: contact_api_inbox,
|
|
params: {}
|
|
).perform
|
|
|
|
expect(conversation.id).to eq(existing_conversation.id)
|
|
end
|
|
end
|
|
end
|
|
end
|