From f6748d558ae0b05c9a0018eaf7a7591be4ef995b Mon Sep 17 00:00:00 2001 From: Dan Ditomaso Date: Mon, 26 May 2025 11:21:43 -0400 Subject: [PATCH] fixing broken tests --- .../NodeDetailsDialog/NodeDetailsDialog.tsx | 5 +- .../Dialog/RebootOTADialog.test.tsx | 9 +- src/components/Dialog/RebootOTADialog.tsx | 2 +- src/components/LanguageSwitcher.tsx | 2 +- .../PageComponents/Config/Bluetooth.tsx | 235 +++++++++--------- .../Messages/TraceRoute.test.tsx | 1 - .../PageComponents/Messages/TraceRoute.tsx | 4 +- src/i18n/locales/en/common.json | 4 +- src/pages/Dashboard/index.tsx | 1 - src/tests/setupTests.ts | 53 +++- 10 files changed, 177 insertions(+), 139 deletions(-) diff --git a/src/components/Dialog/NodeDetailsDialog/NodeDetailsDialog.tsx b/src/components/Dialog/NodeDetailsDialog/NodeDetailsDialog.tsx index 3a01066a..926ff6e1 100644 --- a/src/components/Dialog/NodeDetailsDialog/NodeDetailsDialog.tsx +++ b/src/components/Dialog/NodeDetailsDialog/NodeDetailsDialog.tsx @@ -62,8 +62,7 @@ export const NodeDetailsDialog = ({ onOpenChange, }: NodeDetailsDialogProps) => { const { t } = useTranslation("dialog"); - const { setDialogOpen, connection, setActivePage, getNodeError } = - useDevice(); + const { setDialogOpen, connection, setActivePage } = useDevice(); const { setNodeNumToBeRemoved } = useAppStore(); const { setChatType, setActiveChat } = useMessageStore(); @@ -320,7 +319,7 @@ export const NodeDetailsDialog = ({

{t("locationResponse.altitude")} {node.position.altitude} - {t("unit.meter")} + {t("unit.meter.one")}

)} diff --git a/src/components/Dialog/RebootOTADialog.test.tsx b/src/components/Dialog/RebootOTADialog.test.tsx index 94cc5e7c..4ded7def 100644 --- a/src/components/Dialog/RebootOTADialog.test.tsx +++ b/src/components/Dialog/RebootOTADialog.test.tsx @@ -60,7 +60,8 @@ describe("RebootOTADialog", () => { it("renders dialog with default input value", () => { render( {}} />); expect(screen.getByPlaceholderText(/enter delay/i)).toHaveValue(5); - expect(screen.getByText(/schedule reboot/i)).toBeInTheDocument(); + expect(screen.getByRole("heading", { name: /schedule reboot/i, level: 1 })) + .toBeInTheDocument(); expect(screen.getByText(/reboot to ota mode now/i)).toBeInTheDocument(); }); @@ -72,7 +73,7 @@ describe("RebootOTADialog", () => { target: { value: "3" }, }); - fireEvent.click(screen.getByText(/schedule reboot/i)); + fireEvent.click(screen.getByTestId("scheduleRebootBtn")); expect(screen.getByText(/reboot has been scheduled/i)).toBeInTheDocument(); @@ -99,12 +100,11 @@ describe("RebootOTADialog", () => { it("does not call reboot if connection is undefined", async () => { const onOpenChangeMock = vi.fn(); - // simulate no connection mockConnection = undefined; render(); - fireEvent.click(screen.getByText(/schedule reboot/i)); + fireEvent.click(screen.getByTestId("scheduleRebootBtn")); vi.advanceTimersByTime(5000); await waitFor(() => { @@ -112,7 +112,6 @@ describe("RebootOTADialog", () => { expect(onOpenChangeMock).not.toHaveBeenCalled(); }); - // reset connection for other tests mockConnection = { rebootOta: rebootOtaMock }; }); }); diff --git a/src/components/Dialog/RebootOTADialog.tsx b/src/components/Dialog/RebootOTADialog.tsx index 78670aa6..5276b81b 100644 --- a/src/components/Dialog/RebootOTADialog.tsx +++ b/src/components/Dialog/RebootOTADialog.tsx @@ -94,7 +94,7 @@ export const RebootOTADialog = ( />