test(FN-4627): complete Step 4 — cover worktrunk settings behavior

Fusion-Task-Id: FN-4627
Fusion-Task-Lineage: 39fbecd6-69b3-4ba5-8357-ca3af9060f6a
This commit is contained in:
Fusion (runfusion.ai)
2026-05-15 22:18:32 -07:00
committed by gsxdsm
parent e84673f12c
commit 8f519a94fa

View File

@@ -189,6 +189,10 @@ const defaultSettings = {
executorAllowSiblingBranchRename: false,
worktreeNaming: "random",
worktreesDir: "",
worktrunk: {
enabled: false,
onFailure: "fail",
},
includeTaskIdInCommit: true,
worktreeInitCommand: "",
ntfyEnabled: false,
@@ -2094,6 +2098,70 @@ describe("SettingsModal", () => {
});
});
describe("Worktrunk integration", () => {
it("renders worktrunk controls in the Worktrees section only", async () => {
renderModal();
await waitForSettingsModalReady();
expect(screen.queryByLabelText("Enable worktrunk integration")).not.toBeInTheDocument();
await userEvent.click(screen.getByText("Worktrees"));
expect(screen.getByRole("heading", { name: "Worktrunk integration" })).toBeInTheDocument();
expect(screen.getByLabelText("Enable worktrunk integration")).toBeInTheDocument();
expect(screen.getByLabelText("Worktrunk binary path")).toBeInTheDocument();
expect(screen.getByLabelText("Worktrunk failure behavior")).toBeInTheDocument();
});
it("toggles disabled states and shows the worktreesDir precedence hint", async () => {
renderModal();
await waitForSettingsModalReady();
await userEvent.click(screen.getByText("Worktrees"));
const enabledToggle = screen.getByLabelText("Enable worktrunk integration") as HTMLInputElement;
const binaryPathInput = screen.getByLabelText("Worktrunk binary path") as HTMLInputElement;
const onFailureSelect = screen.getByLabelText("Worktrunk failure behavior") as HTMLSelectElement;
const worktreesDirInput = screen.getByLabelText("Worktrees Directory") as HTMLInputElement;
const browseButton = screen.getByRole("button", { name: "Browse worktrees directory" });
expect(enabledToggle.checked).toBe(false);
expect(binaryPathInput).toBeDisabled();
expect(onFailureSelect).toBeDisabled();
expect(worktreesDirInput).not.toBeDisabled();
expect(browseButton).not.toBeDisabled();
await userEvent.click(enabledToggle);
expect(binaryPathInput).not.toBeDisabled();
expect(onFailureSelect).not.toBeDisabled();
expect(worktreesDirInput).toBeDisabled();
expect(browseButton).toBeDisabled();
expect(screen.getByText(/Disabled because Worktrunk integration is enabled/i)).toBeInTheDocument();
});
it.each(["fail", "fallback-native"])("saves worktrunk payload and defaults onFailure on first enable (%s)", async (onFailure) => {
renderModal();
await waitForSettingsModalReady();
await userEvent.click(screen.getByText("Worktrees"));
const enabledToggle = screen.getByLabelText("Enable worktrunk integration");
await userEvent.click(enabledToggle);
const onFailureSelect = screen.getByLabelText("Worktrunk failure behavior") as HTMLSelectElement;
if (onFailure !== "fail") {
await userEvent.selectOptions(onFailureSelect, onFailure);
}
await userEvent.click(screen.getByRole("button", { name: "Save" }));
await waitFor(() => expect(mockUpdateSettings).toHaveBeenCalled());
const payload = mockUpdateSettings.mock.calls[0][0] as {
worktrunk?: { enabled?: boolean; onFailure?: string; binaryPath?: string };
};
expect(payload.worktrunk).toMatchObject({ enabled: true, onFailure });
});
});
describe("Memory section", () => {
it("renders the Memory section in the sidebar", async () => {
renderModal();