fix the spec for conversation llm formatter

This commit is contained in:
Tanmay Deep Sharma
2025-06-19 13:00:59 +05:30
parent df00820878
commit 3af9e8714a
2 changed files with 3 additions and 34 deletions
@@ -306,4 +306,4 @@ RSpec.describe Captain::OpenAiMessageBuilderService do
end
end
end
end
end
@@ -12,9 +12,7 @@ RSpec.describe LlmFormatter::ConversationLlmFormatter do
"Conversation ID: ##{conversation.display_id}",
"Channel: #{conversation.inbox.channel.name}",
'Message History:',
'No messages in this conversation',
'Conversation Attributes:',
''
'No messages in this conversation'
].join("\n")
expect(formatter.format).to eq(expected_output)
@@ -43,8 +41,6 @@ RSpec.describe LlmFormatter::ConversationLlmFormatter do
'Message History:',
'User: Hello, I need help',
'Support agent: How can I assist you today?',
'',
'Conversation Attributes:',
''
].join("\n")
@@ -59,38 +55,11 @@ RSpec.describe LlmFormatter::ConversationLlmFormatter do
"Channel: #{conversation.inbox.channel.name}",
'Message History:',
'No messages in this conversation',
"Contact Details: #{conversation.contact.to_llm_text}",
'Conversation Attributes:',
''
"Contact Details: #{conversation.contact.to_llm_text}"
].join("\n")
expect(formatter.format(include_contact_details: true)).to eq(expected_output)
end
end
context 'when conversation has custom attributes' do
it 'includes formatted custom attributes in the output' do
create(
:custom_attribute_definition,
account: account,
attribute_display_name: 'Order ID',
attribute_key: 'order_id',
attribute_model: :conversation_attribute
)
conversation.update(custom_attributes: { 'order_id' => '12345' })
expected_output = [
"Conversation ID: ##{conversation.display_id}",
"Channel: #{conversation.inbox.channel.name}",
'Message History:',
'No messages in this conversation',
'Conversation Attributes:',
'Order ID: 12345'
].join("\n")
expect(formatter.format).to eq(expected_output)
end
end
end
end