55
66import * as vscode from 'vscode'
77import assert from 'assert'
8- import {
9- closeAllEditors ,
10- getTestWindow ,
11- registerAuthHook ,
12- resetCodeWhispererGlobalVariables ,
13- TestFolder ,
14- toTextEditor ,
15- using ,
16- } from 'aws-core-vscode/test'
17- import { RecommendationService } from 'aws-core-vscode/codewhisperer'
8+ import { closeAllEditors , registerAuthHook , TestFolder , toTextEditor , using } from 'aws-core-vscode/test'
189import { Commands , globals , sleep , waitUntil , collectionUtil } from 'aws-core-vscode/shared'
1910import { loginToIdC } from '../amazonq/utils/setup'
11+ import { vsCodeState } from 'aws-core-vscode/codewhisperer'
2012
2113describe ( 'Amazon Q Inline' , async function ( ) {
2214 const retries = 3
@@ -40,7 +32,6 @@ describe('Amazon Q Inline', async function () {
4032 const folder = await TestFolder . create ( )
4133 tempFolder = folder . path
4234 await closeAllEditors ( )
43- await resetCodeWhispererGlobalVariables ( )
4435 } )
4536
4637 afterEach ( async function ( ) {
@@ -54,7 +45,6 @@ describe('Amazon Q Inline', async function () {
5445 const events = getUserTriggerDecision ( )
5546 console . table ( {
5647 'telemetry events' : JSON . stringify ( events ) ,
57- 'recommendation service status' : RecommendationService . instance . isRunning ,
5848 } )
5949 }
6050
@@ -123,6 +113,10 @@ describe('Amazon Q Inline', async function () {
123113
124114 await invokeCompletion ( )
125115 originalEditorContents = vscode . window . activeTextEditor ?. document . getText ( )
116+
117+ // wait until all the recommendations have finished
118+ await waitUntil ( ( ) => Promise . resolve ( vsCodeState . isRecommendationsActive === true ) , waitOptions )
119+ await waitUntil ( ( ) => Promise . resolve ( vsCodeState . isRecommendationsActive === false ) , waitOptions )
126120 }
127121
128122 beforeEach ( async ( ) => {
@@ -135,14 +129,12 @@ describe('Amazon Q Inline', async function () {
135129 try {
136130 await setup ( )
137131 console . log ( `test run ${ attempt } succeeded` )
138- logUserDecisionStatus ( )
139132 break
140133 } catch ( e ) {
141134 console . log ( `test run ${ attempt } failed` )
142135 console . log ( e )
143136 logUserDecisionStatus ( )
144137 attempt ++
145- await resetCodeWhispererGlobalVariables ( )
146138 }
147139 }
148140 if ( attempt === retries ) {
@@ -188,29 +180,6 @@ describe('Amazon Q Inline', async function () {
188180 assert . deepStrictEqual ( vscode . window . activeTextEditor ?. document . getText ( ) , originalEditorContents )
189181 } )
190182 } )
191-
192- it . skip ( `${ name } invoke on unsupported filetype` , async function ( ) {
193- await setupEditor ( {
194- name : 'test.zig' ,
195- contents : `fn doSomething() void {
196-
197- }` ,
198- } )
199-
200- /**
201- * Add delay between editor loading and invoking completion
202- * @see beforeEach in supported filetypes for more information
203- */
204- await sleep ( 1000 )
205- await invokeCompletion ( )
206-
207- if ( name === 'automatic' ) {
208- // It should never get triggered since its not a supported file type
209- assert . deepStrictEqual ( RecommendationService . instance . isRunning , false )
210- } else {
211- await getTestWindow ( ) . waitForMessage ( 'currently not supported by Amazon Q inline suggestions' )
212- }
213- } )
214183 } )
215184 }
216185} )
0 commit comments