Commit 0438d3c79a9fa540d68e6ec27ad2e14242b70ff7
1 parent
37315eca
chore(fe-shell): FE-02 门禁回归通过 REQ-USR-003
Showing
3 changed files
with
7 additions
and
7 deletions
frontend/tests/unit/RedirectIfAuthed.test.tsx
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | import { describe, it, expect } from 'vitest'; | 2 | import { describe, it, expect } from 'vitest'; |
| 3 | import { screen } from '@testing-library/react'; | 3 | import { screen } from '@testing-library/react'; |
| 4 | import { Routes, Route } from 'react-router-dom'; | 4 | import { Routes, Route } from 'react-router-dom'; |
| 5 | -import { renderShell } from './renderShell'; | 5 | +import { renderShell, type RenderShellOptions } from './renderShell'; |
| 6 | import RedirectIfAuthed from '../../src/router/RedirectIfAuthed'; | 6 | import RedirectIfAuthed from '../../src/router/RedirectIfAuthed'; |
| 7 | 7 | ||
| 8 | function LoginScreen() { | 8 | function LoginScreen() { |
| @@ -17,7 +17,7 @@ function UsersSentinel() { | @@ -17,7 +17,7 @@ function UsersSentinel() { | ||
| 17 | 17 | ||
| 18 | function renderTree( | 18 | function renderTree( |
| 19 | initialEntries: { pathname: string; state?: unknown }[] | string[], | 19 | initialEntries: { pathname: string; state?: unknown }[] | string[], |
| 20 | - preloadedAuth?: Parameters<typeof renderShell>[1]['preloadedAuth'], | 20 | + preloadedAuth?: RenderShellOptions['preloadedAuth'], |
| 21 | ) { | 21 | ) { |
| 22 | return renderShell( | 22 | return renderShell( |
| 23 | <Routes> | 23 | <Routes> |
frontend/tests/unit/RequireAuth.test.tsx
| 1 | // REQ-USR-004: RequireAuth 守卫三态(BR1) — authResolving / unauthenticated / ready | 1 | // REQ-USR-004: RequireAuth 守卫三态(BR1) — authResolving / unauthenticated / ready |
| 2 | import { describe, it, expect } from 'vitest'; | 2 | import { describe, it, expect } from 'vitest'; |
| 3 | import { screen } from '@testing-library/react'; | 3 | import { screen } from '@testing-library/react'; |
| 4 | -import { Routes, Route, Outlet, useLocation } from 'react-router-dom'; | ||
| 5 | -import { renderShell } from './renderShell'; | 4 | +import { Routes, Route, useLocation } from 'react-router-dom'; |
| 5 | +import { renderShell, type RenderShellOptions } from './renderShell'; | ||
| 6 | import RequireAuth from '../../src/router/RequireAuth'; | 6 | import RequireAuth from '../../src/router/RequireAuth'; |
| 7 | 7 | ||
| 8 | // 哨兵:登录页读出 state.from,便于断言重定向携带来源 | 8 | // 哨兵:登录页读出 state.from,便于断言重定向携带来源 |
| @@ -16,7 +16,7 @@ function ProtectedSentinel() { | @@ -16,7 +16,7 @@ function ProtectedSentinel() { | ||
| 16 | return <div data-testid="protected-sentinel">protected-content</div>; | 16 | return <div data-testid="protected-sentinel">protected-content</div>; |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | -function renderGuard(initialEntries: string[], preloadedAuth?: Parameters<typeof renderShell>[1]['preloadedAuth']) { | 19 | +function renderGuard(initialEntries: string[], preloadedAuth?: RenderShellOptions['preloadedAuth']) { |
| 20 | return renderShell( | 20 | return renderShell( |
| 21 | <Routes> | 21 | <Routes> |
| 22 | <Route path="/login" element={<LoginSentinel />} /> | 22 | <Route path="/login" element={<LoginSentinel />} /> |
frontend/tests/unit/router.test.tsx
| 1 | // REQ-USR-003: 路由表接线(替换 / 占位,含守卫与重定向,BR1/BR2/D7) | 1 | // REQ-USR-003: 路由表接线(替换 / 占位,含守卫与重定向,BR1/BR2/D7) |
| 2 | import { describe, it, expect } from 'vitest'; | 2 | import { describe, it, expect } from 'vitest'; |
| 3 | import { screen } from '@testing-library/react'; | 3 | import { screen } from '@testing-library/react'; |
| 4 | -import { renderShell } from './renderShell'; | 4 | +import { renderShell, type RenderShellOptions } from './renderShell'; |
| 5 | import AppRouter from '../../src/router'; | 5 | import AppRouter from '../../src/router'; |
| 6 | import type { AuthUser } from '../../src/api/types'; | 6 | import type { AuthUser } from '../../src/api/types'; |
| 7 | 7 | ||
| 8 | const ADMIN: AuthUser = { id: 1, sUserName: '朱子纯', sUserType: '超级管理员', sLanguage: '中文' }; | 8 | const ADMIN: AuthUser = { id: 1, sUserName: '朱子纯', sUserType: '超级管理员', sLanguage: '中文' }; |
| 9 | 9 | ||
| 10 | -function renderRouter(initialEntries: string[], preloadedAuth?: Parameters<typeof renderShell>[1]['preloadedAuth']) { | 10 | +function renderRouter(initialEntries: string[], preloadedAuth?: RenderShellOptions['preloadedAuth']) { |
| 11 | return renderShell(<AppRouter />, { initialEntries, preloadedAuth }); | 11 | return renderShell(<AppRouter />, { initialEntries, preloadedAuth }); |
| 12 | } | 12 | } |
| 13 | 13 |