@@ -44,6 +44,7 @@ vi.mock("../runtime-api.js", async (importOriginal) => {
4444 } ;
4545} ) ;
4646
47+ import { fetchChannelMessage , fetchThreadReplies } from "./graph-thread.js" ;
4748import { findGraphUsersByExactIdentity , searchGraphUsers } from "./graph-users.js" ;
4849import {
4950 deleteGraphRequest ,
@@ -216,6 +217,39 @@ describe("msteams graph helpers", () => {
216217 expect ( escapeOData ( "alice.o'hara" ) ) . toBe ( "alice.o''hara" ) ;
217218 } ) ;
218219
220+ it ( "keeps channel parent and reply requests within their Graph query contracts" , async ( ) => {
221+ const parent = { id : "parent-1" , body : { content : "Original question" } } ;
222+ const reply = { id : "reply-1" , body : { content : "Earlier decision" } } ;
223+ mockFetch ( async ( input : string | URL | Request ) => {
224+ const url = new URL ( requestUrl ( input ) ) ;
225+ const isReplies = url . pathname . endsWith ( "/replies" ) ;
226+ const unsupported = [ ...url . searchParams . keys ( ) ] . filter (
227+ ( parameter ) => ! isReplies || parameter !== "$top" ,
228+ ) ;
229+ return jsonResponse (
230+ unsupported . length > 0
231+ ? { error : { code : "BadRequest" , message : "Unsupported query parameter" } }
232+ : isReplies
233+ ? graphCollection ( reply )
234+ : parent ,
235+ unsupported . length > 0 ? { status : 400 } : undefined ,
236+ ) ;
237+ } ) ;
238+
239+ const outcomes = await Promise . allSettled ( [
240+ fetchChannelMessage ( graphToken , "group-1" , "channel-1" , "parent-1" ) ,
241+ fetchThreadReplies ( graphToken , "group-1" , "channel-1" , "parent-1" ) ,
242+ ] ) ;
243+
244+ expect ( outcomes ) . toEqual ( [
245+ { status : "fulfilled" , value : parent } ,
246+ { status : "fulfilled" , value : [ reply ] } ,
247+ ] ) ;
248+ expect ( fetchCallSearchParam ( 0 , "$select" ) ) . toBeNull ( ) ;
249+ expect ( fetchCallSearchParam ( 1 , "$select" ) ) . toBeNull ( ) ;
250+ expect ( fetchCallSearchParam ( 1 , "$top" ) ) . toBe ( "50" ) ;
251+ } ) ;
252+
219253 it ( "lets the shared SSRF guard select the Graph transport" , async ( ) => {
220254 mockGraphCollection ( ) ;
221255
0 commit comments