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

This commit is contained in:
Dan Ditomaso
2025-03-04 14:10:46 -05:00
parent b40079cdc9
commit bd9d599934
2 changed files with 13 additions and 1 deletions
@@ -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();
@@ -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>