Skip to content

fix(/dev): source folder modification now allows any sub-folder #4489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

sannicm
Copy link
Contributor

@sannicm sannicm commented May 17, 2024

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

The source folder modification happens when the customers repository is too big for uploading and /dev allows the customer to select a new source folder from within their working project. Until now, this check was faulty as it would only check for one level of sub-folder from the root, now it is any level. And of course, folders outside the workspace are not allowed. Workspace being for VSCode the project's root.

Before:

yes (root): root 
yes (root's subfolder): root/sub-folder
no (any sub-folder level): root/sub-folder/sub-sub-folder/... 
no (folder outside the root): other-root/folder

Now:

yes (root): root 
yes (root's subfolder): root/sub-folder
yes (any sub-folder level): root/sub-folder/sub-sub-folder/... 
no (folder outside the root): other-root/folder

Checklist

  • My code follows the code style of this project
  • [n/a] I have added tests to cover my changes
  • [n/a] A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • [n/a] I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sannicm sannicm requested a review from a team as a code owner May 17, 2024 15:04
@sannicm sannicm force-pushed the sannicm/fix/modifySourceFolderWorkspaceCheck branch from 11ee25b to ecbf5c6 Compare May 21, 2024 11:16
@sannicm sannicm force-pushed the sannicm/fix/modifySourceFolderWorkspaceCheck branch from ecbf5c6 to 89d6310 Compare May 29, 2024 12:28
@sannicm sannicm requested a review from a team as a code owner May 29, 2024 12:28
@sannicm sannicm force-pushed the sannicm/fix/modifySourceFolderWorkspaceCheck branch 2 times, most recently from 36118ff to 9322415 Compare May 30, 2024 14:50
@@ -66,9 +66,10 @@ class FeatureDevSessionContext(val project: Project, val maxProjectSizeBytes: Lo
"dist/"
).map { Regex(it) }

private var _projectRoot = project.guessProjectDir() ?: error("Cannot guess base directory for project ${project.name}")
val projectRoot = project.guessProjectDir() ?: error("Cannot guess base directory for project ${project.name}")
private var _currentRoot = projectRoot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question]: I wonder if this is a well-descriptive name or not. Maybe selectedFolder would be better? Since this isn't a root folder anymore.

Also, it would help to have some comments in the code to describe what is projectRoot for and what is currentRoot for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, yes, it could be made more similar even to what the feature is about, i.e. selectedSourceFolder, and I'll add comments as well, sure.

@sannicm sannicm force-pushed the sannicm/fix/modifySourceFolderWorkspaceCheck branch 2 times, most recently from 585933b to 2054699 Compare June 3, 2024 11:05
@@ -390,4 +394,119 @@ class FeatureDevControllerTest : FeatureDevTestBase() {
newFileContentsCopy[0].rejected = !newFileContentsCopy[0].rejected
coVerify { messenger.updateFileComponent(testTabId, newFileContentsCopy, deletedFiles, "") }
}

@Test
fun `test modifyDefaultSourceFolder customer does not select a folder`() = runTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we adding the runTest call here specifically?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the test is verifying and running coroutines and need to be under a scope, it feels cleaner to add the runTest enclosing the whole test.

whenever(featureDevClient.createTaskAssistConversation()).thenReturn(exampleCreateTaskAssistConversationResponse)
whenever(chatSessionStorage.getSession(any(), any())).thenReturn(spySession)

mockkObject(AmazonqTelemetry)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep the telemetry portion separate from the implementation, not sure why we are mocking telemetry here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The telemetry sends network events, so mocking to me felt right to verify the object's function modifySourceFolder was being called with the expected arguments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The telemetry call here is a no-op in the test and anyway telemetry calls are automatically skipped for tests so we needn't mock telemetry here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm removing the verification

@sannicm sannicm force-pushed the sannicm/fix/modifySourceFolderWorkspaceCheck branch 3 times, most recently from f24e867 to ebd8954 Compare June 11, 2024 08:56
@sannicm sannicm force-pushed the sannicm/fix/modifySourceFolderWorkspaceCheck branch from ebd8954 to 1892fca Compare June 12, 2024 08:28
Copy link

Quality Gate Passed Quality Gate passed

Issues
5 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@sannicm sannicm merged commit 6759455 into aws:main Jun 12, 2024
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants