Under the hood: +290 tests and 3 hidden bugs

Internal stabilization — no new features for players, but the game is meaningfully more reliable.

TESTS

Wrote around 290 new unit and component tests. Total coverage is up to 574 green tests. Every deploy now runs them all before rolling out to prod.

Covered:
— Golden Rush engine (server + client)
— the main 2p engine (previously had zero tests)
— input validation, anti-cheat, WS message validation
— admin audit, achievements, chat rate-limit, XP engine
— Golden Rush tutorial component
— training data collector, share logic, Victory City helpers

3 HIDDEN BUGS

While writing tests I found three real issues:

1. DB initialization: the idx_season_rewards_user index was declared in the base schema but the table itself was created only by migration #5. On prod this never fired because the DB already exists from previous runs and the table is already there. But on a fresh install or in-memory test DB, initialization crashed with "no such table". Fixed the order: CREATE TABLE first, CREATE INDEX after.

2. AI difficulty label: for a string that "looks like a number but isn't" (data hole), the function returned "Easy" (because parseInt gave 0, and 0 < 150 = easy). Now returns null — same as for null/undefined. Semantics preserved.

3. Golden Rush reward counter: if some bonus was 0, the UI would show "+0 bricks" as a separate line. In practice the server sends non-zero values, but added a > 0 filter just in case.

CI BATTLE

While running tests in CI had to fix a bunch of small things: upgraded GitHub Actions from v4 to v5 (old ones were deprecated along with Node.js 20), added happy-dom and @testing-library/react for component tests, fixed permission-denied on server upload (importing DB in tests created a file with owner-only permissions, scp container couldn't pack it into tar).

WHY BOTHER

Tests don't make the game better today. They make it better the day I write a new feature and accidentally break an old edge case — CI will flash red before it ships. The bugs that showed up this session wouldn't have bitten me, but the first person installing Highrise Heist from scratch — yes.