chore: Update conversation thread rendering in Slack (#6812)
This commit is contained in:
@@ -18,7 +18,9 @@ describe Integrations::Slack::SendOnSlackService do
|
||||
let(:slack_message_content) { double }
|
||||
let(:slack_client) { double }
|
||||
let(:builder) { described_class.new(message: message, hook: hook) }
|
||||
let(:conversation_link) { "#{ENV.fetch('FRONTEND_URL', nil)}/app/accounts/#{account.id}/conversations/#{conversation.display_id}" }
|
||||
let(:conversation_link) do
|
||||
"<#{ENV.fetch('FRONTEND_URL', nil)}/app/accounts/#{account.id}/conversations/#{conversation.display_id}|Click here> to view the conversation."
|
||||
end
|
||||
|
||||
before do
|
||||
allow(builder).to receive(:slack_client).and_return(slack_client)
|
||||
@@ -34,10 +36,11 @@ describe Integrations::Slack::SendOnSlackService do
|
||||
|
||||
expect(slack_client).to receive(:chat_postMessage).with(
|
||||
channel: hook.reference_id,
|
||||
text: "\n*Inbox:* #{inbox.name} (#{inbox.inbox_type})\n*Conversation:* #{conversation_link}\n\n#{message.content}",
|
||||
text: "\n*Inbox:* #{inbox.name} (#{inbox.inbox_type})\n#{conversation_link}\n\n#{message.content}",
|
||||
username: "#{message.sender.name} (Contact)",
|
||||
thread_ts: nil,
|
||||
icon_url: anything
|
||||
icon_url: anything,
|
||||
unfurl_links: false
|
||||
).and_return(slack_message)
|
||||
|
||||
builder.perform
|
||||
@@ -59,11 +62,12 @@ describe Integrations::Slack::SendOnSlackService do
|
||||
|
||||
expect(slack_client).to receive(:chat_postMessage).with(
|
||||
channel: hook.reference_id,
|
||||
text: "\n*Inbox:* #{inbox.name} (#{inbox.inbox_type})\n*Conversation:* #{conversation_link}\n" \
|
||||
text: "\n*Inbox:* #{inbox.name} (#{inbox.inbox_type})\n#{conversation_link}\n" \
|
||||
"*Subject:* Sample subject line\n\n\n#{message.content}",
|
||||
username: "#{message.sender.name} (Contact)",
|
||||
thread_ts: nil,
|
||||
icon_url: anything
|
||||
icon_url: anything,
|
||||
unfurl_links: false
|
||||
).and_return(slack_message)
|
||||
|
||||
builder.perform
|
||||
@@ -84,7 +88,8 @@ describe Integrations::Slack::SendOnSlackService do
|
||||
text: message.content,
|
||||
username: "#{message.sender.name} (Contact)",
|
||||
thread_ts: conversation.identifier,
|
||||
icon_url: anything
|
||||
icon_url: anything,
|
||||
unfurl_links: true
|
||||
).and_return(slack_message)
|
||||
|
||||
builder.perform
|
||||
@@ -98,7 +103,8 @@ describe Integrations::Slack::SendOnSlackService do
|
||||
text: message.content,
|
||||
username: "#{message.sender.name} (Contact)",
|
||||
thread_ts: conversation.identifier,
|
||||
icon_url: anything
|
||||
icon_url: anything,
|
||||
unfurl_links: true
|
||||
).and_return(slack_message)
|
||||
|
||||
attachment = message.attachments.new(account_id: message.account_id, file_type: :image)
|
||||
@@ -131,7 +137,8 @@ describe Integrations::Slack::SendOnSlackService do
|
||||
text: template_message.content,
|
||||
username: "#{template_message.sender.name} (Contact)",
|
||||
thread_ts: conversation.identifier,
|
||||
icon_url: anything
|
||||
icon_url: anything,
|
||||
unfurl_links: true
|
||||
).and_return(slack_message)
|
||||
|
||||
builder.perform
|
||||
@@ -145,7 +152,8 @@ describe Integrations::Slack::SendOnSlackService do
|
||||
text: message.content,
|
||||
username: "#{message.sender.name} (Contact)",
|
||||
thread_ts: conversation.identifier,
|
||||
icon_url: anything
|
||||
icon_url: anything,
|
||||
unfurl_links: true
|
||||
).and_raise(Slack::Web::Api::Errors::AccountInactive.new('Account disconnected'))
|
||||
|
||||
allow(hook).to receive(:authorization_error!)
|
||||
@@ -164,10 +172,11 @@ describe Integrations::Slack::SendOnSlackService do
|
||||
|
||||
expect(slack_client).to receive(:chat_postMessage).with(
|
||||
channel: hook.reference_id,
|
||||
text: "\n*Inbox:* #{inbox.name} (#{inbox.inbox_type})\n*Conversation:* #{conversation_link}\n\n#{formatted_message_text}",
|
||||
text: "\n*Inbox:* #{inbox.name} (#{inbox.inbox_type})\n#{conversation_link}\n\n#{formatted_message_text}",
|
||||
username: "#{message.sender.name} (Contact)",
|
||||
thread_ts: nil,
|
||||
icon_url: anything
|
||||
icon_url: anything,
|
||||
unfurl_links: false
|
||||
).and_return(slack_message)
|
||||
|
||||
builder.perform
|
||||
@@ -183,7 +192,8 @@ describe Integrations::Slack::SendOnSlackService do
|
||||
text: formatted_message_text,
|
||||
username: "#{message.sender.name} (Contact)",
|
||||
thread_ts: 'random_slack_thread_ts',
|
||||
icon_url: anything
|
||||
icon_url: anything,
|
||||
unfurl_links: true
|
||||
).and_return(slack_message)
|
||||
|
||||
builder.perform
|
||||
|
||||
Reference in New Issue
Block a user