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
8 changes: 5 additions & 3 deletions web/src/features/settings/BranchNaming.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, screen, waitFor } from "@testing-library/react";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { beforeEach, expect, it, vi } from "vitest";
import { request } from "../../api/client";
Expand Down Expand Up @@ -37,9 +37,11 @@ it("keeps the prefix without a slash, previews the branch name, and saves it tri
render(<WorktreesSection />);
expect(await screen.findByText("A / is added after the prefix.")).toBeVisible();
const field = screen.getByRole("textbox", { name: "Branch prefix" });
await waitFor(() => expect(field).toBeEnabled());
expect(screen.getByText("orbyn/fix-login")).toBeVisible();
await user.clear(field); await user.type(field, "feat/");
expect(screen.getByText("feat/fix-login")).toBeVisible();
fireEvent.change(field, { target: { value: "feat/" } });
expect(await screen.findByText("feat/fix-login")).toBeVisible();
field.focus();
await user.tab();
await waitFor(() => expect(request).toHaveBeenCalledWith("PUT", "/api/settings/preferences", expect.objectContaining({
edits: { branch_name_prefix: { op: "set", value: "feat" } } })));
Expand Down
8 changes: 6 additions & 2 deletions web/src/features/settings/WorktreeCleanup.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, screen, waitFor } from "@testing-library/react";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { beforeEach, expect, it, vi } from "vitest";
import { request } from "../../api/client";
Expand Down Expand Up @@ -30,8 +30,12 @@ it("shows the saved days beside On, saves a new number on leaving it, and Off hi
const user = userEvent.setup();
render(<WorktreeCleanup />);
const days = await screen.findByRole("spinbutton", { name: "Automatic worktree cleanup: days" });
await waitFor(() => expect(days).toBeEnabled());
expect(days).toHaveValue(14);
await user.clear(days); await user.type(days, "3"); await user.tab();
// One change event rather than keystrokes: typing into a field that is briefly disabled drops characters under load.
days.focus();
fireEvent.change(days, { target: { value: "3" } });
await user.tab();
await waitFor(() => sent({ mode: "custom", rules: { settled_after_days: 3 } }));
// The controls rest while the save and the read after it are under way; a change made then is not taken.
const select = screen.getByRole("combobox", { name: "Automatic worktree cleanup" });
Expand Down
Loading