Files
assistant-storefront/spec/builders/email/from_builder_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

170 lines
5.8 KiB
Ruby

require 'rails_helper'
RSpec.describe Email::FromBuilder do
let(:account) { create(:account, support_email: 'support@example.com') }
let(:agent) { create(:user, account: account) }
let(:conversation) { create(:conversation, account: account) }
let(:current_message) { create(:message, conversation: conversation, sender: agent, message_type: :outgoing) }
describe '#build' do
context 'when inbox is not an email channel' do
let(:channel) { create(:channel_api, account: account) }
let(:inbox) { create(:inbox, channel: channel, account: account) }
it 'returns account support email with sender name formatting' do
builder = described_class.new(inbox: inbox, message: current_message)
result = builder.build
expect(result).to include('support@example.com')
end
context 'with friendly inbox' do
let(:inbox) { create(:inbox, channel: channel, account: account, sender_name_type: :friendly) }
it 'returns friendly formatted sender name with support email' do
builder = described_class.new(inbox: inbox, message: current_message)
result = builder.build
expect(result).to include(agent.available_name)
expect(result).to include('support@example.com')
end
end
context 'with professional inbox' do
let(:inbox) { create(:inbox, channel: channel, account: account, sender_name_type: :professional) }
it 'returns professional formatted sender name with support email' do
builder = described_class.new(inbox: inbox, message: current_message)
result = builder.build
expect(result).to include('support@example.com')
end
end
end
context 'when inbox is an email channel' do
let(:channel) { create(:channel_email, email: 'care@example.com', account: account) }
let(:inbox) { create(:inbox, channel: channel, account: account) }
context 'with standard IMAP/SMTP configuration' do
before do
channel.update!(
imap_enabled: true,
smtp_enabled: true,
imap_address: 'imap.example.com',
smtp_address: 'smtp.example.com'
)
end
it 'returns channel email with sender name formatting' do
builder = described_class.new(inbox: inbox, message: current_message)
result = builder.build
expect(result).to include('care@example.com')
end
end
context 'with Google OAuth configuration' do
before do
channel.update!(
provider: 'google',
imap_enabled: true,
provider_config: { access_token: 'token', refresh_token: 'refresh' }
)
end
it 'returns channel email with sender name formatting' do
builder = described_class.new(inbox: inbox, message: current_message)
result = builder.build
expect(result).to include('care@example.com')
end
end
context 'with Microsoft OAuth configuration' do
before do
channel.update!(
provider: 'microsoft',
imap_enabled: true,
provider_config: { access_token: 'token', refresh_token: 'refresh' }
)
end
it 'returns channel email with sender name formatting' do
builder = described_class.new(inbox: inbox, message: current_message)
result = builder.build
expect(result).to include('care@example.com')
end
end
context 'with forwarding and own SMTP configuration' do
before do
channel.update!(
imap_enabled: false,
smtp_enabled: true,
smtp_address: 'smtp.example.com'
)
end
it 'returns channel email with sender name formatting' do
builder = described_class.new(inbox: inbox, message: current_message)
result = builder.build
expect(result).to include('care@example.com')
end
end
context 'with IMAP enabled and Chatwoot SMTP and channel is verified_for_sending' do
before do
channel.update!(verified_for_sending: true, imap_enabled: true, smtp_enabled: false)
end
it 'returns channel email with sender name formatting' do
builder = described_class.new(inbox: inbox, message: current_message)
result = builder.build
expect(result).to include('care@example.com')
end
end
context 'with IMAP enabled and Chatwoot SMTP and channel is not verified_for_sending' do
before do
channel.update!(verified_for_sending: false, imap_enabled: true, smtp_enabled: false)
end
it 'returns account support email with sender name formatting' do
builder = described_class.new(inbox: inbox, message: current_message)
result = builder.build
expect(result).to include('support@example.com')
end
end
context 'with forwarding and Chatwoot SMTP and channel is verified_for_sending' do
before do
channel.update!(verified_for_sending: true, imap_enabled: false, smtp_enabled: false)
end
it 'returns channel email with sender name formatting' do
builder = described_class.new(inbox: inbox, message: current_message)
result = builder.build
expect(result).to include('care@example.com')
end
end
context 'with forwarding and Chatwoot SMTP and channel is not verified_for_sending' do
before { channel.update!(verified_for_sending: false, imap_enabled: false, smtp_enabled: false) }
it 'returns account support email with sender name formatting' do
builder = described_class.new(inbox: inbox, message: current_message)
result = builder.build
expect(result).to include('support@example.com')
end
end
end
end
end