From fd588b9fe16d121be4c859116a005c6470efb049 Mon Sep 17 00:00:00 2001 From: Colin Ihrig Date: Mon, 18 Oct 2021 12:59:07 -0400 Subject: [PATCH 1/2] test: port @http e2e tests to v2 --- .circleci/config.yml | 191 +++++--- .../__tests__/HttpTransformerV2.e2e.test.ts | 455 ++++++++++++++++++ 2 files changed, 574 insertions(+), 72 deletions(-) create mode 100644 packages/graphql-transformers-e2e-tests/src/__tests__/HttpTransformerV2.e2e.test.ts diff --git a/.circleci/config.yml b/.circleci/config.yml index 14e236d7218..6e08aadaead 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10256,6 +10256,36 @@ jobs: AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/HttpTransformer.e2e.test.ts CLI_REGION: ap-southeast-2 + HttpTransformerV2-e2e-graphql_e2e_tests: + working_directory: ~/repo + parameters: + os: + type: executor + default: linux + executor: << parameters.os >> + steps: + - attach_workspace: + at: ./ + - restore_cache: + key: >- + amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}-{{ + arch }} + - run: + name: Run GraphQL end-to-end tests + command: | + source .circleci/local_publish_helpers.sh + cd packages/graphql-transformers-e2e-tests/ + retry yarn e2e --maxWorkers=3 $TEST_SUITE + environment: + AMPLIFY_CLI_DISABLE_LOGGING: 'true' + no_output_timeout: 90m + - store_test_results: + path: packages/graphql-transformers-e2e-tests/ + environment: + AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin + AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify + TEST_SUITE: src/__tests__/HttpTransformerV2.e2e.test.ts + CLI_REGION: us-east-2 IndexTransformer-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10285,7 +10315,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/IndexTransformer.e2e.test.ts - CLI_REGION: us-east-2 + CLI_REGION: us-west-2 IndexWithAuthV2-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10315,7 +10345,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/IndexWithAuthV2.e2e.test.ts - CLI_REGION: us-west-2 + CLI_REGION: eu-west-2 KeyTransformer-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10345,7 +10375,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/KeyTransformer.e2e.test.ts - CLI_REGION: eu-west-2 + CLI_REGION: eu-central-1 KeyTransformerLocal-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10375,7 +10405,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/KeyTransformerLocal.e2e.test.ts - CLI_REGION: eu-central-1 + CLI_REGION: ap-northeast-1 KeyWithAuth-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10405,7 +10435,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/KeyWithAuth.e2e.test.ts - CLI_REGION: ap-northeast-1 + CLI_REGION: ap-southeast-1 ModelAuthTransformer-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10435,7 +10465,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/ModelAuthTransformer.e2e.test.ts - CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-2 ModelConnectionTransformer-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10465,7 +10495,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/ModelConnectionTransformer.e2e.test.ts - CLI_REGION: ap-southeast-2 + CLI_REGION: us-east-2 ModelConnectionWithKeyTransformer-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10495,7 +10525,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/ModelConnectionWithKeyTransformer.e2e.test.ts - CLI_REGION: us-east-2 + CLI_REGION: us-west-2 ModelTransformer-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10525,7 +10555,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/ModelTransformer.e2e.test.ts - CLI_REGION: us-west-2 + CLI_REGION: eu-west-2 MultiAuthModelAuthTransformer-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10555,7 +10585,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/MultiAuthModelAuthTransformer.e2e.test.ts - CLI_REGION: eu-west-2 + CLI_REGION: eu-central-1 MultiAuthV2Transformer-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10585,7 +10615,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/MultiAuthV2Transformer.e2e.test.ts - CLI_REGION: eu-central-1 + CLI_REGION: ap-northeast-1 MutationCondition-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10615,7 +10645,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/MutationCondition.e2e.test.ts - CLI_REGION: ap-northeast-1 + CLI_REGION: ap-southeast-1 NestedStacksTest-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10645,7 +10675,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/NestedStacksTest.e2e.test.ts - CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-2 NewConnectionTransformer-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10675,7 +10705,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/NewConnectionTransformer.e2e.test.ts - CLI_REGION: ap-southeast-2 + CLI_REGION: us-east-2 NewConnectionWithAuth-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10705,7 +10735,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/NewConnectionWithAuth.e2e.test.ts - CLI_REGION: us-east-2 + CLI_REGION: us-west-2 NoneEnvFunctionTransformer-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10735,7 +10765,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/NoneEnvFunctionTransformer.e2e.test.ts - CLI_REGION: us-west-2 + CLI_REGION: eu-west-2 NonModelAuthFunction-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10765,7 +10795,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/NonModelAuthFunction.e2e.test.ts - CLI_REGION: eu-west-2 + CLI_REGION: eu-central-1 NonModelAuthV2Function-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10795,7 +10825,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/NonModelAuthV2Function.e2e.test.ts - CLI_REGION: eu-central-1 + CLI_REGION: ap-northeast-1 PerFieldAuthTests-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10825,7 +10855,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/PerFieldAuthTests.e2e.test.ts - CLI_REGION: ap-northeast-1 + CLI_REGION: ap-southeast-1 PerFieldAuthV2Transformer-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10855,7 +10885,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/PerFieldAuthV2Transformer.e2e.test.ts - CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-2 PredictionsTransformerTests-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10885,7 +10915,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/PredictionsTransformerTests.e2e.test.ts - CLI_REGION: ap-southeast-2 + CLI_REGION: us-east-2 RelationalTransformers-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10915,7 +10945,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/RelationalTransformers.e2e.test.ts - CLI_REGION: us-east-2 + CLI_REGION: us-west-2 RelationalWithAuthV2-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10945,7 +10975,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/RelationalWithAuthV2.e2e.test.ts - CLI_REGION: us-west-2 + CLI_REGION: eu-west-2 SearchableModelTransformer-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -10975,7 +11005,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/SearchableModelTransformer.e2e.test.ts - CLI_REGION: eu-west-2 + CLI_REGION: eu-central-1 SearchableModelTransformerV2-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -11005,7 +11035,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/SearchableModelTransformerV2.e2e.test.ts - CLI_REGION: eu-central-1 + CLI_REGION: ap-northeast-1 SearchableWithAuthTests-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -11035,7 +11065,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/SearchableWithAuthTests.e2e.test.ts - CLI_REGION: ap-northeast-1 + CLI_REGION: ap-southeast-1 SearchableWithAuthV2-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -11065,7 +11095,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/SearchableWithAuthV2.e2e.test.ts - CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-2 SubscriptionsWithAuthTest-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -11095,7 +11125,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/SubscriptionsWithAuthTest.e2e.test.ts - CLI_REGION: ap-southeast-2 + CLI_REGION: us-east-2 SubscriptionsWithAuthV2-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -11125,7 +11155,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/SubscriptionsWithAuthV2.e2e.test.ts - CLI_REGION: us-east-2 + CLI_REGION: us-west-2 TestComplexStackMappingsLocal-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -11155,7 +11185,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/TestComplexStackMappingsLocal.e2e.test.ts - CLI_REGION: us-west-2 + CLI_REGION: eu-west-2 VersionedModelTransformer-e2e-graphql_e2e_tests: working_directory: ~/repo parameters: @@ -11185,7 +11215,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/packages/amplify-cli/bin AMPLIFY_PATH: /home/circleci/repo/packages/amplify-cli/bin/amplify TEST_SUITE: src/__tests__/VersionedModelTransformer.e2e.test.ts - CLI_REGION: eu-west-2 + CLI_REGION: eu-central-1 migration_tests-auth-deployment-migration-auth-deployment-secrets-amplify_migration_tests_v4: working_directory: ~/repo parameters: @@ -12585,43 +12615,44 @@ workflows: - schema-auth-6-amplify_e2e_tests_pkg - schema-iterative-update-4-amplify_e2e_tests_pkg - AuthV2Transformer-e2e-graphql_e2e_tests + - HttpTransformerV2-e2e-graphql_e2e_tests + - ModelConnectionTransformer-e2e-graphql_e2e_tests + - NewConnectionTransformer-e2e-graphql_e2e_tests + - PredictionsTransformerTests-e2e-graphql_e2e_tests + - SubscriptionsWithAuthTest-e2e-graphql_e2e_tests + - ConnectionsWithAuthTests-e2e-graphql_e2e_tests - IndexTransformer-e2e-graphql_e2e_tests - ModelConnectionWithKeyTransformer-e2e-graphql_e2e_tests - NewConnectionWithAuth-e2e-graphql_e2e_tests - RelationalTransformers-e2e-graphql_e2e_tests - SubscriptionsWithAuthV2-e2e-graphql_e2e_tests - - ConnectionsWithAuthTests-e2e-graphql_e2e_tests + - CustomRoots-e2e-graphql_e2e_tests - IndexWithAuthV2-e2e-graphql_e2e_tests - ModelTransformer-e2e-graphql_e2e_tests - NoneEnvFunctionTransformer-e2e-graphql_e2e_tests - RelationalWithAuthV2-e2e-graphql_e2e_tests - TestComplexStackMappingsLocal-e2e-graphql_e2e_tests - - CustomRoots-e2e-graphql_e2e_tests + - DefaultValueTransformer-e2e-graphql_e2e_tests - KeyTransformer-e2e-graphql_e2e_tests - MultiAuthModelAuthTransformer-e2e-graphql_e2e_tests - NonModelAuthFunction-e2e-graphql_e2e_tests - SearchableModelTransformer-e2e-graphql_e2e_tests - VersionedModelTransformer-e2e-graphql_e2e_tests - - DefaultValueTransformer-e2e-graphql_e2e_tests + - DynamoDBModelTransformer-e2e-graphql_e2e_tests - KeyTransformerLocal-e2e-graphql_e2e_tests - MultiAuthV2Transformer-e2e-graphql_e2e_tests - NonModelAuthV2Function-e2e-graphql_e2e_tests - SearchableModelTransformerV2-e2e-graphql_e2e_tests - - DynamoDBModelTransformer-e2e-graphql_e2e_tests + - FunctionTransformerTests-e2e-graphql_e2e_tests - KeyWithAuth-e2e-graphql_e2e_tests - MutationCondition-e2e-graphql_e2e_tests - PerFieldAuthTests-e2e-graphql_e2e_tests - SearchableWithAuthTests-e2e-graphql_e2e_tests - - FunctionTransformerTests-e2e-graphql_e2e_tests + - HttpTransformer-e2e-graphql_e2e_tests - ModelAuthTransformer-e2e-graphql_e2e_tests - NestedStacksTest-e2e-graphql_e2e_tests - PerFieldAuthV2Transformer-e2e-graphql_e2e_tests - SearchableWithAuthV2-e2e-graphql_e2e_tests - - HttpTransformer-e2e-graphql_e2e_tests - - ModelConnectionTransformer-e2e-graphql_e2e_tests - - NewConnectionTransformer-e2e-graphql_e2e_tests - - PredictionsTransformerTests-e2e-graphql_e2e_tests - - SubscriptionsWithAuthTest-e2e-graphql_e2e_tests - >- migration_tests-auth-deployment-migration-auth-deployment-secrets-amplify_migration_tests_v4 - update_tests-function_migration_update-amplify_migration_tests_v4 @@ -16471,7 +16502,7 @@ workflows: parameters: os: - linux - - IndexTransformer-e2e-graphql_e2e_tests: + - HttpTransformerV2-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16487,7 +16518,7 @@ workflows: parameters: os: - linux - - ModelConnectionWithKeyTransformer-e2e-graphql_e2e_tests: + - ModelConnectionTransformer-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16503,7 +16534,7 @@ workflows: parameters: os: - linux - - NewConnectionWithAuth-e2e-graphql_e2e_tests: + - NewConnectionTransformer-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16519,7 +16550,7 @@ workflows: parameters: os: - linux - - RelationalTransformers-e2e-graphql_e2e_tests: + - PredictionsTransformerTests-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16535,7 +16566,7 @@ workflows: parameters: os: - linux - - SubscriptionsWithAuthV2-e2e-graphql_e2e_tests: + - SubscriptionsWithAuthTest-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16567,7 +16598,7 @@ workflows: parameters: os: - linux - - IndexWithAuthV2-e2e-graphql_e2e_tests: + - IndexTransformer-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16583,7 +16614,7 @@ workflows: parameters: os: - linux - - ModelTransformer-e2e-graphql_e2e_tests: + - ModelConnectionWithKeyTransformer-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16599,7 +16630,7 @@ workflows: parameters: os: - linux - - NoneEnvFunctionTransformer-e2e-graphql_e2e_tests: + - NewConnectionWithAuth-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16615,7 +16646,7 @@ workflows: parameters: os: - linux - - RelationalWithAuthV2-e2e-graphql_e2e_tests: + - RelationalTransformers-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16631,7 +16662,7 @@ workflows: parameters: os: - linux - - TestComplexStackMappingsLocal-e2e-graphql_e2e_tests: + - SubscriptionsWithAuthV2-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16663,7 +16694,7 @@ workflows: parameters: os: - linux - - KeyTransformer-e2e-graphql_e2e_tests: + - IndexWithAuthV2-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16679,7 +16710,7 @@ workflows: parameters: os: - linux - - MultiAuthModelAuthTransformer-e2e-graphql_e2e_tests: + - ModelTransformer-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16695,7 +16726,7 @@ workflows: parameters: os: - linux - - NonModelAuthFunction-e2e-graphql_e2e_tests: + - NoneEnvFunctionTransformer-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16711,7 +16742,7 @@ workflows: parameters: os: - linux - - SearchableModelTransformer-e2e-graphql_e2e_tests: + - RelationalWithAuthV2-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16727,7 +16758,7 @@ workflows: parameters: os: - linux - - VersionedModelTransformer-e2e-graphql_e2e_tests: + - TestComplexStackMappingsLocal-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16759,7 +16790,7 @@ workflows: parameters: os: - linux - - KeyTransformerLocal-e2e-graphql_e2e_tests: + - KeyTransformer-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16775,7 +16806,7 @@ workflows: parameters: os: - linux - - MultiAuthV2Transformer-e2e-graphql_e2e_tests: + - MultiAuthModelAuthTransformer-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16791,7 +16822,7 @@ workflows: parameters: os: - linux - - NonModelAuthV2Function-e2e-graphql_e2e_tests: + - NonModelAuthFunction-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16807,7 +16838,23 @@ workflows: parameters: os: - linux - - SearchableModelTransformerV2-e2e-graphql_e2e_tests: + - SearchableModelTransformer-e2e-graphql_e2e_tests: + context: + - amplify-ecr-image-pull + - e2e-test-context + filters: + branches: + only: + - master + - /tagged-release\/.*/ + - /run-e2e\/.*/ + requires: + - build + matrix: + parameters: + os: + - linux + - VersionedModelTransformer-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16839,7 +16886,7 @@ workflows: parameters: os: - linux - - KeyWithAuth-e2e-graphql_e2e_tests: + - KeyTransformerLocal-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16855,7 +16902,7 @@ workflows: parameters: os: - linux - - MutationCondition-e2e-graphql_e2e_tests: + - MultiAuthV2Transformer-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16871,7 +16918,7 @@ workflows: parameters: os: - linux - - PerFieldAuthTests-e2e-graphql_e2e_tests: + - NonModelAuthV2Function-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16887,7 +16934,7 @@ workflows: parameters: os: - linux - - SearchableWithAuthTests-e2e-graphql_e2e_tests: + - SearchableModelTransformerV2-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16919,7 +16966,7 @@ workflows: parameters: os: - linux - - ModelAuthTransformer-e2e-graphql_e2e_tests: + - KeyWithAuth-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16935,7 +16982,7 @@ workflows: parameters: os: - linux - - NestedStacksTest-e2e-graphql_e2e_tests: + - MutationCondition-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16951,7 +16998,7 @@ workflows: parameters: os: - linux - - PerFieldAuthV2Transformer-e2e-graphql_e2e_tests: + - PerFieldAuthTests-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16967,7 +17014,7 @@ workflows: parameters: os: - linux - - SearchableWithAuthV2-e2e-graphql_e2e_tests: + - SearchableWithAuthTests-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -16999,7 +17046,7 @@ workflows: parameters: os: - linux - - ModelConnectionTransformer-e2e-graphql_e2e_tests: + - ModelAuthTransformer-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -17015,7 +17062,7 @@ workflows: parameters: os: - linux - - NewConnectionTransformer-e2e-graphql_e2e_tests: + - NestedStacksTest-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -17031,7 +17078,7 @@ workflows: parameters: os: - linux - - PredictionsTransformerTests-e2e-graphql_e2e_tests: + - PerFieldAuthV2Transformer-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context @@ -17047,7 +17094,7 @@ workflows: parameters: os: - linux - - SubscriptionsWithAuthTest-e2e-graphql_e2e_tests: + - SearchableWithAuthV2-e2e-graphql_e2e_tests: context: - amplify-ecr-image-pull - e2e-test-context diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/HttpTransformerV2.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/HttpTransformerV2.e2e.test.ts new file mode 100644 index 00000000000..d841b9d8201 --- /dev/null +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/HttpTransformerV2.e2e.test.ts @@ -0,0 +1,455 @@ +import { GraphQLTransform } from '@aws-amplify/graphql-transformer-core'; +import { ModelTransformer } from '@aws-amplify/graphql-model-transformer'; +import { ResourceConstants } from 'graphql-transformer-common'; +import { HttpTransformer } from '@aws-amplify/graphql-http-transformer'; +import { CloudFormationClient } from '../CloudFormationClient'; +import { Output } from 'aws-sdk/clients/cloudformation'; +import { GraphQLClient } from '../GraphQLClient'; +import { default as moment } from 'moment'; +import { cleanupStackAfterTest, deploy } from '../deployNestedStacks'; +import { S3Client } from '../S3Client'; +import { default as S3 } from 'aws-sdk/clients/s3'; +import { deployJsonServer, destroyJsonServer } from '../cdkUtils'; + +jest.setTimeout(2000000); + +const cf = new CloudFormationClient('us-west-2'); +const customS3Client = new S3Client('us-west-2'); +const awsS3Client = new S3({ region: 'us-west-2' }); +const featureFlags = { + getBoolean: jest.fn().mockImplementation((name, defaultValue) => { + if (name === 'improvePluralization') { + return true; + } + return; + }), + getNumber: jest.fn(), + getObject: jest.fn(), + getString: jest.fn(), +}; +const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); +const STACK_NAME = `HttpTransformerV2Test-${BUILD_TIMESTAMP}`; +const BUCKET_NAME = `appsync-http-transformer-v2-test-bucket-${BUILD_TIMESTAMP}`; +const LOCAL_FS_BUILD_DIR = '/tmp/http_transformer_v2_tests/'; +const S3_ROOT_DIR_KEY = 'deployments'; + +let GRAPHQL_CLIENT = undefined; + +function outputValueSelector(key: string) { + return (outputs: Output[]) => { + const output = outputs.find((o: Output) => o.OutputKey === key); + return output ? output.OutputValue : null; + }; +} + +beforeAll(async () => { + const { apiUrl } = deployJsonServer(); + + const validSchema = ` + type Comment @model { + id: ID! + title: String + simpleGet: CompObj @http(method: GET, url: "${apiUrl}posts/1") + simpleGet2: CompObj @http(url: "${apiUrl}posts/2") + complexPost( + id: Int, + title: String!, + body: String, + userId: Int + ): CompObj @http(method: POST, url: "${apiUrl}posts") + complexPut( + id: Int!, + title: String, + body: String, + userId: Int + ): CompObj @http(method: PUT, url: "${apiUrl}posts/:id") + deleter: String @http(method: DELETE, url: "${apiUrl}posts/4") + complexGet( + data: String!, + userId: Int!, + _limit: Int + ): [CompObj] @http(url: "${apiUrl}:data") + complexGet2( + dataType: String!, + postId: Int!, + secondType: String!, + id: Int + ): [PostComment] @http(url: "${apiUrl}:dataType/:postId/:secondType") + } + type CompObj { + userId: Int + id: Int + title: String + body: String + } + type PostComment { + postId: Int + id: Int + name: String + email: String + body: String + } + `; + + try { + await awsS3Client.createBucket({ Bucket: BUCKET_NAME }).promise(); + } catch (e) { + console.error(`Failed to create bucket: ${e}`); + } + + const transformer = new GraphQLTransform({ + featureFlags, + transformers: [new ModelTransformer(), new HttpTransformer()], + sandboxModeEnabled: true, + }); + + const out = transformer.transform(validSchema); + + try { + const finishedStack = await deploy( + customS3Client, + cf, + STACK_NAME, + out, + {}, + LOCAL_FS_BUILD_DIR, + BUCKET_NAME, + S3_ROOT_DIR_KEY, + BUILD_TIMESTAMP, + ); + + // Arbitrary wait to make sure everything is ready. + await cf.wait(5, () => Promise.resolve()); + + expect(finishedStack).toBeDefined(); + + const getApiEndpoint = outputValueSelector(ResourceConstants.OUTPUTS.GraphQLAPIEndpointOutput); + const getApiKey = outputValueSelector(ResourceConstants.OUTPUTS.GraphQLAPIApiKeyOutput); + const endpoint = getApiEndpoint(finishedStack.Outputs); + const apiKey = getApiKey(finishedStack.Outputs); + + expect(apiKey).toBeDefined(); + expect(endpoint).toBeDefined(); + + GRAPHQL_CLIENT = new GraphQLClient(endpoint, { 'x-api-key': apiKey }); + } catch (e) { + console.error(e); + expect(true).toEqual(false); + } +}); + +afterAll(async () => { + destroyJsonServer(); + + await cleanupStackAfterTest(BUCKET_NAME, STACK_NAME, cf); +}); + +/** + * Test queries below + */ +test('Test HTTP GET request', async () => { + try { + const response = await GRAPHQL_CLIENT.query( + `mutation { + createComment(input: { title: "Hello, World!" }) { + id + title + simpleGet { + id + title + body + } + } + }`, + {}, + ); + + const post1Title = 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit'; + + expect(response.errors).toBeUndefined(); + expect(response.data.createComment.id).toBeDefined(); + expect(response.data.createComment.title).toEqual('Hello, World!'); + expect(response.data.createComment.simpleGet).toBeDefined(); + expect(response.data.createComment.simpleGet.title).toEqual(post1Title); + } catch (e) { + console.error(e); + // fail + expect(e).toBeUndefined(); + } +}); + +test('Test HTTP GET request 2', async () => { + try { + const response = await GRAPHQL_CLIENT.query( + `mutation { + createComment(input: { title: "Hello, World!" }) { + id + title + simpleGet2 { + id + title + body + } + } + }`, + {}, + ); + + const post2Title = 'qui est esse'; + + expect(response.errors).toBeUndefined(); + expect(response.data.createComment.id).toBeDefined(); + expect(response.data.createComment.title).toEqual('Hello, World!'); + expect(response.data.createComment.simpleGet2).toBeDefined(); + expect(response.data.createComment.simpleGet2.title).toEqual(post2Title); + } catch (e) { + console.error(e); + // fail + expect(e).toBeUndefined(); + } +}); + +test('Test HTTP POST request', async () => { + try { + const response = await GRAPHQL_CLIENT.query( + `mutation { + createComment(input: { title: "Hello, World!" }) { + id + title + complexPost( + body: { + title: "foo", + body: "bar", + userId: 2 + } + ) { + id + title + body + userId + } + } + }`, + {}, + ); + + expect(response.errors).toBeUndefined(); + expect(response.data.createComment.id).toBeDefined(); + expect(response.data.createComment.title).toEqual('Hello, World!'); + expect(response.data.createComment.complexPost).toBeDefined(); + expect(response.data.createComment.complexPost.title).toEqual('foo'); + expect(response.data.createComment.complexPost.userId).toEqual(2); + } catch (e) { + console.error(e); + // fail + expect(e).toBeUndefined(); + } +}); + +test('Test HTTP PUT request', async () => { + try { + const response = await GRAPHQL_CLIENT.query( + `mutation { + createComment(input: { title: "Hello, World!" }) { + id + title + complexPut( + params: { + id: "3" + }, + body: { + title: "foo", + body: "bar", + userId: 2 + } + ) { + id + title + body + userId + } + } + }`, + {}, + ); + + expect(response.errors).toBeUndefined(); + expect(response.data.createComment.id).toBeDefined(); + expect(response.data.createComment.title).toEqual('Hello, World!'); + expect(response.data.createComment.complexPut).toBeDefined(); + expect(response.data.createComment.complexPut.title).toEqual('foo'); + expect(response.data.createComment.complexPut.userId).toEqual(2); + } catch (e) { + console.error(e); + // fail + expect(e).toBeUndefined(); + } +}); + +test('Test HTTP DELETE request', async () => { + try { + const response = await GRAPHQL_CLIENT.query( + `mutation { + createComment(input: { title: "Hello, World!" }) { + id + title + deleter + } + }`, + {}, + ); + + expect(response.errors).toBeUndefined(); + expect(response.data.createComment.id).toBeDefined(); + expect(response.data.createComment.title).toEqual('Hello, World!'); + expect(response.data.createComment.deleter).not.toBeNull(); + } catch (e) { + console.error(e); + // fail + expect(e).toBeUndefined(); + } +}); + +test('Test GET with URL param and query values', async () => { + try { + const response = await GRAPHQL_CLIENT.query( + `mutation { + createComment(input: { title: "Hello, World!" }) { + id + title + complexGet( + params: { + data: "posts" + }, + query: { + userId: 1, + _limit: 7 + } + ) { + id + title + body + } + } + }`, + {}, + ); + + expect(response.errors).toBeUndefined(); + expect(response.data.createComment.id).toBeDefined(); + expect(response.data.createComment.title).toEqual('Hello, World!'); + expect(response.data.createComment.complexGet).toBeDefined(); + expect(response.data.createComment.complexGet.length).toEqual(7); + } catch (e) { + console.error(e); + // fail + expect(e).toBeUndefined(); + } +}); + +test('Test GET with multiple URL params and query values', async () => { + try { + const response = await GRAPHQL_CLIENT.query( + `mutation { + createComment(input: { title: "Hello, World!" }) { + id + title + complexGet2( + params: { + dataType: "posts", + postId: "1", + secondType: "comments" + }, + query: { + id: 2 + } + ) { + id + name + email + } + } + }`, + {}, + ); + + expect(response.errors).toBeUndefined(); + expect(response.data.createComment.id).toBeDefined(); + expect(response.data.createComment.title).toEqual('Hello, World!'); + expect(response.data.createComment.complexGet2).toBeDefined(); + expect(response.data.createComment.complexGet2[0].email).toEqual('Jayne_Kuhic@sydney.com'); + } catch (e) { + console.error(e); + // fail + expect(e).toBeUndefined(); + } +}); + +test('Test that GET errors when missing a required Query input object', async () => { + try { + const response = await GRAPHQL_CLIENT.query( + `mutation { + createComment(input: { title: "Hello, World!" }) { + id + title + complexGet( + params: { + data: "posts", + } + ) { + id + title + body + } + } + }`, + {}, + ); + + expect(response.data).toBeNull(); + expect(response.errors).toBeDefined(); + expect(response.errors).toHaveLength(1); + expect(response.errors[0].message).toEqual( + "Validation error of type MissingFieldArgument: Missing field argument query @ 'createComment/complexGet'", + ); + } catch (e) { + console.error(e); + // fail + expect(e).toBeUndefined(); + } +}); + +test('Test that POST errors when missing a non-null arg in query/body', async () => { + try { + const response = await GRAPHQL_CLIENT.query( + `mutation { + createComment(input: { title: "Hello, World!" }) { + id + title + complexPost( + body: { + id: 1, + body: "bar" + } + ) { + id + title + body + } + } + }`, + {}, + ); + + expect(response.data.createComment.complexPost).toBeNull(); + expect(response.errors).toBeDefined(); + expect(response.errors).toHaveLength(1); + expect(response.errors[0].message).toEqual( + 'An argument you marked as Non-Null is not present in the query nor the body of your request.', + ); + } catch (e) { + console.error(e); + // fail + expect(e).toBeUndefined(); + } +}); From 7b164f3d0c4a222b2415bb514a500f9fc6a04e2b Mon Sep 17 00:00:00 2001 From: Colin Ihrig Date: Tue, 19 Oct 2021 11:45:56 -0400 Subject: [PATCH 2/2] fixup! test: port @http e2e tests to v2 --- .../src/__tests__/HttpTransformerV2.e2e.test.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/HttpTransformerV2.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/HttpTransformerV2.e2e.test.ts index d841b9d8201..774beb25825 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/HttpTransformerV2.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/HttpTransformerV2.e2e.test.ts @@ -16,17 +16,6 @@ jest.setTimeout(2000000); const cf = new CloudFormationClient('us-west-2'); const customS3Client = new S3Client('us-west-2'); const awsS3Client = new S3({ region: 'us-west-2' }); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `HttpTransformerV2Test-${BUILD_TIMESTAMP}`; const BUCKET_NAME = `appsync-http-transformer-v2-test-bucket-${BUILD_TIMESTAMP}`; @@ -98,7 +87,6 @@ beforeAll(async () => { } const transformer = new GraphQLTransform({ - featureFlags, transformers: [new ModelTransformer(), new HttpTransformer()], sandboxModeEnabled: true, });