feat: complete complex junction transition editing
This commit is contained in:
1 parent
801d8be980
commit
79f83412e6
18 files changed
+400
-59
No files matched your search
@@ -199,6 +199,7 @@ test.describe('workbench editing shell', () => {
|
||||
});
|
||||
|
||||
test('keeps complex junction structure and map selection linked across reload', async ({ page }) => {
|
||||
test.setTimeout(60_000);
|
||||
const initial = await page.request.get('/api/state').then((response) => response.json());
|
||||
const candidate = initial.debug.junctionCandidates.find((item: { nodeIds: string[] }) => item.nodeIds.length >= 3);
|
||||
expect(candidate).toBeTruthy();
|
||||
@@ -251,6 +252,7 @@ test.describe('workbench editing shell', () => {
|
||||
[
|
||||
'cluster-carriageway-width',
|
||||
'cluster-carriageway-cutback',
|
||||
'cluster-carriageway-transition-length',
|
||||
'cluster-corner-radius',
|
||||
'cluster-crossing-inset',
|
||||
'cluster-stop-line-offset',
|
||||
@@ -297,6 +299,58 @@ test.describe('workbench editing shell', () => {
|
||||
await page.reload();
|
||||
await expect(armButtons).toHaveCount(structure.arms.length);
|
||||
await expect(armButtons.first()).toHaveAttribute('aria-pressed', 'false');
|
||||
const transitionGroup = workspace.locator('.parameter-group').filter({ hasText: '车行道过渡长度' });
|
||||
await expect(transitionGroup).toBeVisible();
|
||||
const expandTransition = transitionGroup.getByRole('button', { name: '展开单独定制' });
|
||||
if (await expandTransition.count()) await expandTransition.click();
|
||||
const transitionHandle = scoped.handles.handles.find(
|
||||
(handle: { kind: string; value: { min: number; max: number } }) =>
|
||||
handle.kind === 'cluster-carriageway-transition-length' && handle.value.max - handle.value.min > 1,
|
||||
);
|
||||
expect(transitionHandle).toBeTruthy();
|
||||
const transitionInput = transitionGroup.locator(`[data-handle-id="${transitionHandle.handleId}"] .parameter-input`);
|
||||
const originalTransitionValue = await transitionInput.inputValue();
|
||||
const transitionValue = Math.round(((transitionHandle.value.min + transitionHandle.value.max) / 2) * 100) / 100;
|
||||
|
||||
const transitionResponse = page.waitForResponse(
|
||||
(response) =>
|
||||
response.request().method() === 'POST' &&
|
||||
response.url().endsWith('/api/edit-preview') &&
|
||||
response
|
||||
.request()
|
||||
.postDataJSON()
|
||||
?.constraints?.some(
|
||||
(constraint: { kind: string }) => constraint.kind === 'cluster-carriageway-transition-length',
|
||||
),
|
||||
);
|
||||
await transitionInput.fill(String(transitionValue));
|
||||
await transitionInput.press('Enter');
|
||||
const transitionResult = await (await transitionResponse).json();
|
||||
expect(transitionResult.constraintStates.length).toBeGreaterThan(0);
|
||||
expect(transitionResult.constraintStates.every((state: { applied: boolean }) => state.applied)).toBe(true);
|
||||
await expect(transitionInput).toHaveValue(String(transitionValue));
|
||||
await page.getByRole('button', { name: '撤销', exact: true }).click();
|
||||
await expect(transitionInput).toHaveValue(originalTransitionValue);
|
||||
await expect(page.getByRole('button', { name: '重做', exact: true })).toBeEnabled();
|
||||
await page.getByRole('button', { name: '重做', exact: true }).click();
|
||||
await expect(transitionInput).toHaveValue(String(transitionValue));
|
||||
await page
|
||||
.getByRole('region', { name: '路口编辑工作区' })
|
||||
.getByRole('button', { name: '保存', exact: true })
|
||||
.click();
|
||||
await expect(page.getByRole('status')).toHaveText('已保存并重新生成', { timeout: 30_000 });
|
||||
await page.reload();
|
||||
await expect(transitionGroup).toBeVisible();
|
||||
if (await expandTransition.count()) await expandTransition.click();
|
||||
await expect(transitionInput).toHaveValue(String(transitionValue));
|
||||
|
||||
const transitionRow = transitionGroup.locator(`[data-handle-id="${transitionHandle.handleId}"]`);
|
||||
await transitionRow.getByRole('button', { name: '重置', exact: true }).click();
|
||||
await expect(transitionInput).toHaveValue(originalTransitionValue);
|
||||
await workspace.getByRole('button', { name: '放弃草稿', exact: true }).click();
|
||||
await expect(transitionInput).toHaveValue(String(transitionValue));
|
||||
await expect(workspace.getByRole('button', { name: '保存', exact: true })).toBeDisabled();
|
||||
|
||||
const refreshed = await page.request.get('/api/state').then((response) => response.json());
|
||||
expect(refreshed.junctionStructures[`cluster:${id}`].arms.map((arm: { key: string }) => arm.key)).toEqual(
|
||||
structure.arms.map((arm: { key: string }) => arm.key),
|
||||
|
||||
Reference in new issue
Block a user