Add e2e test runner + fix NPC walking, charname, screenshot OOG#5
Merged
Conversation
E2E:
- Test runner uses the full Game proxy (items/npcs/move/sendPacket); previously
ran with a hand-built minimal game stub that couldn't drive shopping flows.
- Runner has its own __onOogTick that drives splash → SP → char select with
oogSelectChar("EpicSorc"), so e2e is fully autonomous.
- pnpm test:e2e: spawns daemon --tests + run.sh, scrapes aether_log.txt for
the runner's "Results: X passed" line, exits with status.
- New scripts/tests/shopping.test.ts: 7 in-game tests covering shouldKeep,
trader visibility, real openTrade (interact + walk + menu) and short-circuit.
NPC walking (Game.moveTo + unit.ts moveToward):
- A single move click is clipped to the viewport, so the player only walked a
few tiles before stopping. Now we get a path via findPath and walk node by
node with the kolbot pattern: one click → wait for walk to start → wait for
walk to finish → re-click if not close enough. Always closes in on the
actual target.
- NPC.interact() walks before sending the interact packet. Fixes openTrade,
heal and repair when the NPC is more than ~10 tiles away.
charname binding:
- jsUnitGetName now reads pUnitData->szName for player units (UNIT_PLAYER,
dwType=0) — D2CLIENT_GetUnitName doesn't return the char name for players.
Mirrors the d2bs pattern. Monsters/items unchanged.
takeScreenshot:
- Optional name argument (".bmp" appended if missing). Each call overwrites
the same name; multiple names = multiple files.
- Wired into hookOogDraw so screenshots work on splash, char select, etc.
- .d.ts return type corrected (void, not string).
Carry-over from earlier in the session (referenced for context):
- 8 files used game.player.maxHp (undefined) — replaced with hpmax. This was
the root cause of PotionDrinker/heal/overlay never firing.
- itemGetLocation no longer flags Inventory items as Cube (removed grid==3
false-positive — only the page field is authoritative).
- jsNpcMenuByMenuId binding + npcMenuByMenuId(MenuOption.Trade/TradeRepair)
in NPC.openTrade/repair/openGamble. Replaces fragile menu-index lookup.
- shopping.ts openTradeUI uses game.waitUntil; npc.ts healAtNPC retries up to
3 times and verifies hp >= hpmax before declaring success.
Test scaffolding:
- packages/sdk/test/native-stub.ts — all 125 native exports as stubs + a
__mockNative control surface (setUIFlag, setUIFlagAfter, setMenuIdResult
with side-effect callback, getSentPackets, getMenuIdCalls, getInteracts,
getCloseCount, reset).
- packages/sdk/test/mock-game.ts — makeMockGame factory + runGenerator driver.
- 21 new fast unit tests across NPC/shopping/potions.
Verified: 61/61 SDK + 17/17 scripts unit tests pass; 29/29 in-game e2e tests
pass against a live wine/D2 1.14d session.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan