Skip to content

🎥 Make videos programmatically with React

Remove test changes

Jonny Burgere72159747b64
diff --git a/packages/example/e2e/rotation-keyframes.test.mts b/packages/example/e2e/rotation-keyframes.test.mts
index 324f82667c..da1f68a0a8 100644
--- a/packages/example/e2e/rotation-keyframes.test.mts
+++ b/packages/example/e2e/rotation-keyframes.test.mts
@@ -31,11 +31,6 @@ const readRotationKeyframes = () => {
};
};
-const readTranslate = () => {
- const source = fs.readFileSync(rotationKeyframeFile, 'utf-8');
- return /translate:\s*(['"])(.*?)\1/.exec(source)?.[2] ?? null;
-};
-
test.describe('canvas rotation keyframes', () => {
let sourceBefore: string;
@@ -49,9 +44,7 @@ test.describe('canvas rotation keyframes', () => {
fs.writeFileSync(rotationKeyframeFile, sourceBefore);
});
- test('edits rotation keyframes and temporarily translates', async ({
- page,
- }) => {
+ test('inserts and replaces keyframes in keyframed mode', async ({page}) => {
await page.goto(`${STUDIO_URL}/rotation-keyframe-e2e`);
await expect(page).toHaveURL(/rotation-keyframe-e2e/, {timeout: 15_000});
await page.waitForFunction(
@@ -80,8 +73,8 @@ test.describe('canvas rotation keyframes', () => {
await currentFrameInput.fill('10');
await currentFrameInput.press('Enter');
- const getRotationSurfacePoint = () => {
- return rotationSurface.evaluate((surface) => {
+ const dragRotationSurface = async (deltaX: number, deltaY: number) => {
+ const point = await rotationSurface.evaluate((surface) => {
const box = surface.getBoundingClientRect();
for (let yIndex = 1; yIndex < 10; yIndex++) {
for (let xIndex = 1; xIndex < 10; xIndex++) {
@@ -101,9 +94,6 @@ test.describe('canvas rotation keyframes', () => {
throw new Error('Rotation surface should have an interactive point');
});
- };
- const dragRotationSurface = async (deltaX: number, deltaY: number) => {
- const point = await getRotationSurfacePoint();
await page.mouse.move(point.x, point.y);
await page.mouse.down();
await page.mouse.move(point.x + deltaX, point.y + deltaY, {steps: 5});
@@ -122,79 +112,5 @@ test.describe('canvas rotation keyframes', () => {
.poll(() => readRotationKeyframes().values[1])
.not.toBe(firstValueAtFrame10);
expect(readRotationKeyframes().frames).toEqual([0, 10, 30]);
-
- const rotationBeforeTranslation = readRotationKeyframes();
- const translateBefore = readTranslate();
- expect(translateBefore).toBeNull();
- const point = await getRotationSurfacePoint();
- const snapDelta = await rotationSurface.evaluate((surface) => {
- const surfaceBox = surface.getBoundingClientRect();
- const canvasBox = surface.ownerSVGElement?.getBoundingClientRect();
- if (canvasBox === undefined) {
- throw new Error('Rotation surface should be inside the canvas overlay');
- }
-
- return {
- x:
- canvasBox.x +
- canvasBox.width / 2 -
- (surfaceBox.x + surfaceBox.width / 2) +
- 2,
- y:
- canvasBox.y +
- canvasBox.height / 2 -
- (surfaceBox.y + surfaceBox.height / 2) +
- 2,
- };
- });
- const commandKey = await page.evaluate(() =>
- navigator.platform.startsWith('Mac') ? 'Meta' : 'Control',
- );
- await page.mouse.move(point.x, point.y);
- const rotationCursor = await rotationSurface.getAttribute('cursor');
- expect(rotationCursor).not.toBe('default');
- await page.keyboard.down(commandKey);
- await expect(rotationSurface).toHaveAttribute('cursor', 'default');
- await page.keyboard.up(commandKey);
- await expect(rotationSurface).toHaveAttribute('cursor', rotationCursor!);
-
- await page.keyboard.down(commandKey);
- await expect(rotationSurface).toHaveAttribute('pointer-events', 'none');
- await page.mouse.down();
- await page.mouse.move(point.x + snapDelta.x, point.y + snapDelta.y, {
- steps: 5,
- });
- await expect
- .poll(() =>
- rotationSurface.evaluate((surface) => {
- const surfaceBox = surface.getBoundingClientRect();
- const canvasBox = surface.ownerSVGElement?.getBoundingClientRect();
- if (canvasBox === undefined) {
- throw new Error(
- 'Rotation surface should be inside the canvas overlay',
- );
- }
-
- return Math.max(
- Math.abs(
- canvasBox.x +
- canvasBox.width / 2 -
- (surfaceBox.x + surfaceBox.width / 2),
- ),
- Math.abs(
- canvasBox.y +
- canvasBox.height / 2 -
- (surfaceBox.y + surfaceBox.height / 2),
- ),
- );
- }),
- )
- .toBeLessThan(0.5);
- await page.mouse.up();
- await page.keyboard.up(commandKey);
-
- await expect.poll(readTranslate).not.toBeNull();
- expect(readTranslate()).not.toBe(translateBefore);
- expect(readRotationKeyframes()).toEqual(rotationBeforeTranslation);
});
});