From aef964e958c4f9ec5202bbd530d50fc9a7589607 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Fri, 3 Apr 2026 00:02:33 +0200 Subject: [PATCH] Enhance error handling in e2e tests for entity placement and model import --- tests/e2e/entities-foundation.e2e.ts | 5 ++++- 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 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/e2e/entities-foundation.e2e.ts b/tests/e2e/entities-foundation.e2e.ts index f304d929..b506eb07 100644 --- a/tests/e2e/entities-foundation.e2e.ts +++ b/tests/e2e/entities-foundation.e2e.ts @@ -37,7 +37,10 @@ test("user can place and select typed entities from the entity foundation workfl const selectedSoundEmitter = soundEmitterSnapshot.document.entities[selectedSoundEmitterId as string]; - expect(selectedSoundEmitter).toBeDefined(); + if (selectedSoundEmitter === undefined) { + throw new Error("Placed sound emitter is missing from the document snapshot."); + } + 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"); diff --git a/tests/e2e/import-draco-model-asset.e2e.ts b/tests/e2e/import-draco-model-asset.e2e.ts index ed0f4ebe..7f53c93b 100644 --- a/tests/e2e/import-draco-model-asset.e2e.ts +++ b/tests/e2e/import-draco-model-asset.e2e.ts @@ -44,7 +44,10 @@ test("imports a draco-compressed glb asset, places an instance, and survives rel const selectedModelInstance = snapshot.document.modelInstances[selectedModelInstanceId as string]; - expect(selectedModelInstance).toBeDefined(); + if (selectedModelInstance === undefined) { + 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); await page.getByRole("button", { name: "Save Draft" }).click(); diff --git a/tests/e2e/import-external-model-asset.e2e.ts b/tests/e2e/import-external-model-asset.e2e.ts index 66f84a26..15d2c671 100644 --- a/tests/e2e/import-external-model-asset.e2e.ts +++ b/tests/e2e/import-external-model-asset.e2e.ts @@ -48,7 +48,10 @@ test("imports a gltf asset with external resources and places an instance", asyn const selectedModelInstance = snapshot.document.modelInstances[selectedModelInstanceId as string]; - expect(selectedModelInstance).toBeDefined(); + if (selectedModelInstance === undefined) { + 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(pageErrors).toEqual([]); diff --git a/tests/e2e/import-model-asset.e2e.ts b/tests/e2e/import-model-asset.e2e.ts index d01806cd..aa1d4afc 100644 --- a/tests/e2e/import-model-asset.e2e.ts +++ b/tests/e2e/import-model-asset.e2e.ts @@ -50,7 +50,10 @@ test("imports a model asset, places an instance, and survives reload", async ({ const selectedModelInstance = snapshot.document.modelInstances[selectedModelInstanceId as string]; - expect(selectedModelInstance).toBeDefined(); + if (selectedModelInstance === undefined) { + 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); await page.getByRole("button", { name: "Save Draft" }).click();