-
Notifications
You must be signed in to change notification settings - Fork 575
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
Changes from all commits
5c1d84d
d7fd12a
e3c044c
ec64432
ff72ea1
599e8c1
24093c1
8c47d58
d21a334
2b3fe64
2b51d02
85bdfef
1d1fa50
e451f5b
533d55f
5dbbf63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm unable to run the tests in |
||
export * from './errors' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ import { formatError, ToolkitError } from '../shared/errors' | |
import { asString } from './providers/credentials' | ||
import { TreeNode } from '../shared/treeview/resourceTreeDataProvider' | ||
import { createInputBox } from '../shared/ui/inputPrompter' | ||
import { telemetry } from '../shared/telemetry/telemetry' | ||
import { CredentialSourceId, telemetry } from '../shared/telemetry/telemetry' | ||
import { createCommonButtons, createExitButton, createHelpButton, createRefreshButton } from '../shared/ui/buttons' | ||
import { getIdeProperties, isAmazonQ, isCloud9 } from '../shared/extensionUtilities' | ||
import { addScopes, getDependentAuths } from './secondaryAuth' | ||
|
@@ -45,7 +45,7 @@ import { Commands, placeholder } from '../shared/vscode/commands2' | |
import { Auth } from './auth' | ||
import { validateIsNewSsoUrl, validateSsoUrlFormat } from './sso/validation' | ||
import { getLogger } from '../shared/logger' | ||
import { isValidAmazonQConnection, isValidCodeWhispererCoreConnection } from '../codewhisperer/util/authUtil' | ||
import { AuthUtil, isValidAmazonQConnection, isValidCodeWhispererCoreConnection } from '../codewhisperer/util/authUtil' | ||
import { AuthFormId } from '../login/webview/vue/types' | ||
import { extensionVersion } from '../shared/vscode/env' | ||
import { ExtStartUpSources } from '../shared/telemetry' | ||
|
@@ -798,3 +798,13 @@ export function initializeCredentialsProviderManager() { | |
manager.addProviderFactory(new SharedCredentialsProviderFactory()) | ||
manager.addProviders(new Ec2CredentialsProvider(), new EcsCredentialsProvider(), new EnvVarsCredentialsProvider()) | ||
} | ||
|
||
export async function getAuthType() { | ||
let authType: CredentialSourceId | undefined = undefined | ||
if (AuthUtil.instance.isEnterpriseSsoInUse() && AuthUtil.instance.isConnectionValid()) { | ||
authType = 'iamIdentityCenter' | ||
} else if (AuthUtil.instance.isBuilderIdInUse() && AuthUtil.instance.isConnectionValid()) { | ||
authType = 'awsId' | ||
} | ||
return authType | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This above function was previously in |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,11 +10,10 @@ import * as codeWhisperer from '../../codewhisperer/client/codewhisperer' | |
import assert from 'assert' | ||
import { getSha256, uploadArtifactToS3, zipCode } from '../../codewhisperer/service/transformByQ/transformApiHandler' | ||
import request from '../../shared/request' | ||
import AdmZip from 'adm-zip' | ||
import { setValidConnection } from '../util/connection' | ||
import { transformByQState, ZipManifest } from '../../codewhisperer/models/model' | ||
import globals from '../../shared/extensionGlobals' | ||
import { fs } from '../../shared' | ||
import { setValidConnection } from '../../testE2E/util/connection' | ||
|
||
describe('transformByQ', async function () { | ||
let tempDir = '' | ||
|
@@ -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: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not used for these tests |
||
path: tempFilePath, | ||
name: tempFileName, | ||
}, | ||
projectPath: tempDir, | ||
zipManifest: new ZipManifest(), | ||
}) | ||
|
@@ -87,7 +82,7 @@ describe('transformByQ', async function () { | |
) | ||
}) | ||
|
||
it('WHEN createUploadUrl THEN URL uses HTTPS and sets 60 second expiration', async function () { | ||
it('WHEN createUploadUrl THEN URL uses HTTPS and sets 30 minute expiration', async function () { | ||
const buffer = Buffer.from(await fs.readFileBytes(zippedCodePath)) | ||
const sha256 = getSha256(buffer) | ||
const response = await codeWhisperer.codeWhispererClient.createUploadUrl({ | ||
|
@@ -96,17 +91,8 @@ describe('transformByQ', async function () { | |
uploadIntent: CodeWhispererConstants.uploadIntent, | ||
}) | ||
const uploadUrl = response.uploadUrl | ||
const usesHttpsAndExpiresAfter60Seconds = uploadUrl.includes('https') && uploadUrl.includes('X-Amz-Expires=60') | ||
assert.strictEqual(usesHttpsAndExpiresAfter60Seconds, true) | ||
}) | ||
|
||
it('WHEN zipCode THEN ZIP contains all expected files and no unexpected files', async function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved this test to the file above with the other |
||
const zipFiles = new AdmZip(zippedCodePath).getEntries() | ||
const zipFileNames: string[] = [] | ||
zipFiles.forEach((file) => { | ||
zipFileNames.push(file.name) | ||
}) | ||
assert.strictEqual(zipFileNames.length, 2) // expecting only a dummy txt file and a manifest.json | ||
assert.strictEqual(zipFileNames.includes(tempFileName) && zipFileNames.includes('manifest.json'), true) | ||
const usesHttpsAndExpiresAfter30Minutes = | ||
uploadUrl.includes('https') && uploadUrl.includes('X-Amz-Expires=1800') | ||
assert.strictEqual(usesHttpsAndExpiresAfter30Minutes, true) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How often will these tests be run & do they have to be manually triggered?
Modeled from: https://github.com/aws/aws-toolkit-vscode/blob/38850f7c941cc4fbd56e9b9bcb8bd5681c7dbf73/packages/amazonq/test/e2e/amazonq/featureDev.test.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/runIntegrationTests to trigger them
There was a problem hiding this comment.
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.