Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Sign-in resume: e2e for a message refused between two sign-ins a few seconds apart

laijsg16ff3f46af4c2
diff --git a/server/sign-in-resume.e2e.test.ts b/server/sign-in-resume.e2e.test.ts
index 6ddfc7eedb..9141b56f31 100644
--- a/server/sign-in-resume.e2e.test.ts
+++ b/server/sign-in-resume.e2e.test.ts
@@ -1,6 +1,6 @@
// The fake Claude CLI's sign-in is its own files (FAKE_CLAUDE_HOME_FILES, FAKE_CLAUDE_AUTH=file), written here as a
// terminal's `claude auth login` would.
-import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
+import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { expect, it } from "vitest";
@@ -16,6 +16,7 @@ async function withSignedOutClaude(check: (fixture: {
/** How many prompts the fake CLI was given that carry `text`. */
promptsWith: (text: string) => number;
signIn: () => Promise<void>;
+ signOut: () => Promise<void>;
/** The conversation as it reads now: its active branch, from the root to the active leaf. */
activePath: (threadId: string) => Promise<Row[]>;
all: (threadId: string) => Promise<Row[]>;
@@ -53,6 +54,10 @@ async function withSignedOutClaude(check: (fixture: {
writeFileSync(join(claudeHome, "fake-auth.json"), JSON.stringify({ email: "[email protected]" }));
await expect.poll(signedIn, { timeout: 20_000 }).toBe(true);
},
+ signOut: async () => {
+ for (const file of [".credentials.json", "fake-auth.json"]) rmSync(join(claudeHome, file), { force: true });
+ await expect.poll(signedIn, { timeout: 20_000 }).toBe(false);
+ },
activePath: async (threadId) => {
const { messages, activeLeafId } = await page(threadId);
const byId = new Map(messages.map((row) => [row.id, row]));
@@ -130,3 +135,24 @@ it("a conversation moved to another model meanwhile is not run again, and its no
expect(promptsWith("Draft the launch plan")).toBe(1);
});
}, hostTimeout(240_000));
+
+it("a message refused between two sign-ins a few seconds apart runs again after the second, and its notice says so", async () => {
+ await withSignedOutClaude(async ({ control, promptsWith, signIn, signOut, activePath, all, evidence }) => {
+ const kai = (await control("new-bot", "--name", "Kai")).bot;
+ const started = Date.now();
+ await signIn();
+ await signOut();
+ await control("send", "--bot", kai.id, "--task", kai.activeTaskId, "--text", "Draft the launch plan");
+ expect((await control("wait", "--bot", kai.id, "--task", kai.activeTaskId, "--timeout", "30")).status).toBe("failed");
+ expect(promptsWith("Draft the launch plan")).toBe(1);
+ await signIn();
+ evidence.push({ secondsBetweenSignIns: (Date.now() - started) / 1000 });
+ expect(Date.now() - started, "both sign-ins within a minute").toBeLessThan(60_000);
+ await expect.poll(() => promptsWith("Draft the launch plan"), { timeout: 30_000 }).toBe(2);
+ expect((await control("wait", "--bot", kai.id, "--task", kai.activeTaskId, "--timeout", "30")).status).toBe("settled");
+ await expect.poll(async () => (await all(kai.activeTaskId)).some((row) => row.tool?.nameCode === "chat.notice.signedInAgain"), { timeout: 30_000 }).toBe(true);
+ const now = await activePath(kai.activeTaskId);
+ evidence.push({ now });
+ expect(now.filter((row) => row.tool?.setup)).toEqual([]);
+ });
+}, hostTimeout(240_000));