import { expect, test } from "@playwright/test"; import path from "node:path"; const fixture = path.resolve(import.meta.dirname, "../../../tests/files/web/modifier_grease_pencil_scene.blend"); const expectedPointIds = Array.from({ length: 4 }, (_, index) => `grease-pencil-point:GreasePencilData:0:0:${index}`); const expectedStrokeId = "grease-pencil-stroke:GreasePencilData:0:0"; for (const offscreen of [false, true]) { test(`M9-06 marquee selects only the current drawing stable IDs in ${offscreen ? "OffscreenCanvas" : "main-thread"} Chromium`, async ({ page }) => { test.setTimeout(90_000); await page.goto(offscreen ? "/?offscreen=1" : "/"); await expect(page.getByTestId("engine-status")).toContainText("ready, open a .blend file", { timeout: 20_000 }); await page.getByTestId("blend-file-input").setInputFiles(fixture); await page.getByText("GreasePencilObject", { exact: true }).click(); await page.getByRole("button", { name: "Object Mode" }).click(); const app = page.locator(".blender-app"); const revision = Number(await app.getAttribute("data-current-main-revision")); await page.getByRole("button", { name: "Grease Pencil 框选工具" }).click(); const surface = page.getByTestId("grease-pencil-marquee-surface"); await expect(surface).toHaveAttribute("data-drawing-id", "grease-pencil-drawing:GreasePencilData:0"); const bounds = await surface.boundingBox(); if (!bounds) throw new Error("Grease Pencil marquee surface has no bounds"); await page.mouse.move(bounds.x + 3, bounds.y + 3); await page.mouse.down(); await page.mouse.move(bounds.x + bounds.width - 3, bounds.y + bounds.height - 3, { steps: 4 }); await page.mouse.up(); const canvas = page.locator("canvas.viewport-canvas"); await expect(canvas).toHaveAttribute("data-grease-pencil-marquee-count", "4", { timeout: 20_000 }); await expect(canvas).toHaveAttribute("data-grease-pencil-marquee-drawing-id", "grease-pencil-drawing:GreasePencilData:0"); await expect(canvas).toHaveAttribute("data-grease-pencil-marquee-stroke-ids", expectedStrokeId); await expect.poll(async () => (await app.getAttribute("data-selected-grease-pencil-point-ids"))?.split(",").filter(Boolean).sort()).toEqual(expectedPointIds); expect(Number(await app.getAttribute("data-current-main-revision"))).toBe(revision); await expect(canvas).toHaveAttribute("data-renderer-backend", offscreen ? "offscreen-worker" : "webgl-pbr"); }); }