This commit is contained in:
chelsealong 2026-08-26 00:34:01 -06:00 committed by GitHub
commit b08eae138f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 7 deletions

View file

@ -302,7 +302,28 @@ describe("ModelInfoView", () => {
await user.click(testButton);
await waitFor(() => {
expect(mockToast.error).toHaveBeenCalled();
expect(mockToast.fromError).toHaveBeenCalled();
});
});
it("should not truncate the connection test error message", async () => {
// Regression test: the error toast used to cut the message to 100 chars
// via truncateString, hiding the actual provider error from the user.
const user = userEvent.setup();
const longMessage = "Bedrock_mantleException - " + "x".repeat(150);
mockTestConnectionRequest.mockRejectedValue(new Error(longMessage));
render(<ModelInfoView {...DEFAULT_ADMIN_PROPS} />, { wrapper });
await waitFor(() => {
expect(screen.getByText("Model Settings")).toBeInTheDocument();
});
const testButton = screen.getByRole("button", { name: /test connection/i });
await user.click(testButton);
await waitFor(() => {
expect(mockToast.fromError).toHaveBeenCalledWith(expect.stringContaining(longMessage));
});
});

View file

@ -13,7 +13,6 @@ import { ArrowLeft, CheckIcon, CopyIcon, Info } from "lucide-react";
import { useEffect, useMemo, useState } from "react";
import { copyToClipboard as utilCopyToClipboard } from "../utils/dataUtils";
import { stripMaskedSecrets } from "../utils/maskedSecretUtils";
import { truncateString } from "../utils/textUtils";
import AutoRouterConnectionTest from "./add_model/auto_router_connection_test";
import { AutoRouterTestTarget, buildAutoRouterTestTargets } from "./add_model/build_auto_router_test_targets";
import { normalizeTierModels, resolveComplexityDefaultModel } from "./add_model/complexity_router_tiers";
@ -530,11 +529,7 @@ export default function ModelInfoView({
throw new Error(response?.result?.error || response?.message || "Unknown error");
}
} catch (error) {
if (error instanceof Error) {
toast.error("Error testing connection: " + truncateString(error.message, 100));
} else {
toast.error("Error testing connection: " + String(error));
}
toast.fromError("Error testing connection: " + (error instanceof Error ? error.message : String(error)));
}
};