|
| 1 | +import { test, expect } from "@playwright/test"; |
| 2 | +import { |
| 3 | + openNotebookFresh, |
| 4 | + runFirstNCells, |
| 5 | + executeCellAndWaitForOutput, |
| 6 | +} from "./helpers/notebook"; |
| 7 | +import { validateBounds } from "./helpers/assertions"; |
| 8 | +import { drawBboxOnMapLibre } from "./helpers/maplibre"; |
| 9 | + |
| 10 | +test.describe("BBox selection - Overlay render mode", () => { |
| 11 | + test("draws bbox and syncs selected_bounds to Python with overlay render_mode", async ({ |
| 12 | + page, |
| 13 | + }) => { |
| 14 | + const { notebookRoot } = await openNotebookFresh( |
| 15 | + page, |
| 16 | + "simple-map-overlay.ipynb", |
| 17 | + { |
| 18 | + workspaceId: `bbox-overlay-${Date.now()}`, |
| 19 | + }, |
| 20 | + ); |
| 21 | + await runFirstNCells(page, notebookRoot, 2); |
| 22 | + await page.waitForTimeout(5000); |
| 23 | + |
| 24 | + // Start bbox selection mode |
| 25 | + const bboxButton = page.getByRole("button", { name: "Select BBox" }); |
| 26 | + await expect(bboxButton).toBeVisible({ timeout: 10000 }); |
| 27 | + await bboxButton.click(); |
| 28 | + |
| 29 | + // Verify drawing mode is active |
| 30 | + const cancelButton = page.getByRole("button", { name: "Cancel drawing" }); |
| 31 | + await expect(cancelButton).toBeVisible({ timeout: 5000 }); |
| 32 | + |
| 33 | + // Draw bbox using simple mouse events |
| 34 | + await drawBboxOnMapLibre(page, { x: 200, y: 200 }, { x: 400, y: 400 }); |
| 35 | + |
| 36 | + // Verify bbox was drawn successfully |
| 37 | + const finalClearButton = page.getByRole("button", { |
| 38 | + name: "Clear bounding box", |
| 39 | + }); |
| 40 | + await expect(finalClearButton).toBeVisible({ timeout: 5000 }); |
| 41 | + |
| 42 | + // Execute cell to check selected bounds |
| 43 | + const output = await executeCellAndWaitForOutput(notebookRoot, 2); |
| 44 | + const outputText = await output.textContent(); |
| 45 | + validateBounds(outputText); |
| 46 | + }); |
| 47 | +}); |
0 commit comments