🎥 Make videos programmatically with React
Merge remote-tracking branch 'origin/main' into fix-studio-discovery-non-studio-response
Igor Samokhovets2b3d0e1c070b
diff --cc packages/studio-protocol/src/test/install-in-studio.test.tsindex becb95518d,e88a22d1ba..2563e6e712--- a/packages/studio-protocol/src/test/install-in-studio.test.ts+++ b/packages/studio-protocol/src/test/install-in-studio.test.ts@@@ -194,25 -195,79 +195,98 @@@ test('returns an actionable result whe]);});+test('ignores a non-Studio development server on a probed port', async () => {+ const result = await installInStudioWithDependencies(elementPayload, {+ ...dependencies,+ ports: [3000],+ fetchFn: () =>+ Promise.resolve(+ new Response('<!doctype html><html><body>Remotion docs</body></html>', {+ headers: {'Content-Type': 'text/html'},+ }),+ ),+ });++ expect(result).toEqual({+ success: false,+ code: 'no-compatible-studio',+ message: 'Start Remotion Studio and open a composition, then try again.',+ });+});++ test('reports when loopback network access is explicitly denied after discovery', async () => {+ const events: string[] = [];+ const result = await installInStudioWithDependencies(elementPayload, {+ ...dependencies,+ fetchFn: (input) => {+ events.push(String(input));+ return Promise.resolve(new Response(null, {status: 404}));+ },+ permissionQueryFn: ({name}) => {+ events.push(`permission:${name}`);+ return Promise.resolve({state: 'denied'});+ },+ });++ expect(result).toEqual({+ success: false,+ code: 'loopback-network-permission-denied',+ message:+ 'Access to localhost is blocked by your browser. Open the site settings, allow local network access for this site, then try again.',+ });+ expect(events).toEqual([+ 'http://localhost:3000/api/studio-protocol',+ 'http://localhost:3001/api/studio-protocol',+ 'permission:loopback-network',+ ]);+ });++ test('uses the legacy local network permission alias when necessary', async () => {+ const queriedPermissions: string[] = [];+ const result = await installInStudioWithDependencies(elementPayload, {+ ...dependencies,+ fetchFn: () => Promise.resolve(new Response(null, {status: 404})),+ permissionQueryFn: ({name}) => {+ queriedPermissions.push(name);+ if (name === 'loopback-network') {+ return Promise.reject(new TypeError('Unsupported permission name'));+ }++ return Promise.resolve({state: 'denied'});+ },+ });++ expect(result).toEqual({+ success: false,+ code: 'loopback-network-permission-denied',+ message:+ 'Access to localhost is blocked by your browser. Open the site settings, allow local network access for this site, then try again.',+ });+ expect(queriedPermissions).toEqual([+ 'loopback-network',+ 'local-network-access',+ ]);+ });++ test('keeps the generic result when permission is not definitively denied', async () => {+ for (const permissionQueryFn of [+ () => Promise.resolve({state: 'prompt' as const}),+ () => Promise.reject(new Error('Permissions API failed')),+ ]) {+ const result = await installInStudioWithDependencies(elementPayload, {+ ...dependencies,+ fetchFn: () => Promise.resolve(new Response(null, {status: 404})),+ permissionQueryFn,+ });++ expect(result).toEqual({+ success: false,+ code: 'no-compatible-studio',+ message: 'Start Remotion Studio and open a composition, then try again.',+ });+ }+ });+test('waits for Studio discovery while local network permission is pending', async () => {const fetchFn = function (this: void,