Skip to content

Commit

Permalink
chore: test
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Apr 1, 2024
1 parent c1b112d commit 6c9c052
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions tests/edgeless/selection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ import * as actions from '../utils/actions/edgeless.js';
import {
getNoteBoundBoxInEdgeless,
setEdgelessTool,
Shape,
switchEditorMode,
toModelCoord,
} from '../utils/actions/edgeless.js';
import {
addBasicBrushElement,
addBasicConnectorElement,
addBasicRectShapeElement,
clickInCenter,
createConnectorElement,
createShapeElement,
dragBetweenCoords,
enterPlaygroundRoom,
getBoundingRect,
Expand Down Expand Up @@ -633,3 +638,81 @@ test('copilot selection rect should appears when drag with meta key pressed', as
await page.mouse.click(205, 150);
await expect(page.locator('.copilot-selection-rect')).toBeHidden();
});

test.describe('select multiple connectors', () => {
test('should show single selection rect', async ({ page }) => {
await enterPlaygroundRoom(page);
await initEmptyEdgelessState(page);
await switchEditorMode(page);
await actions.zoomResetByKeyboard(page);

await addBasicConnectorElement(
page,
{ x: 100, y: 200 },
{ x: 300, y: 200 }
);
await addBasicConnectorElement(
page,
{ x: 100, y: 230 },
{ x: 300, y: 230 }
);
await addBasicConnectorElement(
page,
{ x: 100, y: 260 },
{ x: 300, y: 260 }
);

await dragBetweenCoords(page, { x: 50, y: 50 }, { x: 400, y: 290 });
await waitNextFrame(page);

expect(
await page
.locator('.affine-edgeless-selected-rect')
.locator('.element-handle')
.count()
).toBe(0);
});

test('should disable resize when a connector is already connected', async ({
page,
}) => {
await enterPlaygroundRoom(page);
await initEmptyEdgelessState(page);
await switchEditorMode(page);
await actions.zoomResetByKeyboard(page);

const start = await toModelCoord(page, [100, 0]);
const end = await toModelCoord(page, [200, 100]);
await createShapeElement(page, start, end, Shape.Diamond);
const c1 = await toModelCoord(page, [200, 50]);
const c2 = await toModelCoord(page, [450, 50]);
await createConnectorElement(page, c1, c2);

await addBasicConnectorElement(
page,
{ x: 250, y: 200 },
{ x: 450, y: 200 }
);
await addBasicConnectorElement(
page,
{ x: 250, y: 230 },
{ x: 450, y: 230 }
);
await addBasicConnectorElement(
page,
{ x: 250, y: 260 },
{ x: 450, y: 260 }
);

await dragBetweenCoords(page, { x: 500, y: 20 }, { x: 400, y: 290 });
await waitNextFrame(page);

const selectedRectLocalor = page.locator('.affine-edgeless-selected-rect');
expect(await selectedRectLocalor.locator('.element-handle').count()).toBe(
0
);
expect(
await selectedRectLocalor.locator('.handle').locator('.resize').count()
).toBe(0);
});
});

0 comments on commit 6c9c052

Please sign in to comment.