This commit is contained in:
2026-06-10 07:24:13 +08:00
parent ac7f351308
commit 2bb54b21a5
47 changed files with 2912 additions and 305 deletions
+10 -1
View File
@@ -723,6 +723,8 @@ func TestWidgetHandler_ChatwootMessageDirectUploadAttachment(t *testing.T) {
attachmentPayload := attachments[0].(map[string]interface{})
assert.Equal(t, "/uploads/widget_direct/signed-widget-upload-1.png", attachmentPayload["data_url"])
assert.Equal(t, "image", attachmentPayload["file_type"])
assert.Equal(t, float64(account.ID), attachmentPayload["account_id"])
assert.NotContains(t, attachmentPayload, "created_at")
var attachment model.Attachment
require.NoError(t, db.Where("file_name = ?", "screenshot.png").First(&attachment).Error)
@@ -743,7 +745,10 @@ func TestWidgetHandler_ChatwootMessageDirectUploadAttachment(t *testing.T) {
indexedMessage := payload[0].(map[string]interface{})
indexedAttachments := indexedMessage["attachments"].([]interface{})
require.Len(t, indexedAttachments, 1)
assert.Equal(t, "/uploads/widget_direct/signed-widget-upload-1.png", indexedAttachments[0].(map[string]interface{})["data_url"])
indexedAttachment := indexedAttachments[0].(map[string]interface{})
assert.Equal(t, "/uploads/widget_direct/signed-widget-upload-1.png", indexedAttachment["data_url"])
assert.Equal(t, float64(account.ID), indexedAttachment["account_id"])
assert.NotContains(t, indexedAttachment, "created_at")
}
func TestWidgetHandler_ChatwootMessageReopensSnoozedConversationWithoutActivity(t *testing.T) {
@@ -2369,6 +2374,8 @@ func TestWidgetHandler_PublicAPIMessageCreatesAttachmentFromSignedUpload(t *test
require.Len(t, attachments, 1)
assert.Equal(t, "image", attachments[0].(map[string]any)["file_type"])
assert.Equal(t, "/uploads/widget_direct/public-signed-upload-1.png", attachments[0].(map[string]any)["data_url"])
assert.Equal(t, float64(account.ID), attachments[0].(map[string]any)["account_id"])
assert.NotContains(t, attachments[0].(map[string]any), "created_at")
var attachment model.Attachment
require.NoError(t, db.Where("file_name = ?", "public.png").First(&attachment).Error)
@@ -2386,6 +2393,8 @@ func TestWidgetHandler_PublicAPIMessageCreatesAttachmentFromSignedUpload(t *test
listedAttachments := listResp[0]["attachments"].([]interface{})
require.Len(t, listedAttachments, 1)
assert.Equal(t, "/uploads/widget_direct/public-signed-upload-1.png", listedAttachments[0].(map[string]any)["data_url"])
assert.Equal(t, float64(account.ID), listedAttachments[0].(map[string]any)["account_id"])
assert.NotContains(t, listedAttachments[0].(map[string]any), "created_at")
show := httptest.NewRecorder()
showReq, _ := http.NewRequest("GET", "/public/api/v1/inboxes/public-api-inbox/contacts/attachment-source/conversations/"+strconv.FormatUint(uint64(conversation.ID), 10), nil)