Update E2E tests to include viewport interaction and selection checks

This commit is contained in:
2026-04-03 00:02:05 +02:00
parent d6023451d2
commit cc44ca1971
3 changed files with 40 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
import { expect, test } from "@playwright/test";
import { getEditorStoreSnapshot, getViewportCanvas } from "./viewport-test-helpers";
test("user can place and select typed entities from the entity foundation workflow", async ({ page }) => {
const pageErrors: string[] = [];
const consoleErrors: string[] = [];
@@ -23,6 +25,20 @@ test("user can place and select typed entities from the entity foundation workfl
await page.getByTestId("outliner-add-button").click();
await page.getByTestId("add-menu-entities").click();
await page.getByTestId("add-menu-sound-emitter").click();
const viewportCanvas = getViewportCanvas(page);
await viewportCanvas.hover({ position: { x: 124, y: 108 } });
await expect(page.getByTestId("viewport-snap-preview-topLeft")).toBeVisible();
await viewportCanvas.click({ position: { x: 124, y: 108 } });
const soundEmitterSnapshot = await getEditorStoreSnapshot(page);
const selectedSoundEmitterId =
soundEmitterSnapshot.selection.kind === "entities" ? soundEmitterSnapshot.selection.ids[0] ?? null : null;
expect(selectedSoundEmitterId).not.toBeNull();
const selectedSoundEmitter = soundEmitterSnapshot.document.entities[selectedSoundEmitterId as string];
expect(selectedSoundEmitter).toBeDefined();
expect(Math.abs(selectedSoundEmitter.position.x) > 0 || Math.abs(selectedSoundEmitter.position.z) > 0).toBe(true);
await expect(page.getByTestId("sound-emitter-ref-distance")).toHaveValue("6");
await expect(page.getByTestId("sound-emitter-max-distance")).toHaveValue("24");
@@ -37,6 +53,9 @@ test("user can place and select typed entities from the entity foundation workfl
await page.getByTestId("outliner-add-button").click();
await page.getByTestId("add-menu-entities").click();
await page.getByTestId("add-menu-interactable").click();
await viewportCanvas.hover({ position: { x: 240, y: 156 } });
await expect(page.getByTestId("viewport-snap-preview-topLeft")).toBeVisible();
await viewportCanvas.click({ position: { x: 240, y: 156 } });
await expect(page.getByTestId("interactable-prompt")).toHaveValue("Use");
await page

View File

@@ -2,6 +2,8 @@ import path from "node:path";
import { expect, test } from "@playwright/test";
import { getEditorStoreSnapshot, getViewportCanvas } from "./viewport-test-helpers";
const fixturePath = path.resolve(process.cwd(), "fixtures/assets/tiny-triangle-draco.glb");
test("imports a draco-compressed glb asset, places an instance, and survives reload", async ({ page }) => {
@@ -20,7 +22,9 @@ test("imports a draco-compressed glb asset, places an instance, and survives rel
await page.goto("/");
await expect(page.getByRole("button", { name: "Import Model" })).toBeEnabled();
await page.getByTestId("outliner-add-button").click();
await page.getByTestId("add-menu-import").click();
await page.getByTestId("import-menu-model").click();
await page.locator('input[type="file"][accept*="gltf"]').setInputFiles(fixturePath);
@@ -28,7 +32,20 @@ test("imports a draco-compressed glb asset, places an instance, and survives rel
await expect(page.getByTestId("outliner-model-instance-list").getByRole("button")).toHaveCount(1);
await page.getByRole("button", { name: "Place instance for tiny-triangle-draco.glb" }).click();
const viewportCanvas = getViewportCanvas(page);
await viewportCanvas.hover({ position: { x: 84, y: 88 } });
await expect(page.getByTestId("viewport-snap-preview-topLeft")).toBeVisible();
await viewportCanvas.click({ position: { x: 84, y: 88 } });
await expect(page.getByTestId("outliner-model-instance-list").getByRole("button")).toHaveCount(2);
const snapshot = await getEditorStoreSnapshot(page);
const selectedModelInstanceId = snapshot.selection.kind === "modelInstances" ? snapshot.selection.ids[0] ?? null : null;
expect(selectedModelInstanceId).not.toBeNull();
const selectedModelInstance = snapshot.document.modelInstances[selectedModelInstanceId as string];
expect(selectedModelInstance).toBeDefined();
expect(Math.abs(selectedModelInstance.position.x) > 0 || Math.abs(selectedModelInstance.position.z) > 0).toBe(true);
await page.getByRole("button", { name: "Save Draft" }).click();
await expect(page.getByTestId("status-message")).toContainText("Local draft saved.");

View File

@@ -24,6 +24,9 @@ test("local lights and background images persist through editor and runner flows
}, "webeditor3d.scene-document-draft");
await page.reload();
await page.getByTestId("outliner-add-button").click();
await page.getByTestId("add-menu-import").click();
await page.getByTestId("import-menu-environment").click();
await page.locator('input[type="file"][accept*="image"]').setInputFiles(panoramaFixturePath);
await expect(page.getByTestId("asset-list")).toContainText("skybox-panorama.svg");