Skip to content

Commit bd9d599

Browse files
committed
fix: if url is already https, toggle should be checked
1 parent b40079c commit bd9d599

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/components/PageComponents/Connect/HTTP.test.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ describe("HTTP Component", () => {
5858
expect(screen.getByText("http://")).toBeInTheDocument();
5959
});
6060

61+
it("enables HTTPS toggle when location protocol is https", () => {
62+
Object.defineProperty(globalThis, "location", {
63+
value: { protocol: "https:" },
64+
writable: true,
65+
});
66+
67+
render(<HTTP closeDialog={vi.fn()} />);
68+
69+
const switchInput = screen.getByRole("switch");
70+
expect(switchInput).toBeChecked();
71+
});
72+
6173
it.skip("submits form and triggers connection process", () => {
6274
// This will need further work to test, as it involves a lot of other plumbing mocking
6375
const closeDialog = vi.fn();

src/components/PageComponents/Connect/HTTP.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const HTTP = ({ closeDialog }: TabElementProps) => {
7070
<Switch
7171
onCheckedChange={setTLS}
7272
disabled={location.protocol === "https:" || connectionInProgress}
73-
checked={tlsValue}
73+
checked={location.protocol === 'https:' || tlsValue}
7474
{...register("tls")}
7575
/>
7676
<Label>Use HTTPS</Label>

0 commit comments

Comments
 (0)