@@ -42,6 +42,16 @@ describe('Amazon Q Inline', async function () {
4242
4343 afterEach ( async function ( ) {
4444 await closeAllEditors ( )
45+ if ( this . currentTest ?. state === undefined || this . currentTest ?. isFailed ( ) || this . currentTest ?. isPending ( ) ) {
46+ const events = getEvents ( 'codewhisperer_userTriggerDecision' )
47+ console . table ( {
48+ 'telemetry events' : JSON . stringify ( events ) ,
49+ 'suggestions states' : JSON . stringify ( session . suggestionStates ) ,
50+ 'valid recommendation' : RecommendationHandler . instance . isValidResponse ( ) ,
51+ 'recommendation service status' : RecommendationService . instance . isRunning ,
52+ recommendations : session . recommendations ,
53+ } )
54+ }
4555 } )
4656
4757 async function setupEditor ( { name, contents } : { name ?: string; contents ?: string } = { } ) {
@@ -82,19 +92,23 @@ describe('Amazon Q Inline', async function () {
8292 } )
8393 return events . some ( ( event ) => event . codewhispererSuggestionState === suggestionState )
8494 } , waitOptions )
85- const events = globals . telemetry . logger
86- . query ( {
87- metricName,
88- } )
89- . map ( ( e ) => collectionUtil . partialClone ( e , 3 , [ 'credentialStartUrl' ] , '[omitted]' ) )
9095 if ( ! ok ) {
91- assert. fail ( `Telemetry failed to be emitted. Current events: ${ JSON . stringify ( events ) } ` )
96+ assert. fail ( `Telemetry for ${ metricName } with suggestionState ${ suggestionState } was not emitted ` )
9297 }
98+ const events = getEvents ( metricName )
9399 if ( events . length > 1 && events [ events . length - 1 ] . codewhispererSuggestionState !== suggestionState ) {
94- assert. fail ( `Telemetry events were emitted in the wrong order. Current events: ${ JSON . stringify ( events ) } ` )
100+ assert. fail ( `Telemetry events were emitted in the wrong order` )
95101 }
96102 }
97103
104+ function getEvents ( metricName : string) {
105+ return globals . telemetry . logger
106+ . query ( {
107+ metricName,
108+ } )
109+ . map ( ( e ) => collectionUtil . partialClone ( e , 3 , [ 'credentialStartUrl' ] , '[omitted]' ) )
110+ }
111+
98112 for ( const [ name , invokeCompletion ] of [
99113 [ 'automatic' , async ( ) => await vscode . commands . executeCommand ( 'type' , { text : '\n' } ) ] ,
100114 [ 'manual' , async ( ) => Commands . tryExecute ( 'aws.amazonq.invokeInlineCompletion' ) ] ,
@@ -122,7 +136,7 @@ describe('Amazon Q Inline', async function () {
122136 */
123137 await waitUntil ( async ( ) => {
124138 console . log (
125- `Waiting for recommenation to service to settle. Current status: ${ RecommendationService . instance . isRunning } `
139+ `Waiting for recommendation service to settle. Current status: ${ RecommendationService . instance . isRunning } `
126140 )
127141 return ! RecommendationService . instance . isRunning
128142 } , waitOptions )
0 commit comments