@@ -15,7 +15,6 @@ import { Messenger } from './framework/messenger'
1515import { FollowUpTypes } from 'aws-core-vscode/amazonq'
1616import { registerAuthHook , using } from 'aws-core-vscode/test'
1717import { loginToIdC } from './utils/setup'
18- import { openDocument } from './utils/workspaceUtils'
1918import { globals } from 'aws-core-vscode/shared'
2019
2120describe ( 'Amazon Q Test Generation' , function ( ) {
@@ -93,7 +92,13 @@ describe('Amazon Q Test Generation', function () {
9392 const { language, filePath } = unsupportedLanguages [ 0 ]
9493
9594 beforeEach ( async ( ) => {
96- const document = await openDocument ( filePath )
95+ const found = await vscode . workspace . findFiles ( filePath )
96+ if ( found . length === 0 ) {
97+ assert . fail ( `Failed to find ${ language } file` )
98+ }
99+
100+ await vscode . commands . executeCommand ( 'vscode.open' , found [ 0 ] )
101+ const document = vscode . workspace . textDocuments . find ( ( o ) => o . uri . fsPath . includes ( found [ 0 ] . fsPath ) )
97102 if ( ! document ) {
98103 assert . fail ( `Failed to open ${ language } file` )
99104 }
@@ -179,8 +184,14 @@ describe('Amazon Q Test Generation', function () {
179184 describe ( `Test Generation for ${ language } ` , ( ) => {
180185 beforeEach ( async ( ) => {
181186 // retry mechanism as loading active document can be sometimes flaky
182- for ( let attempt = 1 ; attempt < 3 ; attempt ++ ) {
183- const document = await openDocument ( filePath )
187+ for ( let attempt = 1 ; attempt <= 3 ; attempt ++ ) {
188+ const found = await vscode . workspace . findFiles ( filePath )
189+ if ( found . length === 0 ) {
190+ assert . fail ( `Failed to find ${ language } file` )
191+ }
192+
193+ await vscode . commands . executeCommand ( 'vscode.open' , found [ 0 ] )
194+ const document = vscode . workspace . textDocuments . find ( ( o ) => o . uri . fsPath . includes ( found [ 0 ] . fsPath ) )
184195 if ( ! document ) {
185196 if ( attempt === 3 ) {
186197 assert . fail ( `Failed to open ${ language } file` )
0 commit comments