Skip to content

test(amazonq): add more tests for /transform #6183

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
merged 16 commits into from
Dec 9, 2024
Merged

Conversation

dhasani23
Copy link
Contributor

Problem

/transform could benefit from more test coverage.

Solution

Add tests.


  • 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.

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

@dhasani23 dhasani23 requested review from a team as code owners December 8, 2024 01:18
authType = 'awsId'
}
return authType
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This above function was previously in transformApiHandler.ts, just moving it here so it's in a shared utils file

assert.strictEqual(usesHttpsAndExpiresAfter60Seconds, true)
})

it('WHEN zipCode THEN ZIP contains all expected files and no unexpected files', async function () {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this test to the file above with the other zipCode tests

@@ -35,10 +34,6 @@ describe('transformByQ', async function () {
await fs.writeFile(tempFilePath, 'sample content for the test file')
transformByQState.setProjectPath(tempDir)
const zipCodeResult = await zipCode({
dependenciesFolder: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not used for these tests

Copy link
Contributor Author

@dhasani23 dhasani23 Dec 8, 2024

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/runIntegrationTests to trigger them

Copy link
Contributor

Choose a reason for hiding this comment

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

They are also run automatically after merging.


describe('Starting a transformation from chat', () => {
it('Can click through all user input forms for a Java upgrade', async () => {
sinon.stub(startTransformByQ, 'getValidSQLConversionCandidateProjects').resolves([])
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 stub some validation-related logic in this test file because 1) we already have unit test coverage of those, and 2) these tests are just as useful even with mocked validation functions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, but when things change in the implementation (e.g. using Flare), stubs/mocks will break easily. Thanks for calling this out in any case.

@dhasani23
Copy link
Contributor Author

dhasani23 commented Dec 9, 2024

test/e2e/amazonq/transformByQ.test.ts:

image

@@ -6,4 +6,7 @@
export { activate } from './activation'
export { default as DependencyVersions } from './models/dependencies'
export { default as MessengerUtils } from './chat/controller/messenger/messengerUtils'
export { GumbyController } from './chat/controller/controller'
export { TabsStorage } from '../amazonq/webview/ui/storages/tabsStorage'
export * as startTransformByQ from '../../src/codewhisperer/commands/startTransformByQ'
Copy link
Contributor Author

@dhasani23 dhasani23 Dec 9, 2024

Choose a reason for hiding this comment

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

I'm unable to run the tests in packages/amazonq/test/e2e/amazonq/transformByQ.test.ts by importing these things from the core module directly where they're defined, as I get an import error when doing that. So instead I have to export them here and then (in the test file, line 11) import them from here.

@dhasani23
Copy link
Contributor Author

/runIntegrationTests

@dhasani23
Copy link
Contributor Author

/runIntegrationTests

@dhasani23
Copy link
Contributor Author

/runIntegrationTests

@dhasani23
Copy link
Contributor Author

/runIntegrationTests

@dhasani23 dhasani23 marked this pull request as draft December 9, 2024 20:38
@dhasani23
Copy link
Contributor Author

/runIntegrationTests

@dhasani23
Copy link
Contributor Author

/runIntegrationTests

@dhasani23
Copy link
Contributor Author

/runIntegrationTests

@dhasani23 dhasani23 marked this pull request as ready for review December 9, 2024 21:50

before(async function () {
await using(registerAuthHook('amazonq-test-account'), async () => {
await loginToIdC()
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 if these tests are using the actual service, then e2e is the right place for them.

@justinmk3 justinmk3 merged commit b80529e into aws:master Dec 9, 2024
32 of 33 checks passed
karanA-aws pushed a commit to karanA-aws/aws-toolkit-vscode that referenced this pull request Jan 17, 2025
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.

3 participants