Skip to content

🎥 Make videos programmatically with React

Merge remote-tracking branch 'origin/main' into element-install-permission

Igor Samokhovetsc65ff84f6d4e
diff --cc packages/studio-protocol/src/test/install-in-studio.test.ts
index 3a29e10002,5642c77bdf..72f0e7a675
--- a/packages/studio-protocol/src/test/install-in-studio.test.ts
+++ b/packages/studio-protocol/src/test/install-in-studio.test.ts
@@@ -184,65 -188,10 +188,69 @@@ test('returns an actionable result whe
code: 'no-compatible-studio',
message: 'Start Remotion Studio and open a composition, then try again.',
});
+ expect(requests).toEqual([
+ 'http://localhost:3000/api/studio-protocol',
+ 'http://localhost:3001/api/studio-protocol',
+ ]);
+});
+
+test('waits for Studio discovery while local network permission is pending', async () => {
+ const fetchFn = (input: string | URL | Request, options?: RequestInit) => {
+ const url = String(input);
+ if (url === 'http://localhost:3000/api/studio-protocol') {
+ return new Promise<Response>((resolve, reject) => {
+ const timeout = setTimeout(() => {
+ resolve(
+ jsonResponse(
+ descriptor({
+ compositionId: 'Main',
+ lastFocusedAt: 950_000,
+ projectName: 'Project',
+ targetId: 'target',
+ }),
+ ),
+ );
+ }, 2100);
+ options?.signal?.addEventListener(
+ 'abort',
+ () => {
+ clearTimeout(timeout);
+ reject(options.signal?.reason);
+ },
+ {once: true},
+ );
+ });
+ }
+
+ if (url === 'http://localhost:3000/api/studio-protocol/install') {
+ return Promise.resolve(
+ jsonResponse({
+ protocol: 'remotion-studio-protocol',
+ protocolVersion: 1,
+ status: 'awaiting-confirmation',
+ }),
+ );
+ }
+
+ return Promise.resolve(new Response(null, {status: 404}));
+ };
+
+ expect(
+ await installInStudioWithDependencies(elementPayload, {
+ ...dependencies,
+ ports: [3000],
+ fetchFn,
+ }),
+ ).toEqual({
+ success: true,
+ status: 'awaiting-confirmation',
+ target: {
+ projectName: 'Project',
+ compositionId: 'Main',
+ studioOrigin: 'http://localhost:3000',
+ studioVersion: '4.0.502',
+ },
+ });
});
test('reports malformed discovery JSON as an invalid response', async () => {