fix(ui): show a single Never resets option in create team when no default is set

Without a default team budget_duration, the create team Reset Budget dropdown
offered both "Not set" and "Never resets", and both created a team that never
resets. The explicit Never resets item is now only shown when there is a
default to opt out of, otherwise the empty option itself reads "Never resets"

Also makes the Reset Budget create tests use chooseSelectOption so they no
longer flake on the select popup's pointer-events transition
This commit is contained in:
Jesus Velarde 2026-10-24 17:01:23 -07:00
parent 3425a052c1
commit 2b37240ecf
2 changed files with 12 additions and 9 deletions

View file

@ -730,9 +730,9 @@ describe("Teams - Reset Budget in team create", () => {
it("should send an explicit null budget_duration when Never resets is selected", async () => {
await openCreateModal();
await screen.findByText("Default: monthly (30d)");
await userEvent.click(resetBudgetSelect());
await userEvent.click(await screen.findByText("Never resets"));
await chooseSelectOption(userEvent, resetBudgetSelect(), "Never resets");
const payload = await submitCreateModal();
@ -752,8 +752,7 @@ describe("Teams - Reset Budget in team create", () => {
it("should send the picked duration when one is selected", async () => {
await openCreateModal();
await userEvent.click(resetBudgetSelect());
await userEvent.click(await screen.findByText("weekly"));
await chooseSelectOption(userEvent, resetBudgetSelect(), "weekly");
const payload = await submitCreateModal();
@ -768,14 +767,18 @@ describe("Teams - Reset Budget in team create", () => {
});
});
it("should fall back to the Not set placeholder when the default settings fetch fails", async () => {
it("should offer a single Never resets option when no server default is configured", async () => {
vi.mocked(getDefaultTeamSettings).mockRejectedValue(new Error("Unauthorized"));
await openCreateModal();
await waitFor(() => {
expect(screen.getByText("Not set")).toBeInTheDocument();
expect(getDefaultTeamSettings).toHaveBeenCalled();
});
await userEvent.click(resetBudgetSelect());
expect(await screen.findAllByRole("option", { name: "Never resets" })).toHaveLength(1);
expect(screen.queryByText("Not set")).not.toBeInTheDocument();
});
});

View file

@ -295,7 +295,7 @@ const Teams: React.FC<TeamProps> = ({ accessToken, userID, userRole, isViewOnly
const defaultBudgetDuration: string | undefined = defaultTeamSettings?.values?.budget_duration ?? undefined;
const budgetDurationPlaceholder = defaultBudgetDuration
? `Default: ${getBudgetDurationLabel(defaultBudgetDuration)} (${defaultBudgetDuration})`
: "Not set";
: undefined;
// Add this useEffect to fetch guardrails
useEffect(() => {
@ -825,7 +825,7 @@ const Teams: React.FC<TeamProps> = ({ accessToken, userID, userRole, isViewOnly
{({ id, value, onChange }) => (
<BudgetDurationDropdown
id={id}
showNeverResets
showNeverResets={Boolean(defaultBudgetDuration)}
placeholder={budgetDurationPlaceholder}
value={value}
onChange={(next) => onChange(next ?? undefined)}