Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

1.1 KB
Raw Blame
import type { ReactNode } from "react";
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it, vi } from "vite-plus/test";

import { BotToolsSection } from "./BotToolsSection";

vi.mock("react-dom", async (importOriginal) => ({
  ...(await importOriginal<typeof import("react-dom")>()),
  createPortal: (children: ReactNode) => children,
}));

vi.stubGlobal("document", { body: null });

const render = (canDelegate?: boolean) =>
  renderToStaticMarkup(
    createElement(BotToolsSection, {
      servers: [],
      accessStatuses: [],
      disabledIds: [],
      onDisabledIdsChange: () => {},
      ...(canDelegate === undefined ? {} : { canDelegate }),
    }),
  );

describe("bot tools delegation note", () => {
  it("explains that a legacy provider cannot hand off work", () => {
    expect(render(false)).toContain("This bot&#x27;s provider cannot hand off work.");
  });

  it("stays quiet for providers that can delegate", () => {
    expect(render(true)).not.toContain("cannot hand off work");
    expect(render()).not.toContain("cannot hand off work");
  });
});