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
@@ -282,6 +282,7 @@ func TestSearchHandler_SearchConversations_ChatwootPayloadShape(t *testing.T) {
require.Len(t, results, 1)
item := results[0].(map[string]any)
assert.Equal(t, float64(42), item["id"])
assert.Equal(t, float64(1), item["account_id"])
assert.Equal(t, float64(createdAt.Unix()), item["created_at"])
assert.Equal(t, "Need pricing", item["additional_attributes"].(map[string]any)["mail_subject"])
assert.Equal(t, "Ada", item["contact"].(map[string]any)["name"])
@@ -289,8 +290,10 @@ func TestSearchHandler_SearchConversations_ChatwootPayloadShape(t *testing.T) {
assert.Equal(t, "Website", item["inbox"].(map[string]any)["name"])
assert.Equal(t, float64(11), item["inbox"].(map[string]any)["channel_id"])
assert.Equal(t, "Agent One", item["agent"].(map[string]any)["available_name"])
assert.Equal(t, float64(13), item["message"].(map[string]any)["id"])
assert.Equal(t, float64(0), item["message"].(map[string]any)["message_type"])
message := item["message"].(map[string]any)
assert.Equal(t, float64(13), message["id"])
assert.Equal(t, float64(1), message["account_id"])
assert.Equal(t, float64(0), message["message_type"])
}
func TestSearchHandler_SearchConversations_IgnoresUnsupportedSearchFilters(t *testing.T) {
@@ -465,6 +468,7 @@ func TestSearchHandler_SearchMessages_MeiliHitPayloadShape(t *testing.T) {
messages := payload["messages"].([]any)
require.Len(t, messages, 1)
message := messages[0].(map[string]any)
assert.Equal(t, float64(1), message["account_id"])
assert.Equal(t, float64(0), message["message_type"])
assert.Equal(t, float64(1700000000), message["created_at"])
assert.Equal(t, float64(42), message["conversation_id"])
@@ -521,6 +525,7 @@ func TestSearchHandler_SearchMessages_HydratesChatwootMessagePayload(t *testing.
messages := payload["messages"].([]any)
require.Len(t, messages, 1)
got := messages[0].(map[string]any)
assert.Equal(t, float64(account.ID), got["account_id"])
assert.Equal(t, float64(displayID), got["conversation_id"])
sender := got["sender"].(map[string]any)
assert.Equal(t, "Agent One", sender["name"])