test: bring the test suite up to date, and let it run on Windows

The smoke, features, account and qol tests had fallen behind the server
and failed before reaching their end. Each now checks what the server
does on purpose today:

- harness: the chat filter messages the server sends unasked ("xfl"
  after every login, "xfa" on the first room) are set aside like "zs".
- smoke: a banned account's sign-in is refused with "account_banned", so
  the login-choices check uses a fresh account instead of the banned Carol.
- features: a shop's name comes from its room file, read the first time
  anyone goes in (the first visitor sees a name made from the path). A
  scout goes in first until the file is read, so the check no longer
  depends on what an earlier run left in cache/.
- account: a deleted account's name is held for NAME_HELD_DAYS, so taking
  it again right away is "username_taken".
- qol: the commands page sets what to type in italics.

And on Windows: withServer waits for the server process to exit before
removing its data directory, and retries; the database stays locked until
the process is gone, and the cleanup's EPERM hid the test's own result.

All seven test files pass (smoke, features, account, qol, buddygames,
restored, and staff in the next commit).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
SnipzilandClaude Opus 5.5 committed 2026-10-16 22:42:36 -04:00
1 parent edca7bf790
commit 63dc43ebb3
5 files changed
+46 -9

No files matched your search

+25 -1
View File
@@ -45,7 +45,7 @@ const wall = async body => (await postJson(`${BASE}/wall`, body)).json();
const run = async () => {
const registerJson = body => fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({avatarType: 1, agreed: true, ...body})});
for (const username of ["Ann", "Ben", "Cat"]) {
for (const username of ["Ann", "Ben", "Cat", "Scout"]) {
assert.strictEqual((await registerJson({username, password: "Password01"})).status, 200);
}
@@ -85,6 +85,30 @@ const run = async () => {
await a.untilXt("ac");
await a.nextXt("il");
// the shop's name and stalls come from its room file (lib/roominfo.js),
// read the first time anyone goes in; until then the name is made from its
// path. a scout goes in first and comes back until the file has been read,
// so that what follows does not depend on what an earlier run left in the
// cache. (the scout never enters the township, so a and b see nothing.)
const scoutAuth = await (await postJson(`${BASE}/authenticate`, {username: "Scout", password: "Password01"})).json();
const scout = new harness.GameClient(GAME_PORT);
await scout.connect();
assert.strictEqual((await scout.logIn("Scout", scoutAuth.auth_token)).status, "1");
let scoutRoom = 1;
for (let tries = 0; ; tries++) {
scout.xt("rj", scoutRoom, "jamaa_township.clothes_shop#1", 1, 0, 0);
const there = await scout.untilXt("rj");
if (there[14] === "Jam Mart Clothing") {
break;
}
assert.ok(tries < 40, `the shop's room file was never read (still "${there[14]}")`);
await new Promise(resolve => setTimeout(resolve, 500));
scout.xt("rj", there[4], "sarepia.room_main#1", 1, 0, 0);
scoutRoom = (await scout.untilXt("rj"))[4];
}
scout.socket.destroy();
await new Promise(resolve => setTimeout(resolve, 300)); // gone before Ben walks in
// --- a shop's title is its room's name, as the id of the string that says so
b.xt("rj", roomId, "jamaa_township.clothes_shop#1", 1, 0, 0);
const shopRoom = await b.untilXt("rj");