This commit is contained in:
Jialong(Bruce) Li 2026-10-22 14:32:02 +00:00 • committed by GitHub
commit 6ea1d855d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 7 deletions

View file

@ -426,7 +426,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 { buildSavedJevConnectionTestRequest } from "./add_model/build_auto_router_routing_test_request";
import { AutoRouterTestTarget, buildComplexityRouterTestTargets } from "./add_model/build_auto_router_test_targets";
@ -476,11 +475,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)));
}
};