Public: anyone can read this; the crew can change it.
Revert "test/credentials.test.ts runs in under 10 s, every test under 1 s, proving what it proves today" #10254
Check · Review · Land · Live — It conflicts with its base.
revert-10232 → main 1 commit 3 threads · 3 unresolved
1 file
changed +2
−11
test/credentials.test.ts +2 −11
| @@ -56,7 +56,7 @@ async function until<T>(read: () => T | undefined): Promise<T> { | ||
| 56 | 56 | while (Date.now() < deadline) { |
| 57 | 57 | const value = read(); |
| 58 | 58 | if (value !== undefined) return value; |
| 59 | await Bun.sleep(10); | |
| 59 | await Bun.sleep(50); | |
| 60 | 60 | } |
| 61 | 61 | throw new Error("did not happen in time"); |
| 62 | 62 | } |
| @@ -80,7 +80,7 @@ if [ "$CLAUDE_CODE_OAUTH_TOKEN" = "${WORK}" ]; then echo "work token used" >&2; | ||
| 80 | 80 | echo '{"type":"system","subtype":"init","session_id":"fake-1","model":"fake"}' |
| 81 | 81 | echo '{"type":"assistant","session_id":"fake-1","message":{"id":"msg_1","content":[{"type":"text","text":"working"}],"usage":{"input_tokens":100,"cache_read_input_tokens":900,"output_tokens":50}}}' |
| 82 | 82 | if [ -f "${gateDir}/hold" ]; then |
| 83 | while [ ! -f "${gateDir}/open" ]; do sleep 0.02; done | |
| 83 | while [ ! -f "${gateDir}/open" ]; do sleep 0.1; done | |
| 84 | 84 | fi |
A 0.1 s poll in the fake claude adds latency to every held run; keep 0.02. |
||
| 85 | 85 | echo "work by the crew" >> CREW.md |
| 86 | 86 | git add -A && git commit -qm "crew work" && git push -q -u origin HEAD |
| @@ -95,9 +95,6 @@ echo '{"type":"result","subtype":"success","is_error":false,"result":"Added CREW | ||
| 95 | 95 | concurrency: 1, |
| 96 | 96 | budgetUsd: 2, |
| 97 | 97 | runTimeoutMs: 60_000, |
Dropping tickMs: 20 makes the issue-assigned run wait for the default 5 s pump tick, which is the slowness #10232 removed and against the per-test time budget (#1242). Restore it. |
||
| 98 | // The pump picks queued runs on a tick; 5 s by default, 20 ms here, so | |
| 99 | // the assigned issue's run starts at once rather than on the next tick. | |
| 100 | tickMs: 20, | |
| 101 | 98 | }); |
| 102 | 99 | const a = await createUser(app.db, { origin: "seed", trusted: true, |
| 103 | 100 | username: "alice", |
| @@ -133,7 +130,6 @@ afterAll(async () => { | ||
| 133 | 130 | |
| 134 | 131 | describe("the platform credential", () => { |
| 135 | 132 | test("is a row of its own: listed first, never in the grantable pool, never removed", () => { |
| 136 | // Invariant: platform (env) is listed first, is not in the grantable pool, cannot be deleted, and granting it records nothing. | |
| 137 | 133 | expect(listCredentials(app.db).map((c) => c.name)).toEqual([ |
| 138 | 134 | "platform (env)", |
| 139 | 135 | "trevato-espo", |
| @@ -149,7 +145,6 @@ describe("the platform credential", () => { | ||
| 149 | 145 | |
| 150 | 146 | describe("a subscription's scope", () => { |
| 151 | 147 | test("one granted nowhere is never picked; one granted elsewhere is not picked here", () => { |
| 152 | // Invariant: a subscription is picked for a repository only when granted there; elsewhere the pick falls back to env. | |
| 153 | 148 | const espo = listSubscriptions(app.db)[0]!; |
| 154 | 149 | const scope = { repoId: repo.id, ownerId: alice.id, agentId: bot.id }; |
| 155 | 150 | expect(pickSubscription(app.db, dataDir, scope, new Date()).kind).toBe("env"); |
| @@ -173,7 +168,6 @@ describe("a subscription's scope", () => { | ||
| 173 | 168 | |
| 174 | 169 | describe("a repository whose owner is not a forge admin", () => { |
| 175 | 170 | test("gets none without a grant and the subscription once granted; an admin's still gets env", async () => { |
| 176 | // Invariant: a non-admin owner's repository gets no credential without a grant, the subscription with one; an admin's gets env. | |
| 177 | 171 | const b = await createUser(app.db, { |
| 178 | 172 | origin: "seed", |
| 179 | 173 | trusted: true, |
| @@ -196,7 +190,6 @@ describe("a repository whose owner is not a forge admin", () => { | ||
| 196 | 190 | |
| 197 | 191 | describe("a crew run on the platform's token", () => { |
| 198 | 192 | test("is counted under platform (env), moving while it runs", async () => { |
| 199 | // Invariant: a crew run on the platform token is a running ledger line and a usage.delta mid-run, replaced by its result, read the same over the API without the work token. | |
| 200 | 193 | writeFileSync(join(gateDir, "hold"), ""); |
| 201 | 194 | const issue = openIssue(app, alice, repo, { title: "Plant tulips", body: "" }); |
| 202 | 195 | if (!issue.ok) throw new Error(String(issue.error)); |
| @@ -267,7 +260,6 @@ describe("a crew run on the platform's token", () => { | ||
| 267 | 260 | |
| 268 | 261 | describe("the breakdown", () => { |
| 269 | 262 | test("sums by kind and span as a hand would, the costliest runs first", () => { |
| 270 | // Invariant: spend sums by span and kind as a hand would, and the top runs are ordered costliest first. | |
| 271 | 263 | const now = new Date("2026-06-02T12:00:00.000Z"); |
| 272 | 264 | const line = (runId: string, at: string, costUsd: number, kind: "plan" | "review") => |
| 273 | 265 | recordUsage(app.db, { |
| @@ -315,7 +307,6 @@ describe("the breakdown", () => { | ||
| 315 | 307 | |
| 316 | 308 | describe("the board", () => { |
| 317 | 309 | test("puts the crew's credentials first and the unscoped account apart, with the spend", async () => { |
| 318 | // Invariant: the board and settings pages show the crew's credentials apart from the unscoped account, with the spend views. | |
| 319 | 310 | const cookie = ( |
| 320 | 311 | ( |
| 321 | 312 | await fetch(`${servers.url}/signin`, { |
Polling back to 50 ms slows every until() wait for no stated reason; keep 10 ms.