20 changed files with 1001 additions and 1001 deletions
File diff suppressed because it is too large
@ -34,32 +34,32 @@ |
|||
}, |
|||
"homepage": "https://meshtastic.org", |
|||
"dependencies": { |
|||
"@bufbuild/protobuf": "^2.2.5", |
|||
"@bufbuild/protobuf": "^2.5.2", |
|||
"@meshtastic/core": "npm:@jsr/[email protected]", |
|||
"@meshtastic/js": "npm:@jsr/[email protected]", |
|||
"@meshtastic/transport-http": "npm:@jsr/meshtastic__transport-http", |
|||
"@meshtastic/transport-web-bluetooth": "npm:@jsr/meshtastic__transport-web-bluetooth", |
|||
"@meshtastic/transport-web-serial": "npm:@jsr/meshtastic__transport-web-serial", |
|||
"@noble/curves": "^1.9.0", |
|||
"@radix-ui/react-accordion": "^1.2.8", |
|||
"@radix-ui/react-checkbox": "^1.2.3", |
|||
"@radix-ui/react-dialog": "^1.1.11", |
|||
"@radix-ui/react-dropdown-menu": "^2.1.12", |
|||
"@radix-ui/react-label": "^2.1.4", |
|||
"@radix-ui/react-menubar": "^1.1.12", |
|||
"@radix-ui/react-popover": "^1.1.11", |
|||
"@radix-ui/react-scroll-area": "^1.2.6", |
|||
"@radix-ui/react-select": "^2.2.2", |
|||
"@radix-ui/react-separator": "^1.1.4", |
|||
"@radix-ui/react-slider": "^1.3.2", |
|||
"@radix-ui/react-switch": "^1.2.2", |
|||
"@radix-ui/react-tabs": "^1.1.9", |
|||
"@radix-ui/react-toast": "^1.2.11", |
|||
"@radix-ui/react-toggle-group": "^1.1.9", |
|||
"@radix-ui/react-tooltip": "^1.2.4", |
|||
"@tanstack/react-router": "^1.120.15", |
|||
"@tanstack/react-router-devtools": "^1.120.16", |
|||
"@tanstack/router-devtools": "^1.120.15", |
|||
"@noble/curves": "^1.9.2", |
|||
"@radix-ui/react-accordion": "^1.2.11", |
|||
"@radix-ui/react-checkbox": "^1.3.2", |
|||
"@radix-ui/react-dialog": "^1.1.14", |
|||
"@radix-ui/react-dropdown-menu": "^2.1.15", |
|||
"@radix-ui/react-label": "^2.1.7", |
|||
"@radix-ui/react-menubar": "^1.1.15", |
|||
"@radix-ui/react-popover": "^1.1.14", |
|||
"@radix-ui/react-scroll-area": "^1.2.9", |
|||
"@radix-ui/react-select": "^2.2.5", |
|||
"@radix-ui/react-separator": "^1.1.7", |
|||
"@radix-ui/react-slider": "^1.3.5", |
|||
"@radix-ui/react-switch": "^1.2.5", |
|||
"@radix-ui/react-tabs": "^1.1.12", |
|||
"@radix-ui/react-toast": "^1.2.14", |
|||
"@radix-ui/react-toggle-group": "^1.1.10", |
|||
"@radix-ui/react-tooltip": "^1.2.7", |
|||
"@tanstack/react-router": "^1.120.20", |
|||
"@tanstack/react-router-devtools": "^1.120.20", |
|||
"@tanstack/router-devtools": "^1.120.20", |
|||
"@turf/turf": "^7.2.0", |
|||
"@types/web-bluetooth": "^0.0.21", |
|||
"base64-js": "^1.5.1", |
|||
@ -67,56 +67,56 @@ |
|||
"clsx": "^2.1.1", |
|||
"cmdk": "^1.1.1", |
|||
"crypto-random-string": "^5.0.0", |
|||
"i18next": "^25.2.0", |
|||
"i18next": "^25.2.1", |
|||
"i18next-browser-languagedetector": "^8.1.0", |
|||
"i18next-http-backend": "^3.0.2", |
|||
"idb-keyval": "^6.2.1", |
|||
"idb-keyval": "^6.2.2", |
|||
"immer": "^10.1.1", |
|||
"js-cookie": "^3.0.5", |
|||
"lucide-react": "^0.507.0", |
|||
"maplibre-gl": "5.4.0", |
|||
"lucide-react": "^0.513.0", |
|||
"maplibre-gl": "5.6.0", |
|||
"react": "^19.1.0", |
|||
"react-dom": "^19.1.0", |
|||
"react-error-boundary": "^6.0.0", |
|||
"react-hook-form": "^7.56.2", |
|||
"react-i18next": "^15.5.1", |
|||
"react-hook-form": "^7.57.0", |
|||
"react-i18next": "^15.5.2", |
|||
"react-map-gl": "8.0.4", |
|||
"react-qrcode-logo": "^3.0.0", |
|||
"rfc4648": "^1.5.4", |
|||
"vite-plugin-i18n-ally": "^6.0.1", |
|||
"vite-plugin-i18n-ally": "^6.1.0", |
|||
"vite-plugin-node-polyfills": "^0.23.0", |
|||
"zod": "^3.25.0", |
|||
"zustand": "5.0.4" |
|||
"zod": "^3.25.57", |
|||
"zustand": "5.0.5" |
|||
}, |
|||
"devDependencies": { |
|||
"@tailwindcss/postcss": "^4.1.5", |
|||
"@tanstack/router-plugin": "^1.120.15", |
|||
"@tailwindcss/postcss": "^4.1.8", |
|||
"@tanstack/router-plugin": "^1.120.20", |
|||
"@testing-library/jest-dom": "^6.6.3", |
|||
"@testing-library/react": "^16.3.0", |
|||
"@testing-library/react-hooks": "^8.0.1", |
|||
"@testing-library/user-event": "^14.6.1", |
|||
"@types/chrome": "^0.0.318", |
|||
"@types/node": "^22.15.3", |
|||
"@types/react": "^19.1.2", |
|||
"@types/react-dom": "^19.1.3", |
|||
"@types/serviceworker": "^0.0.133", |
|||
"@types/chrome": "^0.0.326", |
|||
"@types/node": "^24.0.0", |
|||
"@types/react": "^19.1.7", |
|||
"@types/react-dom": "^19.1.6", |
|||
"@types/serviceworker": "^0.0.139", |
|||
"@types/js-cookie": "^3.0.6", |
|||
"@types/w3c-web-serial": "^1.0.8", |
|||
"@vitejs/plugin-react": "^4.4.1", |
|||
"@vitejs/plugin-react": "^4.5.2", |
|||
"autoprefixer": "^10.4.21", |
|||
"gzipper": "^8.2.1", |
|||
"happy-dom": "^17.4.6", |
|||
"postcss": "^8.5.3", |
|||
"happy-dom": "^17.6.3", |
|||
"postcss": "^8.5.4", |
|||
"simple-git-hooks": "^2.13.0", |
|||
"tailwind-merge": "^3.2.0", |
|||
"tailwindcss": "^4.1.5", |
|||
"tailwind-merge": "^3.3.0", |
|||
"tailwindcss": "^4.1.8", |
|||
"tailwindcss-animate": "^1.0.7", |
|||
"tar": "^7.4.3", |
|||
"testing-library": "^0.0.2", |
|||
"typescript": "^5.8.3", |
|||
"vite": "^6.3.4", |
|||
"vite": "^6.3.5", |
|||
"vite-plugin-pwa": "^1.0.0", |
|||
"vite-plugin-static-copy": "^3.0.0", |
|||
"vitest": "^3.1.2" |
|||
"vitest": "^3.2.3" |
|||
} |
|||
} |
|||
|
|||
@ -1,80 +0,0 @@ |
|||
import { |
|||
createMemoryHistory, |
|||
createRouter, |
|||
Outlet, |
|||
RootRoute, |
|||
Route, |
|||
RouterProvider, |
|||
} from "@tanstack/react-router"; |
|||
import { render as rtlRender, RenderOptions } from "@testing-library/react"; |
|||
import type { FunctionComponent, ReactElement, ReactNode } from "react"; |
|||
|
|||
// a root route for the test router.
|
|||
const rootRoute = new RootRoute({ |
|||
component: () => ( |
|||
<> |
|||
<Outlet /> |
|||
</> |
|||
), |
|||
}); |
|||
|
|||
interface CustomRenderOptions extends Omit<RenderOptions, "wrapper"> { |
|||
initialEntries?: string[]; |
|||
ui?: ReactElement; |
|||
} |
|||
|
|||
let currentRouter: ReturnType<typeof createRouter> | null = null; |
|||
|
|||
/** |
|||
* Custom render function for testing components that need TanStack Router context. |
|||
* @param ui The main ReactElement to render (your component under test). |
|||
* @param options Custom render options including initialEntries for the router. |
|||
* @returns An object containing the testing-library render result and the router instance. |
|||
*/ |
|||
const customRender = ( |
|||
ui: ReactElement, |
|||
options: CustomRenderOptions = {}, |
|||
) => { |
|||
const { initialEntries = ["/"], ...renderOptions } = options; |
|||
|
|||
// A specific route that renders the component under test (ui).
|
|||
// It defaults to the first path in initialEntries or '/'.
|
|||
const testComponentRoute = new Route({ |
|||
getParentRoute: () => rootRoute, |
|||
path: initialEntries[0] || "/", |
|||
component: () => ui, // The component passed to render will be the element for this route
|
|||
}); |
|||
|
|||
const routeTree = rootRoute.addChildren([testComponentRoute]); |
|||
|
|||
const router = createRouter({ |
|||
history: createMemoryHistory({ initialEntries }), |
|||
routeTree, |
|||
// You can add default error components or other router options if needed for tests.
|
|||
// defaultErrorComponent: ({ error }) => <div>Test Error: {error.message}</div>,
|
|||
}); |
|||
|
|||
currentRouter = router; // Store the router instance for access in tests
|
|||
|
|||
const Wrapper: FunctionComponent<{ children?: ReactNode }> = ( |
|||
{ children }, |
|||
) => { |
|||
return ( |
|||
<> |
|||
<RouterProvider router={router} /> |
|||
{children} |
|||
</> |
|||
); |
|||
}; |
|||
|
|||
const renderResult = rtlRender(ui, { wrapper: Wrapper, ...renderOptions }); |
|||
|
|||
return { |
|||
...renderResult, |
|||
router, |
|||
}; |
|||
}; |
|||
|
|||
export * from "@testing-library/react"; |
|||
export { customRender as render }; |
|||
export const getTestRouter = () => currentRouter; |
|||
@ -0,0 +1,37 @@ |
|||
import { ReactElement } from "react"; |
|||
import { render, RenderOptions } from "@testing-library/react"; |
|||
import { |
|||
createMemoryHistory, |
|||
createRouter, |
|||
RouterProvider, |
|||
} from "@tanstack/react-router"; |
|||
import "../i18n/config.ts"; |
|||
import { routeTree } from "../routeTree.gen.ts"; |
|||
|
|||
import { DeviceWrapper } from "@app/DeviceWrapper.tsx"; |
|||
|
|||
const Providers = () => { |
|||
const memoryHistory = createMemoryHistory({ |
|||
initialEntries: ["/"], |
|||
}); |
|||
|
|||
const router = createRouter({ |
|||
routeTree, |
|||
history: memoryHistory, |
|||
}); |
|||
|
|||
return ( |
|||
<DeviceWrapper> |
|||
<RouterProvider router={router} /> |
|||
</DeviceWrapper> |
|||
); |
|||
}; |
|||
|
|||
const renderWithProviders = ( |
|||
ui: ReactElement, |
|||
options?: Omit<RenderOptions, "wrapper">, |
|||
) => render(ui, { wrapper: Providers, ...options }); |
|||
|
|||
export * from "@testing-library/react"; |
|||
|
|||
export { renderWithProviders as render }; |
|||
Loading…
Reference in new issue