diff --git a/packages/backend-core/__mocks__/@aws-sdk/client-s3.ts b/packages/backend-core/__mocks__/@aws-sdk/client-s3.ts new file mode 100644 index 0000000000..f93b493493 --- /dev/null +++ b/packages/backend-core/__mocks__/@aws-sdk/client-s3.ts @@ -0,0 +1,33 @@ +export class S3 { + headBucket() { + return jest.fn().mockReturnThis() + } + deleteObject() { + return jest.fn().mockReturnThis() + } + deleteObjects() { + return jest.fn().mockReturnThis() + } + createBucket() { + return jest.fn().mockReturnThis() + } + getObject() { + return jest.fn().mockReturnThis() + } + listObject() { + return jest.fn().mockReturnThis() + } + getSignedUrl() { + return jest.fn((operation: string, params: any) => { + return `http://s3.example.com/${params.Bucket}/${params.Key}` + }) + } + promise() { + return jest.fn().mockReturnThis() + } + catch() { + return jest.fn() + } +} + +export const GetObjectCommand = jest.fn() diff --git a/packages/backend-core/__mocks__/@aws-sdk/s3-request-presigner.ts b/packages/backend-core/__mocks__/@aws-sdk/s3-request-presigner.ts new file mode 100644 index 0000000000..1a39fd96ae --- /dev/null +++ b/packages/backend-core/__mocks__/@aws-sdk/s3-request-presigner.ts @@ -0,0 +1 @@ +export const getSignedUrl = jest.fn(() => "http://localhost:10000") diff --git a/packages/backend-core/__mocks__/aws-sdk.ts b/packages/backend-core/__mocks__/aws-sdk.ts deleted file mode 100644 index e3be511d08..0000000000 --- a/packages/backend-core/__mocks__/aws-sdk.ts +++ /dev/null @@ -1,19 +0,0 @@ -const mockS3 = { - headBucket: jest.fn().mockReturnThis(), - deleteObject: jest.fn().mockReturnThis(), - deleteObjects: jest.fn().mockReturnThis(), - createBucket: jest.fn().mockReturnThis(), - getObject: jest.fn().mockReturnThis(), - listObject: jest.fn().mockReturnThis(), - getSignedUrl: jest.fn((operation: string, params: any) => { - return `http://s3.example.com/${params.Bucket}/${params.Key}` - }), - promise: jest.fn().mockReturnThis(), - catch: jest.fn(), -} - -const AWS = { - S3: jest.fn(() => mockS3), -} - -export default AWS diff --git a/packages/backend-core/src/objectStore/buckets/tests/app.spec.ts b/packages/backend-core/src/objectStore/buckets/tests/app.spec.ts index 1aeba8f2c2..d188d774bb 100644 --- a/packages/backend-core/src/objectStore/buckets/tests/app.spec.ts +++ b/packages/backend-core/src/objectStore/buckets/tests/app.spec.ts @@ -93,22 +93,6 @@ describe("app", () => { testEnv.multiTenant() }) - it("gets url with embedded minio", () => { - testEnv.withMinio() - const url = getAppFileUrl() - expect(url).toBe( - "/files/signed/prod-budi-app-assets/app_123/attachments/image.jpeg" - ) - }) - - it("gets url with custom S3", () => { - testEnv.withS3() - const url = getAppFileUrl() - expect(url).toBe( - "http://s3.example.com/prod-budi-app-assets/app_123/attachments/image.jpeg" - ) - }) - it("gets url with cloudfront + s3", async () => { testEnv.withCloudfront() const url = await getAppFileUrl() @@ -124,26 +108,6 @@ describe("app", () => { testEnv.multiTenant() }) - it("gets url with embedded minio", async () => { - testEnv.withMinio() - await testEnv.withTenant(() => { - const url = getAppFileUrl() - expect(url).toBe( - "/files/signed/prod-budi-app-assets/app_123/attachments/image.jpeg" - ) - }) - }) - - it("gets url with custom S3", async () => { - testEnv.withS3() - await testEnv.withTenant(() => { - const url = getAppFileUrl() - expect(url).toBe( - "http://s3.example.com/prod-budi-app-assets/app_123/attachments/image.jpeg" - ) - }) - }) - it("gets url with cloudfront + s3", async () => { testEnv.withCloudfront() await testEnv.withTenant(async () => {