Skip to content

Commit 6ea30a6

Browse files
committed
tests
1 parent 440a19d commit 6ea30a6

File tree

2 files changed

+53
-7
lines changed

2 files changed

+53
-7
lines changed

packages/amazonq/test/e2e/lsp/lspInstallerUtil.ts

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
ManifestResolver,
1515
request,
1616
TargetContent,
17+
ToolkitError,
1718
} from 'aws-core-vscode/shared'
1819
import * as semver from 'semver'
1920
import { assertTelemetry } from 'aws-core-vscode/test'
@@ -201,12 +202,6 @@ export function createLspInstallerTests({
201202
id: lspConfig.id,
202203
manifestLocation: 'remote',
203204
languageServerSetupStage: 'getManifest',
204-
result: 'Failed',
205-
},
206-
{
207-
id: lspConfig.id,
208-
manifestLocation: 'cache',
209-
languageServerSetupStage: 'getManifest',
210205
result: 'Succeeded',
211206
},
212207
{
@@ -282,6 +277,58 @@ export function createLspInstallerTests({
282277
const download = await createInstaller(lspConfig).resolve()
283278
assert.ok(download.assetDirectory.endsWith('-rc.0'))
284279
})
280+
281+
it('throws on firewall error', async () => {
282+
// Stub the manifest resolver to return a valid manifest
283+
sandbox.stub(ManifestResolver.prototype, 'resolve').resolves({
284+
manifestSchemaVersion: '0.0.0',
285+
artifactId: 'foo',
286+
artifactDescription: 'foo',
287+
isManifestDeprecated: false,
288+
versions: [createVersion('1.0.0', targetContents)],
289+
})
290+
291+
// Fail all HTTP requests for the language server
292+
sandbox.stub(request, 'fetch').returns({
293+
response: Promise.resolve({
294+
ok: false,
295+
}),
296+
} as any)
297+
298+
// This should now throw a NetworkConnectivityError
299+
await assert.rejects(
300+
async () => await installer.resolve(),
301+
(err: ToolkitError) => {
302+
assert.strictEqual(err.code, 'NetworkConnectivityError')
303+
assert.ok(err.message.includes('Unable to download dependencies'))
304+
return true
305+
}
306+
)
307+
308+
// Verify telemetry for the failed attempts
309+
// const expectedTelemetry: Partial<LanguageServerSetup>[] = [
310+
// {
311+
// id: lspConfig.id,
312+
// manifestLocation: 'remote',
313+
// languageServerSetupStage: 'getManifest',
314+
// result: 'Failed',
315+
// },
316+
// {
317+
// id: lspConfig.id,
318+
// languageServerLocation: 'cache',
319+
// languageServerSetupStage: 'getServer',
320+
// result: 'Failed',
321+
// },
322+
// {
323+
// id: lspConfig.id,
324+
// languageServerLocation: 'remote',
325+
// languageServerSetupStage: 'getServer',
326+
// result: 'Failed',
327+
// },
328+
// ]
329+
330+
// assertTelemetry('languageServer_setup', expectedTelemetry)
331+
})
285332
})
286333
})
287334
}

packages/core/src/shared/lsp/manifestResolver.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export class ManifestResolver {
6969

7070
const localManifest = await this.getLocalManifest(true).catch(() => undefined)
7171
if (localManifest) {
72-
localManifest.location = 'remote'
7372
return localManifest
7473
} else {
7574
// Will emit a `languageServer_setup` result=failed metric...

0 commit comments

Comments
 (0)