Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions apps/frontend/src/components/ui/connection-form.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
})
})
})
6 changes: 5 additions & 1 deletion apps/frontend/src/components/ui/connection-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,18 @@ export function ConnectionModal({
onConnectionDetailsChange({
...connectionDetails,
host,
endpointType: host.includes("cfg") ? "cluster-endpoint" : connectionDetails.endpointType,
})
}}
placeholder="localhost"
required
type="text"
value={connectionDetails.host}
/>
{connectionDetails.endpointType === "node" && connectionDetails.host.includes("cfg") && (
<Typography className="text-muted-foreground mt-1" variant="bodySm">
Hint: If this is a cluster configuration endpoint, switch Endpoint Type to Discovery.
</Typography>
)}
</div>
<div>
<Label className="block mb-1" htmlFor="port">Port</Label>
Expand Down
Loading