Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Cover serve --tailscale's fallback in the startup lifecycle test
Milind Sonie9a2f1e5f9e8
diff --git a/server/cli-lifecycle.test.ts b/server/cli-lifecycle.test.tsindex b4be4b8256..d35dd0c903 100644--- a/server/cli-lifecycle.test.ts+++ b/server/cli-lifecycle.test.ts@@ -14,7 +14,7 @@ const mocks = vi.hoisted(() => ({FLEET_CREDENTIAL_ENV: "OMB_INSTALLATION_CREDENTIAL",denyLogOpen: false,spawn: vi.fn(),- tailscaleStatus: vi.fn(), tailscaleServe: vi.fn(), tailscaleStop: vi.fn(), clearLeftoverTailscaleServe: vi.fn(),+ tailscaleStatus: vi.fn(), tailscaleServe: vi.fn(), tailscaleStop: vi.fn(), clearLeftoverTailscaleServe: vi.fn(), tailnetListenFallback: vi.fn(),createTunnelAccount: vi.fn(), createTunnelOrigin: vi.fn(), cleanupTunnelOrigin: vi.fn(),describeTunnelAccount: vi.fn(), tunnelAccess: vi.fn(), ensureCloudflared: vi.fn(),guardianEntry: vi.fn(), startTunnel: vi.fn(),@@ -35,7 +35,7 @@ vi.mock("node:fs", async (original) => {};});vi.mock("./tailscale.ts", () => ({- tailscaleStatus: mocks.tailscaleStatus, tailscaleServe: mocks.tailscaleServe,+ tailscaleStatus: mocks.tailscaleStatus, tailscaleServe: mocks.tailscaleServe, tailnetListenFallback: mocks.tailnetListenFallback,clearLeftoverTailscaleServe: mocks.clearLeftoverTailscaleServe, explainTailscaleFailure: (failure: string) => failure,}));vi.mock("./tunnel.ts", () => ({ ...mocks, describeTunnelState: () => "Fixture tunnel" }));@@ -84,6 +84,7 @@ beforeEach(() => {mocks.tailscaleStatus.mockResolvedValue({ status: { cli: "/fixture/tailscale", dnsName: "fixture.tail.test", addresses: [], backendState: "Running" } });mocks.tailscaleServe.mockResolvedValue({ origin: "https://fixture.tail.test", stop: mocks.tailscaleStop });mocks.tailscaleStop.mockResolvedValue(undefined);+ mocks.tailnetListenFallback.mockReturnValue(null);mocks.clearLeftoverTailscaleServe.mockResolvedValue(false);mocks.createTunnelAccount.mockReturnValue({ credentials: { status: "available", read: () => ({}) }, service: { retry: async () => ({}), restore: async () => ({}), dispose: vi.fn() } });mocks.describeTunnelAccount.mockReturnValue({ email: "[email protected]" });@@ -129,6 +130,24 @@ describe("CLI startup lifecycle", () => {expect(mocks.tailscaleStop).toHaveBeenCalledOnce();});+ it("starts the server on the tailnet when tailscale serve can't front it, with nothing of Tailscale's to stop", async () => {+ mocks.tailscaleServe.mockResolvedValue({ failure: "https-not-enabled" });+ mocks.tailnetListenFallback.mockReturnValue({ origin: "http://fixture.tail.ts.net:18451", env: { OMB_TAILNET_NAME: "fixture.tail.ts.net", OMB_TAILNET_ADDRESSES: "100.64.0.7" }, line: "tailscale: listening" });+ let started: NodeJS.ProcessEnv = {};+ mocks.spawn.mockImplementation((_command: string, _args: string[], spawned: { env: NodeJS.ProcessEnv }) => { started = spawned.env; throw new Error("Fixture spawn failure"); });+ const log = vi.fn();+ await expect(runServe({ ...options, tailscale: true }, log)).rejects.toThrow("Fixture spawn failure");+ expect(started).toMatchObject({ OMB_TAILNET_NAME: "fixture.tail.ts.net", OMB_TAILNET_ADDRESSES: "100.64.0.7", OMB_PUBLIC_URL: "http://fixture.tail.ts.net:18451" });+ expect(log).toHaveBeenCalledWith("tailscale: listening");+ expect(mocks.tailscaleStop).not.toHaveBeenCalled();+ });++ it("stops with Tailscale's reason when listening on the tailnet can't help either", async () => {+ mocks.tailscaleServe.mockResolvedValue({ failure: "unknown" });+ await expect(runServe({ ...options, tailscale: true }, vi.fn())).rejects.toThrow("--tailscale: ");+ expect(mocks.spawn).not.toHaveBeenCalled();+ });+it.each([{ outcome: "success", result: { origin: "https://fixture.tail.test", stop: mocks.tailscaleStop }, stops: 1 },{ outcome: "failure", result: { failure: "unknown" }, stops: 0 },