From 57eeae5cfe5ada34497b2fdfe21fd7b45d5dad0d Mon Sep 17 00:00:00 2001 From: John Corser Date: Thu, 22 Jul 2021 23:49:41 -0400 Subject: [PATCH] test(amplify-e2e-tests): add layerAndFunctionExist param to trigger capability selection (#7784) --- packages/amplify-e2e-core/src/categories/lambda-function.ts | 4 ++++ packages/amplify-e2e-tests/src/__tests__/layer-2.test.ts | 2 ++ .../lambda-layer-migration/layer-migration.test.ts | 1 + .../__tests__/update_tests/function_migration_update.test.ts | 1 + 4 files changed, 8 insertions(+) diff --git a/packages/amplify-e2e-core/src/categories/lambda-function.ts b/packages/amplify-e2e-core/src/categories/lambda-function.ts index ef73f2f1548..51af3693069 100644 --- a/packages/amplify-e2e-core/src/categories/lambda-function.ts +++ b/packages/amplify-e2e-core/src/categories/lambda-function.ts @@ -175,6 +175,9 @@ const coreFunction = ( selectTemplate(chain, settings.functionTemplate, runtime); } } else { + if (settings.layerOptions && settings.layerOptions.layerAndFunctionExist) { + chain.wait('Select which capability you want to update:').sendCarriageReturn() // lambda function + } chain.wait('Select the Lambda function you want to update').sendCarriageReturn(); // assumes only one function configured in the project } @@ -358,6 +361,7 @@ export const removeFunction = (cwd: string, funcName: string) => export interface LayerOptions { select?: string[]; // list options to select + layerAndFunctionExist?: boolean; // whether this test involves both a function and a layer expectedListOptions?: string[]; // the expected list of all layers versions?: Record; // map with keys for each element of select that determines the verison and expected version for each layer customArns?: string[]; // external ARNs to enter diff --git a/packages/amplify-e2e-tests/src/__tests__/layer-2.test.ts b/packages/amplify-e2e-tests/src/__tests__/layer-2.test.ts index 81f41d67068..840d9f5be73 100644 --- a/packages/amplify-e2e-tests/src/__tests__/layer-2.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/layer-2.test.ts @@ -254,6 +254,7 @@ describe('amplify add lambda layer with changes', () => { expectedListOptions: [fullLayerName], versions: { [fullLayerName]: { version: 1, expectedVersionOptions: [1] } }, skipLayerAssignment: true, + layerAndFunctionExist: true, }, }; @@ -277,6 +278,7 @@ describe('amplify add lambda layer with changes', () => { layerName, projName, layerOptions: { + layerAndFunctionExist: true, layerWalkthrough: (chain: ExecutionContext): void => { chain .wait('Provide existing layers') diff --git a/packages/amplify-migration-tests/src/__tests__/migration_tests/lambda-layer-migration/layer-migration.test.ts b/packages/amplify-migration-tests/src/__tests__/migration_tests/lambda-layer-migration/layer-migration.test.ts index 81d60a69dc6..22d0afd5e5a 100644 --- a/packages/amplify-migration-tests/src/__tests__/migration_tests/lambda-layer-migration/layer-migration.test.ts +++ b/packages/amplify-migration-tests/src/__tests__/migration_tests/lambda-layer-migration/layer-migration.test.ts @@ -172,6 +172,7 @@ describe('test lambda layer migration flow introduced in v5.0.0', () => { layerOptions: { select: [], expectedListOptions: [layerName], + layerAndFunctionExist: true, }, }; diff --git a/packages/amplify-migration-tests/src/__tests__/update_tests/function_migration_update.test.ts b/packages/amplify-migration-tests/src/__tests__/update_tests/function_migration_update.test.ts index 1b4a46d6f83..1755e98afef 100644 --- a/packages/amplify-migration-tests/src/__tests__/update_tests/function_migration_update.test.ts +++ b/packages/amplify-migration-tests/src/__tests__/update_tests/function_migration_update.test.ts @@ -117,6 +117,7 @@ describe('amplify function migration', () => { layerOptions: { select: [projName + layerName], expectedListOptions: [projName + layerName], + layerAndFunctionExist: true, }, name: function1, testingWithLatestCodebase: true,