Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vitest";
import { normalizeAccessEntry, SignInAccessCard, withEntry, withoutEntry } from "./SignInAccessCard";
describe("who may sign in with an emailed code", () => {
it("accepts an address or an @domain and nothing else", () => {
expect(normalizeAccessEntry(" [email protected] ")).toBe("[email protected]");
expect(normalizeAccessEntry("@Agentada.cc")).toBe("@agentada.cc");
expect(normalizeAccessEntry("nope")).toBeNull();
expect(normalizeAccessEntry("@nodot")).toBeNull();
expect(normalizeAccessEntry("two [email protected]")).toBeNull();
expect(normalizeAccessEntry("")).toBeNull();
});
it("moves an entry between the lists instead of duplicating it, and removes from both", () => {
const start = { admins: ["[email protected]"], members: ["[email protected]"] };
expect(withEntry(start, "[email protected]", "admin")).toEqual({ admins: ["[email protected]", "[email protected]"], members: [] });
expect(withEntry(start, "[email protected]", "member")).toEqual({ admins: [], members: ["[email protected]", "[email protected]"] });
expect(withEntry(start, "@y.com", "member")).toEqual({ admins: ["[email protected]"], members: ["[email protected]", "@y.com"] });
expect(withoutEntry(start, "[email protected]")).toEqual({ admins: [], members: ["[email protected]"] });
});
it("renders nothing until it knows who is asking", () => {
expect(renderToStaticMarkup(createElement(SignInAccessCard))).toBe("");
});
});