diff --git a/apps/frontend/src/components/ui/connection-form.test.tsx b/apps/frontend/src/components/ui/connection-form.test.tsx index cae5463e..1b8ea16c 100644 --- a/apps/frontend/src/components/ui/connection-form.test.tsx +++ b/apps/frontend/src/components/ui/connection-form.test.tsx @@ -81,4 +81,30 @@ describe("ConnectionForm", () => { await screen.findByText(/port between 1 and 65535/i) expect(dispatched.find((a) => a.type.endsWith("connectPending"))).toBeUndefined() }) + + it("does not force-switch endpoint type to Discovery when host contains 'cfg'", async () => { + const hint = "If this is a cluster configuration endpoint, switch Endpoint Type to Discovery." + renderForm() + + fireEvent.change(screen.getByLabelText("Host"), { target: { value: "clustercfg.example.com" } }) + fireEvent.change(screen.getByLabelText("Database"), { target: { value: "7" } }) + expect(screen.getByText(hint)).toBeInTheDocument() + expect(screen.getByLabelText("Node")).toBeChecked() + + fireEvent.change(screen.getByLabelText("Host"), { target: { value: "cluster.example.com" } }) + expect(screen.queryByText(hint)).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..24298aaa 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" @@ -160,6 +159,11 @@ export function ConnectionModal({ value={connectionDetails.port} /> + {connectionDetails.endpointType === "node" && connectionDetails.host.includes("cfg") && ( + + If this is a cluster configuration endpoint, switch Endpoint Type to Discovery. + + )} {/* Auth Type */}