Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fixing DDB E2E tests #8707

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this function being referenced?

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