@@ -5,7 +5,10 @@ import {
55 buildRawTriggerInputFromTimelineCandidate ,
66 toCanonicalExecutionInput ,
77} from "../../src/engagement/candidateBoundary.js" ;
8- import { maybeBuildConversationBundle } from "../../src/engagement/conversationBundle.js" ;
8+ import {
9+ buildConversationParentRef ,
10+ maybeBuildConversationBundle ,
11+ } from "../../src/engagement/conversationBundle.js" ;
912
1013describe ( "candidateBoundary" , ( ) => {
1114 it ( "normalizes mention ingress into the shared candidate boundary" , ( ) => {
@@ -23,6 +26,10 @@ describe("candidateBoundary", () => {
2326 const candidate = buildEngagementCandidate ( raw ) ;
2427 const bundle = maybeBuildConversationBundle ( {
2528 candidate,
29+ parentRef : buildConversationParentRef ( {
30+ tweetId : "parent-mention-1" ,
31+ conversationId : candidate . conversationId ,
32+ } ) ,
2633 sourceTweet : {
2734 tweetId : candidate . tweetId ,
2835 conversationId : candidate . conversationId ,
@@ -44,6 +51,7 @@ describe("candidateBoundary", () => {
4451 expect ( candidate . candidateId ) . toBe ( "mention-1" ) ;
4552 expect ( candidate . normalizedText ) . toBe ( "Hello @Gnomes_onchain, can you help?" ) ;
4653 expect ( bundle ?. sourceTweet ?. tweetId ) . toBe ( "mention-1" ) ;
54+ expect ( bundle ?. parentRef ?. tweetId ) . toBe ( "parent-mention-1" ) ;
4755 expect ( bundle ?. authorContext ?. authorHandle ) . toBe ( "Alice" ) ;
4856 expect ( canonical . event_id ) . toBe ( "mention-1" ) ;
4957 expect ( canonical . trigger_type ) . toBe ( "mention" ) ;
@@ -92,6 +100,10 @@ describe("candidateBoundary", () => {
92100 const candidate = buildEngagementCandidate ( raw ) ;
93101 const bundle = maybeBuildConversationBundle ( {
94102 candidate,
103+ parentRef : buildConversationParentRef ( {
104+ tweetId : "parent-tweet-1" ,
105+ conversationId : candidate . conversationId ,
106+ } ) ,
95107 sourceTweet : {
96108 tweetId : candidate . tweetId ,
97109 conversationId : candidate . conversationId ,
@@ -113,6 +125,7 @@ describe("candidateBoundary", () => {
113125 expect ( candidate . candidateId ) . toBe ( "timeline:tweet-1" ) ;
114126 expect ( candidate . normalizedText ) . toBe ( "A thoughtful timeline reply with a clear question?" ) ;
115127 expect ( bundle ?. sourceTweet ?. tweetId ) . toBe ( "tweet-1" ) ;
128+ expect ( bundle ?. parentRef ?. tweetId ) . toBe ( "parent-tweet-1" ) ;
116129 expect ( bundle ?. authorContext ?. sourceAccount ) . toBe ( "timeline" ) ;
117130 expect ( canonical . event_id ) . toBe ( "timeline:tweet-1" ) ;
118131 expect ( canonical . trigger_type ) . toBe ( "reply" ) ;
@@ -133,9 +146,16 @@ describe("candidateBoundary", () => {
133146 } ;
134147 const candidate = buildEngagementCandidate ( raw ) ;
135148
136- const bundle = maybeBuildConversationBundle ( { candidate } ) ;
149+ const bundle = maybeBuildConversationBundle ( {
150+ candidate,
151+ parentRef : buildConversationParentRef ( {
152+ tweetId : "parent-2" ,
153+ conversationId : candidate . conversationId ,
154+ } ) ,
155+ } ) ;
137156
138157 expect ( bundle ?. sourceTweet ?. tweetId ) . toBe ( "mention-2" ) ;
158+ expect ( bundle ?. parentRef ?. tweetId ) . toBe ( "parent-2" ) ;
139159 expect ( bundle ?. authorContext ?. authorId ) . toBe ( "author-3" ) ;
140160 expect ( bundle ?. sourceMetadata ?. authorHandle ) . toBe ( "alice" ) ;
141161 } ) ;
0 commit comments