From 32378e35e62b047aec23b8ef7d3706a8ec6e2048 Mon Sep 17 00:00:00 2001 From: Ghosh Date: Sun, 7 Nov 2021 11:14:22 -0800 Subject: [PATCH] test: fix ddb import e2e tests --- .../src/categories/storage.ts | 21 ++++----------- .../src/import-helpers/expects.ts | 27 ++++++++++++++----- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/packages/amplify-e2e-core/src/categories/storage.ts b/packages/amplify-e2e-core/src/categories/storage.ts index fe77042c03e..fa633bf14e1 100644 --- a/packages/amplify-e2e-core/src/categories/storage.ts +++ b/packages/amplify-e2e-core/src/categories/storage.ts @@ -270,18 +270,7 @@ export function addDynamoDBWithGSIWithSettings(projectDir: string, settings: Add const addColumn = (name, type) => { chain.wait('What would you like to name this column').sendLine(name); - singleSelect(chain.wait('Choose the data type'), type, [ - 'string', - 'number', - 'binary', - 'boolean', - 'list', - 'map', - 'null', - 'string-set', - 'number-set', - 'binary-set', - ]); + chain.wait('Choose the data type').sendCarriageReturn(); // Always selects string }; const addAnotherColumn = () => { @@ -309,11 +298,11 @@ export function addDynamoDBWithGSIWithSettings(projectDir: string, settings: Add chain.wait('Would you like to add another column').sendConfirmNo(); - singleSelect(chain.wait('Choose the data type'), 'pk', ['pk', 'sk', 'gsi-pk', 'gsi-sk', 'title', 'description']); + chain.wait('Choose partition key for the table').sendCarriageReturn(); // choose pk chain.wait('Do you want to add a sort key to your table').sendConfirmYes(); - singleSelect(chain.wait('Choose sort key for the table'), 'sk', ['sk', 'gsi-pk', 'gsi-sk', 'title', 'description']); + chain.wait('Choose sort key for the table').sendCarriageReturn(); // choose sk chain .wait('Do you want to add global secondary indexes to your table?') @@ -321,11 +310,11 @@ export function addDynamoDBWithGSIWithSettings(projectDir: string, settings: Add .wait('Provide the GSI name') .sendLine(settings.gsiName); - singleSelect(chain.wait('Choose partition key for the GSI'), 'gsi-pk', ['sk', 'gsi-pk', 'gsi-sk', 'title', 'description']); + chain.wait('Choose partition key for the GSI').send(KEY_DOWN_ARROW).send(KEY_DOWN_ARROW).sendCarriageReturn(); // choose gsi-pk chain.wait('Do you want to add a sort key to your global secondary index').sendConfirmYes(); - singleSelect(chain.wait('Choose sort key for the GSI'), 'gsi-sk', ['sk', 'gsi-sk', 'title', 'description']); + chain.wait('Choose sort key for the GSI').send(KEY_DOWN_ARROW).send(KEY_DOWN_ARROW).sendCarriageReturn(); // choose gsi-sk chain .wait('Do you want to add more global secondary indexes to your table') diff --git a/packages/amplify-e2e-tests/src/import-helpers/expects.ts b/packages/amplify-e2e-tests/src/import-helpers/expects.ts index ba4428b90dd..f87bd5802e2 100644 --- a/packages/amplify-e2e-tests/src/import-helpers/expects.ts +++ b/packages/amplify-e2e-tests/src/import-helpers/expects.ts @@ -1,7 +1,20 @@ import _ from 'lodash'; import { getProjectMeta, getBackendAmplifyMeta, getTeamProviderInfo, getBackendConfig } from 'amplify-e2e-core'; import { AuthProjectDetails, DynamoDBProjectDetails, readRootStack, StorageProjectDetails } from '.'; -import { AuthParameters } from 'amplify-category-auth'; +import { AuthParameters } from '@aws-amplify/amplify-category-auth'; + +const ddbAttrTypeMapping = { + string: 'S', + number: 'N', + binary: 'B', + boolean: 'BOOL', + list: 'L', + map: 'M', + null: 'NULL', + 'string-set': 'SS', + 'number-set': 'NS', + 'binary-set': 'BS', +}; export const expectAuthProjectDetailsMatch = (projectDetails: AuthProjectDetails, ogProjectDetails: AuthProjectDetails) => { expect(projectDetails.parameters.authSelections).toEqual(ogProjectDetails.parameters.authSelections); @@ -132,18 +145,18 @@ export const expectDynamoDBProjectDetailsMatch = (projectDetails: DynamoDBProjec expect(projectDetails.meta.Name).toEqual(ogProjectDetails.meta.Name); expect(projectDetails.meta.Region).toEqual(ogProjectDetails.meta.Region); expect(projectDetails.meta.PartitionKeyName).toEqual(ogProjectDetails.meta.PartitionKeyName); - expect(projectDetails.meta.PartitionKeyType).toEqual(ogProjectDetails.meta.PartitionKeyType); + expect(projectDetails.meta.PartitionKeyType).toEqual(ddbAttrTypeMapping[ogProjectDetails.meta.PartitionKeyType]); expect(projectDetails.meta.SortKeyName).toEqual(ogProjectDetails.meta.SortKeyName); - expect(projectDetails.meta.SortKeyType).toEqual(ogProjectDetails.meta.SortKeyType); + expect(projectDetails.meta.SortKeyType).toEqual(ddbAttrTypeMapping[ogProjectDetails.meta.SortKeyType]); expect(projectDetails.meta.Arn).toEqual(ogProjectDetails.meta.Arn); expect(projectDetails.meta.StreamArn).toEqual(ogProjectDetails.meta.StreamArn); expect(projectDetails.team.tableName).toEqual(ogProjectDetails.meta.Name); expect(projectDetails.team.region).toEqual(ogProjectDetails.meta.Region); expect(projectDetails.team.partitionKeyName).toEqual(ogProjectDetails.meta.PartitionKeyName); - expect(projectDetails.team.partitionKeyType).toEqual(ogProjectDetails.meta.PartitionKeyType); + expect(projectDetails.team.partitionKeyType).toEqual(ddbAttrTypeMapping[ogProjectDetails.meta.PartitionKeyType]); expect(projectDetails.team.sortKeyName).toEqual(ogProjectDetails.meta.SortKeyName); - expect(projectDetails.team.sortKeyType).toEqual(ogProjectDetails.meta.SortKeyType); + expect(projectDetails.team.sortKeyType).toEqual(ddbAttrTypeMapping[ogProjectDetails.meta.SortKeyType]); expect(projectDetails.team.arn).toEqual(ogProjectDetails.meta.Arn); expect(projectDetails.team.streamArn).toEqual(ogProjectDetails.meta.StreamArn); }; @@ -163,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(ogStorageMeta.output.PartitionKeyType); + expect(storageMeta.output.PartitionKeyType).toEqual(ddbAttrTypeMapping[ogStorageMeta.output.PartitionKeyType]); expect(storageMeta.output.SortKeyName).toEqual(ogStorageMeta.output.SortKeyName); - expect(storageMeta.output.SortKeyType).toEqual(ogStorageMeta.output.SortKeyType); + expect(storageMeta.output.SortKeyType).toEqual(ddbAttrTypeMapping[ogStorageMeta.output.SortKeyType]); expect(storageMeta.output.Arn).toEqual(ogStorageMeta.output.Arn); expect(storageMeta.output.StreamArn).toEqual(ogStorageMeta.output.StreamArn); };