iachat/spec/drops/conversation_drop_spec.rb
Gabriel Jablonski 3b8a38b153
feat: Implement existing template linking for CSAT surveys (#218)
* feat: Implement existing template linking for CSAT surveys

- Added functionality to link existing CSAT templates for WhatsApp channels.
- Introduced a new component for selecting existing templates.
- Updated the dashboard settings page to support template mode switching between creating new and using existing templates.
- Enhanced the CSAT template management service to handle linking existing templates and fetching available templates.
- Updated API routes to include linking and fetching available templates.
- Added tests for the new linking functionality and template availability checks.

* feat: Enhance CSAT template handling and validation across services and components

* feat: Refactor body variable extraction for CSAT templates and update related validations

* feat: Add linked_at field to CSAT template responses and update related handling

* feat: Add tests for ConversationDrop date formatting and CSAT template body variable handling
2026-02-18 18:00:29 -03:00

69 lines
2.6 KiB
Ruby

require 'rails_helper'
describe ConversationDrop do
subject(:conversation_drop) { described_class.new(conversation) }
let(:account) { create(:account) }
let(:conversation) { create(:conversation, account: account) }
describe '#first_reply_created_at' do
it 'returns empty string when first_reply_created_at is nil' do
expect(conversation_drop.first_reply_created_at).to eq ''
end
it 'returns formatted date for en locale' do
conversation.update!(first_reply_created_at: Time.zone.parse('2025-03-15 14:30:00'))
expect(conversation_drop.first_reply_created_at).to eq 'Mar 15, 2025'
end
it 'returns formatted date for pt_BR locale' do
account.update!(locale: 'pt_BR')
conversation.update!(first_reply_created_at: Time.zone.parse('2025-03-15 14:30:00'))
expect(conversation_drop.first_reply_created_at).to eq '15/03/2025'
end
end
describe '#first_reply_created_at_time' do
it 'returns empty string when first_reply_created_at is nil' do
expect(conversation_drop.first_reply_created_at_time).to eq ''
end
it 'returns formatted date with time for en locale' do
conversation.update!(first_reply_created_at: Time.zone.parse('2025-03-15 14:30:00'))
expect(conversation_drop.first_reply_created_at_time).to eq 'Mar 15, 2025 14:30'
end
it 'returns formatted date with time for pt_BR locale' do
account.update!(locale: 'pt_BR')
conversation.update!(first_reply_created_at: Time.zone.parse('2025-03-15 14:30:00'))
expect(conversation_drop.first_reply_created_at_time).to eq '15/03/2025 14:30'
end
end
describe '#last_activity_at' do
it 'returns formatted date' do
conversation.update!(last_activity_at: Time.zone.parse('2025-06-20 09:15:00'))
expect(conversation_drop.last_activity_at).to eq 'Jun 20, 2025'
end
it 'returns formatted date for pt_BR locale' do
account.update!(locale: 'pt_BR')
conversation.update!(last_activity_at: Time.zone.parse('2025-06-20 09:15:00'))
expect(conversation_drop.last_activity_at).to eq '20/06/2025'
end
end
describe '#last_activity_at_time' do
it 'returns formatted date with time' do
conversation.update!(last_activity_at: Time.zone.parse('2025-06-20 09:15:00'))
expect(conversation_drop.last_activity_at_time).to eq 'Jun 20, 2025 09:15'
end
it 'returns formatted date with time for pt_BR locale' do
account.update!(locale: 'pt_BR')
conversation.update!(last_activity_at: Time.zone.parse('2025-06-20 09:15:00'))
expect(conversation_drop.last_activity_at_time).to eq '20/06/2025 09:15'
end
end
end