diff --git a/spec/services/llm_formatter/conversation_llm_formatter_spec.rb b/spec/services/llm_formatter/conversation_llm_formatter_spec.rb index 93fec14f7..9f570d23d 100644 --- a/spec/services/llm_formatter/conversation_llm_formatter_spec.rb +++ b/spec/services/llm_formatter/conversation_llm_formatter_spec.rb @@ -12,7 +12,9 @@ RSpec.describe LlmFormatter::ConversationLlmFormatter do "Conversation ID: ##{conversation.display_id}", "Channel: #{conversation.inbox.channel.name}", 'Message History:', - 'No messages in this conversation' + 'No messages in this conversation', + 'Conversation Attributes:', + '' ].join("\n") expect(formatter.format).to eq(expected_output) @@ -41,6 +43,8 @@ RSpec.describe LlmFormatter::ConversationLlmFormatter do 'Message History:', 'User: Hello, I need help', 'Support agent: How can I assist you today?', + '', + 'Conversation Attributes:', '' ].join("\n") @@ -55,11 +59,38 @@ RSpec.describe LlmFormatter::ConversationLlmFormatter do "Channel: #{conversation.inbox.channel.name}", 'Message History:', 'No messages in this conversation', - "Contact Details: #{conversation.contact.to_llm_text}" + "Contact Details: #{conversation.contact.to_llm_text}", + 'Conversation Attributes:', + '' ].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