Skip to content

Commit

Permalink
test: fixing DDB E2E tests (aws-amplify#8707)
Browse files Browse the repository at this point in the history
* test: fixing DDB E2E tests

* test: fix ddb import e2e test

Co-authored-by: Ghosh <kaustavg@3c22fb229ff6.ant.amazon.com>
  • Loading branch information
2 people authored and Sachin Panemangalore committed Nov 11, 2021
1 parent 41dd605 commit 883d4db
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import * as fs from 'fs-extra';
import uuid from 'uuid';
import { v4 as uuid } from 'uuid';
import { alphanumeric, printer, prompter, Validator } from 'amplify-prompts';
import { $TSContext, AmplifyCategories, ResourceDoesNotExistError, exitOnNextTick, stateManager } from 'amplify-cli-core';
import { DynamoDBInputState } from './dynamoDB-input-state';
Expand Down
13 changes: 12 additions & 1 deletion packages/amplify-e2e-core/src/categories/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,18 @@ 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']);
singleSelect(chain.wait('Choose the data type'), type, [
'string',
'number',
'binary',
'boolean',
'list',
'map',
'null',
'string-set',
'number-set',
'binary-set',
]);
};

const addAnotherColumn = () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/amplify-e2e-tests/overrides/override-storage-ddb.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export function overrideProps(props: any) {
export function override(props: any) {
props.dynamoDBTable.streamSpecification = {
streamViewType: 'NEW_AND_OLD_IMAGES',
};
return props;
}
13 changes: 5 additions & 8 deletions packages/amplify-e2e-tests/overrides/override-storage-s3.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

export function overrideProps(props: any) {
//Enable versioning on the bucket
props.s3Bucket.versioningConfiguration = {
status : "Enabled"
}
return props;
export function override(props: any) {
//Enable versioning on the bucket
props.s3Bucket.versioningConfiguration = {
status: 'Enabled',
};
}

37 changes: 17 additions & 20 deletions packages/amplify-e2e-tests/src/__tests__/storage-1.test.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
import { $TSAny, JSONUtilities } from 'amplify-cli-core';
import { initJSProjectWithProfile, initFlutterProjectWithProfile, deleteProject, amplifyPushAuth } from 'amplify-e2e-core';
import { addAuthWithDefault, addAuthWithGroupsAndAdminAPI } from 'amplify-e2e-core';
import { $TSAny } from 'amplify-cli-core';
import {
addSimpleDDB,
overrideDDB,
buildOverrideStorage,
addDDBWithTrigger,
updateDDBWithTrigger,
addSimpleDDBwithGSI,
updateSimpleDDBwithGSI,
overrideS3,
addAuthWithDefault,
addAuthWithGroupsAndAdminAPI,
addS3AndAuthWithAuthOnlyAccess,
addS3WithGuestAccess,
addS3WithGroupAccess,
addS3WithGuestAccess,
addS3WithTrigger,
amplifyPushAuth,
checkIfBucketExists,
createNewProjectDir,
deleteProject,
deleteProjectDir,
getProjectMeta,
initFlutterProjectWithProfile,
initJSProjectWithProfile,
updateS3AddTrigger,
} from 'amplify-e2e-core';
import { createNewProjectDir, deleteProjectDir, getProjectMeta, getDDBTable, checkIfBucketExists } from 'amplify-e2e-core';
import * as fs from 'fs-extra';
import * as path from 'path';
import uuid from 'uuid';


function getServiceMeta( projectRoot : string, category: string, service : string ): $TSAny {
function getServiceMeta(projectRoot: string, category: string, service: string): $TSAny {
const meta = getProjectMeta(projectRoot);
for ( const storageResourceName of Object.keys(meta[category]) ){
if ( meta.storage[storageResourceName].service.toUpperCase() === service.toUpperCase() ){
for (const storageResourceName of Object.keys(meta[category])) {
if (meta.storage[storageResourceName].service.toUpperCase() === service.toUpperCase()) {
return meta.storage[storageResourceName];
}
}
Expand All @@ -43,7 +40,7 @@ describe('amplify add/update storage(S3)', () => {
});

async function validate(projRoot) {
const serviceMeta = getServiceMeta( projRoot, 'storage', 'S3');
const serviceMeta = getServiceMeta(projRoot, 'storage', 'S3');
const { BucketName: bucketName, Region: region } = serviceMeta.output;

expect(bucketName).toBeDefined();
Expand Down Expand Up @@ -92,7 +89,7 @@ describe('amplify add/update storage(S3)', () => {
await amplifyPushAuth(projRoot);
await validate(projRoot);
});

it('init a project and add S3 bucket with user pool groups and then update S3 bucket to add trigger', async () => {
await initJSProjectWithProfile(projRoot, {});
await addAuthWithGroupsAndAdminAPI(projRoot, {});
Expand Down

0 comments on commit 883d4db

Please sign in to comment.