feat(admin-v2): add ProTable search, scenarios/quick_commands form, tests, remove quota_reset_interval
- Enable ProTable search on Accounts (username/email), Models (model_id/alias), Providers (display_name/name) with hideInSearch for non-searchable columns - Add scenarios (Select tags) and quick_commands (Form.List) to AgentTemplates create form, plus service type updates - Remove unused quota_reset_interval from ProviderKey model, key_pool SQL, handlers, and frontend types; add migration + bump schema to v11 - Add Vitest config, test setup, request interceptor tests (7 cases), authStore tests (8 cases) — all 15 passing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
43
admin-v2/tests/setup.ts
Normal file
43
admin-v2/tests/setup.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
// ============================================================
|
||||
// Test setup: globals, jsdom polyfills, localStorage mock
|
||||
// ============================================================
|
||||
|
||||
import { beforeAll, beforeEach, vi } from 'vitest'
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
// ── localStorage mock (jsdom provides one but we ensure clean state) ──────
|
||||
|
||||
beforeEach(() => {
|
||||
localStorage.clear()
|
||||
})
|
||||
|
||||
// ── Ant Design / rc-util requires matchMedia ──────────────────────────────
|
||||
|
||||
beforeAll(() => {
|
||||
Object.defineProperty(window, 'matchMedia', {
|
||||
writable: true,
|
||||
value: vi.fn().mockImplementation((query: string) => ({
|
||||
matches: false,
|
||||
media: query,
|
||||
onchange: null,
|
||||
addListener: vi.fn(),
|
||||
removeListener: vi.fn(),
|
||||
addEventListener: vi.fn(),
|
||||
removeEventListener: vi.fn(),
|
||||
dispatchEvent: vi.fn(),
|
||||
})),
|
||||
})
|
||||
|
||||
// Ant Design's scrollTo polyfill
|
||||
window.scrollTo = vi.fn()
|
||||
|
||||
// React 19 + jsdom: ensure getComputedStyle returns something useful
|
||||
const originalGetComputedStyle = window.getComputedStyle
|
||||
window.getComputedStyle = (elt: Element, pseudoElt?: string | null) => {
|
||||
try {
|
||||
return originalGetComputedStyle(elt, pseudoElt)
|
||||
} catch {
|
||||
return {} as CSSStyleDeclaration
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user