Improve MineGeo UI and application flows
Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Failing after 2m37s

This commit is contained in:
2026-10-18 11:44:04 +05:00
parent ad73132f15
commit a7085e4e80
50 changed files with 4790 additions and 703 deletions

View File

@@ -1,9 +1,63 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { customDifficultySchema } from "../shared/protocol";
import { customDifficultySchema, scoreGuess } from "../shared/protocol";
import { mergeDifficultyPresets } from "../shared/difficulty-presets";
const rules = { seconds: 90, zoom: true };
test("expanded difficulty rules preserve defaults and validate controls", () => {
const preset = customDifficultySchema.parse({ name: "Classic", ...rules });
assert.deepEqual(
{
pan: preset.pan,
compass: preset.compass,
coordinates: preset.coordinates,
mapZoom: preset.mapZoom,
scoring: preset.scoring,
},
{
pan: true,
compass: true,
coordinates: true,
mapZoom: true,
scoring: "normal",
},
);
for (const key of ["pan", "compass", "coordinates", "mapZoom"])
assert.equal(
customDifficultySchema.safeParse({
name: "Fixture",
...rules,
[key]: "false",
}).success,
false,
);
assert.equal(
customDifficultySchema.safeParse({
name: "Fixture",
...rules,
scoring: "extreme",
}).success,
false,
);
assert.equal(
customDifficultySchema.safeParse({ name: "Fixture", ...rules, rounds: 10 })
.success,
false,
);
});
test("scoring strictness changes distance decay while perfect guesses remain 5000", () => {
const bounds = { minX: 0, minZ: 0, maxX: 100, maxZ: 100 };
const actual = { x: 10, z: 10 },
guess = { x: 40, z: 40 };
const scores = ["strict", "normal", "gentle"].map(
(mode) =>
scoreGuess(actual, guess, bounds, mode as "strict" | "normal" | "gentle")
.score,
);
assert.ok(scores[0] < scores[1] && scores[1] < scores[2]);
for (const mode of ["strict", "normal", "gentle"] as const)
assert.equal(scoreGuess(actual, actual, bounds, mode).score, 5000);
});
test("difficulty names accept normal text and count Unicode characters consistently with PostgreSQL", () => {
for (const name of [
"Normal",