@@ -50,16 +50,15 @@ func slackHistoryReaderFor(t *testing.T, bot *chat.Chat) chat.HistoryReader {
5050 return hr
5151}
5252
53- // A history read inherits the adapter Observation Hook: the shared callWithToken
54- // seam emits ObsAdapterCall around the platform read, so observability is uniform
55- // with every other adapter API call (ADR 0010 + ADR 0009).
53+ // A history read inherits the adapter Observation Hook: the adapter's slackapi
54+ // client emits ObsAdapterCall around the platform read, as it does for every other
55+ // adapter API call (ADR 0010 + ADR 0009).
5656func TestSlackReadHistoryEmitsAdapterCallObservation (t * testing.T ) {
5757 t .Parallel ()
5858
5959 api := newSlackAPIServer (t )
60- api .historyResp = map [string ]any {
61- "ok" : true ,
62- "messages" : []any {map [string ]any {"type" : "message" , "user" : "U1" , "text" : "hi" , "ts" : "111.000" , "thread_ts" : "111.000" }},
60+ api .historyMessages = []map [string ]any {
61+ {"type" : "message" , "user" : "U1" , "text" : "hi" , "ts" : "111.000" , "thread_ts" : "111.000" },
6362 }
6463 obs := & countingObserver {}
6564 bot := newSlackHistoryRuntimeWithObserver (t , api .URL , api .Client (), obs )
@@ -171,41 +170,6 @@ func TestSlackReadHistoryDeadlineBounded(t *testing.T) {
171170 }
172171}
173172
174- // The direct-message path (conversations.history) honors Before (latest=<ts>,
175- // inclusive=false) and clamped limit together, proving cursor + clamping are wired
176- // on both read paths, not only conversations.replies.
177- func TestSlackReadHistoryDirectCursorAndClamp (t * testing.T ) {
178- t .Parallel ()
179-
180- api := newSlackAPIServer (t )
181- bot := newSlackHistoryRuntimeWithObserver (t , api .URL , api .Client (), nil )
182- hr := slackHistoryReaderFor (t , bot )
183-
184- id := slack .EncodeDirectThreadIDForTest ("T1" , "D1" )
185- if _ , err := hr .ReadHistory (context .Background (), id , chat.HistoryQuery {Limit : 9000 , Before : "222.000" }); err != nil {
186- t .Fatalf ("read history: %v" , err )
187- }
188- if len (api .historyReqs ) != 1 {
189- t .Fatalf ("history requests = %d, want 1" , len (api .historyReqs ))
190- }
191- req := api .historyReqs [0 ]
192- if req .Method != "/conversations.history" {
193- t .Fatalf ("method = %q, want conversations.history" , req .Method )
194- }
195- if req .Channel != "D1" {
196- t .Fatalf ("channel = %q, want D1" , req .Channel )
197- }
198- if req .TS != "" {
199- t .Fatalf ("conversations.history carried ts = %q, want empty (no thread root)" , req .TS )
200- }
201- if req .Latest != "222.000" || req .Inclusive {
202- t .Fatalf ("cursor mapping = latest %q inclusive %v, want 222.000/false" , req .Latest , req .Inclusive )
203- }
204- if req .Limit != 1000 {
205- t .Fatalf ("limit = %d, want clamped 1000" , req .Limit )
206- }
207- }
208-
209173// Golden multi-message payload: Slack returns thread replies oldest-first with the
210174// root first, and ReadHistory returns them newest-first with the root last, the
211175// bot's own message normalizes to BotBot with the bot user ID, history Messages are
@@ -215,14 +179,11 @@ func TestSlackReadHistoryGoldenPayloadNormalization(t *testing.T) {
215179 t .Parallel ()
216180
217181 api := newSlackAPIServer (t )
218- api .historyResp = map [string ]any {
219- "ok" : true ,
220- "messages" : []any {
221- map [string ]any {"type" : "message" , "user" : "U1" , "text" : "root" , "ts" : "111.000" , "thread_ts" : "111.000" },
222- map [string ]any {"type" : "message" , "user" : "U2" , "text" : "<@UBOT> hey" , "ts" : "112.000" , "thread_ts" : "111.000" , "edited" : map [string ]any {"user" : "U2" , "ts" : "112.100" }},
223- map [string ]any {"type" : "message" , "bot_id" : "BOTHER" , "subtype" : "bot_message" , "text" : "another bot" , "ts" : "112.500" , "thread_ts" : "111.000" },
224- map [string ]any {"type" : "message" , "user" : "UBOT" , "text" : "I am the bot" , "ts" : "113.000" , "thread_ts" : "111.000" },
225- },
182+ api .historyMessages = []map [string ]any {
183+ {"type" : "message" , "user" : "U1" , "text" : "root" , "ts" : "111.000" , "thread_ts" : "111.000" },
184+ {"type" : "message" , "user" : "U2" , "text" : "<@UBOT> hey" , "ts" : "112.000" , "thread_ts" : "111.000" , "edited" : map [string ]any {"user" : "U2" , "ts" : "112.100" }},
185+ {"type" : "message" , "bot_id" : "BOTHER" , "subtype" : "bot_message" , "text" : "another bot" , "ts" : "112.500" , "thread_ts" : "111.000" },
186+ {"type" : "message" , "user" : "UBOT" , "text" : "I am the bot" , "ts" : "113.000" , "thread_ts" : "111.000" },
226187 }
227188 bot := newSlackHistoryRuntimeWithObserver (t , api .URL , api .Client (), nil )
228189 hr := slackHistoryReaderFor (t , bot )
0 commit comments