Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

1.9 KB
Raw Blame
// @vitest-environment node
import { describe, expect, test } from "vitest";
import { searchApi } from "./searchApi";

describe("searchApi", () => {
  test("finds the database-listing endpoint from a natural-language query", async () => {
    const result = await searchApi({
      query: "list databases in this project",
    });

    expect(result).toMatch(
      /^## Matching endpoints\n\n1\. DatabaseService\/ListDatabases/m
    );
  });

  test("uses response-schema terms when ranking an endpoint", async () => {
    const result = await searchApi({
      query: "view project members",
    });

    expect(result).toMatch(
      /^## Matching endpoints\n\n1\. ProjectService\/GetIamPolicy/m
    );
  });

  test("shows all supported parent scopes when inspecting a listing endpoint", async () => {
    const result = await searchApi({
      operationId: "DatabaseService/ListDatabases",
    });

    expect(result).toContain("projects/{project}: list databases in a project");
    expect(result).toContain(
      "workspaces/{id}: list databases in the workspace"
    );
    expect(result).toContain(
      "instances/{instance}: list databases in an instance"
    );
    expect(result).toContain(
      "projects/{project}/instances/{instance}: list databases in a project instance"
    );
  });

  test("shows declared IAM permission without claiming current access", async () => {
    const result = await searchApi({
      operationId: "ProjectService/UpdateProject",
    });
    expect(result).toContain("Declared IAM permission: bb.projects.update");
    expect(result).toContain(
      "access is checked against its resources before execution"
    );
  });

  test("labels custom authorization as request-dependent", async () => {
    const result = await searchApi({
      operationId: "DatabaseService/ListDatabases",
    });
    expect(result).toContain("Authorization: custom, request-dependent");
  });
});