Skip to content

Commit

Permalink
test: update migration tests to handle new text (#6545)
Browse files Browse the repository at this point in the history
* test: update migration tests to handle new text

* fix: check for headless params
  • Loading branch information
jhockett authored Feb 4, 2021
1 parent 31b980d commit 8647486
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import {
initJSProjectWithProfile,
deleteProject,
addAuthWithDefaultSocial,
isDeploymentSecretForEnvExists,
amplifyPushWithoutCodegen,
amplifyStatus,
amplifyStatusWithMigrate,
amplifyVersion,
amplifyPushWithoutCodegen,
createNewProjectDir,
deleteProject,
deleteProjectDir,
isDeploymentSecretForEnvExists,
} from 'amplify-e2e-core';
import { createNewProjectDir, deleteProjectDir } from 'amplify-e2e-core';
import { initJSProjectWithProfile } from '../../../migration-helpers/init';

describe('amplify auth add with social', () => {
let projRoot: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {
initJSProjectWithProfile,
deleteProject,
addApiWithSchema,
addFeatureFlag,
amplifyPush,
amplifyPushForce,
addApiWithSchema,
updateApiSchema,
amplifyPushUpdate,
apiGqlCompile,
createNewProjectDir,
deleteProject,
deleteProjectDir,
amplifyPushUpdate,
addFeatureFlag
updateApiSchema,
} from 'amplify-e2e-core';
import { initJSProjectWithProfile } from '../../../migration-helpers/init';

describe('amplify key force push', () => {
let projRoot: string;
Expand Down Expand Up @@ -48,11 +48,7 @@ describe('amplify key force push', () => {
updateApiSchema(projRoot, projectName, initialSchema, true);
// gql-compile and force push with codebase cli
await expect(
amplifyPushUpdate(
projRoot,
/Attempting to remove a local secondary index on the TodoTable table in the Todo stack.*/,
true,
),
amplifyPushUpdate(projRoot, /Attempting to remove a local secondary index on the TodoTable table in the Todo stack.*/, true),
).rejects.toThrowError(/Attempting to remove a local secondary index on the TodoTable table in the Todo stack.*/);
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { initJSProjectWithProfile, deleteProject, amplifyPush, amplifyPushUpdate } from 'amplify-e2e-core';
import { addApiWithSchema, updateApiSchema } from 'amplify-e2e-core';
import { createNewProjectDir, deleteProjectDir } from 'amplify-e2e-core';
import {
addApiWithSchema,
amplifyPush,
amplifyPushUpdate,
createNewProjectDir,
deleteProject,
deleteProjectDir,
updateApiSchema,
} from 'amplify-e2e-core';
import { initJSProjectWithProfile } from '../../../migration-helpers/init';

describe('amplify searchable migration', () => {
let projRoot: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { initJSProjectWithProfile, deleteProject, amplifyPush, amplifyPushUpdate } from 'amplify-e2e-core';
import { join } from 'path';
import { existsSync } from 'fs';
import {
addApiWithSchema,
addApiWithSchemaAndConflictDetection,
amplifyPush,
amplifyPushUpdate,
createNewProjectDir,
deleteProject,
deleteProjectDir,
getAppSyncApi,
getProjectMeta,
getTransformConfig,
updateApiSchema,
updateApiWithMultiAuth,
updateAPIWithResolutionStrategy,
} from 'amplify-e2e-core';
import { createNewProjectDir, deleteProjectDir, getProjectMeta, getTransformConfig, getAppSyncApi } from 'amplify-e2e-core';
import { existsSync } from 'fs';
import { TRANSFORM_CURRENT_VERSION } from 'graphql-transformer-core';
import { join } from 'path';
import { initJSProjectWithProfile } from '../../migration-helpers/init';

describe('api migration update test', () => {
let projRoot: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { initJSProjectWithProfile, deleteProject, amplifyPushAuth } from 'amplify-e2e-core';
import { join } from 'path';
import * as fs from 'fs-extra';
import { addAuthWithCustomTrigger, updateAuthWithoutCustomTrigger } from 'amplify-e2e-core';
import {
getUserPool,
getUserPoolClients,
getLambdaFunction,
addAuthWithCustomTrigger,
amplifyPushAuth,
createNewProjectDir,
deleteProject,
deleteProjectDir,
getLambdaFunction,
getProjectMeta,
getUserPool,
getUserPoolClients,
updateAuthWithoutCustomTrigger,
} from 'amplify-e2e-core';
import * as fs from 'fs-extra';
import { join } from 'path';
import { initJSProjectWithProfile } from '../../migration-helpers/init';

describe('amplify auth migration', () => {
let projRoot: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import {
addApiWithSchema,
addFunction,
addLayer,
amplifyPush,
amplifyPushAuth,
createNewProjectDir,
deleteProject,
deleteProjectDir,
getProjectMeta,
invokeFunction,
overrideFunctionSrc,
updateFunction,
updateLayer,
validateLayerMetadata,
} from 'amplify-e2e-core';
import { v4 as uuid } from 'uuid';
import { initJSProjectWithProfile, deleteProject, amplifyPushAuth, amplifyPush } from 'amplify-e2e-core';
import { addFunction, addLayer, invokeFunction, updateFunction, updateLayer, validateLayerMetadata } from 'amplify-e2e-core';
import { createNewProjectDir, deleteProjectDir, getProjectMeta, overrideFunctionSrc } from 'amplify-e2e-core';
import { addApiWithSchema } from 'amplify-e2e-core';
import { initJSProjectWithProfile } from '../../migration-helpers/init';

describe('amplify function migration', () => {
let projRoot: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { initJSProjectWithProfile, deleteProject, amplifyPushAuth } from 'amplify-e2e-core';
import { addSimpleDDB, addDDBWithTrigger, updateDDBWithTrigger } from 'amplify-e2e-core';
import { createNewProjectDir, deleteProjectDir, getProjectMeta, getDDBTable } from 'amplify-e2e-core';
import {
addDDBWithTrigger,
addSimpleDDB,
amplifyPushAuth,
createNewProjectDir,
deleteProject,
deleteProjectDir,
getDDBTable,
getProjectMeta,
updateDDBWithTrigger,
} from 'amplify-e2e-core';
import { initJSProjectWithProfile } from '../../migration-helpers/init';

describe('amplify add/update storage(DDB)', () => {
let projRoot: string;
Expand Down
72 changes: 72 additions & 0 deletions packages/amplify-migration-tests/src/migration-helpers/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { addCircleCITags, getCLIPath, isCI, nspawn as spawn } from 'amplify-e2e-core';

const defaultSettings = {
name: '\r',
envName: 'integtest',
editor: '\r',
appType: '\r',
framework: '\r',
srcDir: '\r',
distDir: '\r',
buildCmd: '\r',
startCmd: '\r',
useProfile: '\r',
profileName: '\r',
region: process.env.CLI_REGION,
local: false,
disableAmplifyAppCreation: true,
};

export function initJSProjectWithProfile(cwd: string, settings: Object, testingWithLatestCodebase = false) {
const s = { ...defaultSettings, ...settings };
let env;

if (s.disableAmplifyAppCreation === true) {
env = {
CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1',
};
}

addCircleCITags(cwd);

return new Promise((resolve, reject) => {
const chain = spawn(getCLIPath(testingWithLatestCodebase), ['init'], { cwd, stripColors: true, env })
.wait('Enter a name for the project')
.sendLine(s.name)
.wait('Enter a name for the environment')
.sendLine(s.envName)
.wait('Choose your default editor:')
.sendLine(s.editor)
.wait("Choose the type of app that you're building")
.sendLine(s.appType)
.wait('What javascript framework are you using')
.sendLine(s.framework)
.wait('Source Directory Path:')
.sendLine(s.srcDir)
.wait('Distribution Directory Path:')
.sendLine(s.distDir)
.wait('Build Command:')
.sendLine(s.buildCmd)
.wait('Start Command:')
.sendCarriageReturn()
.wait('Using default provider awscloudformation');

if (testingWithLatestCodebase || !isCI()) {
chain.wait('Select the authentication method you want to use:').sendCarriageReturn();
} else {
chain.wait('Do you want to use an AWS profile?').sendLine('y');
}

chain
.wait('Please choose the profile you want to use')
.sendLine(s.profileName)
.wait('Try "amplify add api" to create a backend API and then "amplify publish" to deploy everything')
.run((err: Error) => {
if (!err) {
resolve();
} else {
reject(err);
}
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ async function determineAuthFlow(context: $TSContext, projectConfig?: ProjectCon
// Check for headless parameters
let { accessKeyId, profileName, region, secretAccessKey, useProfile } = _.get(
context,
['exeInfo', 'inputParams', 'awscloudformation'],
['exeInfo', 'inputParams', 'awscloudformation', 'config'],
{},
);

Expand Down

0 comments on commit 8647486

Please sign in to comment.