From d6047d3f63314655a0c92c4f5421a4ac6b7b3c30 Mon Sep 17 00:00:00 2001 From: Keepers Date: Fri, 27 Oct 2023 09:10:02 -0600 Subject: [PATCH] add real world test examples (#4558) #### Type of change - [x] :robot: Supportability/Tests #### Issue(s) * #4546 #### Test Plan - [x] :zap: Unit test - [x] :green_heart: E2E --- src/pkg/services/m365/api/channels_test.go | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/pkg/services/m365/api/channels_test.go b/src/pkg/services/m365/api/channels_test.go index 7ac0f13c8..8483d305c 100644 --- a/src/pkg/services/m365/api/channels_test.go +++ b/src/pkg/services/m365/api/channels_test.go @@ -579,6 +579,16 @@ func (suite *ChannelsAPIUnitSuite) TestStripChatMessageContent() { attachments := []models.ChatMessageAttachmentable{attach1, attach2} + realAttach := models.NewChatMessageAttachment() + realAttach.SetId(ptr.To("1693946862569")) + realAttach.SetName(ptr.To("meeting")) + + realAttach2 := models.NewChatMessageAttachment() + realAttach2.SetId(ptr.To("c285cc11-a1ba-473f-ba49-433696e93ef5")) + realAttach2.SetName(ptr.To("thankyoublue.jpg")) + + realAttachments := []models.ChatMessageAttachmentable{realAttach, realAttach2} + attachML := func(id string) string { return fmt.Sprintf(``, id) } @@ -667,6 +677,29 @@ func (suite *ChannelsAPIUnitSuite) TestStripChatMessageContent() { expect: "body\n[attachment:a1][attachment:a2][attachment]\nend", expectErr: assert.NoError, }, + { + name: "real world example 1", + content: "Scheduled a meeting", + attachments: realAttachments, + expect: "Scheduled a meeting[attachment:meeting]", + expectErr: assert.NoError, + }, + { + name: "real world example 2", + //nolint:lll + content: "

gifzz

\n\"The\n

 

", + attachments: attachments, + expect: "gifzz", + expectErr: assert.NoError, + }, + { + name: "real world example 3", + //nolint:lll + content: "

one

\n\"Cracking\n

attach

\n\"StickerOH YEAH!\n

\"🎉\"

\n\"Oh\n

 

", + attachments: realAttachments, + expect: "one\n\nattach\n\nOH YEAH!\n\n[attachment:thankyoublue.jpg]", + expectErr: assert.NoError, + }, } for _, test := range tests { suite.Run(test.name, func() {