mirror of
https://github.com/hanzoai/ingress.git
synced 2026-10-26 02:47:15 +00:00
query-string 9 exports a single object, so the pagination hook reads stringify off it, the way the return-to hook already does. react-router 7 is one package. Every import names it, so the app and its tests share one router instance and one context; react-router-dom and its v5 types are gone. Vite 8 resolves tsconfig paths on its own, so vite-tsconfig-paths is gone and resolve.tsconfigPaths takes its place. faency carries @types/react 18 as a dependency. A pnpm override holds the whole tree at the React 19 types the app declares, so faency's components type as JSX components again. The rest is what React 19 and TypeScript 7 ask for: useRef takes an initial value, the error fallback narrows the unknown it is handed, sha512's output is narrowed once where it meets @noble/ed25519, and the test setup replaces fetch through vi.stubGlobal. pnpm build, pnpm tsc and pnpm test are green; eslint still waits on typescript-eslint support for TypeScript 7. Co-authored-by: Hanzo Dev <[email protected]>
91 lines
2.0 KiB
TypeScript
91 lines
2.0 KiB
TypeScript
// Match the production API mount point. `BASE_PATH` (from
|
|
// src/libs/utils.ts) reads window.APIUrl on first import; without
|
|
// this, fetches resolve to '/http/routers/<x>' instead of
|
|
// '/v1/ingress/http/routers/<x>' and miss every msw handler.
|
|
//
|
|
// Must run BEFORE the imports below — Vitest's setupFiles are
|
|
// processed in source order and the mock server captures BASE_PATH
|
|
// at module load.
|
|
const root = globalThis as unknown as { window?: { APIUrl: string } }
|
|
root.window = root.window || ({} as { APIUrl: string })
|
|
root.window.APIUrl = '/v1/ingress'
|
|
|
|
import '@testing-library/jest-dom'
|
|
import 'vitest-canvas-mock'
|
|
import '@vitest/web-worker'
|
|
|
|
import * as matchers from 'jest-extended'
|
|
import { expect } from 'vitest'
|
|
|
|
import { server } from '../src/mocks/server'
|
|
|
|
expect.extend(matchers)
|
|
|
|
export class IntersectionObserver {
|
|
root = null
|
|
rootMargin = ''
|
|
thresholds = []
|
|
scrollMargin = ''
|
|
|
|
disconnect() {
|
|
return null
|
|
}
|
|
|
|
observe() {
|
|
return null
|
|
}
|
|
|
|
takeRecords() {
|
|
return []
|
|
}
|
|
|
|
unobserve() {
|
|
return null
|
|
}
|
|
}
|
|
|
|
class ResizeObserver {
|
|
observe() {
|
|
return null
|
|
}
|
|
unobserve() {
|
|
return null
|
|
}
|
|
disconnect() {
|
|
return null
|
|
}
|
|
}
|
|
|
|
beforeAll(() => {
|
|
globalThis.IntersectionObserver = IntersectionObserver
|
|
window.IntersectionObserver = IntersectionObserver
|
|
|
|
globalThis.ResizeObserver = ResizeObserver
|
|
window.ResizeObserver = ResizeObserver
|
|
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
writable: true,
|
|
value: vi.fn().mockImplementation((query) => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: vi.fn(), // deprecated
|
|
removeListener: vi.fn(), // deprecated
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
dispatchEvent: vi.fn(),
|
|
})),
|
|
})
|
|
|
|
Object.defineProperty(window, 'scrollTo', {
|
|
writable: true,
|
|
value: vi.fn(),
|
|
})
|
|
|
|
server.listen({ onUnhandledRequest: 'error' })
|
|
})
|
|
|
|
afterEach(() => server.resetHandlers())
|
|
|
|
afterAll(() => server.close())
|