trae: ownclient's tests open one fake at a time, so global.test finds the realm's own hosts (0.2.14's publish run)

checkIn() opened a fake over the one the test had already opened; closing
the second put the first's 127.0.0.1 origin back as trae-cn's hosts, so
global.test.mjs, run after it in one process, read a fake host. The
publish run for 2009f49 went red on it and 0.2.14 never reached npm.
checkIn now closes the fake before it opens another.

Ran: HOME=$(mktemp -d) bun test at the repo root: 1509 pass, 0 fail.
Broken by hand: without the close, `bun test ./ownclient.test.mjs
./global.test.mjs` fails "the realm's table is its own" (26 pass, 1 fail),
as the publish run did.
This commit is contained in:
yetone
2026-10-15 17:07:59 +08:00
parent 2009f49751
commit 103bb24b65
+3
View File
@@ -48,6 +48,9 @@ function client(userId, { encoded = true, dcs = [DC] } = {}) {
}
async function checkIn(auth = signedIn()) {
// one fake at a time: a second opened over the first would put the
// first's host back as the realm's own when it closes
f?.close()
f = fakeTrae()
f.route("POST /trae/api/v2/ug/checkin_credits/claim", () => json({ code: 0 }))
f.route("POST /trae/api/v2/pay/ide_user_ent_usage", () => json({ code: 0 }))