Update e2e tests for model asset import with external resources and improve interaction checks

This commit is contained in:
2026-04-03 00:01:41 +02:00
parent 2ebe4bb8a1
commit d6023451d2
2 changed files with 25 additions and 10 deletions

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 gltfFixturePath = path.resolve(process.cwd(), "fixtures/assets/external-triangle/scene.gltf");
const binFixturePath = path.resolve(process.cwd(), "fixtures/assets/external-triangle/triangle.bin");
@@ -21,7 +23,9 @@ test("imports a gltf asset with external resources and places an instance", asyn
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([gltfFixturePath, binFixturePath]);
@@ -32,7 +36,20 @@ test("imports a gltf asset with external resources and places an instance", asyn
await page.getByRole("button", { name: "Place instance for scene.gltf" }).hover();
await expect(page.getByTestId("status-asset-hover")).toContainText("Storage key:");
await page.getByRole("button", { name: "Place instance for scene.gltf" }).click();
const viewportCanvas = getViewportCanvas(page);
await viewportCanvas.hover({ position: { x: 88, y: 84 } });
await expect(page.getByTestId("viewport-snap-preview-topLeft")).toBeVisible();
await viewportCanvas.click({ position: { x: 88, y: 84 } });
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);
expect(pageErrors).toEqual([]);
expect(consoleErrors).toEqual([]);

View File

@@ -37,23 +37,21 @@ test("imports a model asset, places an instance, and survives reload", async ({
await page.getByRole("button", { name: "Place instance for tiny-triangle.gltf" }).hover();
await expect(page.getByTestId("status-asset-hover")).toContainText("Storage key:");
await page.getByRole("button", { name: "Place instance for tiny-triangle.gltf" }).click();
const viewportCanvas = getViewportCanvas(page);
await viewportCanvas.hover({ position: { x: 92, y: 76 } });
await expect(page.getByTestId("viewport-snap-preview-topLeft")).toBeVisible();
await viewportCanvas.click({ position: { x: 92, y: 76 } });
await expect(page.getByTestId("outliner-model-instance-list").getByRole("button")).toHaveCount(2);
await expect
.poll(async () => getEditorStoreSnapshot(page))
.then((snapshot) => {
const selectedModelInstanceId = snapshot.selection.kind === "modelInstances" ? snapshot.selection.ids[0] ?? null : null;
const snapshot = await getEditorStoreSnapshot(page);
const selectedModelInstanceId = snapshot.selection.kind === "modelInstances" ? snapshot.selection.ids[0] ?? null : null;
expect(selectedModelInstanceId).not.toBeNull();
expect(selectedModelInstanceId).not.toBeNull();
const selectedModelInstance = snapshot.document.modelInstances[selectedModelInstanceId as string];
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);
});
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.");