Browse Source

fix: if url is already https, toggle should be checked

pull/480/head
Dan Ditomaso 1 year ago
parent
commit
bd9d599934
  1. 12
      src/components/PageComponents/Connect/HTTP.test.tsx
  2. 2
      src/components/PageComponents/Connect/HTTP.tsx

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

@ -58,6 +58,18 @@ describe("HTTP Component", () => {
expect(screen.getByText("http://")).toBeInTheDocument();
});
it("enables HTTPS toggle when location protocol is https", () => {
Object.defineProperty(globalThis, "location", {
value: { protocol: "https:" },
writable: true,
});
render(<HTTP closeDialog={vi.fn()} />);
const switchInput = screen.getByRole("switch");
expect(switchInput).toBeChecked();
});
it.skip("submits form and triggers connection process", () => {
// This will need further work to test, as it involves a lot of other plumbing mocking
const closeDialog = vi.fn();

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

@ -70,7 +70,7 @@ export const HTTP = ({ closeDialog }: TabElementProps) => {
<Switch
onCheckedChange={setTLS}
disabled={location.protocol === "https:" || connectionInProgress}
checked={tlsValue}
checked={location.protocol === 'https:' || tlsValue}
{...register("tls")}
/>
<Label>Use HTTPS</Label>

Loading…
Cancel
Save