test(workbench): cover junction workspace deep links

This commit is contained in:
que01 committed 2026-09-03 12:35:45 +08:00
1 parent 8c99bb7340
commit b7d9a1973e
2 files changed
+28

No files matched your search

+17
View File
@@ -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<string, number>();
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();
});
});
+11
View File
@@ -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);