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>
68 lines
2.4 KiB
Ruby
68 lines
2.4 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe Messages::AudioTranscriptionService, type: :service do
|
|
let(:account) { create(:account, audio_transcriptions: true) }
|
|
let(:conversation) { create(:conversation, account: account) }
|
|
let(:message) { create(:message, conversation: conversation) }
|
|
let(:attachment) { message.attachments.create!(account: account, file_type: :audio) }
|
|
|
|
before do
|
|
# Create required installation configs
|
|
create(:installation_config, name: 'CAPTAIN_OPEN_AI_API_KEY', value: 'test-api-key')
|
|
create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-4o-mini')
|
|
|
|
# Mock usage limits for transcription to be available
|
|
allow(account).to receive(:usage_limits).and_return({ captain: { responses: { current_available: 100 } } })
|
|
end
|
|
|
|
describe '#perform' do
|
|
let(:service) { described_class.new(attachment) }
|
|
|
|
context 'when captain_integration feature is not enabled' do
|
|
before do
|
|
account.disable_features!('captain_integration')
|
|
end
|
|
|
|
it 'returns transcription limit exceeded' do
|
|
expect(service.perform).to eq({ error: 'Transcription limit exceeded' })
|
|
end
|
|
end
|
|
|
|
context 'when transcription is successful' do
|
|
before do
|
|
# Mock can_transcribe? to return true and transcribe_audio method
|
|
allow(service).to receive(:can_transcribe?).and_return(true)
|
|
allow(service).to receive(:transcribe_audio).and_return('Hello world transcription')
|
|
end
|
|
|
|
it 'returns successful transcription' do
|
|
result = service.perform
|
|
expect(result).to eq({ success: true, transcriptions: 'Hello world transcription' })
|
|
end
|
|
end
|
|
|
|
context 'when audio transcriptions are disabled' do
|
|
before do
|
|
account.update!(audio_transcriptions: false)
|
|
end
|
|
|
|
it 'returns error for transcription limit exceeded' do
|
|
result = service.perform
|
|
expect(result).to eq({ error: 'Transcription limit exceeded' })
|
|
end
|
|
end
|
|
|
|
context 'when attachment already has transcribed text' do
|
|
before do
|
|
attachment.update!(meta: { transcribed_text: 'Existing transcription' })
|
|
allow(service).to receive(:can_transcribe?).and_return(true)
|
|
end
|
|
|
|
it 'returns existing transcription without calling API' do
|
|
result = service.perform
|
|
expect(result).to eq({ success: true, transcriptions: 'Existing transcription' })
|
|
end
|
|
end
|
|
end
|
|
end
|