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.

10.2 KB
Raw Blame
import * as NodeFS from "node:fs";
import * as NodePath from "node:path";

import * as JPEG from "jpeg-js";
import { describe, expect, it } from "vite-plus/test";

const sourceFile = (path: string) =>
  NodeFS.readFileSync(NodePath.resolve(import.meta.dirname, path), "utf8");

const homeSource = () =>
  [
    sourceFile("pages/index.astro"),
    sourceFile("components/home/Hero.astro"),
    sourceFile("components/home/BotFeatures.astro"),
    sourceFile("components/home/HowItWorks.astro"),
    sourceFile("components/home/DemoGallery.astro"),
    sourceFile("components/home/DownloadSection.astro"),
  ].join("\n");

const layoutSource = () =>
  [
    sourceFile("layouts/Layout.astro"),
    sourceFile("components/SiteHeader.astro"),
    sourceFile("components/SiteFooter.astro"),
    sourceFile("styles/site.css"),
  ].join("\n");

const jpegFrameMarker = (image: Buffer) => {
  let offset = 2;

  while (offset < image.byteLength) {
    while (image[offset] === 0xff) offset += 1;
    const marker = image[offset];
    offset += 1;

    if (marker >= 0xc0 && marker <= 0xc3) return marker;

    if (marker === 0xda || marker === undefined) break;

    const segmentLength = image.readUInt16BE(offset);
    offset += segmentLength;
  }

  return undefined;
};

describe("marketing search metadata", () => {
  it("keeps search metadata while preserving the original home page", () => {
    const home = homeSource();

    expect(home).toContain('title="Akeru Bot | Open-source Grok Bot alternative"');
    expect(home).toContain('description="Run named Grok bots in an open-source desktop app');
    expect(home).toContain('<h1 class="hero-title">An open-source Grok Bot alternative</h1>');
    expect(home).toContain('<h2 class="section-title">Every bot has its own setup</h2>');
  });

  it("keeps fallback and environment claims accurate", () => {
    const home = homeSource();
    const download = sourceFile("pages/download.astro");

    // The hero opens /download until the client script picks a direct release asset,
    // and never falls back to the GitHub releases list.
    expect(home).toContain(
      '<a class="btn-primary" href="/download" data-download-auto {...downloadUrls}>',
    );
    expect(home).not.toContain("All downloads");
    expect(home).toContain("Your environment owns the chats, bot profiles, and memory.");
    expect(home).not.toContain("Everything stays on your machine");
    expect(home).not.toContain("no hosted service");
    expect(download).toMatch(/@media \(prefers-reduced-motion: reduce\)[\s\S]*?animation: none;/);
  });

  it("gives each Grok search intent one page", () => {
    const openSource = sourceFile("pages/open-source-grok-bot.astro");
    const comparison = sourceFile("pages/compare/akeru-vs-grok-bot.astro");
    const selfHosted = sourceFile("pages/guides/self-hosted-grok-bot.astro");

    expect(openSource).toContain('title="Open-source Grok Bot alternative | Akeru Bot"');
    expect(openSource).toContain('heading="An open-source alternative to Grok Bot"');
    expect(comparison).toContain('title="Akeru Bot vs Grok Bot | Open-source comparison"');
    expect(comparison).toContain('heading="Akeru Bot and Grok Bot compared"');
    expect(selfHosted).toContain('title="Self-hosted Grok Bot alternative | Akeru Bot"');
    expect(selfHosted).toContain('heading="Run a Grok bot on an environment you control"');
    expect(openSource).toContain('href="/compare/akeru-vs-grok-bot"');
    expect(comparison).toContain('href="/guides/self-hosted-grok-bot"');
    expect(selfHosted).toContain('href="/open-source-grok-bot"');
    expect(openSource).toContain('datePublished="2026-09-03"');
    expect(comparison).toContain('datePublished="2026-09-03"');
    expect(selfHosted).toContain('datePublished="2026-09-03"');
    expect(comparison).toMatch(
      /<td>Desktop clients<\/td>\s*<td>macOS, Windows, and Linux<\/td>\s*<td>macOS and Windows<\/td>/,
    );
  });

  it("connects Grok discovery to setup without inventing product evidence", () => {
    const home = homeSource();
    const openSource = sourceFile("pages/open-source-grok-bot.astro");
    const selfHosted = sourceFile("pages/guides/self-hosted-grok-bot.astro");
    const sitemap = sourceFile("../public/sitemap.xml");

    expect(home).toContain('href="/open-source-grok-bot"');
    expect(openSource).toContain("Looking for an OSS Grok bot?");
    expect(openSource).toContain('src="/app-screenshot.webp"');
    expect(openSource).toContain("not a benchmark or a recorded Grok result");
    expect(openSource).toContain('href="/guides/self-hosted-grok-bot#first-task"');
    expect(openSource).toContain("Does self-hosting keep my prompts offline?");
    expect(openSource).toContain("Your Grok subscription and any server you rent");

    for (const page of [openSource, selfHosted]) {
      expect(page).toContain("<code>~/.akeru</code> by default");
      expect(page).not.toContain("under Subscriptions");
    }

    expect(selfHosted).toContain('id="first-task"');
    expect(selfHosted).toContain("A prompt is not a permission boundary");
    expect(selfHosted).toContain("Do not edit files, install dependencies, or run commands.");

    for (const path of ["/", "/open-source-grok-bot", "/guides/self-hosted-grok-bot"]) {
      expect(sitemap).toContain(
        `<loc>https://www.akeru-bot.com${path}</loc><lastmod>2026-09-07</lastmod>`,
      );
    }

    expect(openSource).toContain('dateModified="2026-09-07"');
    expect(selfHosted).toContain('dateModified="2026-09-07"');
  });

  it("publishes an editorial blog index that links every Grok article", () => {
    const blog = sourceFile("pages/blog/index.astro");
    const articles = sourceFile("lib/articles.ts");
    const layout = layoutSource();

    expect(blog).toContain('title="Akeru Blog | Open-source AI bot guides"');
    expect(blog).toContain("<h1>Blog</h1>");
    expect(articles).toContain('href: "/open-source-grok-bot"');
    expect(articles).toContain('href: "/compare/akeru-vs-grok-bot"');
    expect(articles).toContain('href: "/guides/self-hosted-grok-bot"');
    expect(blog).toContain('aria-label="Article topics"');
    expect(blog).toContain('<a class="topic-link" href={article.href}>{article.category}</a>');
    expect(blog).toContain('class="article-grid" id="articles"');
    expect(blog).toContain("<BlogCover article={article} />");
    expect(blog).toMatch(/\.blog-header \{[\s\S]*?text-align: center;/);
    expect(blog).not.toMatch(/gradient/);
    expect(layout).toContain('<a class="nav-link" href="/blog">Blog</a>');
  });

  it("uses one sans-serif face across the marketing site", () => {
    const layout = layoutSource();
    const home = homeSource();

    expect(layout).toContain('src: url("/fonts/geist-latin.woff2") format("woff2");');
    expect(layout).toContain('src: url("/fonts/eb-garamond-500-latin.woff2") format("woff2");');
    expect(layout).not.toContain("fonts.googleapis.com");
    expect(layout).toContain('--font-serif: "EB Garamond", Georgia, serif;');
    expect(layout).toContain("--color-muted-foreground: #a1a1a1;");
    expect(home).not.toContain("--color-editorial-muted-foreground");
    expect(home).toContain("data-demo-video");
    expect(home).toMatch(/\.hero-title \{[\s\S]*?font-size: 72px;/);
    expect(home).not.toContain("download-glow");
  });

  it("adds page and breadcrumb structured data to search pages", () => {
    const searchPage = sourceFile("components/SearchPage.astro");
    const layout = layoutSource();

    expect(searchPage).toContain('"@type": "BreadcrumbList"');
    expect(searchPage).toContain('"@type": kind');
    expect(searchPage).toContain("mainEntityOfPage: canonicalUrl");
    expect(searchPage).toContain("datePublished");
    expect(searchPage).toContain("dateModified");
    expect(searchPage).toContain('name: "Blog"');
    expect(searchPage).toContain('name: "Akeru Bot"');
    expect(searchPage).toContain("articlePublishedTime={datePublished}");
    expect(searchPage).toContain("articleModifiedTime={dateModified}");
    expect(searchPage).toContain('class="article-layout"');
    expect(searchPage).toContain('href="/blog" aria-label="Back to blog"');
    expect(searchPage).toContain('<div class="related-grid">');
    expect(searchPage).not.toMatch(/gradient|blur\(/);
    expect(searchPage).toContain(
      "h1 { margin-top: 16px; font-size: 30px; line-height: 41px; letter-spacing: -0.5px; }",
    );
    expect(searchPage).toContain(
      ".article-copy :global(h2) { margin-top: 32px; font-size: 30px; line-height: 41px; }",
    );
    expect(searchPage).not.toMatch(/Akeru maintainers|readingTime|Share on|data-copy-url/);
    expect(searchPage).not.toMatch(/Example|related-art/);
    expect(searchPage).toContain('<BlogCover article={coverArticle} size="feature" />');
    expect(layout).toContain('Astro.url.pathname.replace(/\\/+$/, "")');
  });

  it("keeps wide comparison tables inside the mobile reading column", () => {
    const searchPage = sourceFile("components/SearchPage.astro");

    expect(searchPage).toMatch(/\.article-copy \{[\s\S]*?min-width: 0;/);
    expect(searchPage).toContain("overflow-x: auto;");
  });

  it("serves a crawler-compatible social card from a cache-busted URL", () => {
    const layout = layoutSource();

    const socialImage = NodeFS.readFileSync(
      NodePath.resolve(import.meta.dirname, "../public/og-v2.jpg"),
    );

    const decoded = JPEG.decode(socialImage, { formatAsRGBA: false, useTArray: true });

    expect(layout).toContain('new URL("/og-v2.jpg", siteOrigin)');
    expect(layout).toContain('<meta property="og:image:type" content="image/jpeg" />');
    expect(layout).toContain('<meta property="og:image:width" content="1200" />');
    expect(layout).toContain('<meta property="og:image:height" content="630" />');
    expect(layout).toContain('<meta name="twitter:image:alt"');
    expect(jpegFrameMarker(socialImage)).toBe(0xc0);
    expect(decoded).toMatchObject({ width: 1200, height: 630 });
    expect(decoded.data.byteLength).toBe(1200 * 630 * 3);
    expect(socialImage.byteLength).toBeLessThan(5_000_000);
  });

  it("keeps missing pages out of search results", () => {
    const layout = layoutSource();
    const notFound = sourceFile("pages/404.astro");

    expect(layout).toContain('<meta name="robots" content="noindex, follow" />');
    expect(layout).toContain("description: softwareDescription");
    expect(notFound).toMatch(/<Layout[\s\S]*?noindex/);
  });
});