Skip to content

🎥 Make videos programmatically with React

Move subscription churn coverage into React integration tests

Jonny Burger9a168f91df19
diff --git a/packages/example/e2e/source-subscription-churn.test.mts b/packages/example/e2e/source-subscription-churn.test.mts
index 77fb46622f..d104f6e766 100644
--- a/packages/example/e2e/source-subscription-churn.test.mts
+++ b/packages/example/e2e/source-subscription-churn.test.mts
@@ -1,7 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import {expect, test} from '@playwright/test';
-import type {SubscribeToSequencePropsBatchRequest} from '@remotion/studio-shared';
import {EXPANDED_SIDEBAR_STATE, STUDIO_URL, exampleDir} from './constants.mts';
import {startStudio, stopStudio} from './studio-server.mts';
@@ -10,168 +9,88 @@ test.use({
viewport: {width: 1920, height: 1200},
});
-test('parent trim keeps source subscriptions stable and evaluates each mounted instance', async ({
+test('trimming a parent then its expression child saves with the latest instance context', async ({
page,
}) => {
test.setTimeout(120_000);
const fixture = path.join(exampleDir, 'src', 'SourceSubscriptionChurn.tsx');
const original = fs.readFileSync(fixture, 'utf8');
- const subscriptions: string[] = [];
- const errors: string[] = [];
- page.on('request', (request) => {
- if (/\/api\/(un)?subscribe-to-sequence-props$/.test(request.url()))
- subscriptions.push(request.postData() ?? '');
- });
- page.on('pageerror', (error) => errors.push(error.message));
- page.on('console', (message) => {
- if (message.type() === 'error') errors.push(message.text());
- });
- await startStudio();
- try {
- await page.goto(`${STUDIO_URL}/SourceSubscriptionChurn`);
- const parent = page.locator(
- '[data-timeline-marquee-item][aria-label="Trim this parent"]',
- );
- await expect(parent).toBeVisible({timeout: 30_000});
- await page.keyboard.press('g');
- await page.locator('input:focus').fill('30');
- await page.locator('input:focus').press('Enter');
- await expect(
- page.getByText('Parent scope: 300 frames', {exact: true}),
- ).toBeVisible();
- await expect(
- page.getByText('Expression A: 150 frames', {exact: true}),
- ).toBeVisible();
- await expect(
- page.getByText('Expression B: 200 frames', {exact: true}),
- ).toBeVisible();
- const expression = page.locator(
- '[data-timeline-marquee-item][aria-label="Expression A"]',
+
+ const trimRightEdge = async (
+ label: string,
+ duration: number,
+ delta: number,
+ ) => {
+ const row = page.locator(
+ `[data-timeline-marquee-item][aria-label="${label}"]`,
);
- await expression.click();
- const opacity = page
- .getByRole('group', {name: 'Opacity', exact: true})
- .first();
- await expect(opacity).toBeVisible();
- await opacity.click();
- await expect(
- page
- .getByRole('button', {
- name: 'Select keyframe at frame 299',
- exact: true,
- })
- .last(),
- ).toBeVisible();
- await parent.click();
- const end = parent
+ await row.click();
+ const end = row
.getByRole('separator', {name: 'Drag to change duration', exact: true})
.filter({visible: true})
.first();
- const start = parent
+ const start = row
.getByRole('separator', {name: 'Drag to trim start', exact: true})
.filter({visible: true})
.first();
- await expect(end).toBeVisible();
- const endBox = await end.boundingBox();
- const startBox = await start.boundingBox();
- if (!endBox || !startBox) throw new Error('Expected parent trim handles');
- const pixelsPerFrame = (endBox.x - startBox.x) / 300;
+ let endBox = await end.boundingBox();
+ let startBox = await start.boundingBox();
+ await expect
+ .poll(async () => {
+ await end.scrollIntoViewIfNeeded();
+ endBox = await end.boundingBox();
+ startBox = await start.boundingBox();
+ return endBox !== null && startBox !== null;
+ })
+ .toBe(true);
+ if (!endBox || !startBox) throw new Error('Expected trim handles');
+ const pixelsPerFrame = (endBox.x - startBox.x) / duration;
const x = endBox.x + endBox.width / 2;
const y = endBox.y + endBox.height / 2;
- // The initial batched source subscriptions must finish before measuring preview traffic.
- await page.waitForTimeout(500);
- const subscribedLines = subscriptions
- .flatMap(
- (body) =>
- (JSON.parse(body) as SubscribeToSequencePropsBatchRequest).requests,
- )
- .filter((request) =>
- request.fileName.endsWith('SourceSubscriptionChurn.tsx'),
- )
- .map((request) => request.line);
- const literalChildLines = [
- ...original.matchAll(/<Sequence name="(?:Nested child|Root control) /g),
- ].map((match) => original.slice(0, match.index).split('\n').length);
- expect(literalChildLines).toHaveLength(10);
- expect(subscribedLines).toEqual(expect.arrayContaining(literalChildLines));
- const initialSubscriptions = subscriptions.length;
await page.mouse.move(x, y);
await page.mouse.down();
- for (const delta of [20, 40, 60]) {
- await page.mouse.move(x + pixelsPerFrame * delta, y, {steps: 3});
- await expect(
- page.getByText(`Parent scope: ${300 + delta} frames`, {exact: true}),
- ).toBeVisible();
- for (let i = 1; i <= 8; i++) {
- await expect(
- page.getByText(`Child ${String(i).padStart(2, '0')}: 180 frames`, {
- exact: true,
- }),
- ).toBeVisible();
- }
- for (const label of ['Root control 01', 'Root control 02']) {
- await expect(
- page.getByText(`${label}: 180 frames`, {exact: true}),
- ).toBeVisible();
- }
- await expect(
- page.getByText(`Expression A: ${(300 + delta) / 2} frames`, {
- exact: true,
- }),
- ).toBeVisible();
- await expect(
- page.getByText('Expression B: 200 frames', {exact: true}),
- ).toBeVisible();
- await expect
- .poll(() =>
- page
- .getByTestId('Expression A')
- .evaluate((element) =>
- Number(getComputedStyle(element.parentElement!).opacity),
- ),
- )
- .toBeCloseTo(30 / (299 + delta), 5);
- await expect
- .poll(() =>
- page
- .getByTestId('Expression B')
- .evaluate((element) =>
- Number(getComputedStyle(element.parentElement!).opacity),
- ),
- )
- .toBeCloseTo(30 / 399, 5);
- await expect(
- page
- .getByRole('button', {
- name: `Select keyframe at frame ${299 + delta}`,
- exact: true,
- })
- .last(),
- ).toBeVisible();
- expect(subscriptions).toHaveLength(initialSubscriptions);
- }
+ await page.mouse.move(x + pixelsPerFrame * delta, y, {steps: 5});
+ const saved = page.waitForResponse((response) =>
+ response.url().endsWith('/api/save-sequence-props'),
+ );
await page.mouse.up();
+ expect(await (await saved).json()).toMatchObject({
+ success: true,
+ data: {canUpdate: true},
+ });
+ };
+
+ try {
+ // The example is also editable in the main Studio. Give this test a known
+ // starting point and restore any manual edits afterwards.
+ fs.writeFileSync(
+ fixture,
+ original.replace(
+ /(<Sequence name="Trim this parent" durationInFrames=\{)\d+(\})/,
+ (_, prefix: string, suffix: string) => `${prefix}300${suffix}`,
+ ),
+ );
+ await startStudio();
+ await page.goto(`${STUDIO_URL}/SourceSubscriptionChurn`);
+ await expect(
+ page.getByText('Parent scope: 300 frames', {exact: true}),
+ ).toBeVisible({timeout: 30_000});
+ await page.keyboard.press('g');
+ await page.locator('input:focus').fill('30');
+ await page.locator('input:focus').press('Enter');
+
+ await trimRightEdge('Trim this parent', 300, 60);
await expect
.poll(() => fs.readFileSync(fixture, 'utf8'))
.toMatch(/name="Trim this parent"\s+durationInFrames=\{360\}/);
+ await expect(
+ page.getByText('Expression A: 180 frames', {exact: true}),
+ ).toBeVisible();
+ await expect(
+ page.getByText('Expression B: 200 frames', {exact: true}),
+ ).toBeVisible();
- // Edit the shared JSX using the first instance's latest (360 frame) context.
- await expression.click();
- const expressionEnd = await expression
- .getByRole('separator', {name: 'Drag to change duration', exact: true})
- .boundingBox();
- if (!expressionEnd) throw new Error('Expected expression trim handle');
- await page.mouse.move(
- expressionEnd.x + expressionEnd.width / 2,
- expressionEnd.y + expressionEnd.height / 2,
- );
- await page.mouse.down();
- await page.mouse.move(
- expressionEnd.x + expressionEnd.width / 2 + pixelsPerFrame * 36,
- expressionEnd.y + expressionEnd.height / 2,
- {steps: 5},
- );
- await page.mouse.up();
+ await trimRightEdge('Expression A', 180, 36);
await expect
.poll(() => fs.readFileSync(fixture, 'utf8'))
.toMatch(/durationInFrames=\{duration \* 0\.6\}/);
@@ -181,43 +100,26 @@ test('parent trim keeps source subscriptions stable and evaluates each mounted i
await expect(
page.getByText('Expression B: 240 frames', {exact: true}),
).toBeVisible();
+ await page
+ .getByRole('group', {name: 'Opacity', exact: true})
+ .first()
+ .click();
+ await expect(
+ page
+ .getByRole('button', {
+ name: 'Select keyframe at frame 359',
+ exact: true,
+ })
+ .last(),
+ ).toBeVisible();
- const keyframe = page
- .getByRole('button', {name: 'Select keyframe at frame 359', exact: true})
- .last();
- await keyframe.scrollIntoViewIfNeeded();
- const keyframeBox = await keyframe.boundingBox();
- if (!keyframeBox) throw new Error('Expected duration-dependent keyframe');
- await page.mouse.move(
- keyframeBox.x + keyframeBox.width / 2,
- keyframeBox.y + keyframeBox.height / 2,
- );
- await page.mouse.down();
- await page.mouse.move(
- keyframeBox.x + keyframeBox.width / 2 - pixelsPerFrame * 10,
- keyframeBox.y + keyframeBox.height / 2,
- {steps: 5},
- );
- await page.mouse.up();
- await expect
- .poll(() => fs.readFileSync(fixture, 'utf8'))
- .toContain('duration - 11');
- await expect
- .poll(() =>
- page
- .getByTestId('Expression B')
- .evaluate((element) =>
- Number(getComputedStyle(element.parentElement!).opacity),
- ),
- )
- .toBeCloseTo(30 / 389, 5);
-
- const sourceBefore = fs.readFileSync(fixture, 'utf8');
+ // Keep one real file-watcher update; expression combinations and
+ // subscription counts are covered by the React integration test.
fs.writeFileSync(
fixture,
- sourceBefore
- .replace('duration * 0.6', 'duration * 0.75')
- .replace('duration - 11', 'duration - 2'),
+ fs
+ .readFileSync(fixture, 'utf8')
+ .replace('duration * 0.6', 'duration * 0.75'),
);
await expect(
page.getByText('Expression A: 270 frames', {exact: true}),
@@ -225,18 +127,6 @@ test('parent trim keeps source subscriptions stable and evaluates each mounted i
await expect(
page.getByText('Expression B: 300 frames', {exact: true}),
).toBeVisible();
- await expect
- .poll(() =>
- page
- .getByTestId('Expression A')
- .evaluate((element) =>
- Number(getComputedStyle(element.parentElement!).opacity),
- ),
- )
- .toBeCloseTo(30 / 358, 5);
- expect(
- errors.filter((error) => /maximum update depth/i.test(error)),
- ).toEqual([]);
} finally {
await stopStudio();
fs.writeFileSync(fixture, original);
diff --git a/packages/studio-server/src/test/update-keyframes.test.ts b/packages/studio-server/src/test/update-keyframes.test.ts
index e0adfb0132..5c9b245020 100644
--- a/packages/studio-server/src/test/update-keyframes.test.ts
+++ b/packages/studio-server/src/test/update-keyframes.test.ts
@@ -253,6 +253,39 @@ export const Example: React.FC = () => {
},
],
});
+
+ const resized = await updateSequenceKeyframes({
+ input: output,
+ nodePath: updatedNodePath,
+ updates: [
+ {
+ key: 'style.opacity',
+ operation: {type: 'move', moves: [{fromFrame: 358, toFrame: 349}]},
+ },
+ ],
+ videoConfigValues: {...videoConfigValues, durationInFrames: 360},
+ });
+ expect(resized.output).toContain('[0, durationInFrames - 11]');
+ const resizedStatus = computeSequencePropsStatusFromContent({
+ fileContents: resized.output,
+ nodePath: resized.updatedNodePath,
+ componentIdentity: null,
+ keys: ['style.opacity'],
+ effects: [],
+ });
+ // The same edited source must still evaluate in another mounted instance.
+ expect(
+ NoReactInternals.evaluateSourcePropStatuses(resizedStatus.props, {
+ ...videoConfigValues,
+ durationInFrames: 400,
+ })['style.opacity'],
+ ).toMatchObject({
+ status: 'keyframed',
+ keyframes: [
+ {frame: 0, value: 0.35},
+ {frame: 389, value: 1},
+ ],
+ });
});
const colorInput = `import React from 'react';
diff --git a/packages/studio-server/src/test/update-sequence-props.test.ts b/packages/studio-server/src/test/update-sequence-props.test.ts
index 93d9295150..10ebdd0d00 100644
--- a/packages/studio-server/src/test/update-sequence-props.test.ts
+++ b/packages/studio-server/src/test/update-sequence-props.test.ts
@@ -31,12 +31,12 @@ test('updateSequenceProps preserves video config multiplication expressions', as
const input = `import {Sequence, useVideoConfig} from 'remotion';
export const Example: React.FC = () => {
- const {fps} = useVideoConfig();
+ const {fps, durationInFrames: duration} = useVideoConfig();
return (
<Sequence
premountFor={(2 * fps) as number}
postmountFor={fps * 2}
- durationInFrames={(2 * fps) as number}
+ durationInFrames={(duration * 0.5) as number}
from={2 * fps}
style={{opacity: 2 * fps}}
/>
@@ -60,10 +60,22 @@ export const Example: React.FC = () => {
expect(output).toContain('premountFor={2.5 * fps}');
expect(output).toContain('postmountFor={fps * 3}');
- expect(output).toContain('durationInFrames={(2 * fps) as number}');
+ expect(output).toContain('durationInFrames={(duration * 0.5) as number}');
expect(output).toContain('from={0}');
expect(output).not.toContain('0 * fps');
expect(output).toContain('opacity: 4 * fps');
+
+ // Reuse the source after resizing its parent. The edit must use the current
+ // mounted instance's duration, rather than the context from the first read.
+ const resized = await updateSequenceProps({
+ input: output,
+ nodePath: lineColumnToNodePath(output, 6),
+ updates: [{key: 'durationInFrames', value: 216, defaultValue: null}],
+ schema: NoReactInternals.sequenceSchema,
+ prettierConfigOverride: null,
+ videoConfigValues: {...videoConfigValues, durationInFrames: 360},
+ });
+ expect(resized.output).toContain('durationInFrames={duration * 0.6}');
});
test('updateSequenceProps should update a number value', async () => {
diff --git a/packages/studio/src/test/source-subscription-churn.test.tsx b/packages/studio/src/test/source-subscription-churn.test.tsx
new file mode 100644
index 0000000000..316bdfc293
--- /dev/null
+++ b/packages/studio/src/test/source-subscription-churn.test.tsx
@@ -0,0 +1,313 @@
+import {expect, test} from 'bun:test';
+import {readFileSync} from 'node:fs';
+import {CodemodsInternals} from '@remotion/codemods';
+import type {SubscribeToSequencePropsBatchRequest} from '@remotion/studio-shared';
+import {act, render, waitFor} from '@testing-library/react';
+import {useContext, type ContextType} from 'react';
+import {
+ Internals,
+ Sequence,
+ interpolate,
+ useCurrentFrame,
+ useVideoConfig,
+} from 'remotion';
+import {ExpandedTracksProvider} from '../components/ExpandedTracksProvider';
+import {SequencePropsSubscriptionProvider} from '../components/SequencePropsSubscriptionProvider';
+import {shouldSubscribeToSequenceProps} from '../components/Timeline/should-subscribe-to-sequence-props';
+import {SubscribeToNodePaths} from '../components/Timeline/SubscribeToNodePaths';
+import {StudioServerConnectionCtx} from '../helpers/client-id';
+
+const fileName = __filename;
+const source = readFileSync(fileName, 'utf8').split('\ntest(')[0];
+
+// Supply the source locations normally injected by the Studio bundler. The
+// subscription parser reads the same JSX that React mounts below.
+const sourceProps = (name: string) => {
+ const attribute = source.indexOf('name="' + name + '"');
+ const opening = source.lastIndexOf('<Sequence', attribute);
+ return {
+ [Internals.REMOTION_INTERNAL_STACK_PROP]: Internals.makeOriginalSourceStack(
+ {
+ fileName,
+ lineNumber: source.slice(0, opening).split('\n').length,
+ columnNumber: 0,
+ },
+ ),
+ };
+};
+
+const Readout = ({label}: {readonly label: string}) => (
+ <div data-testid={label}>{useVideoConfig().durationInFrames}</div>
+);
+
+const Expression = ({label}: {readonly label: string}) => {
+ const {durationInFrames: duration} = useVideoConfig();
+ const frame = useCurrentFrame();
+ return (
+ <Sequence
+ {...sourceProps('Expression')}
+ name="Expression"
+ durationInFrames={duration * 0.5}
+ style={{opacity: interpolate(frame, [0, duration - 1], [0, 1])}}
+ >
+ <Readout label={label} />
+ </Sequence>
+ );
+};
+
+const Fixture = () => (
+ <>
+ <Sequence {...sourceProps('Parent')} name="Parent" durationInFrames={300}>
+ <Readout label="parent" />
+ <Sequence
+ {...sourceProps('Literal')}
+ name="Literal"
+ durationInFrames={180}
+ >
+ <Readout label="literal" />
+ </Sequence>
+ <Expression label="A" />
+ </Sequence>
+ <Sequence durationInFrames={400}>
+ <Expression label="B" />
+ </Sequence>
+ <Sequence {...sourceProps('Root')} name="Root" durationInFrames={180}>
+ <Readout label="root" />
+ </Sequence>
+ </>
+);
+
+test('parent previews keep source subscriptions stable while mounted instances evaluate shared source', async () => {
+ const previousFetch = globalThis.fetch;
+ const requests: string[] = [];
+ const subscriptions: ReturnType<
+ typeof CodemodsInternals.computeSequencePropsSubscriptionFromContent
+ >[] = [];
+ const setters: {
+ current: ContextType<typeof Internals.VisualModeSettersContext> | null;
+ } = {current: null};
+
+ // Only the HTTP transport is replaced. Source parsing, subscription lifecycle,
+ // registration, drag overrides, and rendered expressions use production code.
+ // The reduced E2E covers the actual server, source writes, and refresh.
+ globalThis.fetch = ((input, init) => {
+ const endpoint = String(input);
+ requests.push(endpoint);
+ if (endpoint === '/api/unsubscribe-from-sequence-props') {
+ return Promise.resolve(Response.json({success: true}));
+ }
+
+ if (endpoint !== '/api/subscribe-to-sequence-props') {
+ throw new Error(`Unexpected request: ${endpoint}`);
+ }
+
+ const body = JSON.parse(
+ String(init?.body),
+ ) as SubscribeToSequencePropsBatchRequest;
+ const results = body.requests.map((request) =>
+ CodemodsInternals.computeSequencePropsSubscriptionFromContent({
+ fileContents: source,
+ absolutePath: fileName,
+ line: request.line,
+ preferredNodePath: request.nodePath,
+ componentIdentity: request.componentIdentity,
+ keys: request.keys,
+ assetKeys: request.assetKeys,
+ effects: request.effects,
+ }),
+ );
+ subscriptions.push(...results);
+ return Promise.resolve(Response.json({success: true, data: {results}}));
+ }) as typeof fetch;
+
+ const Subscriptions = () => {
+ const sequences = Internals.useSequenceManagerSequences();
+ setters.current = useContext(Internals.VisualModeSettersContext);
+ return sequences.map((sequence) =>
+ shouldSubscribeToSequenceProps(sequence, true) ? (
+ <SubscribeToNodePaths
+ key={sequence.id}
+ overrideId={sequence.controls.overrideId}
+ componentIdentity={sequence.controls.componentIdentity}
+ schema={sequence.controls.schema}
+ getStack={sequence.getStack}
+ effects={sequence.effects}
+ />
+ ) : null,
+ );
+ };
+
+ const metadata = {
+ durationInFrames: 600,
+ fps: 30,
+ width: 1280,
+ height: 720,
+ props: {},
+ defaultCodec: null,
+ defaultOutName: null,
+ defaultPixelFormat: null,
+ defaultProResProfile: null,
+ defaultSampleRate: null,
+ defaultVideoImageFormat: null,
+ };
+ const timeline = {
+ frame: {test: 30},
+ isPlaying: () => false,
+ isInsideFreeze: false,
+ audioAndVideoTags: {current: []},
+ };
+ let rendered: ReturnType<typeof render> | null = null;
+ try {
+ rendered = render(
+ <Internals.RemotionEnvironmentContext.Provider
+ value={{
+ isStudio: true,
+ isPlayer: false,
+ isRendering: false,
+ isReadOnlyStudio: false,
+ isClientSideRendering: false,
+ }}
+ >
+ <Internals.CanUseRemotionHooksProvider>
+ <Internals.CompositionManager.Provider
+ value={{
+ compositions: [
+ {
+ ...metadata,
+ id: 'test',
+ component: Fixture,
+ defaultProps: {},
+ folderName: null,
+ parentFolderName: null,
+ order: null,
+ calculateMetadata: null,
+ schema: null,
+ stack: null,
+ },
+ ],
+ folders: [],
+ canvasContent: {type: 'composition', compositionId: 'test'},
+ currentCompositionMetadata: metadata,
+ currentAssetMetadata: null,
+ }}
+ >
+ <Internals.AbsoluteTimeContext.Provider value={timeline}>
+ <Internals.TimelineContext.Provider value={timeline}>
+ <Internals.SequenceManagerProvider>
+ <SequencePropsSubscriptionProvider>
+ <ExpandedTracksProvider>
+ <StudioServerConnectionCtx.Provider
+ value={{
+ previewServerState: {
+ type: 'connected',
+ clientId: 'test',
+ },
+ configFileChangeRevision: 0,
+ restartRequired: false,
+ subscribeToEvent: () => () => undefined,
+ }}
+ >
+ <Fixture />
+ <Subscriptions />
+ </StudioServerConnectionCtx.Provider>
+ </ExpandedTracksProvider>
+ </SequencePropsSubscriptionProvider>
+ </Internals.SequenceManagerProvider>
+ </Internals.TimelineContext.Provider>
+ </Internals.AbsoluteTimeContext.Provider>
+ </Internals.CompositionManager.Provider>
+ </Internals.CanUseRemotionHooksProvider>
+ </Internals.RemotionEnvironmentContext.Provider>,
+ );
+ await waitFor(() => expect(subscriptions).toHaveLength(4));
+ expect(subscriptions.every((result) => result.success)).toBe(true);
+ const parent = subscriptions.find(
+ (result) =>
+ result.success &&
+ result.status.props.name.status === 'static' &&
+ result.status.props.name.codeValue === 'Parent',
+ );
+ const expression = subscriptions.find(
+ (result) =>
+ result.success &&
+ result.status.props.name.status === 'static' &&
+ result.status.props.name.codeValue === 'Expression',
+ );
+ if (!parent?.success || !expression?.success || !setters.current) {
+ throw new Error('Expected source subscriptions and visual mode setters');
+ }
+
+ const initialRequests = [...requests];
+ for (const previewDuration of [300, 320, 340, 360]) {
+ act(() =>
+ setters.current!.setDragOverrides(parent.nodePath, 'durationInFrames', {
+ type: 'static',
+ value: previewDuration,
+ }),
+ );
+ // Flush React effects and the subscription batch scheduled for the next task.
+ await act(async () => {
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ });
+ expect(rendered.getByTestId('parent').textContent).toBe(
+ String(previewDuration),
+ );
+ expect(rendered.getByTestId('A').textContent).toBe(
+ String(previewDuration / 2),
+ );
+ expect(rendered.getByTestId('B').textContent).toBe('200');
+ for (const label of ['literal', 'root']) {
+ expect(rendered.getByTestId(label).textContent).toBe('180');
+ }
+
+ expect(
+ Number(rendered.getByTestId('A').parentElement!.style.opacity),
+ ).toBeCloseTo(30 / (previewDuration - 1), 5);
+ expect(
+ Number(rendered.getByTestId('B').parentElement!.style.opacity),
+ ).toBeCloseTo(30 / 399, 5);
+ expect(requests).toEqual(initialRequests);
+ }
+
+ // A source update must affect both instances without using either instance's
+ // configuration as the shared value. No recompilation is needed to apply it.
+ const updated =
+ CodemodsInternals.computeSequencePropsSubscriptionFromContent({
+ fileContents: source
+ .replace('duration * 0.5', 'duration * 0.75')
+ .replace('duration - 1', 'duration - 2'),
+ absolutePath: fileName,
+ line: 1,
+ preferredNodePath: expression.nodePath.nodePath,
+ componentIdentity: 'dev.remotion.remotion.Sequence',
+ keys: expression.nodePath.sequenceKeys,
+ effects: [],
+ });
+ if (!updated.success) throw new Error('Expected updated source');
+ act(() =>
+ setters.current!.setPropStatuses(updated.nodePath, () => updated.status),
+ );
+ expect(rendered.getByTestId('A').textContent).toBe('270');
+ expect(rendered.getByTestId('B').textContent).toBe('300');
+ expect(
+ Number(rendered.getByTestId('A').parentElement!.style.opacity),
+ ).toBeCloseTo(30 / 358, 5);
+ expect(
+ Number(rendered.getByTestId('B').parentElement!.style.opacity),
+ ).toBeCloseTo(30 / 398, 5);
+ expect(requests).toEqual(initialRequests);
+ } finally {
+ await act(async () => {
+ rendered?.unmount();
+ await Promise.resolve();
+ });
+ globalThis.fetch = previousFetch;
+ }
+
+ // Verify that unsubscribe traffic is actually observed by the test.
+ expect(
+ requests.filter(
+ (endpoint) => endpoint === '/api/unsubscribe-from-sequence-props',
+ ),
+ ).toHaveLength(4);
+});