fix: specs

This commit is contained in:
Muhsin Keloth
2024-01-29 21:06:08 +05:30
parent 27c51a0bdf
commit d88d195e73
2 changed files with 17 additions and 12 deletions
@@ -28,7 +28,8 @@ describe Messages::Facebook::MessageBuilder do
contact = facebook_channel.inbox.contacts.first
message = facebook_channel.inbox.messages.first
expect(contact.name).to eq('Jane Dae')
expect(contact.name).to eq('Jane')
expect(contact.last_name).to eq('Dae')
expect(message.content).to eq('facebook message')
end
@@ -53,10 +54,11 @@ describe Messages::Facebook::MessageBuilder do
contact = facebook_channel.inbox.contacts.first
# Refer: https://github.com/chatwoot/chatwoot/pull/3016 for this check
default_name = 'John Doe'
default_name = 'John'
expect(facebook_channel.inbox.reload.contacts.count).to eq(1)
expect(contact.name).to eq(default_name)
expect(contact.last_name).to eq(default_name)
end
end
end
@@ -51,7 +51,8 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(Contact.all.first.last_name).to eq('Jose')
expect(telegram_channel.inbox.messages.first.content).to eq('test')
end
end
@@ -64,7 +65,8 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(Contact.all.first.last_name).to eq('Jose')
expect(Contact.all.first.additional_attributes['social_telegram_user_id']).to eq(23)
expect(Contact.all.first.additional_attributes['social_telegram_user_name']).to eq('sojan')
expect(telegram_channel.inbox.messages.first.content).to eq('test')
@@ -106,7 +108,7 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(Contact.all.first.additional_attributes['social_telegram_user_id']).to eq(23)
expect(Contact.all.first.additional_attributes['social_telegram_user_name']).to eq('sojan')
expect(telegram_channel.inbox.messages.first.attachments.first.file_type).to eq('audio')
@@ -127,7 +129,7 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(telegram_channel.inbox.messages.first.attachments.first.file_type).to eq('image')
end
end
@@ -152,7 +154,7 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(telegram_channel.inbox.messages.first.attachments.first.file_type).to eq('image')
end
end
@@ -174,7 +176,7 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(telegram_channel.inbox.messages.first.attachments.first.file_type).to eq('video')
end
end
@@ -193,7 +195,7 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(telegram_channel.inbox.messages.first.attachments.first.file_type).to eq('audio')
end
end
@@ -214,7 +216,7 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(telegram_channel.inbox.messages.first.attachments.first.file_type).to eq('file')
end
end
@@ -252,7 +254,7 @@ describe Telegram::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(telegram_channel.inbox.messages.first.attachments.first.file_type).to eq('location')
end
end
@@ -280,7 +282,8 @@ describe Telegram::IncomingMessageService do
described_class.new(inbox: telegram_channel.inbox, params: params).perform
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(Contact.all.first.last_name).to eq('Jose')
expect(Contact.all.first.additional_attributes['social_telegram_user_id']).to eq(5_171_248)
expect(telegram_channel.inbox.messages.first.content).to eq('Option 1')
end