Skip to content

Commit d398be4

Browse files
authored
Merge #3226 test: CodeCatalyst E2E
2 parents 2f126ec + 419e3b5 commit d398be4

File tree

9 files changed

+569
-293
lines changed

9 files changed

+569
-293
lines changed

.vscode/launch.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,24 @@
119119
},
120120
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
121121
"preLaunchTask": "${defaultBuildTask}"
122+
},
123+
{
124+
"name": "E2E Test (current file)",
125+
"type": "extensionHost",
126+
"request": "launch",
127+
"runtimeExecutable": "${execPath}",
128+
"args": [
129+
"${workspaceFolder}/dist/src/testFixtures/workspaceFolder",
130+
"--extensionDevelopmentPath=${workspaceFolder}",
131+
"--extensionTestsPath=${workspaceFolder}/dist/src/testE2E/index.js"
132+
],
133+
"env": {
134+
"TEST_FILE": "${relativeFile}",
135+
"DEVELOPMENT_PATH": "${workspaceFolder}",
136+
"AWS_TOOLKIT_AUTOMATION": "local"
137+
},
138+
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
139+
"preLaunchTask": "${defaultBuildTask}"
122140
}
123141
],
124142
"compounds": [

docs/TESTPLAN.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ The test suite has two categories of tests:
3333
- Global state is shared across tests, thus there is a risk that later tests are polluted by earlier tests.
3434
- Trigger VSCode commands and UI elements to test codepaths as from an actual user session, instead of invoking functions directly.
3535
- Do not use mocks.
36+
- E2E Tests: **slow** tests
37+
- Live in `src/testE2E`
38+
- These tests are heavier than Integration tests.
3639

3740
## Test files
3841

scripts/test/integrationTest.ts

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,8 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { join, resolve } from 'path'
7-
import { runTests } from '@vscode/test-electron'
8-
import { VSCODE_EXTENSION_ID } from '../../src/shared/extensions'
9-
import { installVSCodeExtension, setupVSCodeTestInstance, getCliArgsToDisableExtensions } from './launchTestUtilities'
10-
11-
const disableWorkspaceTrust = '--disable-workspace-trust'
12-
13-
async function setupVSCode(): Promise<string> {
14-
console.log('Setting up VS Code Test instance...')
15-
const vsCodeExecutablePath = await setupVSCodeTestInstance()
16-
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.python)
17-
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.yaml)
18-
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.go)
19-
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.java)
20-
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.javadebug)
21-
console.log('VS Code Test instance has been set up')
22-
return vsCodeExecutablePath
23-
}
24-
6+
import { resolve } from 'path'
7+
import { integrationSuite, runToolkitTests } from './launchTestUtilities'
258
;(async () => {
26-
try {
27-
console.log('Running Integration test suite...')
28-
const vsCodeExecutablePath = await setupVSCode()
29-
const cwd = process.cwd()
30-
const testEntrypoint = resolve(cwd, 'dist', 'src', 'integrationTest', 'index.js')
31-
const workspacePath = join(cwd, 'dist', 'src', 'testFixtures', 'workspaceFolder')
32-
console.log(`Starting tests: ${testEntrypoint}`)
33-
34-
const disableExtensions = await getCliArgsToDisableExtensions(vsCodeExecutablePath, {
35-
except: [
36-
VSCODE_EXTENSION_ID.python,
37-
VSCODE_EXTENSION_ID.yaml,
38-
VSCODE_EXTENSION_ID.jupyter,
39-
VSCODE_EXTENSION_ID.go,
40-
VSCODE_EXTENSION_ID.java,
41-
VSCODE_EXTENSION_ID.javadebug,
42-
VSCODE_EXTENSION_ID.git,
43-
],
44-
})
45-
const args = {
46-
vscodeExecutablePath: vsCodeExecutablePath,
47-
extensionDevelopmentPath: cwd,
48-
extensionTestsPath: testEntrypoint,
49-
launchArgs: [...disableExtensions, workspacePath, disableWorkspaceTrust],
50-
extensionTestsEnv: {
51-
['DEVELOPMENT_PATH']: cwd,
52-
['AWS_TOOLKIT_AUTOMATION']: 'integration',
53-
},
54-
}
55-
console.log(`runTests() args:\n${JSON.stringify(args, undefined, 2)}`)
56-
const result = await runTests(args)
57-
58-
console.log(`Finished running Integration test suite with result code: ${result}`)
59-
process.exit(result)
60-
} catch (err) {
61-
console.error(err)
62-
console.error('Failed to run tests')
63-
process.exit(1)
64-
}
9+
await runToolkitTests(integrationSuite, resolve('dist', 'src', 'integrationTest', 'index.js'))
6510
})()

scripts/test/launchTestUtilities.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66
import * as child_process from 'child_process'
77
import * as manifest from '../../package.json'
88
import { downloadAndUnzipVSCode, resolveCliArgsFromVSCodeExecutablePath } from '@vscode/test-electron'
9+
import { join, resolve } from 'path'
10+
import { runTests } from '@vscode/test-electron'
11+
import { VSCODE_EXTENSION_ID } from '../../src/shared/extensions'
912

1013
const envvarVscodeTestVersion = 'VSCODE_TEST_VERSION'
1114

1215
const stable = 'stable'
1316
const minimum = 'minimum'
1417

18+
const disableWorkspaceTrust = '--disable-workspace-trust'
19+
20+
export const integrationSuite = 'integration'
21+
export const e2eSuite = 'e2e'
22+
1523
/**
1624
* Downloads and unzips a copy of VS Code to run tests against.
1725
*
@@ -107,3 +115,57 @@ export function getMinVsCodeVersion(): string {
107115
console.log(`Using minimum VSCode version specified in package.json: ${sanitizedVersion}`)
108116
return sanitizedVersion
109117
}
118+
119+
async function setupVSCode(): Promise<string> {
120+
console.log('Setting up VS Code Test instance...')
121+
const vsCodeExecutablePath = await setupVSCodeTestInstance()
122+
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.python)
123+
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.yaml)
124+
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.go)
125+
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.java)
126+
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.javadebug)
127+
console.log('VS Code Test instance has been set up')
128+
return vsCodeExecutablePath
129+
}
130+
131+
export async function runToolkitTests(suiteName: string, relativeEntryPoint: string) {
132+
try {
133+
console.log(`Running ${suiteName} test suite...`)
134+
const vsCodeExecutablePath = await setupVSCode()
135+
const cwd = process.cwd()
136+
const testEntrypoint = resolve(cwd, relativeEntryPoint)
137+
const workspacePath = join(cwd, 'dist', 'src', 'testFixtures', 'workspaceFolder')
138+
console.log(`Starting tests: ${testEntrypoint}`)
139+
140+
const disableExtensions = await getCliArgsToDisableExtensions(vsCodeExecutablePath, {
141+
except: [
142+
VSCODE_EXTENSION_ID.python,
143+
VSCODE_EXTENSION_ID.yaml,
144+
VSCODE_EXTENSION_ID.jupyter,
145+
VSCODE_EXTENSION_ID.go,
146+
VSCODE_EXTENSION_ID.java,
147+
VSCODE_EXTENSION_ID.javadebug,
148+
VSCODE_EXTENSION_ID.git,
149+
],
150+
})
151+
const args = {
152+
vscodeExecutablePath: vsCodeExecutablePath,
153+
extensionDevelopmentPath: cwd,
154+
extensionTestsPath: testEntrypoint,
155+
launchArgs: [...disableExtensions, workspacePath, disableWorkspaceTrust],
156+
extensionTestsEnv: {
157+
['DEVELOPMENT_PATH']: cwd,
158+
['AWS_TOOLKIT_AUTOMATION']: suiteName,
159+
},
160+
}
161+
console.log(`runTests() args:\n${JSON.stringify(args, undefined, 2)}`)
162+
const result = await runTests(args)
163+
164+
console.log(`Finished running ${suiteName} test suite with result code: ${result}`)
165+
process.exit(result)
166+
} catch (err) {
167+
console.error(err)
168+
console.error('Failed to run tests')
169+
process.exit(1)
170+
}
171+
}

scripts/test/testE2E.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*!
2+
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import { resolve } from 'path'
7+
import { e2eSuite, runToolkitTests } from './launchTestUtilities'
8+
;(async () => {
9+
await runToolkitTests(e2eSuite, resolve('dist', 'src', 'testE2E', 'index.js'))
10+
})()

src/codecatalyst/vue/create/backend.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ export class CodeCatalystCreateWebview extends VueWebview {
133133
}
134134

135135
public async submit(settings: DevEnvironmentSettings, source: SourceResponse) {
136+
const devenv = await this.createDevEnvOfType(settings, source)
137+
this.commands.openDevEnv.execute(devenv)
138+
}
139+
140+
public async createDevEnvOfType(settings: DevEnvironmentSettings, source: SourceResponse) {
136141
const devenv: DevEnvironment = await (() => {
137142
switch (source.type) {
138143
case 'none':
@@ -146,7 +151,7 @@ export class CodeCatalystCreateWebview extends VueWebview {
146151
telemetry.codecatalyst_createDevEnvironment.record({ codecatalyst_createDevEnvironmentRepoType: source.type })
147152

148153
this.onComplete(devenv)
149-
this.commands.openDevEnv.execute(devenv)
154+
return devenv
150155
}
151156

152157
private async createEmptyDevEnv(settings: DevEnvironmentSettings, source: EmptyResponse) {

0 commit comments

Comments
 (0)