Files
MCMapper-Backend/e2e/tests/admin.spec.ts
T
octoturge f8216b6e77 Phase 11: real block textures for 2D tiles
Layers texture-averaged colors on top of palette.rs's hand-picked table as a
fallback (color_for_textured), not a hard replacement — biome-tinted/animated
blocks (grass top, leaves, water, lava) deliberately keep the hand-picked
color since averaging their raw jar textures would be wrong, not just
imprecise.

Vanilla: worker/src/textures.rs downloads Mojang's official client jar
directly from launchermeta/piston-meta/piston-data (same endpoints the real
launcher uses, gated behind ACCEPT_MINECRAFT_EULA=true, off by default,
mirrors BlueMap's accept-download) and averages every block texture, cached
to disk so it's not re-downloaded every restart.

Modded: ingests block_registry/block_textures messages from the mod (new
Postgres tables + MinIO storage in api/src/textures.ts) — sent once per
connection over the existing WS gateway.

texturepacks/<name>/ (Dynmap-style flat PNGs) lets an operator override the
vanilla defaults worker-wide via TEXTURE_PACK. A per-server texturePack
admin column/API exists for the same purpose, but render-time per-server
resolution (of both the admin selection and the ingested modded textures) is
explicitly deferred — the worker still applies one process-wide palette; true
per-server resolution needs the render pipeline to thread a server-scoped
palette through the batch/GPU-dispatch path, judged too big a change for this
phase. Documented in README.

Docker was unavailable in this dev environment for the usual integration-test
verification; bunx tsc --noEmit was used as a fallback static check instead
(clean except 2 pre-existing unrelated errors in markers.test.ts).
2026-08-09 23:21:31 +02:00

78 lines
3.9 KiB
TypeScript

// Covers the admin panel's token-unlock flow and server registry management (Phase 6) — the
// api-level admin.ts/index.ts routes are already unit/integration tested, so this focuses on the
// browser-side glue: the token gate, and register/edit/delete round-tripping through the real UI.
import { test, expect } from "@playwright/test";
import { readE2eState } from "../config";
const state = readE2eState();
test.describe("admin panel", () => {
test.use({ storageState: { cookies: [], origins: [] } });
test("wrong token shows an error and does not unlock", async ({ page }) => {
await page.goto("/admin");
await page.getByTestId("admin-token-input").fill("not-the-right-token");
await page.getByTestId("admin-unlock").click();
await expect(page.getByTestId("admin-error")).toBeVisible();
await expect(page.getByTestId("admin-token-input")).toBeVisible();
});
test("correct token unlocks and lists the seeded e2e server", async ({ page }) => {
await page.goto("/admin");
await page.getByTestId("admin-token-input").fill(state.adminToken);
await page.getByTestId("admin-unlock").click();
await expect(page.getByTestId("admin-lock")).toBeVisible();
await expect(page.locator('[data-testid="admin-server-row"][data-server-name="e2e-server"]')).toBeVisible();
});
test("registering a new server adds it to the list with a generated token", async ({ page }) => {
await page.goto("/admin");
await page.getByTestId("admin-token-input").fill(state.adminToken);
await page.getByTestId("admin-unlock").click();
await page.getByTestId("admin-new-name").fill("e2e-admin-created");
await page.getByTestId("admin-new-authmode").selectOption("online");
await page.getByTestId("admin-register-submit").click();
const row = page.locator('[data-testid="admin-server-row"][data-server-name="e2e-admin-created"]');
await expect(row).toBeVisible();
await expect(row.getByTestId("admin-server-token")).not.toHaveText("");
});
test("editing settings and saving persists across a reload", async ({ page }) => {
await page.goto("/admin");
await page.getByTestId("admin-token-input").fill(state.adminToken);
await page.getByTestId("admin-unlock").click();
const row = page.locator('[data-testid="admin-server-row"][data-server-name="e2e-server"]');
await row.getByTestId("admin-server-waypointformat").selectOption("xaero");
await row.getByTestId("admin-server-anonchat").uncheck();
await row.getByTestId("admin-server-texturepack").fill("my-resource-pack");
await row.getByTestId("admin-server-save").click();
await expect(row.getByTestId("admin-server-status")).toHaveText("saved");
// The admin token is remembered in localStorage (see admin.js's init()), so a reload
// auto-unlocks again rather than showing the token prompt.
await page.reload();
const reloadedRow = page.locator('[data-testid="admin-server-row"][data-server-name="e2e-server"]');
await expect(reloadedRow.getByTestId("admin-server-waypointformat")).toHaveValue("xaero");
await expect(reloadedRow.getByTestId("admin-server-anonchat")).not.toBeChecked();
await expect(reloadedRow.getByTestId("admin-server-texturepack")).toHaveValue("my-resource-pack");
});
test("deleting a server removes it from the list", async ({ page }) => {
await page.goto("/admin");
await page.getByTestId("admin-token-input").fill(state.adminToken);
await page.getByTestId("admin-unlock").click();
await page.getByTestId("admin-new-name").fill("e2e-admin-deleteme");
await page.getByTestId("admin-new-authmode").selectOption("offline");
await page.getByTestId("admin-register-submit").click();
const row = page.locator('[data-testid="admin-server-row"][data-server-name="e2e-admin-deleteme"]');
await expect(row).toBeVisible();
await row.getByTestId("admin-server-delete").click();
await expect(row).toHaveCount(0);
});
});