Merge pull request #487 from danditomaso/issue-455-cant-scroll-up-in-chat
fix: resolved issue with being unable to scroll up in the input field
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { describe, it, vi, expect } from "vitest";
|
||||
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
|
||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
||||
import { HTTP } from "@components/PageComponents/Connect/HTTP.tsx";
|
||||
import { TransportHTTP } from "@meshtastic/transport-http";
|
||||
import { MeshDevice } from "@meshtastic/core";
|
||||
import { TransportHTTP } from "@meshtastic/transport-http";
|
||||
import { vi, describe, it, expect } from "vitest";
|
||||
|
||||
vi.mock("@core/stores/appStore.ts", () => ({
|
||||
useAppStore: vi.fn(() => ({ setSelectedDevice: vi.fn() })),
|
||||
@@ -41,25 +41,27 @@ describe("HTTP Component", () => {
|
||||
|
||||
it("allows input field to be updated", () => {
|
||||
render(<HTTP closeDialog={vi.fn()} />);
|
||||
const input = screen.getByRole("textbox");
|
||||
fireEvent.change(input, { target: { value: "meshtastic.local" } });
|
||||
expect(input).toHaveValue("meshtastic.local");
|
||||
const inputField = screen.getByRole("textbox");
|
||||
fireEvent.change(inputField, { target: { value: 'meshtastic.local' } })
|
||||
expect(screen.getByPlaceholderText("000.000.000.000 / meshtastic.local")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("toggles HTTPS switch and updates prefix", () => {
|
||||
render(<HTTP closeDialog={vi.fn()} />);
|
||||
|
||||
const switchInput = screen.getByRole("switch");
|
||||
expect(screen.getByText("http://")).toBeInTheDocument();
|
||||
fireEvent.click(switchInput);
|
||||
|
||||
fireEvent.click(switchInput)
|
||||
expect(screen.getByText("https://")).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(switchInput);
|
||||
fireEvent.click(switchInput)
|
||||
expect(switchInput).not.toBeChecked();
|
||||
expect(screen.getByText("http://")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("enables HTTPS toggle when location protocol is https", () => {
|
||||
Object.defineProperty(globalThis, "location", {
|
||||
Object.defineProperty(window, "location", {
|
||||
value: { protocol: "https:" },
|
||||
writable: true,
|
||||
});
|
||||
@@ -72,22 +74,23 @@ describe("HTTP Component", () => {
|
||||
expect(screen.getByText("https://")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it.skip("submits form and triggers connection process", () => {
|
||||
// This will need further work to test, as it involves a lot of other plumbing mocking
|
||||
it.skip("submits form and triggers connection process", async () => {
|
||||
const closeDialog = vi.fn();
|
||||
render(<HTTP closeDialog={closeDialog} />);
|
||||
|
||||
const button = screen.getByRole("button", { name: "Connect" });
|
||||
expect(button).not.toBeDisabled();
|
||||
|
||||
fireEvent.click(button);
|
||||
|
||||
waitFor(() => {
|
||||
expect(button).toBeDisabled();
|
||||
expect(closeDialog).toHaveBeenCalled();
|
||||
expect(TransportHTTP.create).toHaveBeenCalled();
|
||||
expect(MeshDevice).toHaveBeenCalled();
|
||||
});
|
||||
try {
|
||||
fireEvent.click(button);
|
||||
await waitFor(() => {
|
||||
expect(button).toBeDisabled();
|
||||
expect(closeDialog).toBeCalled();
|
||||
expect(TransportHTTP.create).toBeCalled();
|
||||
expect(MeshDevice).toBeCalled();
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user