Skip to content

Commit 4e56897

Browse files
authored
fix(amazonq): Test generation shows incorrect view diff view (aws#6676)
## Problem - When users attempt to generate unit test cases using the /test command for packages other than the primary one in the workspace, they encounter a diff view suggesting the absence of an existing file. However, this is incorrect as there is already an existing test file in the package. ## Solution - Fixed this issue by getting the project path from the target file. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 59e1c3c commit 4e56897

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Amazon Q /test: Unit test generation displays an inaccurate diff view for non-primary packages in the workspace."
4+
}

packages/core/src/amazonqTest/chat/controller/controller.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -678,12 +678,7 @@ export class TestController {
678678
private async openDiff(message: OpenDiffMessage) {
679679
const session = this.sessionStorage.getSession()
680680
const filePath = session.generatedFilePath
681-
const workspaceFolder = vscode.workspace.workspaceFolders?.[0]
682-
if (!workspaceFolder) {
683-
throw new Error('No workspace folder found')
684-
}
685-
const projectPath = workspaceFolder.uri.fsPath
686-
const absolutePath = path.join(projectPath, filePath)
681+
const absolutePath = path.join(session.projectRootPath, filePath)
687682
const fileExists = await fs.existsFile(absolutePath)
688683
const leftUri = fileExists ? vscode.Uri.file(absolutePath) : vscode.Uri.from({ scheme: 'untitled' })
689684
const rightUri = vscode.Uri.file(path.join(this.tempResultDirPath, 'resultArtifacts', filePath))

0 commit comments

Comments
 (0)