zcode: the team seat's request test uses a key of its own

start.test.mjs's "a team seat's request goes as the agent sent it" used
key "team.secret", the same as team-gift.test.mjs. In one bun test
process the two files share index.mjs's routes cache (key + jwt), and
when both jwts were built in the same second the seat test read
team-gift's cached route, skipped the billing/balance read and saw 1
request where it expects 2. That kept publish.yml red since ba343b8, so
zcode 0.1.28 (and every other package) never published.

Run: with both files' jwt exp pinned to one value, `bun test
./team-gift.test.mjs ./start.test.mjs` fails the seat test on the old
key and passes 19/19 with "seat.secret". Whole-repo `bun test` (HOME
under TMPDIR, as CI): zcode all pass; the 20 reds are gcp-ai's, which
another session is fixing. `bun scripts/check.mjs` ok.
This commit is contained in:
yetone
2026-10-25 14:38:06 +08:00
parent d467d29746
commit 2d59003f8e
+3 -3
View File
@@ -383,13 +383,13 @@ test("a GLM Coding Plan key's request goes as the agent sent it", async () => {
})
test("a team seat's request goes as the agent sent it, ZCode's token or not", async () => {
const s = { site: "zai", base: "https://api.z.ai/api/anthropic", key: "team.secret", token: "tok", org: "o1", project: "p1", jwt, device: DEVICE }
const s = { site: "zai", base: "https://api.z.ai/api/anthropic", key: "seat.secret", token: "tok", org: "o1", project: "p1", jwt, device: DEVICE }
const auth = { type: "oauth", access: s.key, refresh: JSON.stringify(s), expires: 0 }
sentAsIs(await send(auth, agentText, { requests: 2 }), "team.secret", "/api.z.ai/api/anthropic/v1/messages")
sentAsIs(await send(auth, agentText, { requests: 2 }), "seat.secret", "/api.z.ai/api/anthropic/v1/messages")
expect(got.filter((r) => r.path.endsWith("/billing/balance"))).toHaveLength(1)
expect(got.filter((r) => r.path.endsWith("/subscription/list"))).toHaveLength(0)
got.length = 0
sentAsIs(await send({ ...auth, refresh: JSON.stringify({ ...s, jwt: "" }) }, agentText), "team.secret", "/api.z.ai/api/anthropic/v1/messages")
sentAsIs(await send({ ...auth, refresh: JSON.stringify({ ...s, jwt: "" }) }, agentText), "seat.secret", "/api.z.ai/api/anthropic/v1/messages")
expect(got).toHaveLength(1)
})