fix(ui): warn that team models are deleted in the delete-team modal

The delete-team confirmation modal warned that a team's keys would be
deleted but said nothing about models. #29977 made team deletion also
delete the team's BYOK models, so the modal copy was understating what
gets removed.

The warning banner now mentions models alongside keys, and the
always-shown confirmation message does too so a team that has models but
no keys (the banner only renders when keys exist) still gets warned.
This commit is contained in:
Yuneng Jiang 2026-06-08 17:08:36 -07:00
parent dfd6cbc514
commit 9bade875b0
No known key found for this signature in database
2 changed files with 64 additions and 2 deletions

View file

@ -1106,3 +1106,65 @@ describe("OldTeams - Resources column keys badge", () => {
expect(cyanTag?.textContent).toContain("2");
});
});
describe("OldTeams - delete team warning copy", () => {
beforeEach(() => {
vi.clearAllMocks();
mockUseOrganizations.mockReturnValue({ data: [] });
});
const openDeleteModal = async (team: any) => {
renderWithQueryClient(
<OldTeams
teams={[team]}
searchParams={{}}
accessToken="test-token"
setTeams={vi.fn()}
userID="user-123"
userRole="Admin"
organizations={[]}
/>,
);
await waitFor(() => {
expect(screen.getByTestId("delete-team-button")).toBeInTheDocument();
});
act(() => {
fireEvent.click(screen.getByTestId("delete-team-button"));
});
expect(screen.getByText("Delete Team?")).toBeInTheDocument();
};
const baseTeam = {
team_id: "1",
team_alias: "Test Team",
organization_id: "org-123",
models: ["gpt-4"],
max_budget: 100,
budget_duration: "1d",
tpm_limit: 1000,
rpm_limit: 1000,
created_at: new Date().toISOString(),
members_with_roles: [],
spend: 0,
};
it("warns that the team's models are deleted when the team has keys", async () => {
await openDeleteModal({ ...baseTeam, keys: [], keys_count: 2 });
expect(screen.getByText(/Warning: This team has 2 keys associated with it/i)).toHaveTextContent(
/along with any models created for this team/i,
);
expect(screen.getByText(/Are you sure you want to delete this team/i)).toHaveTextContent(
/any models created for it/i,
);
});
it("still warns about model deletion in the confirmation message when the team has no keys", async () => {
await openDeleteModal({ ...baseTeam, keys: [], keys_count: 0 });
expect(screen.queryByText(/Warning: This team has/i)).not.toBeInTheDocument();
expect(screen.getByText(/Are you sure you want to delete this team/i)).toHaveTextContent(
/any models created for it/i,
);
});
});

View file

@ -979,9 +979,9 @@ const Teams: React.FC<TeamProps> = ({
const deleteKeyCount = teamToDelete?.keys_count ?? teamToDelete?.keys?.length ?? 0;
return deleteKeyCount === 0
? undefined
: `Warning: This team has ${deleteKeyCount} keys associated with it. Deleting the team will also delete all associated keys. This action is irreversible.`;
: `Warning: This team has ${deleteKeyCount} keys associated with it. Deleting the team will also delete all associated keys, along with any models created for this team. This action is irreversible.`;
})()}
message="Are you sure you want to delete this team and all its keys? This action cannot be undone."
message="Are you sure you want to delete this team, all its keys, and any models created for it? This action cannot be undone."
resourceInformationTitle="Team Information"
resourceInformation={[
{ label: "Team ID", value: teamToDelete?.team_id, code: true },