Skip to content
Merged
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
26 changes: 26 additions & 0 deletions apps/frontend/src/components/ui/connection-form.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
})
})
})
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,7 +134,6 @@ export function ConnectionModal({
onConnectionDetailsChange({
...connectionDetails,
host,
endpointType: host.includes("cfg") ? "cluster-endpoint" : connectionDetails.endpointType,
})
}}
placeholder="localhost"
Expand All @@ -160,6 +159,11 @@ export function ConnectionModal({
value={connectionDetails.port}
/>
</div>
{connectionDetails.endpointType === "node" && connectionDetails.host.includes("cfg") && (
<Typography className="col-span-2 -mt-2" variant="bodyXs">
If this is a cluster configuration endpoint, switch Endpoint Type to Discovery.
</Typography>
)}
</div>

{/* Auth Type */}
Expand Down
Loading