From 7b4d3ce24459efb69194c7260a9dceb0d4b55970 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Tue, 31 Mar 2026 02:39:34 +0200 Subject: [PATCH] Add face material authoring test and update box brush test --- tests/e2e/box-brush-authoring.e2e.ts | 2 +- tests/e2e/face-material-authoring.e2e.ts | 38 ++++++++++++++++++++++++ tests/geometry/box-face-uvs.test.ts | 6 ++-- 3 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 tests/e2e/face-material-authoring.e2e.ts diff --git a/tests/e2e/box-brush-authoring.e2e.ts b/tests/e2e/box-brush-authoring.e2e.ts index ff82594c..4feea120 100644 --- a/tests/e2e/box-brush-authoring.e2e.ts +++ b/tests/e2e/box-brush-authoring.e2e.ts @@ -36,7 +36,7 @@ test("user can create a box brush and keep it through a draft reload", async ({ await expect(page.getByRole("button", { name: /Box Brush 1/ })).toBeVisible(); await expect(page.getByRole("button", { name: /center 0, 2, 0/ })).toBeVisible(); await expect(page.getByRole("button", { name: /size 2, 2, 4/ })).toBeVisible(); - await expect(page.getByText("1 box brushes loaded. Click a brush in the viewport or outliner to select it.")).toBeVisible(); + await expect(page.getByText("1 box brushes loaded. Click a brush face in the viewport or use the face selector to texture it.")).toBeVisible(); expect(pageErrors).toEqual([]); expect(consoleErrors).toEqual([]); diff --git a/tests/e2e/face-material-authoring.e2e.ts b/tests/e2e/face-material-authoring.e2e.ts new file mode 100644 index 00000000..32780c7d --- /dev/null +++ b/tests/e2e/face-material-authoring.e2e.ts @@ -0,0 +1,38 @@ +import { expect, test } from "@playwright/test"; + +test("user can assign a face material through the UI and keep it through a draft reload", async ({ page }) => { + const pageErrors: string[] = []; + const consoleErrors: string[] = []; + + page.on("pageerror", (error) => { + pageErrors.push(error.message); + }); + + page.on("console", (message) => { + if (message.type() === "error") { + consoleErrors.push(message.text()); + } + }); + + await page.goto("/"); + await page.evaluate((storageKey) => { + window.localStorage.removeItem(storageKey); + }, "webeditor3d.scene-document-draft"); + await page.reload(); + + await page.getByTestId("create-box-brush").click(); + 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 page.getByRole("button", { name: "Save Draft" }).click(); + await page.reload(); + + await page.getByRole("button", { name: /Box Brush 1/ }).click(); + await page.getByTestId("face-button-posZ").click(); + await expect(page.getByTestId("selected-face-material-name")).toContainText("Amber Grid"); + + expect(pageErrors).toEqual([]); + expect(consoleErrors).toEqual([]); +}); diff --git a/tests/geometry/box-face-uvs.test.ts b/tests/geometry/box-face-uvs.test.ts index b5f54bce..f1617dfa 100644 --- a/tests/geometry/box-face-uvs.test.ts +++ b/tests/geometry/box-face-uvs.test.ts @@ -70,9 +70,7 @@ describe("box face UV projection", () => { } ); - expect(transformedUv).toEqual({ - x: expect.closeTo(1.5), - y: expect.closeTo(1.75) - }); + expect(transformedUv.x).toBeCloseTo(1.5); + expect(transformedUv.y).toBeCloseTo(1.75); }); });