Skip to content

Commit 151507c

Browse files
committed
use openTextDocument helper
1 parent da22b2a commit 151507c

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

packages/amazonq/test/e2e/amazonq/testGen.test.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { FollowUpTypes } from 'aws-core-vscode/amazonq'
1616
import { registerAuthHook, using } from 'aws-core-vscode/test'
1717
import { loginToIdC } from './utils/setup'
1818
import { globals } from 'aws-core-vscode/shared'
19+
import { openTextDocument } from 'aws-core-vscode/shared'
1920

2021
describe('Amazon Q Test Generation', function () {
2122
let framework: qTestingFramework
@@ -92,13 +93,8 @@ describe('Amazon Q Test Generation', function () {
9293
const { language, filePath } = unsupportedLanguages[0]
9394

9495
beforeEach(async () => {
95-
const found = await vscode.workspace.findFiles(filePath)
96-
if (found.length === 0) {
97-
assert.fail(`Failed to find ${language} file`)
98-
}
96+
const document = await openTextDocument(filePath)
9997

100-
await vscode.commands.executeCommand('vscode.open', found[0])
101-
const document = vscode.workspace.textDocuments.find((o) => o.uri.fsPath.includes(found[0].fsPath))
10298
if (!document) {
10399
assert.fail(`Failed to open ${language} file`)
104100
}
@@ -185,13 +181,8 @@ describe('Amazon Q Test Generation', function () {
185181
beforeEach(async () => {
186182
// retry mechanism as loading active document can be sometimes flaky
187183
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-
}
184+
const document = await openTextDocument(filePath)
192185

193-
await vscode.commands.executeCommand('vscode.open', found[0])
194-
const document = vscode.workspace.textDocuments.find((o) => o.uri.fsPath.includes(found[0].fsPath))
195186
if (!document) {
196187
if (attempt === 3) {
197188
assert.fail(`Failed to open ${language} file`)

packages/core/src/shared/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export { AmazonqCreateUpload, Metric } from './telemetry/telemetry'
3030
export { getClientId, getOperatingSystem } from './telemetry/util'
3131
export { extensionVersion } from './vscode/env'
3232
export { cast } from './utilities/typeConstructors'
33+
export { openTextDocument } from './utilities/workspaceUtils'
3334
export {
3435
CodewhispererUserTriggerDecision,
3536
CodewhispererLanguage,

0 commit comments

Comments
 (0)