Skip to content

🎥 Make videos programmatically with React

Test removing premountFor and styleWhile* when switching to layout="none"

JonnyBurgerec518113f2f1
diff --git a/packages/studio-server/src/test/discriminated-union-update.test.ts b/packages/studio-server/src/test/discriminated-union-update.test.ts
index 1edd3baf61..33bc682693 100644
--- a/packages/studio-server/src/test/discriminated-union-update.test.ts
+++ b/packages/studio-server/src/test/discriminated-union-update.test.ts
@@ -37,6 +37,7 @@ test('Should expose absolute-fill variant fields when active', () => {
'style.scale',
'style.rotate',
'style.opacity',
+ 'premountFor',
]);
});
@@ -130,3 +131,51 @@ test('Should remove variant-specific props when switching enum value', () => {
}
}
});
+
+test('Should remove premountFor and styleWhile* when switching to layout="none"', () => {
+ const file = readFileSync(
+ path.join(__dirname, 'snapshots', 'discriminated-union-with-premount.tsx'),
+ 'utf-8',
+ );
+
+ const ast = parseAst(file);
+
+ const nodePath = lineColumnToNodePath(ast, 3);
+ assert(nodePath, 'No node path found');
+
+ const update = updateSequencePropsAst({
+ input: file,
+ nodePath,
+ updates: [
+ {
+ key: 'layout',
+ value: 'none',
+ defaultValue: Internals.sequenceSchema.layout.default,
+ },
+ ],
+ schema: Internals.sequenceSchema,
+ });
+
+ const expected = readFileSync(
+ path.join(
+ __dirname,
+ 'snapshots',
+ 'discriminated-union-with-premount-expected.tsx',
+ ),
+ 'utf-8',
+ );
+ const actualLines = update.serialized.split('\n');
+ const expectedLines = expected.split('\n');
+ const maxLines = Math.max(actualLines.length, expectedLines.length);
+ for (let i = 0; i < maxLines; i++) {
+ if (actualLines[i] !== expectedLines[i]) {
+ // eslint-disable-next-line no-console
+ console.log(update);
+ // eslint-disable-next-line no-console
+ console.log(actualLines[i], expectedLines[i]);
+ throw new Error(
+ `Line ${i + 1} differs ${actualLines[i]} ${expectedLines[i]}`,
+ );
+ }
+ }
+});
diff --git a/packages/studio-server/src/test/snapshots/discriminated-union-with-premount-expected.tsx b/packages/studio-server/src/test/snapshots/discriminated-union-with-premount-expected.tsx
new file mode 100644
index 0000000000..40927b1ab7
--- /dev/null
+++ b/packages/studio-server/src/test/snapshots/discriminated-union-with-premount-expected.tsx
@@ -0,0 +1,3 @@
+export const ExperimentalControlsShowcase: React.FC = () => {
+ return (<Sequence layout={"none"}></Sequence>);
+};
diff --git a/packages/studio-server/src/test/snapshots/discriminated-union-with-premount.tsx b/packages/studio-server/src/test/snapshots/discriminated-union-with-premount.tsx
new file mode 100644
index 0000000000..7f96ef7518
--- /dev/null
+++ b/packages/studio-server/src/test/snapshots/discriminated-union-with-premount.tsx
@@ -0,0 +1,10 @@
+export const ExperimentalControlsShowcase: React.FC = () => {
+ return (
+ <Sequence
+ style={{opacity: 0.5}}
+ premountFor={25}
+ styleWhilePostmounted={{opacity: 0}}
+ styleWhilePremounted={{opacity: 0}}
+ ></Sequence>
+ );
+};