@@ -114,4 +114,54 @@ describe("qqbot message adapter", () => {
114114 expect ( proofResults . find ( ( result ) => result . capability === "media" ) ?. status ) . toBe ( "verified" ) ;
115115 expect ( proofResults . find ( ( result ) => result . capability === "replyTo" ) ?. status ) . toBe ( "verified" ) ;
116116 } ) ;
117+
118+ it ( "rejects media sends when QQBot reports an outbound error" , async ( ) => {
119+ sendMediaMock . mockResolvedValue ( { error : "QQ API returned 400 Bad Request" } ) ;
120+
121+ await expect (
122+ qqbotPlugin . message ?. send ?. media ?.( {
123+ cfg,
124+ to : "qqbot:c2c:user-1" ,
125+ text : "image" ,
126+ mediaUrl : "https://example.com/image.png" ,
127+ } ) ,
128+ ) . rejects . toThrow ( "QQ API returned 400 Bad Request" ) ;
129+ } ) ;
130+
131+ it ( "rejects text sends when QQBot reports an outbound error" , async ( ) => {
132+ sendTextMock . mockResolvedValue ( { error : "QQ API returned 400 Bad Request" } ) ;
133+
134+ await expect (
135+ qqbotPlugin . message ?. send ?. text ?.( {
136+ cfg,
137+ to : "qqbot:c2c:user-1" ,
138+ text : "hello" ,
139+ } ) ,
140+ ) . rejects . toThrow ( "QQ API returned 400 Bad Request" ) ;
141+ } ) ;
142+
143+ it ( "rejects media sends without a QQ platform message id" , async ( ) => {
144+ sendMediaMock . mockResolvedValue ( { } ) ;
145+
146+ await expect (
147+ qqbotPlugin . message ?. send ?. media ?.( {
148+ cfg,
149+ to : "qqbot:c2c:user-1" ,
150+ text : "image" ,
151+ mediaUrl : "https://example.com/image.png" ,
152+ } ) ,
153+ ) . rejects . toThrow ( "QQBot message adapter send did not return a platform message id" ) ;
154+ } ) ;
155+
156+ it ( "rejects text sends without a QQ platform message id" , async ( ) => {
157+ sendTextMock . mockResolvedValue ( { } ) ;
158+
159+ await expect (
160+ qqbotPlugin . message ?. send ?. text ?.( {
161+ cfg,
162+ to : "qqbot:c2c:user-1" ,
163+ text : "hello" ,
164+ } ) ,
165+ ) . rejects . toThrow ( "QQBot message adapter send did not return a platform message id" ) ;
166+ } ) ;
117167} ) ;
0 commit comments