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 = (
/>
- ↓ {snr?.[i + 1] ?? t("traceRoute.snrUnknown")}
+ ↓ {snr?.[i + 1] ?? t("unknown.num")}
{t("unit.dbm")}
diff --git a/src/i18n/locales/en/common.json b/src/i18n/locales/en/common.json
index 830bf9ae..dc44bf70 100644
--- a/src/i18n/locales/en/common.json
+++ b/src/i18n/locales/en/common.json
@@ -63,9 +63,9 @@
},
"unknown": {
"longName": "Unknown",
- "shortName": "UNK"
+ "shortName": "UNK",
+ "num": "??"
},
- "snrUnknown": "??",
"nodeUnknownPrefix": "!",
"unset": "UNSET",
"fallbackName": "Meshtastic {{last4}}"
diff --git a/src/pages/Dashboard/index.tsx b/src/pages/Dashboard/index.tsx
index 3cccff0c..86cd8bab 100644
--- a/src/pages/Dashboard/index.tsx
+++ b/src/pages/Dashboard/index.tsx
@@ -14,7 +14,6 @@ import {
} from "lucide-react";
import { useMemo } from "react";
import { useTranslation } from "react-i18next";
-import LanguageSwitcher from "@components/LanguageSwitcher.tsx";
export const Dashboard = () => {
const { t } = useTranslation("dashboard");
diff --git a/src/tests/setupTests.ts b/src/tests/setupTests.ts
index 34c5fd07..37f1f3c1 100644
--- a/src/tests/setupTests.ts
+++ b/src/tests/setupTests.ts
@@ -5,7 +5,16 @@ import "@testing-library/jest-dom";
import "@testing-library/user-event";
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
-import enTranslations from "@app/i18n/locales/en.json";
+import channelsEN from "@app/i18n/locales/en/channels.json";
+import commandPaletteEN from "@app/i18n/locales/en/commandPalette.json";
+import commonEN from "@app/i18n/locales/en/common.json";
+import deviceConfigEN from "@app/i18n/locales/en/deviceConfig.json";
+import moduleConfigEN from "@app/i18n/locales/en/moduleConfig.json";
+import dashboardEN from "@app/i18n/locales/en/dashboard.json";
+import dialogEN from "@app/i18n/locales/en/dialog.json";
+import messagesEN from "@app/i18n/locales/en/messages.json";
+import nodesEN from "@app/i18n/locales/en/nodes.json";
+import uiEN from "@app/i18n/locales/en/ui.json";
enableMapSet();
@@ -24,22 +33,56 @@ globalThis.ResizeObserver = class {
disconnect() {}
};
+const appNamespaces = [
+ "channels",
+ "commandPalette",
+ "common",
+ "deviceConfig",
+ "moduleConfig",
+ "dashboard",
+ "dialog",
+ "messages",
+ "nodes",
+ "ui",
+];
+const appFallbackNS = ["common", "ui", "dialog"];
+const appDefaultNS = "common";
+
i18n
.use(initReactI18next)
.init({
lng: "en",
fallbackLng: "en",
- debug: false,
+
+ ns: appNamespaces,
+ defaultNS: appDefaultNS,
+ fallbackNS: appFallbackNS,
+
+ supportedLngs: ["en"],
+
resources: {
en: {
- translation: enTranslations,
+ channels: channelsEN,
+ commandPalette: commandPaletteEN,
+ common: commonEN,
+ deviceConfig: deviceConfigEN,
+ moduleConfig: moduleConfigEN,
+ dashboard: dashboardEN,
+ dialog: dialogEN,
+ messages: messagesEN,
+ nodes: nodesEN,
+ ui: uiEN,
},
},
+
interpolation: {
escapeValue: false,
},
- defaultNS: "translation",
- initImmediate: true,
+
+ react: {
+ useSuspense: false,
+ },
+ debug: false,
});
afterEach(() => {