Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 4 additions & 25 deletions apps/app/src/components/code/DiffHost.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,31 +121,6 @@ afterEach(() => {
});

describe("DiffHost", () => {
it("skips BB's renderer and passes full-file contents when a replacement never delegates", async () => {
registerDiffRenderer((props) => {
receivedProps.push(props);
return <div data-testid="plugin-diff">plugin diff</div>;
});

render(
<DiffHost
file={parseFixture()}
patchText={PATCH}
fullFileContents={FULL_FILE_CONTENTS}
view="split"
/>,
);

expect(await screen.findByTestId("plugin-diff")).toBeDefined();
await act(async () => {
await Promise.resolve();
});
expect(bbDiff.lastProps).toBeNull();
expect(receivedProps.at(-1)?.experimental_fullFileContents).toBe(
FULL_FILE_CONTENTS,
);
});

it("hands the replacement resolved semantic props, not BB's host-only inputs", async () => {
registerDiffRenderer((props) => {
receivedProps.push(props);
Expand All @@ -165,6 +140,10 @@ describe("DiffHost", () => {
);

await screen.findByTestId("plugin-diff");
await act(async () => {
await Promise.resolve();
});
expect(bbDiff.lastProps).toBeNull();
const props = receivedProps.at(-1);
expect(props?.patch).toBe(PATCH);
expect(props?.path).toBe("src/app.ts");
Expand Down
62 changes: 10 additions & 52 deletions apps/app/src/components/commands/CommandPalette.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,15 @@ describe("CommandPalette", () => {
expect(screen.queryByRole("combobox")).toBeNull();
expect(testState.targets).toEqual([screen.getByTestId("origin")]);
expect(document.activeElement).toBe(screen.getByTestId("origin"));

fireEvent.keyDown(screen.getByTestId("origin"), {
key: "o",
ctrlKey: true,
shiftKey: true,
});
await waitFor(() =>
expect(testState.calls).toEqual(["thread.new", "thread.new"]),
);
},
);

Expand Down Expand Up @@ -873,6 +882,7 @@ describe("CommandPalette", () => {

fireEvent.keyDown(screen.getByRole("combobox"), { key: "Escape" });
await waitFor(() => expect(screen.queryByRole("combobox")).toBeNull());
expect(testState.calls).toEqual([]);
});

it("uses the shared tab-pill clear affordance without running the mode command", async () => {
Expand Down Expand Up @@ -2099,38 +2109,6 @@ describe("CommandPalette", () => {
expect(optionTitles()).toEqual(initialTitles);
});

it("closes on Escape without running anything", async () => {
renderPalette();
openPalette();
await waitFor(() => expect(searchField()).toBeTruthy());

fireEvent.keyDown(searchField(), { key: "Escape" });

await waitFor(() => expect(screen.queryByRole("combobox")).toBeNull());
expect(testState.calls).toEqual([]);
});

it("keeps app shortcuts working after a shortcut closes the palette", async () => {
renderPalette();
const pressThreadNew = () =>
fireEvent.keyDown(document.activeElement ?? window, {
key: "o",
ctrlKey: true,
shiftKey: true,
bubbles: true,
});

openPalette();
await waitFor(() => expect(searchField()).toBeTruthy());
pressThreadNew();
await waitFor(() => expect(testState.calls).toEqual(["thread.new"]));
await waitFor(() => expect(screen.queryByRole("combobox")).toBeNull());
pressThreadNew();
await waitFor(() =>
expect(testState.calls).toEqual(["thread.new", "thread.new"]),
);
});

it("scrolls the highlighted row into view when arrowing, but not on hover", async () => {
const scrollIntoView = vi.spyOn(
Element.prototype,
Expand Down Expand Up @@ -2277,26 +2255,6 @@ describe("CommandPalette", () => {
},
);

it("opens a specific settings page", async () => {
renderPalette();
openPalette();
await waitFor(() => expect(searchField()).toBeTruthy());

fireEvent.change(searchField(), {
target: { value: "keyboard settings" },
});
await waitFor(() =>
expect(selectedOption()?.textContent).toContain("Keyboard settings"),
);
fireEvent.keyDown(searchField(), { key: "Enter" });

await waitFor(() =>
expect(screen.getByTestId("location").textContent).toBe(
"/settings/keyboard",
),
);
});

it("only includes Files settings when local helper access is available", async () => {
renderPalette();
openPalette();
Expand Down
16 changes: 0 additions & 16 deletions apps/app/src/components/dialogs/AddMachineDialog.expiry.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,4 @@ describe("MachineLaunchCommand", () => {
screen.getByRole("button", { name: "Generate a new command" }).click();
expect(onRegenerate).toHaveBeenCalledTimes(1);
});

it("stops offering a copy after the server withdraws the command", () => {
render(
<MachineLaunchCommand
command={COMMAND}
windowsCommand="irm windows-command | iex"
expiresAt={15 * 60_000}
unavailable
onRegenerate={() => {}}
/>,
);
expect(screen.getByRole("status").textContent).toBe("Command used");
expect(
screen.getByRole("button", { name: "Copy" }).hasAttribute("disabled"),
).toBe(true);
});
});
9 changes: 2 additions & 7 deletions apps/app/src/components/layout/app-chrome-selection.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,8 @@ describe("app chrome opts out of text selection", () => {
expect(getPanel().classList.contains("select-none")).toBe(true);
});

it("marks the right panel's top chrome with and without the diff toolbar", () => {
expect(getSecondaryPanelChromeStackClassName(false)).toContain(
"select-none",
);
expect(getSecondaryPanelChromeStackClassName(true)).toContain(
"select-none",
);
it("marks the right panel's top chrome", () => {
expect(getSecondaryPanelChromeStackClassName()).toContain("select-none");
});

it("restores native selection on editable controls inside opted-out chrome", () => {
Expand Down
23 changes: 0 additions & 23 deletions apps/app/src/components/onboarding/OnboardingGate.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,6 @@ describe("OnboardingGate", () => {
);
});

it("shows the guide again when the completion time is cleared after a close in the same session", async () => {
configWith({ onboardingCompletedAt: null });
const { view } = renderGate();
fireEvent.click(await screen.findByText("Setup guide at agent"));

configWith({ onboardingCompletedAt: COMPLETED_AT });
view.rerender(
<OnboardingGate>
<div>App shell</div>
</OnboardingGate>,
);
expect(screen.getByText("App shell")).toBeTruthy();

configWith({ onboardingCompletedAt: null });
view.rerender(
<OnboardingGate>
<div>App shell</div>
</OnboardingGate>,
);

expect(await screen.findByText("Setup guide at agent")).toBeTruthy();
});

it("holds a first-time browser blank until settings load, but boots a returning browser straight into the app", () => {
mocks.useSystemConfig.mockReturnValue({ data: undefined, isError: false });
const first = renderGate();
Expand Down
40 changes: 4 additions & 36 deletions apps/app/src/components/pickers/EnvironmentPicker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,10 @@ describe("EnvironmentPickerUI", () => {
screen.queryByRole("option", { name: /New branch workspace/u }),
).toBeNull();
expect(
screen.getByRole("option", { name: /Optional sandbox/u }),
).toBeTruthy();
screen
.getByRole("option", { name: /Optional sandbox/u })
.getAttribute("aria-disabled"),
).toBe("false");
expect(screen.getByText("Configure credentials")).toBeTruthy();
});
it("omits a projectless-only provider from a project picker", () => {
Expand Down Expand Up @@ -393,40 +395,6 @@ describe("EnvironmentPickerUI", () => {
).toBeTruthy();
});

it("shows a setup-required provider enabled with its message", () => {
render(
<EnvironmentPickerUI
value="provider:project-checkout"
sources={sources}
host={host}
isLocal
providers={[
checkoutProvider,
{
...branchProvider,
availability: {
status: "setup-required",
message: "Configure credentials",
},
},
]}
selectedProviderHostId={host.id}
onSelectProvider={vi.fn()}
modal={false}
/>,
);

fireEvent.click(screen.getByRole("button", { name: "Environment" }), {
button: 0,
});

const branchItem = screen.getByRole("option", {
name: /New branch workspace/u,
});
expect(branchItem.getAttribute("aria-disabled")).toBe("false");
expect(screen.getByText("Configure credentials")).toBeTruthy();
});

it("selects a setup-required composed provider without navigating away", () => {
const onSelectProvider = vi.fn();
const setupRequiredProvider: SystemEnvironmentProvider = {
Expand Down
26 changes: 0 additions & 26 deletions apps/app/src/components/pickers/ModelReasoningPicker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1138,25 +1138,6 @@ describe("ModelReasoningPicker", () => {
expect(onModelChange).toHaveBeenCalledWith(apiModel);
});

it("uses picker search policy and selects the match by keyboard", () => {
const { onModelChange } = renderPicker({ modelOptions: manyCodexModels });

fireEvent.click(
screen.getByRole("button", { name: "Provider, model and reasoning" }),
);

const search = screen.getByPlaceholderText("Search models");
fireEvent.change(search, { target: { value: "o4m" } });

expect(screen.getByText("o4-mini")).not.toBeNull();
expect(screen.queryByText("Sonnet")).toBeNull();

fireEvent.keyDown(search, { key: "ArrowDown" });
fireEvent.keyDown(search, { key: "Enter" });

expect(onModelChange).toHaveBeenCalledWith("o4-mini");
});

it("ranks primary and selected-only model matches together", () => {
const looseMatch = "Super GPT-4 Compatibility";
const directMatch = "GPT-4 Turbo";
Expand Down Expand Up @@ -1619,13 +1600,6 @@ describe("ModelReasoningPicker service tiers", () => {
).toEqual(["flex", true]);
});

it("shows no agent options when the provider reports none", () => {
renderPicker();
openPicker();

expect(screen.queryByRole("switch")).toBeNull();
});

it("greys out a model the chosen options rule out and never selects it", () => {
const { onModelChange } = renderPicker({
modelOptions: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@ import {
} from "./environment-picker-value";

describe("provider environment values", () => {
it("round-trips a provider id containing dashes", () => {
it("round-trips provider ids with dashes, underscores, and digits", () => {
const value = encodeProviderValue("docker-sandbox");
expect(value).toBe("provider:docker-sandbox");
expect(parseEnvironmentValue(value)).toEqual({
type: "provider",
environmentProviderId: "docker-sandbox",
});
});

it("round-trips provider ids with underscores and digits", () => {
const value = encodeProviderValue("wt_2");
expect(parseEnvironmentValue(value)).toEqual({
expect(parseEnvironmentValue(encodeProviderValue("wt_2"))).toEqual({
type: "provider",
environmentProviderId: "wt_2",
});
Expand Down
7 changes: 7 additions & 0 deletions apps/app/src/components/pickers/modelPickerToggle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ describe("ownsModelPickerCycleChord", () => {
);
}
}
const unrelatedEditable = {
...base,
caretInThisComposer: false,
editableOutsideComposer: true,
};
expect(ownsModelPickerToggleChord(unrelatedEditable)).toBe(true);
expect(ownsModelPickerCycleChord(unrelatedEditable)).toBe(false);
});

it("owns the chord while the picker is open and the caret is nowhere", () => {
Expand Down
7 changes: 0 additions & 7 deletions apps/app/src/components/plugin/PluginBranchPicker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ function renderPicker(props: {
}

describe("PluginBranchPicker", () => {
it("shows the placeholder while nothing is picked", () => {
renderPicker({ value: null, placeholder: "Pick a base" });
expect(
screen.getByRole("combobox", { name: "Branch" }).textContent,
).toContain("Pick a base");
});

it.each(["Compare with:", "Checkout:", "Branch from:"])(
"uses %s for the trigger prefix and menu heading",
(label) => {
Expand Down
14 changes: 0 additions & 14 deletions apps/app/src/components/promptbox/FollowUpPromptBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1558,18 +1558,4 @@ describe("FollowUpPromptBox", () => {

expect(screen.getByTestId("prompt-box")).toBe(initialPromptBox);
});

it("uses the caller-specific compact placeholder", () => {
mocks.isCompactViewport = true;
mocks.isPointerCoarse = true;
const props = createFollowUpPromptBoxProps({
kind: "queue-while-stopping",
});
if (props.composer === null) throw new Error("Missing composer");
props.composer.compactPromptPlaceholder = "Stopping side chat...";
props.composer.promptPlaceholder = "Stopping side chat...";
render(<FollowUpPromptBox {...props} />);

expect(screen.getByText("Stopping side chat...")).toBeTruthy();
});
});
Loading
Loading