test: verify complex entry edits in workbench

This commit is contained in:
que01 committed 2026-09-11 09:56:47 +08:00
1 parent 067c0e370d
commit 858db529ae
2 files changed
+41

No files matched your search

+39
View File
@@ -274,6 +274,12 @@ test.describe('workbench editing shell', () => {
const baselinePreview = await page.request
.post('/api/edit-preview', { data: { previewSeq: 0, document: scoped.document, selection: { cluster: id } } })
.then((response) => response.json());
const roadGeometry = (
preview: {
layers: { roadSurface: { features: Array<{ properties: { native_id?: string }; geometry: unknown }> } };
},
nativeId: string,
) => preview.layers.roadSurface.features.find((feature) => feature.properties.native_id === nativeId)?.geometry;
const previewRequest = page.waitForRequest(
(request) => request.method() === 'POST' && request.url().endsWith('/api/edit-preview'),
);
@@ -299,6 +305,39 @@ test.describe('workbench editing shell', () => {
}) => preview.layers.roadSurface.features.find((feature) => feature.properties.corner_key === cornerKey)?.geometry;
expect(cornerGeometry(updatedPreview)).not.toEqual(cornerGeometry(baselinePreview));
await expect(parameterInput).toHaveValue(String(parameterValue + 2));
for (const edit of [
{ kind: 'cluster-carriageway-position', label: '车行道接入位置', delta: 1 },
{ kind: 'cluster-carriageway-direction', label: '车行道接入方向', delta: 1 },
{ kind: 'cluster-carriageway-edge-offset', label: '车行道左右边界', delta: 0.25 },
]) {
const handle = scoped.handles.handles.find(
(candidate: { kind: string; value: { current: number; max: number }; affects: string[] }) =>
candidate.kind === edit.kind && candidate.value.current + edit.delta <= candidate.value.max,
);
expect(handle).toBeTruthy();
const group = workspace.locator('.parameter-group').filter({ hasText: edit.label }).first();
await expect(group).toBeVisible();
const expand = group.getByRole('button', { name: '展开单独定制' });
if (await expand.count()) await expand.click();
const input = group.locator(`[data-handle-id="${handle.handleId}"] .parameter-input`);
const nextValue = Math.round((handle.value.current + edit.delta) * 100) / 100;
const editResponse = page.waitForResponse(
(candidate) =>
candidate.request().method() === 'POST' &&
candidate.url().endsWith('/api/edit-preview') &&
candidate
.request()
.postDataJSON()
?.constraints?.some((constraint: { kind: string }) => constraint.kind === edit.kind),
);
await input.fill(String(nextValue));
await input.press('Enter');
const editResult = await (await editResponse).json();
expect(editResult.constraintStates.every((state: { applied: boolean }) => state.applied)).toBe(true);
expect(roadGeometry(editResult, handle.affects[0])).not.toEqual(roadGeometry(baselinePreview, handle.affects[0]));
await page.getByRole('button', { name: '撤销', exact: true }).click();
}
await page.reload();
await expect(armButtons).toHaveCount(structure.arms.length);
await expect(armButtons.first()).toHaveAttribute('aria-pressed', 'false');