diff --git a/apps/frontend/src/components/ui/connection-form.test.tsx b/apps/frontend/src/components/ui/connection-form.test.tsx index 3f22edc9..b20c0559 100644 --- a/apps/frontend/src/components/ui/connection-form.test.tsx +++ b/apps/frontend/src/components/ui/connection-form.test.tsx @@ -53,4 +53,32 @@ describe("ConnectionForm", () => { connectionId: buildConnectionId("localhost", "6380", 0), }) }) + + it("does not force-switch endpoint type to Discovery when host contains 'cfg'", async () => { + renderForm() + + fireEvent.change(screen.getByLabelText("Host"), { target: { value: "clustercfg.example.com" } }) + fireEvent.change(screen.getByLabelText("Database"), { target: { value: "7" } }) + expect(screen.getByText("Hint: If this is a cluster configuration endpoint, switch Endpoint Type to Discovery.")).toBeInTheDocument() + expect(screen.getByLabelText("Node")).toBeChecked() + + fireEvent.change(screen.getByLabelText("Host"), { target: { value: "cluster.example.com" } }) + expect(screen.queryByText("Hint: If this is a cluster configuration endpoint, switch Endpoint Type to Discovery.")).not.toBeInTheDocument() + expect(screen.getByLabelText("Node")).toBeChecked() + expect(screen.getByLabelText("Database")).toHaveValue(7) + + fireEvent.change(screen.getByLabelText("Host"), { target: { value: "clustercfg.example.com" } }) + fireEvent.click(screen.getByRole("button", { name: "Connect" })) + + await screen.findByRole("button", { name: /Connect/ }) + + const pending = dispatched.find((a) => a.type.endsWith("connectPending")) + expect(pending?.payload).toMatchObject({ + connectionId: buildConnectionId("clustercfg.example.com", "6379", 7), + connectionDetails: expect.objectContaining({ + endpointType: "node", + db: 7, + }), + }) + }) }) diff --git a/apps/frontend/src/components/ui/connection-modal.tsx b/apps/frontend/src/components/ui/connection-modal.tsx index 1046a7e8..d6b14a1c 100644 --- a/apps/frontend/src/components/ui/connection-modal.tsx +++ b/apps/frontend/src/components/ui/connection-modal.tsx @@ -134,7 +134,6 @@ export function ConnectionModal({ onConnectionDetailsChange({ ...connectionDetails, host, - endpointType: host.includes("cfg") ? "cluster-endpoint" : connectionDetails.endpointType, }) }} placeholder="localhost" @@ -142,6 +141,11 @@ export function ConnectionModal({ type="text" value={connectionDetails.host} /> + {connectionDetails.endpointType === "node" && connectionDetails.host.includes("cfg") && ( + + Hint: If this is a cluster configuration endpoint, switch Endpoint Type to Discovery. + + )}