@@ -186,6 +186,19 @@ export class Assistant {
186
186
await expect ( this . code . driver . page . locator ( '.token-usage' ) ) . not . toBeVisible ( ) ;
187
187
}
188
188
189
+ async verifyTotalTokenUsageVisible ( ) {
190
+ await expect ( this . code . driver . page . locator ( '.token-usage-total' ) ) . toBeVisible ( ) ;
191
+ await expect ( this . code . driver . page . locator ( '.token-usage-total' ) ) . toHaveText ( / T o t a l t o k e n s : ↑ \d + ↓ \d + / ) ;
192
+ }
193
+
194
+ async verifyNumberOfVisibleResponses ( expectedCount : number , checkTokenUsage : boolean = false ) {
195
+ const responses = this . code . driver . page . locator ( '.interactive-response' ) ;
196
+ await expect ( responses ) . toHaveCount ( expectedCount ) ;
197
+ if ( checkTokenUsage ) {
198
+ this . code . driver . page . locator ( '.token-usage' ) . nth ( expectedCount - 1 ) . waitFor ( { state : 'visible' } ) ;
199
+ }
200
+ }
201
+
189
202
async getTokenUsage ( ) {
190
203
const tokenUsageElement = this . code . driver . page . locator ( '.token-usage' ) ;
191
204
await expect ( tokenUsageElement ) . toBeVisible ( ) ;
@@ -198,4 +211,22 @@ export class Assistant {
198
211
outputTokens : outputMatch ? parseInt ( outputMatch [ 1 ] , 10 ) : 0
199
212
} ;
200
213
}
214
+
215
+ async getTotalTokenUsage ( ) {
216
+ const totalTokenUsageElement = this . code . driver . page . locator ( '.token-usage-total' ) ;
217
+ await expect ( totalTokenUsageElement ) . toBeVisible ( ) ;
218
+ const text = await totalTokenUsageElement . textContent ( ) ;
219
+ console . log ( 'Total Token Usage Text:' , text ) ;
220
+ expect ( text ) . not . toBeNull ( ) ;
221
+ const totalMatch = text ? text . match ( / T o t a l t o k e n s : ↑ ( \d + ) ↓ ( \d + ) / ) : null ;
222
+ return {
223
+ inputTokens : totalMatch ? parseInt ( totalMatch [ 1 ] , 10 ) : 0 ,
224
+ outputTokens : totalMatch ? parseInt ( totalMatch [ 2 ] , 10 ) : 0
225
+ } ;
226
+ }
227
+
228
+ async waitForReadyToSend ( timeout : number = 5000 ) {
229
+ await this . code . driver . page . waitForSelector ( '.chat-input-toolbars .codicon-send' , { timeout } ) ;
230
+ await this . code . driver . page . waitForSelector ( '.detail-container .detail:has-text("Working")' , { state : 'hidden' , timeout } ) ;
231
+ }
201
232
}
0 commit comments