Skip to content

🎥 Make videos programmatically with React

some more progress

Jonny Burgeraf03f55fe224
diff --git a/packages/lambda/src/api/__mocks__/bucket-exists.ts b/packages/lambda/src/api/__mocks__/bucket-exists.ts
index 090a06a632..52e92a83d1 100644
--- a/packages/lambda/src/api/__mocks__/bucket-exists.ts
+++ b/packages/lambda/src/api/__mocks__/bucket-exists.ts
@@ -1,5 +1,5 @@
+import {mockBucketExists} from '../../test/mocks/mock-store';
import type {bucketExistsInRegion as original} from '../bucket-exists';
-import {mockBucketExists} from './mock-store';
export const bucketExistsInRegion: typeof original = (input) => {
return Promise.resolve(mockBucketExists(input.bucketName, input.region));
diff --git a/packages/lambda/src/api/__mocks__/create-bucket.ts b/packages/lambda/src/api/__mocks__/create-bucket.ts
deleted file mode 100644
index 3ff1688358..0000000000
--- a/packages/lambda/src/api/__mocks__/create-bucket.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import type {createBucket as original} from '../create-bucket';
-import {addMockBucket} from './mock-store';
-
-export const createBucket: typeof original = (input) => {
- addMockBucket({
- region: input.region,
- creationDate: 0,
- name: input.bucketName,
- });
- return Promise.resolve();
-};
diff --git a/packages/lambda/src/api/__mocks__/get-buckets.ts b/packages/lambda/src/api/__mocks__/get-buckets.ts
deleted file mode 100644
index 4df28f0cfe..0000000000
--- a/packages/lambda/src/api/__mocks__/get-buckets.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import type {getRemotionS3Buckets as original} from '../get-buckets';
-import {getMockBuckets} from './mock-store';
-
-export const getRemotionS3Buckets = (): ReturnType<typeof original> => {
- return Promise.resolve({
- remotionBuckets: getMockBuckets(),
- });
-};
diff --git a/packages/lambda/src/api/__mocks__/mock-s3.ts b/packages/lambda/src/api/__mocks__/mock-s3.ts
index b5ce028043..2a8d0c9438 100644
--- a/packages/lambda/src/api/__mocks__/mock-s3.ts
+++ b/packages/lambda/src/api/__mocks__/mock-s3.ts
@@ -1,6 +1,6 @@
+import type {Privacy} from '@remotion/serverless/client';
import type {ReadStream} from 'node:fs';
-import type {Privacy} from '../../defaults';
-import type {AwsRegion} from '../../pricing/aws-regions';
+import type {AwsRegion} from '../../regions';
type S3MockFile = {
bucketName: string;
diff --git a/packages/lambda/src/functions/helpers/__mocks__/check-if-render-exists.ts b/packages/lambda/src/functions/helpers/__mocks__/check-if-render-exists.ts
deleted file mode 100644
index 00cdeee0a6..0000000000
--- a/packages/lambda/src/functions/helpers/__mocks__/check-if-render-exists.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import type {checkIfRenderExists as original} from '../check-if-render-exists';
-
-export const checkIfRenderExists: typeof original = () => {
- return undefined;
-};
diff --git a/packages/lambda/src/functions/helpers/__mocks__/get-browser-instance.ts b/packages/lambda/src/functions/helpers/__mocks__/get-browser-instance.ts
index e0515117c5..25c5274854 100644
--- a/packages/lambda/src/functions/helpers/__mocks__/get-browser-instance.ts
+++ b/packages/lambda/src/functions/helpers/__mocks__/get-browser-instance.ts
@@ -1,9 +1,9 @@
import {openBrowser} from '@remotion/renderer';
-import type {Await} from '../../../shared/await';
import type {
forgetBrowserEventLoop as originalForget,
getBrowserInstance as originalGetBrowserInstance,
-} from '../../helpers/get-browser-instance';
+} from '@remotion/serverless';
+import type {Await} from '@remotion/serverless/client';
let _browserInstance: Await<ReturnType<typeof openBrowser>> | null;
diff --git a/packages/lambda/src/functions/helpers/__mocks__/get-chromium-executable-path.ts b/packages/lambda/src/functions/helpers/__mocks__/get-chromium-executable-path.ts
deleted file mode 100644
index b8711ef79b..0000000000
--- a/packages/lambda/src/functions/helpers/__mocks__/get-chromium-executable-path.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import type {executablePath as original} from '../../../functions/helpers/get-chromium-executable-path';
-
-export const executablePath: typeof original = () => {
- return undefined;
-};
diff --git a/packages/lambda/src/functions/helpers/__mocks__/get-current-region.ts b/packages/lambda/src/functions/helpers/__mocks__/get-current-region.ts
deleted file mode 100644
index 480633074a..0000000000
--- a/packages/lambda/src/functions/helpers/__mocks__/get-current-region.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import type {getCurrentRegionInFunction as original} from '../get-current-region';
-
-export const getCurrentRegionInFunction: typeof original = () => {
- return 'eu-central-1';
-};
diff --git a/packages/lambda/src/functions/helpers/__mocks__/io.ts b/packages/lambda/src/functions/helpers/__mocks__/io.ts
index 3364b27890..1f543ceab6 100644
--- a/packages/lambda/src/functions/helpers/__mocks__/io.ts
+++ b/packages/lambda/src/functions/helpers/__mocks__/io.ts
@@ -40,7 +40,7 @@ export const lambdaWriteFile: typeof writeOriginal = ({
region,
}) => {
writeMockS3File({
- body,
+ body: body as string,
bucketName,
key,
privacy,
diff --git a/packages/lambda/src/shared/__mocks__/aws-clients.ts b/packages/lambda/src/shared/__mocks__/aws-clients.ts
index 5b60aa5688..6e941d4d65 100644
--- a/packages/lambda/src/shared/__mocks__/aws-clients.ts
+++ b/packages/lambda/src/shared/__mocks__/aws-clients.ts
@@ -1,5 +1,6 @@
import type {LambdaClient} from '@aws-sdk/client-lambda';
+import {awsImplementation} from '../../functions/aws-implementation';
import {ResponseStream} from '../../functions/helpers/streamify-response';
import type {getLambdaClient as original} from '../../shared/aws-clients';
export const getLambdaClient: typeof original = (region, timeoutInTest) => {
@@ -22,11 +23,16 @@ export const getLambdaClient: typeof original = (region, timeoutInTest) => {
const {routine} = await import('../../functions/index');
const responseStream = new ResponseStream();
- const prom = routine(payload, responseStream, {
- invokedFunctionArn: 'arn:fake',
- getRemainingTimeInMillis: () => timeoutInTest ?? 120000,
- awsRequestId: 'fake',
- });
+ const prom = routine(
+ payload,
+ responseStream,
+ {
+ invokedFunctionArn: 'arn:fake',
+ getRemainingTimeInMillis: () => timeoutInTest ?? 120000,
+ awsRequestId: 'fake',
+ },
+ awsImplementation,
+ );
if (
params.input.InvocationType === 'RequestResponse' ||
params.input.InvocationType === 'Event'
diff --git a/packages/lambda/src/test/mock-implementation.ts b/packages/lambda/src/test/mock-implementation.ts
new file mode 100644
index 0000000000..87f6a3be43
--- /dev/null
+++ b/packages/lambda/src/test/mock-implementation.ts
@@ -0,0 +1,21 @@
+import type {ProviderSpecifics} from '@remotion/serverless';
+import type {AwsRegion} from '../regions';
+import {addMockBucket, getMockBuckets} from './mocks/mock-store';
+
+export const mockImplementation: ProviderSpecifics<AwsRegion> = {
+ applyLifeCycle: () => Promise.resolve(),
+ regionType: 'us-east-1',
+ getChromiumPath() {
+ return null;
+ },
+ getCurrentRegionInFunction: () => 'eu-central-1',
+ createBucket: (input) => {
+ addMockBucket({
+ region: input.region,
+ creationDate: 0,
+ name: input.bucketName,
+ });
+ return Promise.resolve();
+ },
+ getBuckets: () => Promise.resolve(getMockBuckets()),
+};
diff --git a/packages/lambda/src/api/__mocks__/mock-store.ts b/packages/lambda/src/test/mocks/mock-store.ts
similarity index 86%
rename from packages/lambda/src/api/__mocks__/mock-store.ts
rename to packages/lambda/src/test/mocks/mock-store.ts
index 2d1e8a30b3..bb947dafd4 100644
--- a/packages/lambda/src/api/__mocks__/mock-store.ts
+++ b/packages/lambda/src/test/mocks/mock-store.ts
@@ -1,4 +1,4 @@
-import type {BucketWithLocation} from '../get-buckets';
+import type {BucketWithLocation} from '../../api/get-buckets';
export const mockBucketStore: BucketWithLocation[] = [];
diff --git a/packages/lambda/src/test/setup.ts b/packages/lambda/src/test/setup.ts
index 9247456a41..5d12b0c6a8 100644
--- a/packages/lambda/src/test/setup.ts
+++ b/packages/lambda/src/test/setup.ts
@@ -1,8 +1,5 @@
import {vi} from 'vitest';
-vi.mock('../api/get-buckets', () =>
- vi.importActual('../api/__mocks__/get-buckets'),
-);
vi.mock('../cli/helpers/quit', () =>
vi.importActual('../cli/helpers/__mocks__/quit'),
);
@@ -44,9 +41,6 @@ vi.mock('../shared/get-account-id', () =>
vi.mock('../shared/aws-clients', () =>
vi.importActual('../shared/__mocks__/aws-clients'),
);
-vi.mock('../api/create-bucket', () =>
- vi.importActual('../api/__mocks__/create-bucket'),
-);
vi.mock('../shared/read-dir', () =>
vi.importActual('../shared/__mocks__/read-dir'),
);
diff --git a/packages/serverless/src/provider-implementation.ts b/packages/serverless/src/provider-implementation.ts
index ec14880853..e4736f97c5 100644
--- a/packages/serverless/src/provider-implementation.ts
+++ b/packages/serverless/src/provider-implementation.ts
@@ -24,7 +24,7 @@ type ApplyLifeCycle<Region extends string> = (params: {
}) => Promise<void>;
export type ProviderSpecifics<Region extends string> = {
- getChromiumPath: () => string;
+ getChromiumPath: () => string | null;
getCurrentRegionInFunction: () => Region;
regionType: Region;
getBuckets: GetBuckets<Region>;