@@ -29,13 +29,14 @@ import { captureEventOnce } from '../../test/testUtil'
29
29
import { toStream } from '../../shared/utilities/collectionUtils'
30
30
import { toCollection } from '../../shared/utilities/asyncCollection'
31
31
import { getLogger } from '../../shared/logger'
32
- import { isAwsError } from '../../shared/errors'
32
+ import { isAwsError , ToolkitError } from '../../shared/errors'
33
33
import {
34
34
scopesCodeCatalyst ,
35
35
createBuilderIdProfile ,
36
36
isValidCodeCatalystConnection ,
37
37
SsoConnection ,
38
38
} from '../../auth/connection'
39
+ import { hasKey } from '../../shared/utilities/tsUtils'
39
40
40
41
let spaceName : CodeCatalystOrg [ 'name' ]
41
42
let projectName : CodeCatalystProject [ 'name' ]
@@ -86,7 +87,7 @@ let projectName: CodeCatalystProject['name']
86
87
* integ tests, but using the ssh hostname that we get from
87
88
* {@link prepareDevEnvConnection}.
88
89
*/
89
- describe . skip ( 'Test how this codebase uses the CodeCatalyst API' , function ( ) {
90
+ describe ( 'Test how this codebase uses the CodeCatalyst API' , function ( ) {
90
91
let client : CodeCatalystClient
91
92
let commands : CodeCatalystCommands
92
93
let webviewClient : CodeCatalystCreateWebview
@@ -193,11 +194,11 @@ describe.skip('Test how this codebase uses the CodeCatalyst API', function () {
193
194
assert . strictEqual ( actualDevEnv . persistentStorage . sizeInGiB , 32 )
194
195
} )
195
196
196
- it ( 'creates a Dev Environment using an existing branch' , async function ( ) {
197
- // TODO: The CC API does not provide a way to create a repository
198
- // due to this we'll want to revisit this test.
199
- // For now, we can manually create repository in the test project
200
- // and then continue this test from that point .
197
+ it . skip ( 'creates a Dev Environment using an existing branch' , async function ( ) {
198
+ // TODO: Write this test now that an API is available in the SDK:
199
+ // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CodeCatalyst.html#createSourceRepository-property
200
+ // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CodeCatalyst.html#createSourceRepositoryBranch-property
201
+ // For now, the repository is manually created in the account .
201
202
} )
202
203
203
204
it ( 'prompts to install the ssh extension if not available' , async function ( ) {
@@ -354,16 +355,15 @@ describe.skip('Test how this codebase uses the CodeCatalyst API', function () {
354
355
assert . ok ( spaces . find ( space => space . name === spaceName ) )
355
356
} )
356
357
357
- it ( 'lists all projects for the given user' , async function ( ) {
358
+ // TODO: Re-add this test when the CoCa SDK offers a way to delete projects.
359
+ it . skip ( 'lists all projects for the given user' , async function ( ) {
358
360
// Create lots of projects
359
- // const ephemeralProjectNames = []
360
- // for (let index = 0; index < 30; index++) {
361
- // ephemeralProjectNames.push(`ephemeral-project-${index}`)
362
- // }
363
- // await Promise.all(
364
- // ephemeralProjectNames.map(name => tryCreateTestProject(spaceName, name))
365
- // )
366
- // const projects = await client.listProjects({spaceName}).flatten().promise()
361
+ const ephemeralProjectNames = [ ]
362
+ for ( let index = 0 ; index < 30 ; index ++ ) {
363
+ ephemeralProjectNames . push ( `ephemeral-project-${ index } ` )
364
+ }
365
+ await Promise . all ( ephemeralProjectNames . map ( name => tryCreateTestProject ( spaceName , name ) ) )
366
+ await client . listProjects ( { spaceName } ) . flatten ( ) . promise ( )
367
367
} )
368
368
369
369
function buildDevEnvSettings (
@@ -425,7 +425,15 @@ describe.skip('Test how this codebase uses the CodeCatalyst API', function () {
425
425
*/
426
426
async function createTestCodeCatalystClient ( auth : Auth ) : Promise < CodeCatalystClient > {
427
427
const conn = await useCodeCatalystSsoConnection ( auth )
428
- return await createCodeCatalystClient ( conn )
428
+ return await createCodeCatalystClient ( conn , undefined , undefined , {
429
+ // Add retries for tests since many may be running in parallel in github CI.
430
+ // AWS SDK adds jitter automatically.
431
+ // https://github.com/aws/aws-sdk-js/blob/3e616251947c73d5239178c167a9d73d985ca581/lib/util.js#L884
432
+ retryDelayOptions : {
433
+ base : 1200 , // ms
434
+ } ,
435
+ maxRetries : 5 ,
436
+ } )
429
437
}
430
438
431
439
/**
@@ -457,7 +465,8 @@ describe.skip('Test how this codebase uses the CodeCatalyst API', function () {
457
465
description : 'This project is autogenerated by the AWS Toolkit VSCode Integ Test.' ,
458
466
} )
459
467
} catch ( e ) {
460
- if ( isAwsError ( e ) && e . code === 'ConflictException' ) {
468
+ if ( ( isAwsError ( e ) || e instanceof ToolkitError ) && e . code === 'ConflictException' ) {
469
+ getLogger ( ) . debug ( `Tried to create test project but it already exists: ${ spaceName } /${ projectName } ` )
461
470
return client . getProject ( {
462
471
spaceName,
463
472
name : projectName ,
@@ -578,8 +587,10 @@ describe.skip('Test how this codebase uses the CodeCatalyst API', function () {
578
587
let devEnvBeingDeleted : DevEnvironment
579
588
try {
580
589
devEnvBeingDeleted = await client . getDevEnvironment ( { spaceName, projectName, id } )
581
- } catch ( e ) {
582
- if ( e instanceof Error && e . name === AccessDeniedException . name ) {
590
+ } catch ( e : any ) {
591
+ // Cannot use isAwsError() because the client actually returns a regular Error
592
+ // with a 'code' property for this call.
593
+ if ( hasKey ( e , 'code' ) && e . code === AccessDeniedException . name ) {
583
594
// This error is thrown because the dev env does not exist anymore
584
595
// on the server. The name doesn't make it obvious IMO.
585
596
return true
0 commit comments