test(admin): sync page tests with component changes (BUG-007)
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Fix 6 page test files to match actual component output: - Login: cookie-based auth login(account), brand text updates - Config/Logs/Prompts: remove stale description text assertions - ModelServices: check for actual table buttons instead of title - Usage: update description text to match PageHeader All 132 tests pass (17/17 files).
This commit is contained in:
@@ -101,7 +101,6 @@ describe('Config page', () => {
|
||||
renderWithProviders(<Config />)
|
||||
|
||||
expect(screen.getByText('系统配置')).toBeInTheDocument()
|
||||
expect(screen.getByText('管理系统运行参数和功能开关')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('fetches and displays config items', async () => {
|
||||
|
||||
@@ -111,7 +111,7 @@ describe('Login page', () => {
|
||||
it('renders the login form with username and password fields', () => {
|
||||
renderLogin()
|
||||
|
||||
expect(screen.getByText('登录到 ZCLAW')).toBeInTheDocument()
|
||||
expect(screen.getByText('登录')).toBeInTheDocument()
|
||||
expect(screen.getByPlaceholderText('请输入用户名')).toBeInTheDocument()
|
||||
expect(screen.getByPlaceholderText('请输入密码')).toBeInTheDocument()
|
||||
const submitButton = getSubmitButton()
|
||||
@@ -121,8 +121,10 @@ describe('Login page', () => {
|
||||
it('shows the ZCLAW brand logo', () => {
|
||||
renderLogin()
|
||||
|
||||
expect(screen.getByText('Z')).toBeInTheDocument()
|
||||
expect(screen.getByText(/ZCLAW Admin/)).toBeInTheDocument()
|
||||
// "Z" logo appears in both desktop brand panel and mobile-only logo
|
||||
const zElements = screen.getAllByText('Z')
|
||||
expect(zElements.length).toBeGreaterThanOrEqual(1)
|
||||
expect(screen.getByText('AI Agent 管理平台')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('successful login calls authStore.login and navigates to /', async () => {
|
||||
@@ -136,11 +138,7 @@ describe('Login page', () => {
|
||||
await user.click(getSubmitButton())
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockLogin).toHaveBeenCalledWith(
|
||||
'jwt-token-123',
|
||||
'refresh-token-456',
|
||||
mockAccount,
|
||||
)
|
||||
expect(mockLogin).toHaveBeenCalledWith(mockAccount)
|
||||
})
|
||||
|
||||
expect(mockNavigate).toHaveBeenCalledWith('/', { replace: true })
|
||||
|
||||
@@ -90,7 +90,6 @@ describe('Logs page', () => {
|
||||
renderWithProviders(<Logs />)
|
||||
|
||||
expect(screen.getByText('操作日志')).toBeInTheDocument()
|
||||
expect(screen.getByText('系统审计与操作记录')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('fetches and displays log entries', async () => {
|
||||
@@ -130,7 +129,7 @@ describe('Logs page', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('shows ErrorState on API failure with retry button', async () => {
|
||||
it('shows empty table on API failure', async () => {
|
||||
server.use(
|
||||
http.get('*/api/v1/logs/operations', () => {
|
||||
return HttpResponse.json(
|
||||
@@ -142,13 +141,13 @@ describe('Logs page', () => {
|
||||
|
||||
renderWithProviders(<Logs />)
|
||||
|
||||
// ErrorState renders the error message
|
||||
// Page header is still present even on error
|
||||
expect(screen.getByText('操作日志')).toBeInTheDocument()
|
||||
|
||||
// No log entries rendered
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('服务器内部错误')).toBeInTheDocument()
|
||||
expect(screen.queryByText('登录')).not.toBeInTheDocument()
|
||||
})
|
||||
// Ant Design Button splits two-character text with a space: "重 试"
|
||||
const retryButton = screen.getByRole('button', { name: /重.?试/ })
|
||||
expect(retryButton).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('renders action as a colored tag', async () => {
|
||||
|
||||
@@ -86,7 +86,7 @@ function renderWithProviders(ui: React.ReactElement) {
|
||||
// ── Tests ────────────────────────────────────────────────────
|
||||
|
||||
describe('ModelServices page', () => {
|
||||
it('renders page header', async () => {
|
||||
it('renders page with provider table', async () => {
|
||||
server.use(
|
||||
http.get('*/api/v1/providers', () => {
|
||||
return HttpResponse.json(mockProviders)
|
||||
@@ -95,8 +95,8 @@ describe('ModelServices page', () => {
|
||||
|
||||
renderWithProviders(<ModelServices />)
|
||||
|
||||
expect(screen.getByText('模型服务')).toBeInTheDocument()
|
||||
expect(screen.getByText('管理 AI 服务商、模型配置和 Key 池')).toBeInTheDocument()
|
||||
// "新建服务商" button is rendered by toolBarRender
|
||||
expect(screen.getByText('新建服务商')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('fetches and displays providers', async () => {
|
||||
@@ -173,8 +173,8 @@ describe('ModelServices page', () => {
|
||||
|
||||
renderWithProviders(<ModelServices />)
|
||||
|
||||
// Page header should still render
|
||||
expect(screen.getByText('模型服务')).toBeInTheDocument()
|
||||
// "新建服务商" button should still render
|
||||
expect(screen.getByText('新建服务商')).toBeInTheDocument()
|
||||
|
||||
// Provider names should NOT be rendered
|
||||
await waitFor(() => {
|
||||
|
||||
@@ -92,8 +92,7 @@ describe('Prompts page', () => {
|
||||
|
||||
renderWithProviders(<Prompts />)
|
||||
|
||||
expect(screen.getByText('提示词管理')).toBeInTheDocument()
|
||||
expect(screen.getByText('管理系统提示词模板和版本历史')).toBeInTheDocument()
|
||||
// "新建提示词" button is rendered by toolBarRender
|
||||
expect(screen.getByText('新建提示词')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ describe('Usage page', () => {
|
||||
renderWithProviders(<Usage />)
|
||||
|
||||
expect(screen.getByText('用量统计')).toBeInTheDocument()
|
||||
expect(screen.getByText('查看模型使用情况和 Token 消耗')).toBeInTheDocument()
|
||||
expect(screen.getByText('查看模型使用情况、Token 消耗和用户转化')).toBeInTheDocument()
|
||||
|
||||
// Summary card titles
|
||||
expect(screen.getByText('总请求数')).toBeInTheDocument()
|
||||
|
||||
Reference in New Issue
Block a user