11//special handling needed to test prediction
22//This test will faile due to a possible AppSync bug, see details below the test code
3- import path from 'path' ;
4- import fs from 'fs-extra' ;
5- import aws from 'aws-sdk' ;
63import gql from 'graphql-tag' ;
7- import { addAuthWithDefault , addS3Storage , getBackendAmplifyMeta , addApi , amplifyPush } from '@aws-amplify/amplify-e2e-core' ;
4+ import { addAuthWithDefault , addS3Storage , addApi , amplifyPush } from '@aws-amplify/amplify-e2e-core' ;
85
96import { getApiKey , configureAmplify , getConfiguredAppsyncClientAPIKeyAuth } from '../authHelper' ;
107import { updateSchemaInTestProject } from '../common' ;
118
12- const imageKey = 'public/myimage.jpg' ;
13-
149export async function runTest ( projectDir : string , testModule : any ) {
1510 await addAuthWithDefault ( projectDir ) ;
1611 await addS3Storage ( projectDir ) ;
1712 await addApi ( projectDir , { transformerVersion : 1 } ) ;
1813 updateSchemaInTestProject ( projectDir , testModule . schema ) ;
1914
2015 await amplifyPush ( projectDir ) ;
21-
22- await uploadImageFile ( projectDir ) ;
23-
2416 const apiKey = getApiKey ( projectDir ) ;
2517 const awsconfig = configureAmplify ( projectDir ) ;
2618 const appSyncClient = getConfiguredAppsyncClientAPIKeyAuth ( awsconfig . aws_appsync_graphqlEndpoint , awsconfig . aws_appsync_region , apiKey ) ;
@@ -40,38 +32,6 @@ export async function runTest(projectDir: string, testModule: any) {
4032 }
4133}
4234
43- async function uploadImageFile ( projectDir : string ) {
44- const imageFilePath = path . join ( __dirname , 'predictions-usage-image.jpg' ) ;
45- const s3Client = new aws . S3 ( {
46- accessKeyId : process . env . AWS_ACCESS_KEY_ID ,
47- secretAccessKey : process . env . AWS_SECRET_ACCESS_KEY ,
48- sessionToken : process . env . AWS_SESSION_TOKEN ,
49- region : process . env . AWS_DEFAULT_REGION ,
50- } ) ;
51-
52- const amplifyMeta = getBackendAmplifyMeta ( projectDir ) ;
53- const storageResourceName = Object . keys ( amplifyMeta . storage ) . find ( ( key : any ) => {
54- return amplifyMeta . storage [ key ] . service === 'S3' ;
55- } ) as any ;
56-
57- const bucketName = amplifyMeta . storage [ storageResourceName ] . output . BucketName ;
58- try {
59- const fileStream = fs . createReadStream ( imageFilePath ) ;
60- const uploadParams = {
61- Bucket : bucketName ,
62- Key : imageKey ,
63- Body : fileStream ,
64- ContentType : 'image/jpeg' ,
65- ACL : 'public-read' ,
66- } ;
67- await s3Client . upload ( uploadParams ) . promise ( ) ;
68- } catch ( err ) {
69- if ( err . code !== 'AccessControlListNotSupported' ) {
70- throw err ;
71- }
72- }
73- }
74-
7535//schema
7636export const schema = `
7737type Query {
0 commit comments