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

opened this

Check · Review · Land · Live — It conflicts with its base. Next: builder, it conflicts with its base.

Conflicts with main

revert-10232 → main 1 commit 3 threads · 3 unresolved

Review

Sign in to review this change.
1 file changed +2 −11
test/credentials.test.ts +2 −11
@@ -56,7 +56,7 @@ async function until<T>(read: () => T | undefined): Promise<T> {
5656 while (Date.now() < deadline) {
5757 const value = read();
5858 if (value !== undefined) return value;
59 await Bun.sleep(10);
59 await Bun.sleep(50);

Polling back to 50 ms slows every until() wait for no stated reason; keep 10 ms.

6060 }
6161 throw new Error("did not happen in time");
6262 }
@@ -80,7 +80,7 @@ if [ "$CLAUDE_CODE_OAUTH_TOKEN" = "${WORK}" ]; then echo "work token used" >&2;
8080 echo '{"type":"system","subtype":"init","session_id":"fake-1","model":"fake"}'
8181 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}}}'
8282 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
8484 fi

A 0.1 s poll in the fake claude adds latency to every held run; keep 0.02.

8585 echo "work by the crew" >> CREW.md
8686 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
9595 concurrency: 1,
9696 budgetUsd: 2,
9797 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,
10198 });
10299 const a = await createUser(app.db, { origin: "seed", trusted: true,
103100 username: "alice",
@@ -133,7 +130,6 @@ afterAll(async () => {
133130
134131 describe("the platform credential", () => {
135132 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.
137133 expect(listCredentials(app.db).map((c) => c.name)).toEqual([
138134 "platform (env)",
139135 "trevato-espo",
@@ -149,7 +145,6 @@ describe("the platform credential", () => {
149145
150146 describe("a subscription's scope", () => {
151147 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.
153148 const espo = listSubscriptions(app.db)[0]!;
154149 const scope = { repoId: repo.id, ownerId: alice.id, agentId: bot.id };
155150 expect(pickSubscription(app.db, dataDir, scope, new Date()).kind).toBe("env");
@@ -173,7 +168,6 @@ describe("a subscription's scope", () => {
173168
174169 describe("a repository whose owner is not a forge admin", () => {
175170 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.
177171 const b = await createUser(app.db, {
178172 origin: "seed",
179173 trusted: true,
@@ -196,7 +190,6 @@ describe("a repository whose owner is not a forge admin", () => {
196190
197191 describe("a crew run on the platform's token", () => {
198192 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.
200193 writeFileSync(join(gateDir, "hold"), "");
201194 const issue = openIssue(app, alice, repo, { title: "Plant tulips", body: "" });
202195 if (!issue.ok) throw new Error(String(issue.error));
@@ -267,7 +260,6 @@ describe("a crew run on the platform's token", () => {
267260
268261 describe("the breakdown", () => {
269262 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.
271263 const now = new Date("2026-06-02T12:00:00.000Z");
272264 const line = (runId: string, at: string, costUsd: number, kind: "plan" | "review") =>
273265 recordUsage(app.db, {
@@ -315,7 +307,6 @@ describe("the breakdown", () => {
315307
316308 describe("the board", () => {
317309 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.
319310 const cookie = (
320311 (
321312 await fetch(`${servers.url}/signin`, {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs