π₯ Make videos programmatically with React
fix tests
Jonny Burgera3f3ea094f67
diff --git a/packages/example/src/VisualControls/index.tsx b/packages/example/src/VisualControls/index.tsxindex c46f9f9970..06e88c87e9 100644--- a/packages/example/src/VisualControls/index.tsx+++ b/packages/example/src/VisualControls/index.tsx@@ -1,17 +1,31 @@+import {makeTransform, matrix3d} from '@remotion/animation-utils';import {visualControl} from '@remotion/studio';-import {AbsoluteFill} from 'remotion';+import {zMatrix, zTextarea} from '@remotion/zod-types';+import {AbsoluteFill, staticFile} from 'remotion';export const VisualControls = () => {- const rotation = visualControl('rotation', 180);+ const matrix = visualControl(+ 'my-matrix',+ [9.63, 0.83, 1.3, 0, 0, 2.79, 0, 0, 1.26, 0.35, 1, 0, 0, 0, 0, 1] as const,+ zMatrix(),+ );++ const matrix2 = visualControl(`my-matrix-2`, 123);+ const val3 = visualControl('my-matrix-4', 1234);+ const val4 = visualControl(`value π`, 'hi there');+ const val5 = visualControl(`text π`, 'hi there', zTextarea());++ const val6 = visualControl('file', staticFile('clip001.mkv'));return (<AbsoluteFillclassName="bg-red-300 text-7xl flex flex-1 items-center justify-center"style={{- transform: `rotate(${rotation}deg)`,+ transform: makeTransform([matrix3d(...matrix)]),}}>- Hello+ <p>{matrix.join(', ')}</p>+ <p>{val5}</p></AbsoluteFill>);};diff --git a/packages/it-tests/src/codemods/visual-controls.test.ts b/packages/it-tests/src/codemods/visual-controls.test.tsindex b0cb98aad5..b20e55aaab 100644--- a/packages/it-tests/src/codemods/visual-controls.test.ts+++ b/packages/it-tests/src/codemods/visual-controls.test.ts@@ -1,43 +1,63 @@import {StudioServerInternals} from '@remotion/studio-server';import {expect, test} from 'bun:test';-import {readFileSync} from 'fs';-import {resolve} from 'path';-const visualControlFile = resolve(- __dirname,- '..',- '..',- '..',- 'example',- 'src',- 'VisualControls',- 'index.tsx',-);+const contents = `+import {makeTransform, matrix3d} from '@remotion/animation-utils';+import {visualControl} from '@remotion/studio';+import {zMatrix, zTextarea} from '@remotion/zod-types';+import {AbsoluteFill, staticFile} from 'remotion';++export const VisualControls = () => {+ const matrix = visualControl(+ 'my-matrix',+ [9.63, 0.83, 1.3, 0, 0, 2.79, 0, 0, 1.26, 0.35, 1, 0, 0, 0, 0, 1] as const,+ zMatrix(),+ );++ // Is being tested against+ const matrix2 = visualControl(\`my-matrix-2\`, 123);+ const val3 = visualControl('my-matrix-4', 1234);+ const val4 = visualControl(\`value π\`, 'hi there');+ const val5 = visualControl(\`text π\`, 'hi there', zTextarea());++ const val6 = visualControl('file', staticFile('clip001.mkv'));++ return (+ <AbsoluteFill+ className="bg-red-300 text-7xl flex flex-1 items-center justify-center"+ style={{+ transform: makeTransform([matrix3d(...matrix)]),+ }}+ >+ <p>{matrix.join(', ')}</p>+ <p>{val5}</p>+ </AbsoluteFill>+ );+};+`;test('Should be able to create visual control', () => {const {newContents} = StudioServerInternals.parseAndApplyCodemod({- input: readFileSync(visualControlFile, 'utf-8'),+ input: contents,codeMod: {type: 'apply-visual-control',changes: [{- id: 'my-matrix',- newValueSerialized: '123',+ id: 'my-matrix-4',+ newValueSerialized: JSON.stringify(123),enumPaths: [],},{id: 'my-matrix-2',- newValueSerialized: '"456" as const',- enumPaths: [],+ newValueSerialized: JSON.stringify(456),+ enumPaths: [[]],},],},});+ expect(newContents).toContain(`visualControl('my-matrix-4', 123`);expect(newContents).toContain(- `const matrix = visualControl('my-matrix', 123,`,- );- expect(newContents).toContain(- 'const matrix2 = visualControl(`my-matrix-2`, "456" as const,',+ 'const matrix2 = visualControl(`my-matrix-2`, 456 as const',);});