fix bounding box in tracking mode

This commit is contained in:
Anatoly Antonov 2026-07-04 04:19:16 +09:00
parent 48140f0f77
commit a617d40777
13 changed files with 392 additions and 16 deletions

64
tests/e2e/track.spec.ts Normal file
View file

@ -0,0 +1,64 @@
import { test, expect, openPredict, login } from './fixtures';
test.beforeEach(async ({ context, page }) => {
await login(context);
await page.goto('/');
await page.evaluate(() => localStorage.removeItem('workspaces'));
});
/** Count map layers whose scoped id belongs to a bounding-box scene. */
function bboxLayerCount(page: import('@playwright/test').Page) {
return page.evaluate(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const map: any = (window as any)._lsvMap;
if (!map) return 0;
return map.getStyle().layers.filter((l: { id: string }) => l.id.startsWith('bbox')).length;
});
}
// Regression: the bounding box is drawn only by WorkspaceRenderer (predict-only).
// Selecting the same forecast on /track must redraw its box, otherwise it
// "disappears" the moment the user switches into tracking mode.
test('selected forecast bounding box is drawn on the tracking page', async ({ page }) => {
test.setTimeout(90_000);
await openPredict(page);
const panel = page.locator('.panel-container-right');
const runBtn = panel
.locator('.workspace-row')
.first()
.getByRole('button', { name: /Рассчитать|Run/ });
await runBtn.click();
// Wait for the run to complete (workspace scene appears).
await expect
.poll(
() =>
page.evaluate(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const map: any = (window as any)._lsvMap;
if (!map) return 0;
return map
.getStyle()
.layers.filter((l: { id: string }) => l.id.startsWith('ws/')).length;
}),
{ timeout: 75_000, intervals: [1000, 2000, 3000] },
)
.toBeGreaterThan(0);
// Enable the bounding box for this forecast.
await panel.getByRole('button', { name: /Построить рамку|Generate bounding box/ }).click();
await expect.poll(() => bboxLayerCount(page), { timeout: 10_000 }).toBeGreaterThan(0);
// Client-side navigate to tracking (a full reload would drop the in-memory
// prediction result, which is intentionally not persisted).
await page.getByRole('link', { name: /Слежение|Track/ }).click();
await page
.locator('.map-container canvas')
.first()
.waitFor({ state: 'attached', timeout: 15_000 });
// Select the forecast to track against — its box must appear on this map.
await page.locator('#forecast-select').selectOption({ index: 1 });
await expect.poll(() => bboxLayerCount(page), { timeout: 10_000 }).toBeGreaterThan(0);
});