@@ -14,6 +14,7 @@ import {
1414 ManifestResolver ,
1515 request ,
1616 TargetContent ,
17+ ToolkitError ,
1718} from 'aws-core-vscode/shared'
1819import * as semver from 'semver'
1920import { 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}
0 commit comments