@@ -42,6 +42,15 @@ 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+ } )
53+ }
4554 } )
4655
4756 async function setupEditor ( { name, contents } : { name ?: string; contents ?: string } = { } ) {
@@ -82,19 +91,23 @@ describe('Amazon Q Inline', async function () {
8291 } )
8392 return events . some ( ( event ) => event . codewhispererSuggestionState === suggestionState )
8493 } , waitOptions )
85- const events = globals . telemetry . logger
86- . query ( {
87- metricName,
88- } )
89- . map ( ( e ) => collectionUtil . partialClone ( e , 3 , [ 'credentialStartUrl' ] , '[omitted]' ) )
9094 if ( ! ok ) {
91- assert. fail ( `Telemetry failed to be emitted. Current events: ${ JSON . stringify ( events ) } ` )
95+ assert. fail ( `Telemetry for ${ metricName } with suggestionState ${ suggestionState } was not emitted ` )
9296 }
97+ const events = getEvents ( metricName )
9398 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 ) } ` )
99+ assert. fail ( `Telemetry events were emitted in the wrong order` )
95100 }
96101 }
97102
103+ function getEvents ( metricName : string) {
104+ return globals . telemetry . logger
105+ . query ( {
106+ metricName,
107+ } )
108+ . map ( ( e ) => collectionUtil . partialClone ( e , 3 , [ 'credentialStartUrl' ] , '[omitted]' ) )
109+ }
110+
98111 for ( const [ name , invokeCompletion ] of [
99112 [ 'automatic' , async ( ) => await vscode . commands . executeCommand ( 'type' , { text : '\n' } ) ] ,
100113 [ 'manual' , async ( ) => Commands . tryExecute ( 'aws.amazonq.invokeInlineCompletion' ) ] ,
@@ -122,7 +135,7 @@ describe('Amazon Q Inline', async function () {
122135 */
123136 await waitUntil ( async ( ) => {
124137 console . log (
125- `Waiting for recommenation to service to settle. Current status: ${ RecommendationService . instance . isRunning } `
138+ `Waiting for recommendation service to settle. Current status: ${ RecommendationService . instance . isRunning } `
126139 )
127140 return ! RecommendationService . instance . isRunning
128141 } , waitOptions )
0 commit comments