Fixed conditional logic bug in combineResponses
This commit is contained in:
Родитель
f741584093
Коммит
a5eace48be
|
@ -156,18 +156,19 @@ class MicrosoftTeamsMiddleware extends BaseMiddleware
|
|||
# If the stored message doesn't have an adaptive card, just append the new
|
||||
# attachments
|
||||
if storedCard == null
|
||||
storedMessage.attachments.push.apply(newMessage.attachments)
|
||||
|
||||
for attachment in newMessage.attachments
|
||||
# If it's not an adaptive card, just append it, otherwise
|
||||
# combine the cards
|
||||
if attachment.contentType != "application/vnd.microsoft.card.adaptive"
|
||||
for attachment in newMessage.attachments
|
||||
storedMessage.attachments.push(attachment)
|
||||
else
|
||||
storedCard = HubotResponseCards.appendCardBody(storedCard, \
|
||||
attachment)
|
||||
storedCard = HubotResponseCards.appendCardActions(storedCard, \
|
||||
attachment)
|
||||
else
|
||||
for attachment in newMessage.attachments
|
||||
# If it's not an adaptive card, just append it, otherwise
|
||||
# combine the cards
|
||||
if attachment.contentType != "application/vnd.microsoft.card.adaptive"
|
||||
storedMessage.attachments.push(attachment)
|
||||
else
|
||||
storedCard = HubotResponseCards.appendCardBody(storedCard, \
|
||||
attachment)
|
||||
storedCard = HubotResponseCards.appendCardActions(storedCard, \
|
||||
attachment)
|
||||
|
||||
# Constructs a text message response to indicate an error to the user in the
|
||||
# message channel they are using
|
||||
|
|
|
@ -960,13 +960,13 @@ describe 'MicrosoftTeamsMiddleware', ->
|
|||
|
||||
it 'should not change stored payload attachments when new doesn\'t have attachments', ->
|
||||
# Setup
|
||||
storedPayload.attachments = [
|
||||
storedPayload[1].attachments = [
|
||||
{
|
||||
contentType: 'image'
|
||||
url: 'some-image-url'
|
||||
}
|
||||
]
|
||||
expected.attachments = [
|
||||
expected[1].attachments = [
|
||||
{
|
||||
contentType: 'image'
|
||||
url: 'some-image-url'
|
||||
|
@ -984,13 +984,13 @@ describe 'MicrosoftTeamsMiddleware', ->
|
|||
# stored doesn't have, set stored to equal new attachments
|
||||
it 'should add all attachments to stored when stored doesn\'t have attachments and new does', ->
|
||||
# Setup
|
||||
newPayload.attachments = [
|
||||
newPayload[1].attachments = [
|
||||
{
|
||||
contentType: 'image'
|
||||
url: 'some-image-url'
|
||||
}
|
||||
]
|
||||
expected.attachments = [
|
||||
expected[1].attachments = [
|
||||
{
|
||||
contentType: 'image'
|
||||
url: 'some-image-url'
|
||||
|
@ -1009,13 +1009,13 @@ describe 'MicrosoftTeamsMiddleware', ->
|
|||
# stored doesn't have, set stored to equal new attachments
|
||||
it 'should append all new attachments when stored doesn\'t have adaptive card attachment', ->
|
||||
# Setup
|
||||
storedPayload.attachments = [
|
||||
storedPayload[1].attachments = [
|
||||
{
|
||||
contentType: 'image'
|
||||
url: 'some-image-url'
|
||||
}
|
||||
]
|
||||
newPayload.attachments = [
|
||||
newPayload[1].attachments = [
|
||||
{
|
||||
contentType: 'image'
|
||||
url: 'another-image-url'
|
||||
|
@ -1037,7 +1037,7 @@ describe 'MicrosoftTeamsMiddleware', ->
|
|||
}
|
||||
}
|
||||
]
|
||||
expected.attachments = [
|
||||
expected[1].attachments = [
|
||||
{
|
||||
contentType: 'image'
|
||||
url: 'some-image-url'
|
||||
|
@ -1074,7 +1074,7 @@ describe 'MicrosoftTeamsMiddleware', ->
|
|||
|
||||
it 'should combine attachments correctly so there is only one adaptive card attachment in the end', ->
|
||||
# Setup
|
||||
storedPayload.attachments = [
|
||||
storedPayload[1].attachments = [
|
||||
{
|
||||
contentType: 'image'
|
||||
url: 'some-image-url'
|
||||
|
@ -1096,7 +1096,7 @@ describe 'MicrosoftTeamsMiddleware', ->
|
|||
}
|
||||
}
|
||||
]
|
||||
newPayload.attachments = [
|
||||
newPayload[1].attachments = [
|
||||
{
|
||||
contentType: 'image'
|
||||
url: 'another-image-url'
|
||||
|
@ -1118,15 +1118,11 @@ describe 'MicrosoftTeamsMiddleware', ->
|
|||
}
|
||||
}
|
||||
]
|
||||
expected.attachments = [
|
||||
expected[1].attachments = [
|
||||
{
|
||||
contentType: 'image'
|
||||
url: 'some-image-url'
|
||||
},
|
||||
{
|
||||
contentType: 'image'
|
||||
url: 'another-image-url'
|
||||
},
|
||||
{
|
||||
'contentType': 'application/vnd.microsoft.card.adaptive'
|
||||
'content': {
|
||||
|
@ -1149,6 +1145,10 @@ describe 'MicrosoftTeamsMiddleware', ->
|
|||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
contentType: 'image'
|
||||
url: 'another-image-url'
|
||||
}
|
||||
]
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче