UI tests
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* Group editing tests for Lightningbeam
|
||||
* Tests that shapes can be edited inside groups with correct relative positioning
|
||||
*/
|
||||
|
||||
import { describe, it, before } from 'mocha';
|
||||
import { expect } from '@wdio/globals';
|
||||
import { waitForAppReady } from '../helpers/app.js';
|
||||
import {
|
||||
drawRectangle,
|
||||
selectMultipleShapes,
|
||||
useKeyboardShortcut,
|
||||
doubleClickCanvas,
|
||||
clickCanvas
|
||||
} from '../helpers/canvas.js';
|
||||
import { assertShapeExists } from '../helpers/assertions.js';
|
||||
|
||||
describe('Group Editing', () => {
|
||||
before(async () => {
|
||||
await waitForAppReady();
|
||||
});
|
||||
|
||||
describe('Entering and Editing Groups', () => {
|
||||
it('should maintain shape positions when editing inside a group', async () => {
|
||||
// Draw a rectangle
|
||||
await drawRectangle(200, 200, 100, 100);
|
||||
|
||||
// Verify it exists at the expected location
|
||||
await assertShapeExists(250, 250, 'Rectangle should exist at center before grouping');
|
||||
|
||||
// Select it (click on the center)
|
||||
await clickCanvas(250, 250);
|
||||
await browser.pause(200);
|
||||
|
||||
// Group it (even though it's just one shape)
|
||||
await useKeyboardShortcut('g', true);
|
||||
await browser.pause(300);
|
||||
|
||||
// The shape should still be visible at the same location
|
||||
await assertShapeExists(250, 250, 'Rectangle should still exist at same position after grouping');
|
||||
|
||||
// Double-click on the group to enter editing mode
|
||||
await doubleClickCanvas(250, 250);
|
||||
|
||||
// The shape should STILL be at the same position when editing the group
|
||||
await assertShapeExists(250, 250, 'Rectangle should remain at same position when editing group');
|
||||
});
|
||||
|
||||
it('should correctly position new shapes drawn inside a group', async () => {
|
||||
// Draw a rectangle
|
||||
await drawRectangle(100, 400, 80, 80);
|
||||
|
||||
// Select and group it
|
||||
await clickCanvas(140, 440);
|
||||
await browser.pause(200);
|
||||
await useKeyboardShortcut('g', true);
|
||||
await browser.pause(300);
|
||||
|
||||
// Double-click to enter group editing mode
|
||||
await doubleClickCanvas(140, 440);
|
||||
|
||||
// Draw another rectangle inside the group at a specific location
|
||||
await drawRectangle(200, 400, 80, 80);
|
||||
|
||||
// Verify the new shape is where we drew it
|
||||
await assertShapeExists(240, 440, 'New shape should be at the coordinates where it was drawn');
|
||||
|
||||
// Verify the original shape still exists
|
||||
await assertShapeExists(140, 440, 'Original shape should still exist');
|
||||
});
|
||||
|
||||
it('should handle nested group editing with correct positioning', async () => {
|
||||
// Create first group with two shapes
|
||||
await drawRectangle(400, 100, 60, 60);
|
||||
await drawRectangle(480, 100, 60, 60);
|
||||
await selectMultipleShapes([
|
||||
{ x: 430, y: 130 },
|
||||
{ x: 510, y: 130 }
|
||||
]);
|
||||
await useKeyboardShortcut('g', true);
|
||||
await browser.pause(300);
|
||||
|
||||
// Verify both shapes exist
|
||||
await assertShapeExists(430, 130, 'First shape should exist');
|
||||
await assertShapeExists(510, 130, 'Second shape should exist');
|
||||
|
||||
// Create another shape and group everything together
|
||||
await drawRectangle(400, 180, 60, 60);
|
||||
await selectMultipleShapes([
|
||||
{ x: 470, y: 130 }, // Center of first group
|
||||
{ x: 430, y: 210 } // Center of new shape
|
||||
]);
|
||||
await useKeyboardShortcut('g', true);
|
||||
await browser.pause(300);
|
||||
|
||||
// Double-click to enter outer group
|
||||
await doubleClickCanvas(470, 130);
|
||||
|
||||
// Double-click again to enter inner group
|
||||
await doubleClickCanvas(470, 130);
|
||||
|
||||
// All shapes should still be at their original positions
|
||||
await assertShapeExists(430, 130, 'First shape should maintain position in nested group');
|
||||
await assertShapeExists(510, 130, 'Second shape should maintain position in nested group');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Mouse Coordinate Transformation', () => {
|
||||
it('should correctly translate mouse coordinates when drawing in groups', async () => {
|
||||
// Draw and group a shape
|
||||
await drawRectangle(300, 300, 50, 50);
|
||||
await clickCanvas(325, 325);
|
||||
await browser.pause(200);
|
||||
await useKeyboardShortcut('g', true);
|
||||
await browser.pause(300);
|
||||
|
||||
// Enter group
|
||||
await doubleClickCanvas(325, 325);
|
||||
|
||||
// Draw shapes at precise coordinates to test mouse transformation
|
||||
await drawRectangle(350, 300, 30, 30);
|
||||
await drawRectangle(300, 350, 30, 30);
|
||||
await drawRectangle(350, 350, 30, 30);
|
||||
|
||||
// Verify all shapes are at expected positions
|
||||
await assertShapeExists(365, 315, 'Shape to the right should be at correct position');
|
||||
await assertShapeExists(315, 365, 'Shape below should be at correct position');
|
||||
await assertShapeExists(365, 365, 'Shape diagonal should be at correct position');
|
||||
await assertShapeExists(325, 325, 'Original shape should still exist');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* Shape grouping tests for Lightningbeam
|
||||
*/
|
||||
|
||||
import { describe, it, before, beforeEach } from 'mocha';
|
||||
import { expect } from '@wdio/globals';
|
||||
import { waitForAppReady } from '../helpers/app.js';
|
||||
import { drawRectangle, drawEllipse, selectMultipleShapes, useKeyboardShortcut, clickCanvas } from '../helpers/canvas.js';
|
||||
import { assertShapeExists } from '../helpers/assertions.js';
|
||||
|
||||
describe('Shape Grouping', () => {
|
||||
before(async () => {
|
||||
await waitForAppReady();
|
||||
});
|
||||
|
||||
describe('Grouping Multiple Shapes', () => {
|
||||
it('should group two rectangles together', async () => {
|
||||
// Draw two rectangles
|
||||
await drawRectangle(100, 100, 100, 100);
|
||||
await drawRectangle(250, 100, 100, 100);
|
||||
|
||||
// Select both shapes (click centers with Ctrl held)
|
||||
await selectMultipleShapes([
|
||||
{ x: 150, y: 150 },
|
||||
{ x: 300, y: 150 }
|
||||
]);
|
||||
|
||||
// Group with Ctrl+G
|
||||
await useKeyboardShortcut('g', true);
|
||||
|
||||
// Verify both shapes still exist after grouping
|
||||
await assertShapeExists(150, 150, 'First rectangle should still exist after grouping');
|
||||
await assertShapeExists(300, 150, 'Second rectangle should still exist after grouping');
|
||||
});
|
||||
|
||||
it('should group rectangle and ellipse together', async () => {
|
||||
// Draw rectangle and ellipse
|
||||
await drawRectangle(100, 250, 120, 80);
|
||||
await drawEllipse(280, 250, 120, 80);
|
||||
|
||||
// Select both shapes
|
||||
await selectMultipleShapes([
|
||||
{ x: 160, y: 290 },
|
||||
{ x: 340, y: 290 }
|
||||
]);
|
||||
|
||||
// Group them
|
||||
await useKeyboardShortcut('g', true);
|
||||
|
||||
// Verify shapes exist
|
||||
await assertShapeExists(160, 290, 'Rectangle should exist in group');
|
||||
await assertShapeExists(340, 290, 'Ellipse should exist in group');
|
||||
});
|
||||
|
||||
it('should group three or more shapes', async () => {
|
||||
// Draw three rectangles
|
||||
await drawRectangle(50, 400, 80, 80);
|
||||
await drawRectangle(150, 400, 80, 80);
|
||||
await drawRectangle(250, 400, 80, 80);
|
||||
|
||||
// Select all three
|
||||
await selectMultipleShapes([
|
||||
{ x: 90, y: 440 },
|
||||
{ x: 190, y: 440 },
|
||||
{ x: 290, y: 440 }
|
||||
]);
|
||||
|
||||
// Group them
|
||||
await useKeyboardShortcut('g', true);
|
||||
|
||||
// Verify all shapes exist
|
||||
await assertShapeExists(90, 440, 'First shape should exist in group');
|
||||
await assertShapeExists(190, 440, 'Second shape should exist in group');
|
||||
await assertShapeExists(290, 440, 'Third shape should exist in group');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Group Manipulation', () => {
|
||||
it('should be able to select and move a group', async () => {
|
||||
// Draw two shapes
|
||||
await drawRectangle(400, 100, 80, 80);
|
||||
await drawRectangle(500, 100, 80, 80);
|
||||
|
||||
// Select and group
|
||||
await selectMultipleShapes([
|
||||
{ x: 440, y: 140 },
|
||||
{ x: 540, y: 140 }
|
||||
]);
|
||||
await useKeyboardShortcut('g', true);
|
||||
|
||||
// Click on the group to select it (click between the shapes)
|
||||
await clickCanvas(490, 140);
|
||||
|
||||
// Note: Moving would require drag testing which is already covered in canvas.js
|
||||
// This test verifies the group can be selected
|
||||
});
|
||||
});
|
||||
|
||||
describe('Nested Groups', () => {
|
||||
it('should allow grouping of groups', async () => {
|
||||
// Create first group
|
||||
await drawRectangle(100, 100, 60, 60);
|
||||
await drawRectangle(180, 100, 60, 60);
|
||||
await selectMultipleShapes([
|
||||
{ x: 130, y: 130 },
|
||||
{ x: 210, y: 130 }
|
||||
]);
|
||||
await useKeyboardShortcut('g', true);
|
||||
|
||||
// Create second group
|
||||
await drawRectangle(100, 200, 60, 60);
|
||||
await drawRectangle(180, 200, 60, 60);
|
||||
await selectMultipleShapes([
|
||||
{ x: 130, y: 230 },
|
||||
{ x: 210, y: 230 }
|
||||
]);
|
||||
await useKeyboardShortcut('g', true);
|
||||
|
||||
// Now group both groups together
|
||||
// Select center of each group
|
||||
await selectMultipleShapes([
|
||||
{ x: 170, y: 130 },
|
||||
{ x: 170, y: 230 }
|
||||
]);
|
||||
await useKeyboardShortcut('g', true);
|
||||
|
||||
// Verify all original shapes still exist
|
||||
await assertShapeExists(130, 130, 'First group first shape should exist');
|
||||
await assertShapeExists(210, 130, 'First group second shape should exist');
|
||||
await assertShapeExists(130, 230, 'Second group first shape should exist');
|
||||
await assertShapeExists(210, 230, 'Second group second shape should exist');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* Paint bucket tool tests for Lightningbeam
|
||||
*/
|
||||
|
||||
import { describe, it, before } from 'mocha';
|
||||
import { expect } from '@wdio/globals';
|
||||
import { waitForAppReady } from '../helpers/app.js';
|
||||
import { drawRectangle, selectTool, clickCanvas, getPixelColor } from '../helpers/canvas.js';
|
||||
import { assertPixelColor } from '../helpers/assertions.js';
|
||||
|
||||
describe('Paint Bucket Tool', () => {
|
||||
before(async () => {
|
||||
await waitForAppReady();
|
||||
});
|
||||
|
||||
describe('Fill Shape', () => {
|
||||
it('should fill a rectangle with color', async () => {
|
||||
// Draw an unfilled rectangle (outline only)
|
||||
await drawRectangle(100, 100, 200, 150, false);
|
||||
|
||||
// Get the color before filling (should be stroke/outline only, center is white)
|
||||
const colorBefore = await getPixelColor(200, 175);
|
||||
|
||||
// Select paint bucket tool
|
||||
await selectTool('paint_bucket');
|
||||
|
||||
// Click inside the rectangle to fill it
|
||||
await clickCanvas(200, 175);
|
||||
|
||||
// Get the color after filling
|
||||
const colorAfter = await getPixelColor(200, 175);
|
||||
|
||||
// The color should have changed from white background to filled color
|
||||
expect(colorBefore.toLowerCase()).toBe('#ffffff'); // Was white (unfilled)
|
||||
expect(colorAfter.toLowerCase()).not.toBe('#ffffff'); // Now filled with a color
|
||||
});
|
||||
|
||||
it('should fill only the clicked shape, not adjacent shapes', async () => {
|
||||
// Draw two separate unfilled rectangles
|
||||
await drawRectangle(100, 300, 100, 100, false);
|
||||
await drawRectangle(250, 300, 100, 100, false);
|
||||
|
||||
// Fill only the first rectangle
|
||||
await selectTool('paint_bucket');
|
||||
await clickCanvas(150, 350);
|
||||
|
||||
// Get colors from both shapes
|
||||
const firstColor = await getPixelColor(150, 350);
|
||||
const secondColor = await getPixelColor(300, 350);
|
||||
|
||||
// The shapes should potentially have different colors
|
||||
// (or at least we confirmed we could click them individually)
|
||||
});
|
||||
});
|
||||
|
||||
describe('Fill with Different Colors', () => {
|
||||
it('should respect the selected fill color when using paint bucket', async () => {
|
||||
// This test would require setting a specific fill color first
|
||||
// Then drawing and filling a shape
|
||||
// For now, this is a placeholder structure
|
||||
|
||||
await drawRectangle(400, 100, 150, 100, false);
|
||||
|
||||
// TODO: Add color selection logic when color picker helpers are available
|
||||
// await selectColor('#ff0000');
|
||||
|
||||
await selectTool('paint_bucket');
|
||||
await clickCanvas(475, 150);
|
||||
|
||||
// Verify the fill color
|
||||
const color = await getPixelColor(475, 150);
|
||||
// TODO: Assert expected color when we know how to set it
|
||||
});
|
||||
});
|
||||
|
||||
describe('Fill Gaps Setting', () => {
|
||||
it('should handle fill gaps setting for incomplete shapes', async () => {
|
||||
// This test would draw an incomplete shape and test the fillGaps parameter
|
||||
// Placeholder for now - would need specific incomplete shape drawing
|
||||
|
||||
// The fillGaps setting controls how the paint bucket handles gaps in shapes
|
||||
// This is a more advanced test that would need:
|
||||
// 1. A way to draw incomplete/open shapes
|
||||
// 2. A way to set the fillGaps parameter
|
||||
// 3. Verification that the fill respects the gap threshold
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* Shape drawing tests for Lightningbeam
|
||||
*/
|
||||
|
||||
import { describe, it, before } from 'mocha';
|
||||
import { waitForAppReady } from '../helpers/app.js';
|
||||
import { drawRectangle, drawEllipse } from '../helpers/canvas.js';
|
||||
import { assertShapeExists } from '../helpers/assertions.js';
|
||||
|
||||
describe('Shape Drawing', () => {
|
||||
before(async () => {
|
||||
await waitForAppReady();
|
||||
});
|
||||
|
||||
describe('Rectangle Tool', () => {
|
||||
it('should draw a rectangle on the canvas', async () => {
|
||||
// Draw a rectangle at (100, 100) with size 200x150
|
||||
await drawRectangle(100, 100, 200, 150);
|
||||
|
||||
// Verify the shape exists by checking pixels at various points
|
||||
// Check center of the rectangle
|
||||
await assertShapeExists(200, 175, 'Rectangle should be drawn at center');
|
||||
|
||||
// Check edges
|
||||
await assertShapeExists(110, 110, 'Rectangle should exist at top-left');
|
||||
await assertShapeExists(290, 110, 'Rectangle should exist at top-right');
|
||||
await assertShapeExists(110, 240, 'Rectangle should exist at bottom-left');
|
||||
await assertShapeExists(290, 240, 'Rectangle should exist at bottom-right');
|
||||
});
|
||||
|
||||
it('should draw multiple rectangles without interference', async () => {
|
||||
// Draw first rectangle
|
||||
await drawRectangle(50, 50, 100, 100);
|
||||
await assertShapeExists(100, 100, 'First rectangle should exist');
|
||||
|
||||
// Draw second rectangle in different location
|
||||
await drawRectangle(300, 300, 100, 100);
|
||||
await assertShapeExists(350, 350, 'Second rectangle should exist');
|
||||
|
||||
// Verify first rectangle still exists
|
||||
await assertShapeExists(100, 100, 'First rectangle should still exist');
|
||||
});
|
||||
|
||||
it('should draw small rectangles', async () => {
|
||||
// Draw a small rectangle
|
||||
await drawRectangle(400, 100, 20, 20);
|
||||
await assertShapeExists(410, 110, 'Small rectangle should exist');
|
||||
});
|
||||
|
||||
it('should draw large rectangles', async () => {
|
||||
// Draw a large rectangle
|
||||
await drawRectangle(50, 300, 400, 200);
|
||||
await assertShapeExists(250, 400, 'Large rectangle should exist at center');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Ellipse Tool', () => {
|
||||
it('should draw an ellipse on the canvas', async () => {
|
||||
// Draw an ellipse at (100, 100) with size 200x150
|
||||
await drawEllipse(100, 100, 200, 150);
|
||||
|
||||
// Check center of the ellipse
|
||||
await assertShapeExists(200, 175, 'Ellipse should be drawn at center');
|
||||
});
|
||||
|
||||
it('should draw a circle (equal width and height)', async () => {
|
||||
// Draw a circle
|
||||
await drawEllipse(300, 100, 150, 150);
|
||||
|
||||
// Check center
|
||||
await assertShapeExists(375, 175, 'Circle should exist at center');
|
||||
});
|
||||
|
||||
it('should draw wide ellipses', async () => {
|
||||
// Draw a wide ellipse
|
||||
await drawEllipse(50, 400, 300, 100);
|
||||
await assertShapeExists(200, 450, 'Wide ellipse should exist');
|
||||
});
|
||||
|
||||
it('should draw tall ellipses', async () => {
|
||||
// Draw a tall ellipse
|
||||
await drawEllipse(500, 100, 100, 300);
|
||||
await assertShapeExists(550, 250, 'Tall ellipse should exist');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Mixed Shapes', () => {
|
||||
it('should draw both rectangles and ellipses in the same scene', async () => {
|
||||
// Draw a rectangle
|
||||
await drawRectangle(100, 100, 150, 100);
|
||||
|
||||
// Draw an ellipse
|
||||
await drawEllipse(300, 100, 150, 100);
|
||||
|
||||
// Verify both exist
|
||||
await assertShapeExists(175, 150, 'Rectangle should exist');
|
||||
await assertShapeExists(375, 150, 'Ellipse should exist');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,273 @@
|
||||
/**
|
||||
* Timeline animation tests for Lightningbeam
|
||||
* Tests shape and object animations across keyframes
|
||||
*/
|
||||
|
||||
import { describe, it, before } from 'mocha';
|
||||
import { expect } from '@wdio/globals';
|
||||
import { waitForAppReady } from '../helpers/app.js';
|
||||
import {
|
||||
drawRectangle,
|
||||
drawEllipse,
|
||||
clickCanvas,
|
||||
dragCanvas,
|
||||
selectMultipleShapes,
|
||||
useKeyboardShortcut,
|
||||
setPlayheadTime,
|
||||
getPlayheadTime,
|
||||
addKeyframe,
|
||||
getPixelColor
|
||||
} from '../helpers/canvas.js';
|
||||
import { assertShapeExists } from '../helpers/assertions.js';
|
||||
|
||||
describe('Timeline Animation', () => {
|
||||
before(async () => {
|
||||
await waitForAppReady();
|
||||
});
|
||||
|
||||
describe('Shape Keyframe Animation', () => {
|
||||
it('should animate shape position across keyframes', async () => {
|
||||
// Draw a rectangle at frame 1 (time 0)
|
||||
await drawRectangle(100, 100, 100, 100);
|
||||
|
||||
// Select the shape by dragging a selection box over it
|
||||
await selectMultipleShapes([{ x: 150, y: 150 }]);
|
||||
await browser.pause(200);
|
||||
|
||||
// Verify it exists at original position
|
||||
await assertShapeExists(150, 150, 'Shape should exist at frame 1');
|
||||
|
||||
// Move to frame 10 (time in seconds, assuming 30fps: frame 10 = 10/30 ≈ 0.333s)
|
||||
await setPlayheadTime(0.333);
|
||||
|
||||
// Add a keyframe at this position
|
||||
await addKeyframe();
|
||||
await browser.pause(200);
|
||||
|
||||
// Shape is selected, so dragging from its center will move it
|
||||
await dragCanvas(150, 150, 250, 150);
|
||||
await browser.pause(300);
|
||||
|
||||
// At frame 10, shape should be at the new position (moved 100px to the right)
|
||||
await assertShapeExists(250, 150, 'Shape should be at new position at frame 10');
|
||||
|
||||
// Go back to frame 1
|
||||
await setPlayheadTime(0);
|
||||
await browser.pause(200);
|
||||
|
||||
// Shape should be at original position
|
||||
await assertShapeExists(150, 150, 'Shape should be at original position at frame 1');
|
||||
|
||||
// Go to middle frame (frame 5, time ≈ 0.166s)
|
||||
await setPlayheadTime(0.166);
|
||||
await browser.pause(200);
|
||||
|
||||
// Shape should be interpolated between the two positions
|
||||
// At frame 5 (halfway), shape should be around x=200 (halfway between 150 and 250)
|
||||
await assertShapeExists(200, 150, 'Shape should be interpolated at frame 5');
|
||||
});
|
||||
|
||||
it('should modify shape edges when dragging edge of unselected shape', async () => {
|
||||
// Draw a rectangle
|
||||
await drawRectangle(400, 100, 100, 100);
|
||||
|
||||
// Get color at center
|
||||
const centerColorBefore = await getPixelColor(450, 150);
|
||||
|
||||
// WITHOUT selecting the shape, drag the right edge
|
||||
// The right edge is at x=500, so drag from there
|
||||
await dragCanvas(500, 150, 550, 150);
|
||||
await browser.pause(300);
|
||||
|
||||
// The shape should now be modified - it's been curved/stretched
|
||||
// The original center should still have the shape
|
||||
await assertShapeExists(450, 150, 'Center should still have shape');
|
||||
|
||||
// And there should be shape data extended to the right
|
||||
const rightColorAfter = await getPixelColor(525, 150);
|
||||
// This should have color (not white) since we dragged the edge there
|
||||
expect(rightColorAfter.toLowerCase()).not.toBe('#ffffff');
|
||||
});
|
||||
|
||||
it('should handle multiple keyframes on the same shape', async () => {
|
||||
// Draw a shape
|
||||
await drawRectangle(100, 300, 80, 80);
|
||||
|
||||
// Select it
|
||||
await selectMultipleShapes([{ x: 140, y: 340 }]);
|
||||
await browser.pause(200);
|
||||
|
||||
// Keyframe 1: time 0 (original position at x=140, y=340)
|
||||
|
||||
// Keyframe 2: time 0.333 (move right)
|
||||
await setPlayheadTime(0.333);
|
||||
await addKeyframe();
|
||||
await browser.pause(200);
|
||||
// Shape should still be selected, drag to move
|
||||
await dragCanvas(140, 340, 200, 340);
|
||||
await browser.pause(300);
|
||||
|
||||
// Keyframe 3: time 0.666 (move down but stay within canvas)
|
||||
await setPlayheadTime(0.666);
|
||||
await addKeyframe();
|
||||
await browser.pause(200);
|
||||
// Drag to move down (y=380 instead of 400 to stay in canvas)
|
||||
await dragCanvas(200, 340, 200, 380);
|
||||
await browser.pause(300);
|
||||
|
||||
// Verify positions at each keyframe
|
||||
await setPlayheadTime(0);
|
||||
await browser.pause(200);
|
||||
await assertShapeExists(140, 340, 'Shape at keyframe 1 (x=140, y=340)');
|
||||
|
||||
await setPlayheadTime(0.333);
|
||||
await browser.pause(200);
|
||||
await assertShapeExists(200, 340, 'Shape at keyframe 2 (x=200, y=340)');
|
||||
|
||||
await setPlayheadTime(0.666);
|
||||
await browser.pause(200);
|
||||
await assertShapeExists(200, 380, 'Shape at keyframe 3 (x=200, y=380)');
|
||||
|
||||
// Check interpolation between keyframe 1 and 2 (at t=0.166, halfway)
|
||||
await setPlayheadTime(0.166);
|
||||
await browser.pause(200);
|
||||
await assertShapeExists(170, 340, 'Shape interpolated between kf1 and kf2');
|
||||
|
||||
// Check interpolation between keyframe 2 and 3 (at t=0.5, halfway)
|
||||
await setPlayheadTime(0.5);
|
||||
await browser.pause(200);
|
||||
await assertShapeExists(200, 360, 'Shape interpolated between kf2 and kf3');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Group/Object Animation', () => {
|
||||
it('should animate group position across keyframes', async () => {
|
||||
// Create a group with two shapes
|
||||
await drawRectangle(300, 300, 60, 60);
|
||||
await drawRectangle(380, 300, 60, 60);
|
||||
|
||||
await selectMultipleShapes([
|
||||
{ x: 330, y: 330 },
|
||||
{ x: 410, y: 330 }
|
||||
]);
|
||||
await useKeyboardShortcut('g', true);
|
||||
await browser.pause(300);
|
||||
|
||||
// Verify both shapes exist at frame 1
|
||||
await assertShapeExists(330, 330, 'First shape at frame 1');
|
||||
await assertShapeExists(410, 330, 'Second shape at frame 1');
|
||||
|
||||
// Select the group by dragging a selection box over it
|
||||
await selectMultipleShapes([{ x: 370, y: 330 }]);
|
||||
await browser.pause(200);
|
||||
|
||||
// Move to frame 10 and add keyframe
|
||||
await setPlayheadTime(0.333);
|
||||
await addKeyframe();
|
||||
await browser.pause(200);
|
||||
|
||||
// Group is selected, so dragging will move it
|
||||
// Drag from center of group down (but keep it within canvas bounds)
|
||||
await dragCanvas(370, 330, 370, 380);
|
||||
await browser.pause(300);
|
||||
|
||||
// At frame 10, group should be at new position (moved 50px down)
|
||||
await assertShapeExists(330, 380, 'First shape at new position at frame 10');
|
||||
await assertShapeExists(410, 380, 'Second shape at new position at frame 10');
|
||||
|
||||
// Go to frame 1
|
||||
await setPlayheadTime(0);
|
||||
await browser.pause(200);
|
||||
|
||||
// Group should be at original position
|
||||
await assertShapeExists(330, 330, 'First shape at original position at frame 1');
|
||||
await assertShapeExists(410, 330, 'Second shape at original position at frame 1');
|
||||
|
||||
// Go to frame 5 (middle, t=0.166)
|
||||
await setPlayheadTime(0.166);
|
||||
await browser.pause(200);
|
||||
|
||||
// Group should be interpolated (halfway between y=330 and y=380, so y=355)
|
||||
await assertShapeExists(330, 355, 'First shape interpolated at frame 5');
|
||||
await assertShapeExists(410, 355, 'Second shape interpolated at frame 5');
|
||||
});
|
||||
|
||||
it('should maintain relative positions of shapes within animated group', async () => {
|
||||
// Create a group (using safer y coordinates)
|
||||
await drawRectangle(100, 250, 50, 50);
|
||||
await drawRectangle(170, 250, 50, 50);
|
||||
|
||||
await selectMultipleShapes([
|
||||
{ x: 125, y: 275 },
|
||||
{ x: 195, y: 275 }
|
||||
]);
|
||||
await useKeyboardShortcut('g', true);
|
||||
await browser.pause(300);
|
||||
|
||||
// Select group
|
||||
await selectMultipleShapes([{ x: 160, y: 275 }]);
|
||||
await browser.pause(200);
|
||||
|
||||
// Add keyframe and move
|
||||
await setPlayheadTime(0.333);
|
||||
await addKeyframe();
|
||||
await browser.pause(200);
|
||||
|
||||
await dragCanvas(160, 275, 260, 275);
|
||||
await browser.pause(300);
|
||||
|
||||
// At both keyframes, shapes should maintain 70px horizontal distance
|
||||
await setPlayheadTime(0);
|
||||
await browser.pause(200);
|
||||
await assertShapeExists(125, 275, 'First shape at frame 1');
|
||||
await assertShapeExists(195, 275, 'Second shape at frame 1 (70px apart)');
|
||||
|
||||
await setPlayheadTime(0.333);
|
||||
await browser.pause(200);
|
||||
// Both shapes moved 100px to the right
|
||||
await assertShapeExists(225, 275, 'First shape at frame 10');
|
||||
await assertShapeExists(295, 275, 'Second shape at frame 10 (still 70px apart)');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Interpolation', () => {
|
||||
it('should smoothly interpolate between keyframes', async () => {
|
||||
// Draw a simple shape
|
||||
await drawRectangle(500, 100, 50, 50);
|
||||
|
||||
// Select it
|
||||
await selectMultipleShapes([{ x: 525, y: 125 }]);
|
||||
await browser.pause(200);
|
||||
|
||||
// Keyframe at start (x=525)
|
||||
await setPlayheadTime(0);
|
||||
await browser.pause(100);
|
||||
|
||||
// Keyframe at end (1 second = frame 30, move to x=725)
|
||||
await setPlayheadTime(1.0);
|
||||
await addKeyframe();
|
||||
await browser.pause(200);
|
||||
|
||||
await dragCanvas(525, 125, 725, 125);
|
||||
await browser.pause(300);
|
||||
|
||||
// Check multiple intermediate frames for smooth interpolation
|
||||
// Total movement: 200px over 1 second
|
||||
|
||||
// At 25% (0.25s), x should be 525 + 50 = 575
|
||||
await setPlayheadTime(0.25);
|
||||
await browser.pause(200);
|
||||
await assertShapeExists(575, 125, 'Shape at 25% interpolation');
|
||||
|
||||
// At 50% (0.5s), x should be 525 + 100 = 625
|
||||
await setPlayheadTime(0.5);
|
||||
await browser.pause(200);
|
||||
await assertShapeExists(625, 125, 'Shape at 50% interpolation');
|
||||
|
||||
// At 75% (0.75s), x should be 525 + 150 = 675
|
||||
await setPlayheadTime(0.75);
|
||||
await browser.pause(200);
|
||||
await assertShapeExists(675, 125, 'Shape at 75% interpolation');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user