diff --git a/packages/amplify-e2e-core/src/categories/storage.ts b/packages/amplify-e2e-core/src/categories/storage.ts index 194ac6f95c7..6d5718331cf 100644 --- a/packages/amplify-e2e-core/src/categories/storage.ts +++ b/packages/amplify-e2e-core/src/categories/storage.ts @@ -1,5 +1,5 @@ -import { getCLIPath, KEY_DOWN_ARROW, nspawn as spawn } from '..'; import { singleSelect } from '../utils/selectors'; +import { getCLIPath, nspawn as spawn } from '..'; export type AddStorageSettings = { resourceName: string; @@ -16,7 +16,8 @@ export function addSimpleDDB(cwd: string, settings: any): Promise { return new Promise((resolve, reject) => { spawn(getCLIPath(), ['add', 'storage'], { cwd, stripColors: true }) .wait('Select from one of the below mentioned services') - .sendLine(KEY_DOWN_ARROW) + .sendKeyDown() + .sendCarriageReturn() .wait('Provide a friendly name') .sendLine(settings.name || '\r') .wait('Provide table name') @@ -56,7 +57,8 @@ export function addDDBWithTrigger(cwd: string, settings: { ddbResourceName?: str return new Promise((resolve, reject) => { const chain = spawn(getCLIPath(), ['add', 'storage'], { cwd, stripColors: true }) .wait('Select from one of the below mentioned services') - .sendLine(KEY_DOWN_ARROW) + .sendKeyDown() + .sendCarriageReturn() .wait('Provide a friendly name'); if (settings.ddbResourceName) { chain.sendLine(settings.ddbResourceName); @@ -88,7 +90,8 @@ export function addDDBWithTrigger(cwd: string, settings: { ddbResourceName?: str .wait('Do you want to add a Lambda Trigger for your Table') .sendConfirmYes() .wait('Select from the following options') - .sendLine(KEY_DOWN_ARROW) + .sendKeyDown() + .sendCarriageReturn() .wait('Do you want to edit the local') .sendConfirmNo() .sendEof() @@ -106,7 +109,8 @@ export function updateDDBWithTrigger(cwd: string, settings: any): Promise return new Promise((resolve, reject) => { spawn(getCLIPath(), ['update', 'storage'], { cwd, stripColors: true }) .wait('Select from one of the below mentioned services') - .sendLine(KEY_DOWN_ARROW) + .sendKeyDown() + .sendCarriageReturn() .wait('Specify the resource that you would want to update') .sendCarriageReturn() .wait('Would you like to add another column') @@ -116,7 +120,8 @@ export function updateDDBWithTrigger(cwd: string, settings: any): Promise .wait('Do you want to add a Lambda Trigger for your Table') .sendConfirmYes() .wait('Select from the following options') - .sendLine(KEY_DOWN_ARROW) + .sendKeyDown() + .sendCarriageReturn() .wait('Do you want to edit the local') .sendLine('n') .sendEof() @@ -134,7 +139,7 @@ export function updateSimpleDDBwithGSI(cwd: string, settings: any): Promise { spawn(getCLIPath(), ['update', 'storage'], { cwd, stripColors: true }) .wait('Select from one of the below mentioned services') - .send(KEY_DOWN_ARROW) + .sendKeyDown() .sendCarriageReturn() .wait('Specify the resource that you would want to update') .sendCarriageReturn() @@ -177,7 +182,7 @@ export function addSimpleDDBwithGSI(cwd: string, settings: any): Promise { return new Promise((resolve, reject) => { spawn(getCLIPath(), ['add', 'storage'], { cwd, stripColors: true }) .wait('Select from one of the below mentioned services') - .send(KEY_DOWN_ARROW) + .sendKeyDown() .sendCarriageReturn() .wait('Provide a friendly name') .sendCarriageReturn() @@ -204,7 +209,7 @@ export function addSimpleDDBwithGSI(cwd: string, settings: any): Promise { .wait('Provide the GSI name') .sendLine('gsi1') .wait('Choose partition key for the GSI') - .send(KEY_DOWN_ARROW) + .sendKeyDown() .sendCarriageReturn() .wait('Do you want to add a sort key to your global secondary index?') .sendConfirmNo() @@ -245,15 +250,14 @@ export function buildOverrideStorage(cwd: string, settings: {}) { return new Promise((resolve, reject) => { // Add 'storage' as a category param once implemented const args = ['build']; - const chain = spawn(getCLIPath(), args, { cwd, stripColors: true }) - chain - .run((err: Error) => { - if (!err) { - resolve({}); - } else { - reject(err); - } - }); + const chain = spawn(getCLIPath(), args, { cwd, stripColors: true }); + chain.run((err: Error) => { + if (!err) { + resolve({}); + } else { + reject(err); + } + }); }); } @@ -309,11 +313,11 @@ export function addDynamoDBWithGSIWithSettings(projectDir: string, settings: Add .wait('Provide the GSI name') .sendLine(settings.gsiName); - chain.wait('Choose partition key for the GSI').send(KEY_DOWN_ARROW).send(KEY_DOWN_ARROW).sendCarriageReturn(); // choose gsi-pk + chain.wait('Choose partition key for the GSI').sendKeyDown(2).sendCarriageReturn(); // choose gsi-pk chain.wait('Do you want to add a sort key to your global secondary index').sendConfirmYes(); - chain.wait('Choose sort key for the GSI').send(KEY_DOWN_ARROW).send(KEY_DOWN_ARROW).sendCarriageReturn(); // choose gsi-sk + chain.wait('Choose sort key for the GSI').sendKeyDown(2).sendCarriageReturn(); // choose gsi-sk chain .wait('Do you want to add more global secondary indexes to your table') @@ -442,9 +446,9 @@ export function addS3WithGroupAccess(cwd: string, settings: any): Promise .sendKeyDown() .sendCarriageReturn() // Individual groups .wait('Select groups') - .send(' ') //select Admin + .send(' ') // select Admin .sendKeyDown() - .send(' ')//select User + .send(' ') // select User .sendCarriageReturn() .wait('What kind of access do you want') // for users? .sendCtrlA() // Select all permissions @@ -574,13 +578,14 @@ export function addS3StorageWithIdpAuth(projectDir: string): Promise { .wait('Who should have access:') .sendCarriageReturn(); - chain.wait('What kind of access do you want for Authenticated users?') - .send(' ') //'create/update' - .sendKeyDown() - .send(' ') //'read' - .sendKeyDown() - .send(' ') //'delete' - .sendCarriageReturn() + chain + .wait('What kind of access do you want for Authenticated users?') + .send(' ') //'create/update' + .sendKeyDown() + .send(' ') //'read' + .sendKeyDown() + .send(' ') //'delete' + .sendCarriageReturn(); chain.wait('Do you want to add a Lambda Trigger for your S3 Bucket?').sendConfirmNo(); diff --git a/packages/amplify-e2e-core/src/utils/headless.ts b/packages/amplify-e2e-core/src/utils/headless.ts index afca3e6c485..cd767247155 100644 --- a/packages/amplify-e2e-core/src/utils/headless.ts +++ b/packages/amplify-e2e-core/src/utils/headless.ts @@ -32,7 +32,7 @@ export const addHeadlessAuth = async (cwd: string, request: AddAuthRequest): Pro return await executeHeadlessCommand(cwd, 'auth', 'add', request); }; -export const updateHeadlessAuth = async (cwd: string, request: UpdateAuthRequest, settings: any): Promise> => { +export const updateHeadlessAuth = async (cwd: string, request: UpdateAuthRequest, settings?: any): Promise> => { return await executeHeadlessCommand(cwd, 'auth', 'update', request, settings); }; @@ -75,8 +75,8 @@ const executeHeadlessCommand = async ( request: AnyHeadlessRequest, reject: boolean = true, allowDestructiveUpdates: boolean = false, - settings:any = {testingWithLatestCodebase : true }, -): Promise => { + settings = { testingWithLatestCodebase: true }, +) => { const args = [operation, category, '--headless']; if (allowDestructiveUpdates) { args.push('--allow-destructive-graphql-schema-updates'); diff --git a/packages/amplify-e2e-tests/src/__tests__/import_dynamodb_1.test.ts b/packages/amplify-e2e-tests/src/__tests__/import_dynamodb_1.test.ts index a290393c863..7ed47ac1d15 100644 --- a/packages/amplify-e2e-tests/src/__tests__/import_dynamodb_1.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/import_dynamodb_1.test.ts @@ -1,5 +1,3 @@ -import * as path from 'path'; -import * as fs from 'fs-extra'; import { $TSObject, JSONUtilities } from 'amplify-cli-core'; import { addAuthWithDefault, @@ -13,32 +11,28 @@ import { deleteProject, deleteProjectDir, getAppId, - getTeamProviderInfo, initJSProjectWithProfile, } from 'amplify-e2e-core'; -import { randomizedFunctionName } from '../schema-api-directives/functionTester'; -import { addEnvironmentWithImportedAuth, checkoutEnvironment, removeEnvironment } from '../environment/env'; +import * as fs from 'fs-extra'; +import * as path from 'path'; import { + createDynamoDBSettings, + DynamoDBProjectDetails, + expectDynamoDBLocalAndOGMetaFilesOutputMatching, + expectDynamoDBProjectDetailsMatch, expectLocalAndCloudMetaFilesMatching, expectLocalAndPulledBackendConfigMatching, - getShortId, - readRootStack, - expectNoStorageInMeta, expectLocalTeamInfoHasOnlyAuthCategoryAndNoStorage, - headlessPullExpectError, - headlessPull, - createDynamoDBSettings, - DynamoDBProjectDetails, - getOGDynamoDBProjectDetails, - importDynamoDBTable, + expectNoStorageInMeta, getDynamoDBProjectDetails, - expectDynamoDBProjectDetailsMatch, getDynamoDBResourceName, - expectDynamoDBLocalAndOGMetaFilesOutputMatching, + getOGDynamoDBProjectDetails, + getShortId, + importDynamoDBTable, + readRootStack, removeImportedDynamoDBWithDefault, } from '../import-helpers'; - -const profileName = 'amplify-integ-test-user'; +import { randomizedFunctionName } from '../schema-api-directives/functionTester'; describe('dynamodb import', () => { const projectPrefix = 'ddbimp'; diff --git a/packages/amplify-e2e-tests/src/__tests__/import_dynamodb_2.test.ts b/packages/amplify-e2e-tests/src/__tests__/import_dynamodb_2.test.ts index 68721e64621..2688bc080b2 100644 --- a/packages/amplify-e2e-tests/src/__tests__/import_dynamodb_2.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/import_dynamodb_2.test.ts @@ -1,12 +1,7 @@ -import * as path from 'path'; -import * as fs from 'fs-extra'; -import { $TSObject, JSONUtilities } from 'amplify-cli-core'; import { addAuthWithDefault, AddDynamoDBSettings, addDynamoDBWithGSIWithSettings, - addFunction, - amplifyPull, amplifyPushAuth, amplifyStatus, createNewProjectDir, @@ -16,26 +11,19 @@ import { getTeamProviderInfo, initJSProjectWithProfile, } from 'amplify-e2e-core'; -import { randomizedFunctionName } from '../schema-api-directives/functionTester'; import { addEnvironmentWithImportedAuth, checkoutEnvironment, removeEnvironment } from '../environment/env'; import { + createDynamoDBSettings, + DynamoDBProjectDetails, + expectDynamoDBLocalAndOGMetaFilesOutputMatching, expectLocalAndCloudMetaFilesMatching, expectLocalAndPulledBackendConfigMatching, + getDynamoDBProjectDetails, + getOGDynamoDBProjectDetails, getShortId, - readRootStack, - expectNoStorageInMeta, - expectLocalTeamInfoHasOnlyAuthCategoryAndNoStorage, - headlessPullExpectError, headlessPull, - createDynamoDBSettings, - DynamoDBProjectDetails, - getOGDynamoDBProjectDetails, + headlessPullExpectError, importDynamoDBTable, - getDynamoDBProjectDetails, - expectDynamoDBProjectDetailsMatch, - getDynamoDBResourceName, - expectDynamoDBLocalAndOGMetaFilesOutputMatching, - removeImportedDynamoDBWithDefault, } from '../import-helpers'; const profileName = 'amplify-integ-test-user'; diff --git a/packages/amplify-e2e-tests/src/__tests__/storage-5.test.ts b/packages/amplify-e2e-tests/src/__tests__/storage-5.test.ts index f90903913a0..cb2480adc91 100644 --- a/packages/amplify-e2e-tests/src/__tests__/storage-5.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/storage-5.test.ts @@ -1,5 +1,24 @@ import { $TSAny, JSONUtilities } from 'amplify-cli-core'; -import { addAuthWithDefault, addDDBWithTrigger, addS3WithGuestAccess, addSimpleDDB, addSimpleDDBwithGSI, amplifyPushAuth, buildOverrideStorage, checkIfBucketExists, createNewProjectDir, deleteProject, deleteProjectDir, getDDBTable, getProjectMeta, initJSProjectWithProfile, overrideDDB, overrideS3, updateDDBWithTrigger, updateSimpleDDBwithGSI } from 'amplify-e2e-core'; +import { + addAuthWithDefault, + addDDBWithTrigger, + addS3WithGuestAccess, + addSimpleDDB, + addSimpleDDBwithGSI, + amplifyPushAuth, + buildOverrideStorage, + checkIfBucketExists, + createNewProjectDir, + deleteProject, + deleteProjectDir, + getDDBTable, + getProjectMeta, + initJSProjectWithProfile, + overrideDDB, + overrideS3, + updateDDBWithTrigger, + updateSimpleDDBwithGSI, +} from 'amplify-e2e-core'; import * as fs from 'fs-extra'; import * as path from 'path'; import uuid from 'uuid'; @@ -128,7 +147,6 @@ describe('amplify add/update storage(DDB)', () => { }); }); - describe('ddb override tests', () => { let projRoot: string; beforeEach(async () => { @@ -148,7 +166,15 @@ describe('ddb override tests', () => { const srcOverrideFilePath = path.join(__dirname, '..', '..', 'overrides', 'override-storage-ddb.ts'); const destOverrideFilePath = path.join(projRoot, 'amplify', 'backend', 'storage', resourceName, 'override.ts'); - const cfnFilePath = path.join(projRoot, 'amplify', 'backend', 'storage', resourceName, 'build', `${resourceName}-cloudformation-template.json`); + const cfnFilePath = path.join( + projRoot, + 'amplify', + 'backend', + 'storage', + resourceName, + 'build', + `${resourceName}-cloudformation-template.json`, + ); fs.copyFileSync(srcOverrideFilePath, destOverrideFilePath); await buildOverrideStorage(projRoot, {}); diff --git a/packages/amplify-e2e-tests/src/import-helpers/expects.ts b/packages/amplify-e2e-tests/src/import-helpers/expects.ts index f87bd5802e2..72bf7d093ac 100644 --- a/packages/amplify-e2e-tests/src/import-helpers/expects.ts +++ b/packages/amplify-e2e-tests/src/import-helpers/expects.ts @@ -176,9 +176,9 @@ export const expectDynamoDBLocalAndOGMetaFilesOutputMatching = (projectRoot: str expect(storageMeta.output.Name).toEqual(ogStorageMeta.output.Name); expect(storageMeta.output.Region).toEqual(ogStorageMeta.output.Region); expect(storageMeta.output.PartitionKeyName).toEqual(ogStorageMeta.output.PartitionKeyName); - expect(storageMeta.output.PartitionKeyType).toEqual(ddbAttrTypeMapping[ogStorageMeta.output.PartitionKeyType]); + expect(storageMeta.output.PartitionKeyType).toEqual(ogStorageMeta.output.PartitionKeyType); expect(storageMeta.output.SortKeyName).toEqual(ogStorageMeta.output.SortKeyName); - expect(storageMeta.output.SortKeyType).toEqual(ddbAttrTypeMapping[ogStorageMeta.output.SortKeyType]); + expect(storageMeta.output.SortKeyType).toEqual(ogStorageMeta.output.SortKeyType); expect(storageMeta.output.Arn).toEqual(ogStorageMeta.output.Arn); expect(storageMeta.output.StreamArn).toEqual(ogStorageMeta.output.StreamArn); }; diff --git a/packages/amplify-e2e-tests/tsconfig.tests.json b/packages/amplify-e2e-tests/tsconfig.tests.json index 1cb95fd0b68..6807354862a 100644 --- a/packages/amplify-e2e-tests/tsconfig.tests.json +++ b/packages/amplify-e2e-tests/tsconfig.tests.json @@ -13,5 +13,5 @@ "typeRoots": ["../../node_modules/@types", "node_modules/@types", "./typings"] }, "references": [{ "path": "../amplify-e2e-core" }], - "exclude": ["node_modules", "lib", "__tests__"] + "exclude": ["node_modules", "lib", "__tests__", "custom-resources", "overrides"] }