Add map import and export with durable refresh progress

This commit is contained in:
2026-10-07 19:44:49 +05:00
parent dac8650ac1
commit 1307436e65
37 changed files with 2207 additions and 85 deletions

27
tests/map-refresh.test.ts Normal file
View File

@@ -0,0 +1,27 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { refreshCapture } from "../shared/map-refresh";
const original = {
id: "original",
name: "My Minecraft map",
created_at: "2026-10-07T09:51:39Z",
};
const contribution = {
id: "accepted",
name: "My Minecraft map",
created_at: "2026-10-07T10:28:01Z",
};
test("refresh chooses the newest eligible capture, including newly accepted contributions with the same name", () => {
assert.equal(refreshCapture([original]), "original");
assert.equal(refreshCapture([original, contribution]), "accepted");
assert.equal(refreshCapture([contribution, original]), "accepted");
});
test("a deliberately selected older capture stays selected when the list reloads", () => {
assert.equal(
refreshCapture([contribution, original], "original"),
"original",
);
assert.equal(refreshCapture([contribution], "original"), "accepted");
assert.equal(refreshCapture([]), "");
});