Skip to content
Merged
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .bb/skills/test-audit/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ pass after the owner-boundary repair. A regression test that never demonstrably
failed proves the mock, not the fix. One regression at the owner boundary
covers the bug; do not replay the same scenario at every layer it crosses.

bb test rules: never mock the database; use `createConnection(":memory:")`
and `migrate(db)` from `@bb/db`. Vitest projects come from
bb test rules: never mock the database; use `createMigratedConnection()` from
`@bb/db/testing`, which copies a template built by the real migrations. Vitest projects come from
`sharedWorkerProjects` in `vitest.shared.ts`: Node test files share workers
(`isolate: false`), and files that use `vi.mock`, `vi.stubGlobal`, fake timers,
`process.env` writes, or global assignments are isolated automatically.
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

- Use targeted `WHERE`/`JOIN` queries instead of loading all rows and filtering in JavaScript. Add indexes only when required by the query.
- Change Drizzle schemas and regenerate migrations/snapshots; never edit snapshot JSON manually.
- Never mock the database in tests. Use `createConnection(":memory:")` and `migrate(db)`.
- Never mock the database in tests. Use `createMigratedConnection()` from `@bb/db/testing`, a real SQLite database copied from a template built once by the real migrations. Call `migrate(db)` directly only when testing migrations or an on-disk database.

## UI

Expand Down
3 changes: 2 additions & 1 deletion apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"storybook:build": "ladle build",
"lint": "oxlint src vite.config.ts vite.dev.config.ts vite-bundle-stats.ts vite-font-preload.ts vite-split-prefetch.ts vite-forkable-plugin-paths.ts vite-shared-ui-seam.ts vite-react-compiler.ts",
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.node.json",
"test": "node scripts/generate-pwa-icons.mjs --check && vitest run --config vitest.config.ts"
"test": "node scripts/generate-pwa-icons.mjs --check && vitest run --config vitest.config.ts",
"bench": "cross-env BB_SIDEBAR_BENCH=1 PROMPTBOX_PERF=1 vitest run --config vitest.config.ts src/components/sidebar/sidebar.bench.test.tsx src/components/promptbox/editor/prompt-paste-performance.test.ts"
},
"dependencies": {
"@bb/client-core": "workspace:*",
Expand Down
26 changes: 0 additions & 26 deletions apps/app/src/components/AppErrorBoundary.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,4 @@ describe("AppErrorBoundary", () => {
expect(container.textContent).toContain("render exploded");
dispose();
});

it("catches the commit-phase removeChild failure instead of blanking the root", () => {
vi.spyOn(console, "error").mockImplementation(() => undefined);
const { container, render, dispose } = mountRoot();

function Tree({ mounted }: { mounted: boolean }) {
return <div>{mounted ? <p data-moved="">body</p> : null}</div>;
}
render(
<AppErrorBoundary>
<Tree mounted />
</AppErrorBoundary>,
);
const moved = container.querySelector("[data-moved]");
expect(moved).not.toBeNull();
document.createElement("section").appendChild(moved!);

render(
<AppErrorBoundary>
<Tree mounted={false} />
</AppErrorBoundary>,
);

expect(container.textContent).toContain("bb hit an error and stopped");
dispose();
});
});
30 changes: 0 additions & 30 deletions apps/app/src/components/AppToaster.loading.test.tsx

This file was deleted.

96 changes: 0 additions & 96 deletions apps/app/src/components/code/renderer-lazy-loading.test.tsx

This file was deleted.

8 changes: 2 additions & 6 deletions apps/app/src/components/commands/CommandPalette.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
waitFor,
within,
} from "@testing-library/react";
import { MemoryRouter, useLocation } from "react-router-dom";
import { MemoryRouter } from "react-router-dom";
import { createStore, Provider } from "jotai";
import { paletteThreadLifecyclesAtom } from "@/lib/command-palette/palette-preferences";
import { splitLayoutAtom } from "@/lib/split-layout/atoms";
Expand Down Expand Up @@ -42,6 +42,7 @@ import {
} from "@/lib/plugin-thread-row-status";
import { makePluginRegistrationSet } from "@/test/fixtures/plugins";
import { collectPluginAppRegistrations } from "@get-bb/plugin-sdk/internal/plugin-app-collector";
import { LocationProbe } from "@/test/location-probe";

beforeAll(async () => {
await import("./ThreadSearchPaletteMode");
Expand Down Expand Up @@ -275,11 +276,6 @@ function Handler({ command }: { command: AppCommandId }) {
return null;
}

function LocationProbe() {
const location = useLocation();
return <output data-testid="location">{location.pathname}</output>;
}

const threadUpdatedAt = Date.now();

function makeThread(
Expand Down
19 changes: 0 additions & 19 deletions apps/app/src/components/create-via-prompt-examples.test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/app/src/components/create-via-prompt-examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ interface CreateExample {
prompt: string;
}

export function getCreateExamples(kind: CreateViaPromptKind): {
function getCreateExamples(kind: CreateViaPromptKind): {
examples: CreateExample[];
} {
const config = CONFIG[kind];
Expand Down
32 changes: 2 additions & 30 deletions apps/app/src/components/dialogs/ProjectPathDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ describe("ProjectPathDialog machine selection", () => {
host({
id: "host_modal",
name: "Modal sandbox 3f9a",
type: "ephemeral",
machineProviderId: "modal",
}),
]}
onOpenChange={vi.fn()}
Expand All @@ -147,36 +149,6 @@ describe("ProjectPathDialog machine selection", () => {
).toBeTruthy();
});

it("uses a provider-made host as the only project machine", () => {
const onSubmit = vi.fn();
render(
<ProjectPathDialog
target={{ kind: "create" }}
platform="linux"
hostId="host_modal"
hostName="Modal sandbox 3f9a"
hosts={[
host({
id: "host_modal",
name: "Modal sandbox 3f9a",
}),
]}
onOpenChange={vi.fn()}
onSubmit={onSubmit}
/>,
);

fireEvent.click(
screen.getByRole("button", { name: "Choose folder on host_modal" }),
);
fireEvent.click(screen.getByRole("button", { name: "Add project" }));
expect(onSubmit).toHaveBeenCalledWith(
{ kind: "create" },
"/home/deploy/repos/givecare",
"host_modal",
);
});

it("blocks submission when every listed machine is offline", () => {
const onSubmit = vi.fn();
render(
Expand Down
1 change: 0 additions & 1 deletion apps/app/src/components/git-diff/git-diff-parsing.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @vitest-environment jsdom
import { describe, expect, it } from "vitest";
import {
enrichGitDiffFileForContext,
Expand Down
16 changes: 7 additions & 9 deletions apps/app/src/components/layout/AppBreadcrumbs.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
// @vitest-environment jsdom

import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { MemoryRouter, useLocation } from "react-router-dom";
import { MemoryRouter } from "react-router-dom";
import { afterEach, describe, expect, it } from "vitest";
import { AppBreadcrumbs } from "./AppBreadcrumbs";
import { LocationProbe } from "@/test/location-probe";

afterEach(cleanup);

function LocationProbe() {
return (
<output aria-label="Current location">{useLocation().pathname}</output>
);
}

describe("AppBreadcrumbs", () => {
it("navigates through ancestors while keeping the resource passive", () => {
render(
Expand All @@ -31,7 +26,10 @@ describe("AppBreadcrumbs", () => {
label: "Installed",
to: "/plugins/automations/automations",
},
{ label: "Weekly review" },
{
label: "Weekly review",
to: "/plugins/automations/automations/proj_personal/weekly-review",
},
]}
usesDesktopChrome={false}
/>
Expand All @@ -45,7 +43,7 @@ describe("AppBreadcrumbs", () => {
expect(screen.queryByRole("link", { name: "Weekly review" })).toBeNull();

fireEvent.click(screen.getByRole("link", { name: "Installed" }));
expect(screen.getByLabelText("Current location").textContent).toBe(
expect(screen.getByTestId("location").textContent).toBe(
"/plugins/automations/automations",
);
});
Expand Down
Loading
Loading