conversation_test.rb 997 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # frozen_string_literal: true
  2. require 'test_helper'
  3. class PingConversationTest < Test::Unit::TestCase
  4. def test_create_conversation
  5. fake "api/ping-api/v1/conversations", method: :post, body: load_fixture('ping/conversation')
  6. conversation = ShopifyAPI::Ping::Conversation.new(
  7. topic: 'my topic',
  8. participants: [
  9. {
  10. name: 'foo',
  11. id: 'test',
  12. group: 'customer',
  13. },
  14. ]
  15. )
  16. conversation.save
  17. assert_equal "d315d4f7-53bd-49ec-8808-23f6db3c641a", conversation.id
  18. end
  19. def test_send_message
  20. fake "api/ping-api/v1/conversations/123/messages", method: :post, body: load_fixture('ping/message')
  21. conversation = ShopifyAPI::Ping::Conversation.new(id: '123')
  22. message = conversation.send_message(
  23. dedupe_key: SecureRandom.uuid,
  24. content: {
  25. text: "Hello from shopify_api",
  26. },
  27. sender_id: 'test',
  28. )
  29. assert_equal "d0c7a2e6-8084-4e79-8483-e4a1352b81f7", message.id
  30. end
  31. end