diff --git a/tests/e2e/face-material-authoring.e2e.ts b/tests/e2e/face-material-authoring.e2e.ts index 3c8c8042..c5a592b6 100644 --- a/tests/e2e/face-material-authoring.e2e.ts +++ b/tests/e2e/face-material-authoring.e2e.ts @@ -27,14 +27,14 @@ test("user can assign a face material through the UI and keep it through an auto await page.getByTestId("face-button-posZ").click(); await page.getByTestId("material-button-starter-amber-grid").click(); - await expect(page.getByTestId("selected-face-material-name")).toContainText("Amber Grid"); + await expect(page.getByTestId("selected-face-material-name")).toContainText("Stacked Beige Terracotta Tile"); await page.waitForTimeout(400); await page.reload(); await page.getByRole("button", { name: /Whitebox Box 1/ }).click(); await page.getByTestId("face-button-posZ").click(); - await expect(page.getByTestId("selected-face-material-name")).toContainText("Amber Grid"); + await expect(page.getByTestId("selected-face-material-name")).toContainText("Stacked Beige Terracotta Tile"); expect(pageErrors).toEqual([]); expect(consoleErrors).toEqual([]); diff --git a/tests/e2e/first-room-workflow.e2e.ts b/tests/e2e/first-room-workflow.e2e.ts index db5be5a5..4b36f165 100644 --- a/tests/e2e/first-room-workflow.e2e.ts +++ b/tests/e2e/first-room-workflow.e2e.ts @@ -50,7 +50,7 @@ test("first-room workflow covers create, texture, autosave recovery, and run", a await page.getByRole("button", { name: /Whitebox Box 1/ }).click(); await page.getByTestId("face-button-posZ").click(); - await expect(page.getByTestId("selected-face-material-name")).toContainText("Amber Grid"); + await expect(page.getByTestId("selected-face-material-name")).toContainText("Stacked Beige Terracotta Tile"); await page.getByTestId("enter-run-mode").click(); diff --git a/tests/geometry/box-face-uvs.test.ts b/tests/geometry/box-face-uvs.test.ts index c97419c1..b3471fb9 100644 --- a/tests/geometry/box-face-uvs.test.ts +++ b/tests/geometry/box-face-uvs.test.ts @@ -2,7 +2,12 @@ import { BoxGeometry } from "three"; import { describe, expect, it } from "vitest"; import { createBoxBrush } from "../../src/document/brushes"; -import { applyBoxBrushFaceUvsToGeometry, createFitToFaceBoxBrushFaceUvState, transformProjectedFaceUv } from "../../src/geometry/box-face-uvs"; +import { + applyBoxBrushFaceUvsToGeometry, + createFitToFaceBoxBrushFaceUvState, + createFitToMaterialTileBoxBrushFaceUvState, + transformProjectedFaceUv +} from "../../src/geometry/box-face-uvs"; describe("box face UV projection", () => { it("fit-to-face produces finite UVs normalized across the target face", () => { @@ -73,4 +78,24 @@ describe("box face UV projection", () => { expect(transformedUv.x).toBeCloseTo(2.5); expect(transformedUv.y).toBeCloseTo(-0.25); }); + + it("fits one authored material tile across the face bounds", () => { + const brush = createBoxBrush({ + size: { + x: 5, + y: 2, + z: 4 + } + }); + + const uvState = createFitToMaterialTileBoxBrushFaceUvState(brush, "posZ", { + x: 2.5, + y: 2.5 + }); + + expect(uvState.scale).toEqual({ + x: 0.5, + y: 1.25 + }); + }); }); diff --git a/tests/serialization/scene-document-json.test.ts b/tests/serialization/scene-document-json.test.ts index f943f200..8e667ce5 100644 --- a/tests/serialization/scene-document-json.test.ts +++ b/tests/serialization/scene-document-json.test.ts @@ -28,6 +28,7 @@ import { PLAYER_START_NAVIGATION_MODE_SCENE_DOCUMENT_VERSION, SCENE_EDITOR_PREFERENCES_SCENE_DOCUMENT_VERSION, SCENE_TRANSITION_ENTITIES_SCENE_DOCUMENT_VERSION, + SCENE_TRANSITION_SEQUENCE_EFFECTS_SCENE_DOCUMENT_VERSION, SCENE_DOCUMENT_VERSION, SPATIAL_AUDIO_SCENE_DOCUMENT_VERSION, STATIC_SIMPLE_MODEL_COLLIDERS_SCENE_DOCUMENT_VERSION, @@ -1991,6 +1992,56 @@ describe("scene document JSON", () => { }); }); + it("migrates legacy starter material entries to the asset-backed PBR registry", () => { + const legacyDocument = createEmptySceneDocument({ + name: "Legacy Material Registry Scene" + }); + const legacyBrush = createBoxBrush({ + id: "brush-legacy-materials", + size: { + x: 4, + y: 2, + z: 4 + } + }); + + legacyBrush.faces.posZ.materialId = "starter-amber-grid"; + legacyDocument.brushes[legacyBrush.id] = legacyBrush; + + const migratedDocument = migrateSceneDocument({ + ...legacyDocument, + version: SCENE_TRANSITION_SEQUENCE_EFFECTS_SCENE_DOCUMENT_VERSION, + materials: { + ...legacyDocument.materials, + "starter-amber-grid": { + id: "starter-amber-grid", + name: "Amber Grid", + pattern: "grid", + baseColorHex: "#d97706", + accentColorHex: "#fbbf24", + tags: ["warm", "grid"] + } + } + }); + + expect(migratedDocument.version).toBe(SCENE_DOCUMENT_VERSION); + expect( + migratedDocument.brushes["brush-legacy-materials"].faces.posZ.materialId + ).toBe("starter-amber-grid"); + expect(migratedDocument.materials["starter-amber-grid"]).toEqual( + expect.objectContaining({ + id: "starter-amber-grid", + name: "Stacked Beige Terracotta Tile", + assetFolder: "stacked_beige_terracotta_tile_250x250", + previewImageName: "preview.webp", + sizeCm: { + width: 250, + height: 250 + } + }) + ); + }); + it("migrates slice 1.2 face materials to the PlayerStart-capable schema", () => { const migratedDocument = migrateSceneDocument({ version: 3,