Browse Source
* feat: added router * feat: added params to messages page * fixing tests, added translation labels * Update src/i18n/locales/en/ui.json Co-authored-by: Copilot <[email protected]> * Update src/components/Dialog/NodeDetailsDialog/NodeDetailsDialog.tsx Co-authored-by: Copilot <[email protected]> * Update src/components/PageComponents/Map/NodeDetail.tsx Co-authored-by: Copilot <[email protected]> * Update src/pages/Messages.tsx Co-authored-by: Copilot <[email protected]> * updated dev tools * fixing tests --------- Co-authored-by: Copilot <[email protected]>pull/648/head
committed by
GitHub
27 changed files with 694 additions and 211 deletions
@ -27,6 +27,10 @@ |
|||
"npm:@radix-ui/react-toggle-group@^1.1.9": "1.1.10_@[email protected]_@[email protected]__@[email protected][email protected][email protected][email protected]", |
|||
"npm:@radix-ui/react-tooltip@^1.2.4": "1.2.4_@[email protected]_@[email protected]__@[email protected][email protected][email protected][email protected]", |
|||
"npm:@tailwindcss/postcss@^4.1.5": "4.1.5", |
|||
"npm:@tanstack/react-router-devtools@^1.120.16": "1.120.16_@[email protected][email protected][email protected][email protected][email protected][email protected][email protected][email protected][email protected]", |
|||
"npm:@tanstack/react-router@^1.120.15": "[email protected][email protected][email protected]", |
|||
"npm:@tanstack/router-devtools@^1.120.15": "1.120.15_@[email protected][email protected][email protected][email protected][email protected][email protected][email protected]", |
|||
"npm:@tanstack/router-plugin@^1.120.15": "1.120.15_@[email protected][email protected][email protected][email protected][email protected]__@[email protected][email protected]_@[email protected][email protected][email protected][email protected]_@[email protected]", |
|||
"npm:@testing-library/jest-dom@^6.6.3": "6.6.3", |
|||
"npm:@testing-library/react@^16.3.0": "16.3.0_@[email protected]_@[email protected]_@[email protected]__@[email protected][email protected][email protected][email protected]", |
|||
"npm:@testing-library/user-event@^14.6.1": "14.6.1_@[email protected]", |
|||
@ -366,6 +370,20 @@ |
|||
"@babel/helper-plugin-utils" |
|||
] |
|||
}, |
|||
"@babel/[email protected]_@[email protected]": { |
|||
"integrity": "sha512-y8YTNIeKoyhGd9O0Jiyzyyqk8gdjnumGTQPsz0xOZOQ2RmkVJeZ1vmmfIvFEKqucBG6axJGBZDE/7iI5suUI/w==", |
|||
"dependencies": [ |
|||
"@babel/core", |
|||
"@babel/helper-plugin-utils" |
|||
] |
|||
}, |
|||
"@babel/[email protected]_@[email protected]": { |
|||
"integrity": "sha512-xfYCBMxveHrRMnAWl1ZlPXOZjzkN82THFvLhQhFXFt81Z5HnN+EtUkZhv/zcKpmT3fzmWZB0ywiBrbC3vogbwQ==", |
|||
"dependencies": [ |
|||
"@babel/core", |
|||
"@babel/helper-plugin-utils" |
|||
] |
|||
}, |
|||
"@babel/[email protected]_@[email protected]": { |
|||
"integrity": "sha512-727YkEAPwSIQTv5im8QHz3upqp92JTWhidIC81Tdx4VJYIte/VndKf1qKrfnnhPLiPghStWfvC/iFaMCQu7Nqg==", |
|||
"dependencies": [ |
|||
@ -2341,6 +2359,136 @@ |
|||
"tailwindcss" |
|||
] |
|||
}, |
|||
"@tanstack/[email protected]": { |
|||
"integrity": "sha512-K7JJNrRVvyjAVnbXOH2XLRhFXDkeP54Kt2P4FR1Kl2KDGlIbkua5VqZQD2rot3qaDrpufyUa63nuLai1kOLTsQ==" |
|||
}, |
|||
"@tanstack/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected][email protected][email protected][email protected]": { |
|||
"integrity": "sha512-5KcUXc3fkiLo/6Y56gOM3JqmYXG1ElIH2iyUWuG5IlcegLrpXhu4OBQ+8Q4+62CD0OKy0ifUDyemrCOAEOfCvw==", |
|||
"dependencies": [ |
|||
"@tanstack/react-router", |
|||
"@tanstack/router-devtools-core", |
|||
"react", |
|||
"react-dom", |
|||
"solid-js" |
|||
] |
|||
}, |
|||
"@tanstack/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected][email protected][email protected][email protected]": { |
|||
"integrity": "sha512-DWXmMLknVJJMGP2k5yeUWBDhJOHbV2jVfnZKxtGzA64xXhwDFgU9qpodcmYSq3+kHWsKrd7iX0wc7d27rGwGDA==", |
|||
"dependencies": [ |
|||
"@tanstack/react-router", |
|||
"@tanstack/router-devtools-core", |
|||
"react", |
|||
"react-dom", |
|||
"solid-js" |
|||
] |
|||
}, |
|||
"@tanstack/[email protected][email protected][email protected][email protected]": { |
|||
"integrity": "sha512-apzBmXh4pHwqUGU3kD8y2FJMi7rVoUbRxh5oV7v8kEb6Aq5Xpdo+OcpThw8h/M2zv7v4Ef8IoY6WFCKKu3HBjQ==", |
|||
"dependencies": [ |
|||
"@tanstack/history", |
|||
"@tanstack/react-store", |
|||
"@tanstack/router-core", |
|||
"[email protected]", |
|||
"react", |
|||
"react-dom", |
|||
"tiny-invariant", |
|||
"tiny-warning" |
|||
] |
|||
}, |
|||
"@tanstack/[email protected][email protected][email protected][email protected]": { |
|||
"integrity": "sha512-qUTEKdId6QPWGiWyKAPf/gkN29scEsz6EUSJ0C3HgLMgaqTAyBsQ2sMCfGVcqb+kkhEXAdjleCgH6LAPD6f2sA==", |
|||
"dependencies": [ |
|||
"@tanstack/store", |
|||
"react", |
|||
"react-dom", |
|||
"use-sync-external-store" |
|||
] |
|||
}, |
|||
"@tanstack/[email protected]": { |
|||
"integrity": "sha512-soLj+mEuvSxAVFK/3b85IowkkvmSuQL6J0RSIyKJFGFgy0CmUzpcBGEO99+JNWvvvzHgIoY4F4KtLIN+rvFSFA==", |
|||
"dependencies": [ |
|||
"@tanstack/history", |
|||
"@tanstack/store", |
|||
"tiny-invariant" |
|||
] |
|||
}, |
|||
"@tanstack/[email protected]_@[email protected][email protected][email protected][email protected]": { |
|||
"integrity": "sha512-AT9obPHKpJqnHMbwshozSy6sApg5LchiAll3blpS3MMDybUCidYHrdhe9MZJLmlC99IQiEGmuZERP3VRcuPNHg==", |
|||
"dependencies": [ |
|||
"@tanstack/router-core", |
|||
"clsx", |
|||
"goober", |
|||
"solid-js", |
|||
"tiny-invariant" |
|||
] |
|||
}, |
|||
"@tanstack/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected][email protected]": { |
|||
"integrity": "sha512-u7KbvupWSppoEUYuhCBzmWkd1hcODzHhvGIuWZKoQO9q/qeNY5XptbzGqBSUooXyoF4T/pAdCRILF5zFIqexJw==", |
|||
"dependencies": [ |
|||
"@tanstack/react-router", |
|||
"@tanstack/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected][email protected][email protected][email protected]", |
|||
"clsx", |
|||
"goober", |
|||
"react", |
|||
"react-dom" |
|||
] |
|||
}, |
|||
"@tanstack/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected][email protected]": { |
|||
"integrity": "sha512-QwZ0rNXxzgOEUDRRAEWVjofKxuxSMIYEdYC3z20k6a7jkLC6pnlCORFx41Vf4xVCO6eElqlrUKXWLTleYSsvQw==", |
|||
"dependencies": [ |
|||
"@tanstack/react-router", |
|||
"@tanstack/virtual-file-routes", |
|||
"prettier", |
|||
"tsx", |
|||
"zod" |
|||
], |
|||
"optionalPeers": [ |
|||
"@tanstack/react-router" |
|||
] |
|||
}, |
|||
"@tanstack/[email protected]_@[email protected][email protected][email protected][email protected][email protected]__@[email protected][email protected]_@[email protected][email protected][email protected][email protected]_@[email protected]": { |
|||
"integrity": "sha512-ARuuPRKO5HzN3V0LzmkIGm0e447t5VCy2ijbUnzd08KjcJm3lG221ViC2qI+vTom1zp6yeNZHfJW1LBh1yLrTw==", |
|||
"dependencies": [ |
|||
"@babel/core", |
|||
"@babel/plugin-syntax-jsx", |
|||
"@babel/plugin-syntax-typescript", |
|||
"@babel/template", |
|||
"@babel/traverse", |
|||
"@babel/types", |
|||
"@tanstack/react-router", |
|||
"@tanstack/router-core", |
|||
"@tanstack/router-generator", |
|||
"@tanstack/router-utils", |
|||
"@tanstack/virtual-file-routes", |
|||
"@types/babel__core", |
|||
"@types/babel__template", |
|||
"@types/babel__traverse", |
|||
"babel-dead-code-elimination", |
|||
"chokidar", |
|||
"unplugin", |
|||
"vite", |
|||
"zod" |
|||
], |
|||
"optionalPeers": [ |
|||
"@tanstack/react-router", |
|||
"vite" |
|||
] |
|||
}, |
|||
"@tanstack/[email protected]": { |
|||
"integrity": "sha512-Dng4y+uLR9b5zPGg7dHReHOTHQa6x+G6nCoZshsDtWrYsrdCcJEtLyhwZ5wG8OyYS6dVr/Cn+E5Bd2b6BhJ89w==", |
|||
"dependencies": [ |
|||
"@babel/generator", |
|||
"@babel/parser", |
|||
"ansis", |
|||
"diff" |
|||
] |
|||
}, |
|||
"@tanstack/[email protected]": { |
|||
"integrity": "sha512-PjUQKXEXhLYj2X5/6c1Xn/0/qKY0IVFxTJweopRfF26xfjVyb14yALydJrHupDh3/d+1WKmfEgZPBVCmDkzzwg==" |
|||
}, |
|||
"@tanstack/[email protected]": { |
|||
"integrity": "sha512-XLUh1Py3AftcERrxkxC5Y5m5mfllRH3YR6YVlyjFgI2Tc2Ssy2NKmQFQIafoxfW459UJ8Dn81nWKETEIJifE4g==" |
|||
}, |
|||
"@testing-library/[email protected]": { |
|||
"integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==", |
|||
"dependencies": [ |
|||
@ -3972,6 +4120,9 @@ |
|||
"[email protected]": { |
|||
"integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==" |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-0qWUglt9JEqLFr3w1I1pbrChn1grhaiAR2ocX1PP/flRmxgtwTzPFFFnfIlD6aMOLQZgSuCRlidD70lvx8yhzg==" |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", |
|||
"dependencies": [ |
|||
@ -4071,6 +4222,15 @@ |
|||
"possible-typed-array-names" |
|||
] |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-DV5bdJZTzZ0zn0DC24v3jD7Mnidh6xhKa4GfKCbq3sfW8kaWhDdZjP3i81geA8T33tdYqWKw4D3fVv0CwEgKVA==", |
|||
"dependencies": [ |
|||
"@babel/core", |
|||
"@babel/parser", |
|||
"@babel/traverse", |
|||
"@babel/types" |
|||
] |
|||
}, |
|||
"[email protected]_@[email protected]": { |
|||
"integrity": "sha512-3sX/eOms8kd3q2KZ6DAhKPc0dgm525Gqq5NtWKZ7QYYZEv57OQ54KtblzJzH1lQF/eQxO8KjWGIK9IPUJNus5g==", |
|||
"dependencies": [ |
|||
@ -4559,6 +4719,9 @@ |
|||
"[email protected]": { |
|||
"integrity": "sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==" |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==" |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", |
|||
"dependencies": [ |
|||
@ -5018,6 +5181,12 @@ |
|||
"gopd" |
|||
] |
|||
}, |
|||
"[email protected][email protected]": { |
|||
"integrity": "sha512-erjk19y1U33+XAMe1VTvIONHYoSqE4iS7BYUZfHaqeohLmnC0FdxEh7rQU+6MZ4OajItzjZFSRtVANrQwNq6/g==", |
|||
"dependencies": [ |
|||
"csstype" |
|||
] |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==" |
|||
}, |
|||
@ -5937,6 +6106,10 @@ |
|||
"[email protected]": { |
|||
"integrity": "sha512-Q+/tYsFU9r7xoOJ+y/ZTtdVQwTWfzjbiXBDMM/JKUux3+QPP02iUuIoeBQ+Ot6oEDlC+/PGjB/5A3K7KKb7hcw==" |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", |
|||
"bin": true |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==" |
|||
}, |
|||
@ -6358,6 +6531,15 @@ |
|||
"randombytes" |
|||
] |
|||
}, |
|||
"[email protected][email protected]": { |
|||
"integrity": "sha512-0QvCV2lM3aj/U3YozDiVwx9zpH0q8A60CTWIv4Jszj/givcudPb48B+rkU5D51NJ0pTpweGMttHjboPa9/zoIQ==", |
|||
"dependencies": [ |
|||
"seroval" |
|||
] |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-RbcPH1n5cfwKrru7v7+zrZvjLurgHhGyso3HTyGtRivGWgYjbOmGuivCQaORNELjNONoK35nj28EoWul9sb1zQ==" |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", |
|||
"dependencies": [ |
|||
@ -6465,6 +6647,14 @@ |
|||
"[email protected]": { |
|||
"integrity": "sha512-g6T+p7QO8npa+/hNx9ohv1E5pVCmWrVCUzUXJyLdMmftX6ER0oiWY/w9knEonLpnOp6b6FenKnMfR8gqwWdwig==" |
|||
}, |
|||
"[email protected][email protected]": { |
|||
"integrity": "sha512-/saTKi8iWEM233n5OSi1YHCCuh66ZIQ7aK2hsToPe4tqGm7qAejU1SwNuTPivbWAYq7SjuHVVYxxuZQNRbICiw==", |
|||
"dependencies": [ |
|||
"csstype", |
|||
"seroval", |
|||
"seroval-plugins" |
|||
] |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-umMGhjPeHAI6YjABoSTrFp2zaBtXBej1a0yKkuMUyjjqu6FJsTF+JYwCswWDg+zJfk/5npWUUbd33HH/WLzpaA==" |
|||
}, |
|||
@ -6720,6 +6910,12 @@ |
|||
"setimmediate" |
|||
] |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==" |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==" |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==" |
|||
}, |
|||
@ -6909,6 +7105,14 @@ |
|||
"[email protected]": { |
|||
"integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==" |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-RyWSb5AHmGtjjNQ6gIlA67sHOsWpsbWpwDokLwTcejVdOjEkJZh7QKu14J00gDDVSh8kGH4KYC/TNBceXFZhtw==", |
|||
"dependencies": [ |
|||
"acorn", |
|||
"[email protected]", |
|||
"webpack-virtual-modules" |
|||
] |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==" |
|||
}, |
|||
@ -6951,6 +7155,12 @@ |
|||
"@types/react" |
|||
] |
|||
}, |
|||
"[email protected][email protected]": { |
|||
"integrity": "sha512-Rb46I4cGGVBmjamjphe8L/UnvJD+uPPtTkNvX5mZgqdbavhI4EbgIWJiIHXJ8bc/i9EQGPRh4DwEURJ552Do0A==", |
|||
"dependencies": [ |
|||
"react" |
|||
] |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" |
|||
}, |
|||
@ -7100,6 +7310,9 @@ |
|||
"[email protected]": { |
|||
"integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==" |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==" |
|||
}, |
|||
"[email protected]": { |
|||
"integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==" |
|||
}, |
|||
@ -7390,6 +7603,10 @@ |
|||
"npm:@radix-ui/react-toggle-group@^1.1.9", |
|||
"npm:@radix-ui/react-tooltip@^1.2.4", |
|||
"npm:@tailwindcss/postcss@^4.1.5", |
|||
"npm:@tanstack/react-router-devtools@^1.120.16", |
|||
"npm:@tanstack/react-router@^1.120.15", |
|||
"npm:@tanstack/router-devtools@^1.120.15", |
|||
"npm:@tanstack/router-plugin@^1.120.15", |
|||
"npm:@testing-library/jest-dom@^6.6.3", |
|||
"npm:@testing-library/react@^16.3.0", |
|||
"npm:@testing-library/user-event@^14.6.1", |
|||
|
|||
@ -1,27 +0,0 @@ |
|||
import MapPage from "@app/pages/Map/index.tsx"; |
|||
import { useDevice } from "@core/stores/deviceStore.ts"; |
|||
import ChannelsPage from "@pages/Channels.tsx"; |
|||
import ConfigPage from "@pages/Config/index.tsx"; |
|||
import MessagesPage from "@pages/Messages.tsx"; |
|||
import NodesPage from "@pages/Nodes.tsx"; |
|||
import { ErrorBoundary } from "react-error-boundary"; |
|||
import { ErrorPage } from "@components/UI/ErrorPage.tsx"; |
|||
|
|||
export const ErrorBoundaryWrapper = ({ |
|||
children, |
|||
}: { children: React.ReactNode }) => ( |
|||
<ErrorBoundary FallbackComponent={ErrorPage}>{children}</ErrorBoundary> |
|||
); |
|||
|
|||
export const PageRouter = () => { |
|||
const { activePage } = useDevice(); |
|||
return ( |
|||
<ErrorBoundary FallbackComponent={ErrorPage}> |
|||
{activePage === "messages" && <MessagesPage />} |
|||
{activePage === "map" && <MapPage />} |
|||
{activePage === "config" && <ConfigPage />} |
|||
{activePage === "channels" && <ChannelsPage />} |
|||
{activePage === "nodes" && <NodesPage />} |
|||
</ErrorBoundary> |
|||
); |
|||
}; |
|||
@ -1,12 +1,80 @@ |
|||
import { render } from "@testing-library/react"; |
|||
import type { ReactElement } from "react"; |
|||
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"; |
|||
|
|||
function customRender(ui: ReactElement, options = {}) { |
|||
return render(ui, { |
|||
// wrapper: ({ children }) => <MapProvider>{children}</MapProvider>,
|
|||
...options, |
|||
}); |
|||
// 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,59 @@ |
|||
/* eslint-disable */ |
|||
|
|||
// @ts-nocheck
|
|||
|
|||
// noinspection JSUnusedGlobalSymbols
|
|||
|
|||
// This file was automatically generated by TanStack Router.
|
|||
// You should NOT make any changes in this file as it will be overwritten.
|
|||
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
|||
|
|||
// Import Routes
|
|||
|
|||
import { Route as rootRoute } from './routes/__root' |
|||
|
|||
// Create/Update Routes
|
|||
|
|||
// Populate the FileRoutesByPath interface
|
|||
|
|||
declare module '@tanstack/react-router' { |
|||
interface FileRoutesByPath {} |
|||
} |
|||
|
|||
// Create and export the route tree
|
|||
|
|||
export interface FileRoutesByFullPath {} |
|||
|
|||
export interface FileRoutesByTo {} |
|||
|
|||
export interface FileRoutesById { |
|||
__root__: typeof rootRoute |
|||
} |
|||
|
|||
export interface FileRouteTypes { |
|||
fileRoutesByFullPath: FileRoutesByFullPath |
|||
fullPaths: never |
|||
fileRoutesByTo: FileRoutesByTo |
|||
to: never |
|||
id: '__root__' |
|||
fileRoutesById: FileRoutesById |
|||
} |
|||
|
|||
export interface RootRouteChildren {} |
|||
|
|||
const rootRouteChildren: RootRouteChildren = {} |
|||
|
|||
export const routeTree = rootRoute |
|||
._addFileChildren(rootRouteChildren) |
|||
._addFileTypes<FileRouteTypes>() |
|||
|
|||
/* ROUTE_MANIFEST_START |
|||
{ |
|||
"routes": { |
|||
"__root__": { |
|||
"filePath": "__root.tsx", |
|||
"children": [] |
|||
} |
|||
} |
|||
} |
|||
ROUTE_MANIFEST_END */ |
|||
@ -0,0 +1,79 @@ |
|||
import { createRoute, redirect } from "@tanstack/react-router"; |
|||
import { Dashboard } from "@pages/Dashboard/index.tsx"; |
|||
import MessagesPage from "@pages/Messages.tsx"; |
|||
import MapPage from "@pages/Map/index.tsx"; |
|||
import ConfigPage from "@pages/Config/index.tsx"; |
|||
import ChannelsPage from "@pages/Channels.tsx"; |
|||
import NodesPage from "@pages/Nodes.tsx"; |
|||
import { createRootRoute } from "@tanstack/react-router"; |
|||
import { App } from "./App.tsx"; |
|||
import { DialogManager } from "@components/Dialog/DialogManager.tsx"; |
|||
|
|||
const rootRoute = createRootRoute({ |
|||
component: App, |
|||
}); |
|||
|
|||
const indexRoute = createRoute({ |
|||
getParentRoute: () => rootRoute, |
|||
path: "/", |
|||
component: Dashboard, |
|||
loader: () => { |
|||
// Redirect to the broadcast messages page on initial load
|
|||
return redirect({ to: `/messages/broadcast/0`, replace: true }); |
|||
}, |
|||
}); |
|||
|
|||
const messagesRoute = createRoute({ |
|||
getParentRoute: () => rootRoute, |
|||
path: "/messages", |
|||
component: MessagesPage, |
|||
}); |
|||
|
|||
const messagesWithParamsRoute = createRoute({ |
|||
getParentRoute: () => rootRoute, |
|||
path: "/messages/$type/$chatId", |
|||
component: MessagesPage, |
|||
}); |
|||
|
|||
const mapRoute = createRoute({ |
|||
getParentRoute: () => rootRoute, |
|||
path: "/map", |
|||
component: MapPage, |
|||
}); |
|||
|
|||
const configRoute = createRoute({ |
|||
getParentRoute: () => rootRoute, |
|||
path: "/config", |
|||
component: ConfigPage, |
|||
}); |
|||
|
|||
const channelsRoute = createRoute({ |
|||
getParentRoute: () => rootRoute, |
|||
path: "/channels", |
|||
component: ChannelsPage, |
|||
}); |
|||
|
|||
const nodesRoute = createRoute({ |
|||
getParentRoute: () => rootRoute, |
|||
path: "/nodes", |
|||
component: NodesPage, |
|||
}); |
|||
|
|||
const dialogWithParamsRoute = createRoute({ |
|||
getParentRoute: () => rootRoute, |
|||
path: "/dialog/$dialogId", |
|||
component: DialogManager, |
|||
}); |
|||
|
|||
export const routeTree = rootRoute.addChildren([ |
|||
indexRoute, |
|||
messagesRoute, |
|||
messagesWithParamsRoute, |
|||
mapRoute, |
|||
configRoute, |
|||
channelsRoute, |
|||
nodesRoute, |
|||
dialogWithParamsRoute, |
|||
]); |
|||
|
|||
export { rootRoute }; |
|||
Loading…
Reference in new issue