feat(admin-ui): RequireAuth gate + RTL component тесты
RequireAuth: гейтит весь UI по аутентификации. Anonymous юзер вместо красного "AxiosError 401" получает immediate signinRedirect на Keycloak; authenticated юзер с истёкшим токеном получает silent renew → fallback на full redirect. Guards против infinite loop: - auth.isLoading / activeNavigator — bootstrap или signin/signout уже идёт - ?error= в URL — вернулись с провалом из Keycloak, показываем сообщение - auth.error без isAuthenticated — Keycloak недоступен, показываем сообщение main.tsx: RequireAuth обёрнут вокруг Router/Query, чтобы tan-stack-router и React Query не делали запросов до auth (иначе 401-каскад на старте). TokenSync: 401 interceptor теперь редиректит и anonymous (раньше срабатывал только для authenticated с истёкшим токеном), с теми же guards. RTL component тесты — 22 теста на 3 ключевых компонента: - SchemaBuilder (7): empty state, add/remove/reorder properties - PropertyEditor (10): kind change, required/unique toggle, kind-specific поля (string→pattern, integer→min/max, enum→values, array_string→uniqueItems), move up/down disabled на boundaries - SchemaDrivenForm (5): identity tab с required, переключение на extra, isPending → save disabled, cancel callback, serverError → Alert Setup: - vite.config.ts: test block (jsdom env, setup file, css off) - src/test/setup.ts: jest-dom matchers, cleanup, HTMLCanvasElement.getContext stub (lottie-web из @nstart/ui крашит в jsdom без canvas) - src/test/render.tsx: renderWithI18n helper, форсит ru-RU (LanguageDetector в node по умолчанию даёт en-US) Deps: +@testing-library/react +@testing-library/jest-dom +@testing-library/user-event +jsdom
This commit is contained in:
@@ -31,9 +31,13 @@
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.0.0-beta.7",
|
||||
"@tanstack/router-vite-plugin": "^1.86.0",
|
||||
"@testing-library/jest-dom": "^6.9.1",
|
||||
"@testing-library/react": "^16.3.2",
|
||||
"@testing-library/user-event": "^14.6.1",
|
||||
"@types/react": "^19.0.0",
|
||||
"@types/react-dom": "^19.0.0",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"jsdom": "^29.1.1",
|
||||
"tailwindcss": "^4.0.0-beta.7",
|
||||
"typescript": "^5.7.2",
|
||||
"vite": "^6.0.5",
|
||||
|
||||
Reference in New Issue
Block a user