- Political map country names were invisible because the label SVG had a zero-sized viewport, which some browsers never paint; size it to the world and guard it with a test. - Added a Devlog button showing the ten latest commits, generated into client/js/devlog_data.js by scripts/generate-devlog.js and refreshed by the pre-commit hook. - Worked through FIXME.md: the city button and a unit double-click now open the city, and the stat tooltip escapes the HUD so the unit panel cannot cover it. - The server creates its game at startup and clients only join it; the Create game screen and the configure_game path are gone, and testing is a --testing server flag. - A page on a loopback host signs in as adrien, claims France and gets the free, instant testing buttons, while the server grants free orders only to a loopback socket whose Origin is also loopback.
73 lines
2.8 KiB
JavaScript
73 lines
2.8 KiB
JavaScript
import { TestCase } from "./framework/test_case.js";
|
|
import { setupDom, teardownDom } from "./framework/dom.js";
|
|
import { formatCommitDate, renderDevlog } from "../client/js/devlog.js";
|
|
import { DEVLOG } from "../client/js/devlog_data.js";
|
|
|
|
const FIXTURE = [
|
|
{
|
|
hash: "abc1234",
|
|
date: "2026-09-21",
|
|
subject: "Fixed the invisible country names",
|
|
body: "A longer explanation of the fix.",
|
|
},
|
|
{
|
|
hash: "def5678",
|
|
date: "2026-09-20",
|
|
subject: "Added the devlog",
|
|
body: "",
|
|
},
|
|
];
|
|
|
|
export class DevlogTest extends TestCase {
|
|
test_dates_read_without_a_locale() {
|
|
this.assertEqual(formatCommitDate("2026-09-21"), "21 Sep 2026");
|
|
this.assertEqual(formatCommitDate("2026-01-02"), "2 Jan 2026");
|
|
this.assertEqual(formatCommitDate("not a date"), "not a date");
|
|
this.assertEqual(formatCommitDate(""), "");
|
|
}
|
|
|
|
async test_headers_show_the_date_and_subject_and_expand() {
|
|
const env = await setupDom();
|
|
try {
|
|
renderDevlog(env.$("#devlog-list"), FIXTURE);
|
|
const headers = env.$("#devlog-list .devlog-header");
|
|
this.assertSize(headers, 2, "one header per commit");
|
|
this.assertTrue(
|
|
headers.eq(0).find(".devlog-date").text().includes("21 Sep 2026"),
|
|
"the newest commit shows its date"
|
|
);
|
|
this.assertTrue(
|
|
headers.eq(1).find(".devlog-subject").text().includes("Added the devlog"),
|
|
"the subject is shown"
|
|
);
|
|
|
|
const bodies = env.$("#devlog-list .devlog-body");
|
|
this.assertTrue(bodies.eq(0).hasClass("hidden"), "a message starts collapsed");
|
|
headers.eq(0).trigger("click");
|
|
this.assertFalse(bodies.eq(0).hasClass("hidden"), "clicking the header expands it");
|
|
this.assertTrue(
|
|
bodies.eq(0).find(".devlog-message").text().includes("A longer explanation"),
|
|
"the full message is shown"
|
|
);
|
|
this.assertEqual(headers.eq(0).attr("aria-expanded"), "true", "the header reports it is open");
|
|
headers.eq(0).trigger("click");
|
|
this.assertTrue(bodies.eq(0).hasClass("hidden"), "clicking again collapses it");
|
|
} finally {
|
|
teardownDom(env);
|
|
}
|
|
}
|
|
|
|
test_the_generated_devlog_carries_ten_dated_commits() {
|
|
this.assertTrue(Array.isArray(DEVLOG), "the devlog data is a list");
|
|
this.assertGreater(DEVLOG.length, 0, "there is at least one commit");
|
|
this.assertLess(DEVLOG.length, 11, "at most ten commits are shipped");
|
|
for (const commit of DEVLOG) {
|
|
this.assertTrue(/^[0-9a-f]+$/.test(commit.hash), `a short hash: ${commit.hash}`);
|
|
this.assertTrue(/^\d{4}-\d{2}-\d{2}$/.test(commit.date), `a date: ${commit.date}`);
|
|
this.assertTrue(typeof commit.subject === "string" && commit.subject.length > 0,
|
|
"a commit has a subject");
|
|
this.assertTrue(typeof commit.body === "string", "a commit has a body field");
|
|
}
|
|
}
|
|
}
|