diff --git a/test/e2e/workbench.spec.ts b/test/e2e/workbench.spec.ts index 32dea94..19c966f 100644 --- a/test/e2e/workbench.spec.ts +++ b/test/e2e/workbench.spec.ts @@ -103,4 +103,21 @@ test.describe('workbench editing shell', () => { await page.getByRole('switch', { name: '编辑模式' }).uncheck(); await expect(page.getByRole('button', { name: '撤销' })).toHaveCount(0); }); + + test('opens an ordinary junction from a deep link with its workspace context', async ({ page }) => { + const state = await page.request.get('/api/state').then((response) => response.json()); + const nodeCounts = new Map(); + for (const endpoint of state.compiled.model.endpoints) { + const nodeId = String(endpoint.nodeId); + nodeCounts.set(nodeId, (nodeCounts.get(nodeId) || 0) + 1); + } + const nodeId = [...nodeCounts].find(([, count]) => count >= 2)?.[0]; + expect(nodeId).toBeTruthy(); + await page.goto(`/junction/node/${encodeURIComponent(nodeId!)}`); + await expect(page.getByLabel('路口编辑工作区')).toBeVisible(); + await expect(page.getByText(`路口节点 ${nodeId}`)).toBeVisible(); + await expect(page.getByText('设施与验证', { exact: true })).toBeVisible(); + await page.getByRole('switch', { name: '编辑模式' }).check(); + await expect(page.getByLabel('路口编辑工作区').getByText('道路参数', { exact: true })).toBeVisible(); + }); }); diff --git a/workbench/client/src/App.tsx b/workbench/client/src/App.tsx index d7242a1..138e455 100644 --- a/workbench/client/src/App.tsx +++ b/workbench/client/src/App.tsx @@ -178,6 +178,17 @@ function App() { () => (state && junctionRoute ? hotspotAt(junctionDescriptors(state), junctionRoute) : null), [junctionRoute, state], ); + // A deep link starts without a map click, so it has no selected approach from + // which the existing manifest loader can scope its request. Pick the first + // descriptor-owned approach here as well as in the click path; this is a + // selection convenience only, never a second JunctionTools data source. + useEffect(() => { + if (!junctionDescriptor || !state || junctionDescriptor.ref.type !== 'node') return; + const approach = junctionDescriptor.approachRoadIds + .map((roadId) => state.compiled.model.roads.find((road) => road.id === roadId)) + .find((road): road is Road => Boolean(road)); + if (approach) setSelected(approach); + }, [junctionDescriptor, state]); useEffect(() => { if (!junctionRoute) { setJunctionSession(null);