AkurAI Build
Menu

popagent

public

Latest change da13a7bebe63bf4b2693180d2d4850aabeaa0807 - Add autonomous evolution and self-healing by AkurAI Build

import { describe, expect, test } from "bun:test";
import { appRoutePath, parseAppRoute } from "./routes";

describe("browser routes", () => {
  test("maps durable application URLs", () => {
    expect(parseAppRoute("/")).toEqual({ page: "overview" });
    expect(parseAppRoute("/settings/browser")).toEqual({ page: "settings", section: "browser" });
    expect(parseAppRoute("/settings/secrets")).toEqual({ page: "settings", section: "secrets" });
    expect(parseAppRoute("/settings/observability")).toEqual({ page: "settings", section: "observability" });
    expect(parseAppRoute("/settings/channels")).toEqual({ page: "settings", section: "channels" });
    expect(parseAppRoute("/settings/autonomy")).toEqual({ page: "settings", section: "autonomy" });
    expect(parseAppRoute("/settings")).toEqual({ page: "settings", section: "agents" });
    expect(parseAppRoute("/workspaces/my%20repo")).toEqual({ page: "workspace", workspaceId: "my repo" });
    expect(parseAppRoute("/workspaces/my%20repo/docs/docs/guide/start.md")).toEqual({ page: "documentation", workspaceId: "my repo", path: "docs/guide/start.md" });
    expect(parseAppRoute("/chats/session-1")).toEqual({ page: "chat", sessionId: "session-1" });
    expect(parseAppRoute("/channels/general")).toEqual({ page: "channel", channelId: "general" });
  });

  test("generates canonical paths and safely falls back for unknown routes", () => {
    expect(appRoutePath({ page: "settings", section: "browser" })).toBe("/settings/browser");
    expect(appRoutePath({ page: "settings", section: "secrets" })).toBe("/settings/secrets");
    expect(appRoutePath({ page: "settings", section: "autonomy" })).toBe("/settings/autonomy");
    expect(appRoutePath({ page: "channel", channelId: "general" })).toBe("/channels/general");
    expect(appRoutePath({ page: "workspace", workspaceId: "my repo" })).toBe("/workspaces/my%20repo");
    expect(appRoutePath({ page: "documentation", workspaceId: "my repo", path: "docs/index.md" })).toBe("/workspaces/my%20repo/docs/docs/index.md");
    expect(parseAppRoute("/settings/unknown")).toEqual({ page: "overview" });
    expect(parseAppRoute("/chats/%E0%A4%A")).toEqual({ page: "overview" });
  });
});