fix: connector should remain the same when its target or source switch to other

shape type (#11369)

Fixes [BS-1431](https://linear.app/affine-design/issue/BS-1431/改变-shape-形状后,connector-丢失)
This commit is contained in:
doouding
2025-04-02 05:10:30 +00:00
parent c20514f269
commit ef76c83184
4 changed files with 118 additions and 19 deletions

View File

@@ -1082,6 +1082,19 @@ type Action =
| 'autoArrange'
| 'autoResize';
export async function triggerShapeSwitch(
page: Page,
type: 'Square' | 'Ellipse' | 'Diamond' | 'Triangle' | 'Rounded rectangle'
) {
const button = locatorComponentToolbar(page)
.getByLabel('Switch shape type')
.first();
await button.click();
const shapeButton = locatorComponentToolbar(page).getByLabel(type);
await shapeButton.click();
}
export async function triggerComponentToolbarAction(
page: Page,
action: Action
@@ -1598,6 +1611,31 @@ export async function getConnectorPath(page: Page, index = 0): Promise<IVec[]> {
);
}
export async function getConnectorPathWithInOut(
page: Page,
index = 0
): Promise<
{
point: IVec;
in: IVec;
out: IVec;
}[]
> {
return page.evaluate(
([index]) => {
const container = document.querySelector('affine-edgeless-root');
if (!container) throw new Error('container not found');
const connectors = container.service.crud.getElementsByType('connector');
return connectors[index].absolutePath.map(path => ({
point: [path[0], path[1]],
in: path.in,
out: path.out,
}));
},
[index]
);
}
export async function getEdgelessElementBound(
page: Page,
elementId: string