From 592730462810094c6a7b60f9f0c4f39258540dac Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Fri, 3 Apr 2026 00:08:35 +0200 Subject: [PATCH] Update e2e tests to specify model instance positions and use new viewport placement helper --- tests/e2e/import-draco-model-asset.e2e.ts | 5 ++++- tests/e2e/import-external-model-asset.e2e.ts | 5 ++++- tests/e2e/import-model-asset.e2e.ts | 5 ++++- tests/e2e/local-lights-and-background.e2e.ts | 15 +++++++-------- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/tests/e2e/import-draco-model-asset.e2e.ts b/tests/e2e/import-draco-model-asset.e2e.ts index f7509edb..5da8f0f2 100644 --- a/tests/e2e/import-draco-model-asset.e2e.ts +++ b/tests/e2e/import-draco-model-asset.e2e.ts @@ -61,7 +61,10 @@ test("imports a draco-compressed glb asset, places an instance, and survives rel throw new Error("Placed model instance is missing from the document snapshot."); } - expect(Math.abs(selectedModelInstance.position.x) > 0 || Math.abs(selectedModelInstance.position.z) > 0).toBe(true); + expect(selectedModelInstance.position).toMatchObject({ + x: 84, + z: -88 + }); await page.getByRole("button", { name: "Save Draft" }).click(); await expect(page.getByTestId("status-message")).toContainText("Local draft saved."); diff --git a/tests/e2e/import-external-model-asset.e2e.ts b/tests/e2e/import-external-model-asset.e2e.ts index 819aba42..55251323 100644 --- a/tests/e2e/import-external-model-asset.e2e.ts +++ b/tests/e2e/import-external-model-asset.e2e.ts @@ -60,7 +60,10 @@ test("imports a gltf asset with external resources and places an instance", asyn throw new Error("Placed model instance is missing from the document snapshot."); } - expect(Math.abs(selectedModelInstance.position.x) > 0 || Math.abs(selectedModelInstance.position.z) > 0).toBe(true); + expect(selectedModelInstance.position).toMatchObject({ + x: 88, + z: -84 + }); expect(pageErrors).toEqual([]); expect(consoleErrors).toEqual([]); diff --git a/tests/e2e/import-model-asset.e2e.ts b/tests/e2e/import-model-asset.e2e.ts index 6b5f27ac..6a03b04c 100644 --- a/tests/e2e/import-model-asset.e2e.ts +++ b/tests/e2e/import-model-asset.e2e.ts @@ -62,7 +62,10 @@ test("imports a model asset, places an instance, and survives reload", async ({ throw new Error("Placed model instance is missing from the document snapshot."); } - expect(Math.abs(selectedModelInstance.position.x) > 0 || Math.abs(selectedModelInstance.position.z) > 0).toBe(true); + expect(selectedModelInstance.position).toMatchObject({ + x: 92, + z: -76 + }); await page.getByRole("button", { name: "Save Draft" }).click(); await expect(page.getByTestId("status-message")).toContainText("Local draft saved."); diff --git a/tests/e2e/local-lights-and-background.e2e.ts b/tests/e2e/local-lights-and-background.e2e.ts index aed568ec..bb3896a7 100644 --- a/tests/e2e/local-lights-and-background.e2e.ts +++ b/tests/e2e/local-lights-and-background.e2e.ts @@ -2,7 +2,7 @@ import path from "node:path"; import { expect, test } from "@playwright/test"; -import { getViewportCanvas } from "./viewport-test-helpers"; +import { setViewportPlacementPreview } from "./viewport-test-helpers"; const panoramaFixturePath = path.resolve(process.cwd(), "fixtures/assets/skybox-panorama.svg"); @@ -39,10 +39,9 @@ test("local lights and background images persist through editor and runner flows await page.getByTestId("outliner-add-button").click(); await page.getByTestId("add-menu-lights").click(); await page.getByTestId("add-menu-point-light").click(); - await page.getByTestId("viewport-panel-topLeft").click({ position: { x: 16, y: 16 }, force: true }); - const viewportCanvas = getViewportCanvas(page); - await viewportCanvas.hover({ position: { x: 172, y: 116 }, force: true }); - await viewportCanvas.click({ position: { x: 172, y: 116 }, force: true }); + await setViewportPlacementPreview(page, "topLeft", { kind: "entity", entityKind: "pointLight", audioAssetId: null }, { x: 12, y: 3, z: -4 }); + await expect(page.getByTestId("viewport-snap-preview-topLeft")).toBeVisible(); + await page.getByTestId("viewport-fallback-place-topLeft").click(); await expect(page.getByTestId("point-light-distance")).toHaveValue("8"); await page.getByTestId("point-light-distance").fill("12"); await page.getByTestId("point-light-distance").press("Tab"); @@ -50,9 +49,9 @@ test("local lights and background images persist through editor and runner flows await page.getByTestId("outliner-add-button").click(); await page.getByTestId("add-menu-lights").click(); await page.getByTestId("add-menu-spot-light").click(); - await page.getByTestId("viewport-panel-topLeft").click({ position: { x: 16, y: 16 }, force: true }); - await viewportCanvas.hover({ position: { x: 240, y: 132 }, force: true }); - await viewportCanvas.click({ position: { x: 240, y: 132 }, force: true }); + await setViewportPlacementPreview(page, "topLeft", { kind: "entity", entityKind: "spotLight", audioAssetId: null }, { x: -10, y: 4, z: 6 }); + await expect(page.getByTestId("viewport-snap-preview-topLeft")).toBeVisible(); + await page.getByTestId("viewport-fallback-place-topLeft").click(); await expect(page.getByTestId("spot-light-angle")).toHaveValue("35"); await page.getByTestId("spot-light-angle").fill("48"); await page.getByTestId("spot-light-angle").press("Tab");