chore: clean git cache
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
import { QueryClient, QueryKey } from '@tanstack/react-query'
|
||||
|
||||
interface InitialDataEntry {
|
||||
key: QueryKey
|
||||
data: unknown
|
||||
}
|
||||
|
||||
export function createTestQueryClient(initialData: InitialDataEntry[] = []) {
|
||||
const client = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: { retry: false, gcTime: Infinity },
|
||||
mutations: { retry: false },
|
||||
},
|
||||
})
|
||||
|
||||
initialData.forEach(({ key, data }) => client.setQueryData(key, data))
|
||||
return client
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
import { ProxyHost } from '../hooks/useProxyHosts'
|
||||
import { RemoteServer } from '../hooks/useRemoteServers'
|
||||
|
||||
export const mockProxyHosts: ProxyHost[] = [
|
||||
{
|
||||
uuid: '123e4567-e89b-12d3-a456-426614174000',
|
||||
name: 'App Local',
|
||||
domain_names: 'app.local.dev',
|
||||
forward_scheme: 'http',
|
||||
forward_host: 'localhost',
|
||||
forward_port: 3000,
|
||||
ssl_forced: false,
|
||||
http2_support: true,
|
||||
hsts_enabled: false,
|
||||
hsts_subdomains: false,
|
||||
block_exploits: true,
|
||||
websocket_support: true,
|
||||
application: 'none',
|
||||
locations: [],
|
||||
advanced_config: undefined,
|
||||
enabled: true,
|
||||
created_at: '2025-11-18T10:00:00Z',
|
||||
updated_at: '2025-11-18T10:00:00Z',
|
||||
},
|
||||
{
|
||||
uuid: '223e4567-e89b-12d3-a456-426614174001',
|
||||
name: 'API Local',
|
||||
domain_names: 'api.local.dev',
|
||||
forward_scheme: 'http',
|
||||
forward_host: '192.168.1.100',
|
||||
forward_port: 8080,
|
||||
ssl_forced: false,
|
||||
http2_support: true,
|
||||
hsts_enabled: false,
|
||||
hsts_subdomains: false,
|
||||
block_exploits: true,
|
||||
websocket_support: false,
|
||||
application: 'none',
|
||||
locations: [],
|
||||
advanced_config: undefined,
|
||||
enabled: true,
|
||||
created_at: '2025-11-18T10:00:00Z',
|
||||
updated_at: '2025-11-18T10:00:00Z',
|
||||
},
|
||||
]
|
||||
|
||||
export const mockRemoteServers: RemoteServer[] = [
|
||||
{
|
||||
uuid: '323e4567-e89b-12d3-a456-426614174002',
|
||||
name: 'Local Docker Registry',
|
||||
provider: 'docker',
|
||||
host: 'localhost',
|
||||
port: 5000,
|
||||
username: undefined,
|
||||
enabled: true,
|
||||
reachable: false,
|
||||
last_check: undefined,
|
||||
created_at: '2025-11-18T10:00:00Z',
|
||||
updated_at: '2025-11-18T10:00:00Z',
|
||||
},
|
||||
{
|
||||
uuid: '423e4567-e89b-12d3-a456-426614174003',
|
||||
name: 'Development API Server',
|
||||
provider: 'generic',
|
||||
host: '192.168.1.100',
|
||||
port: 8080,
|
||||
username: undefined,
|
||||
enabled: true,
|
||||
reachable: true,
|
||||
last_check: '2025-11-18T10:00:00Z',
|
||||
created_at: '2025-11-18T10:00:00Z',
|
||||
updated_at: '2025-11-18T10:00:00Z',
|
||||
},
|
||||
]
|
||||
|
||||
export const mockImportPreview = {
|
||||
hosts: [
|
||||
{
|
||||
domain_names: 'test.example.com',
|
||||
forward_scheme: 'http',
|
||||
forward_host: 'localhost',
|
||||
forward_port: 8080,
|
||||
ssl_forced: true,
|
||||
http2_support: true,
|
||||
websocket_support: false,
|
||||
},
|
||||
],
|
||||
conflicts: ['app.local.dev'],
|
||||
errors: [],
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
|
||||
describe('Test setup file checks', () => {
|
||||
it('sets the React act environment flag', () => {
|
||||
expect(globalThis.IS_REACT_ACT_ENVIRONMENT).toBe(true)
|
||||
})
|
||||
|
||||
it('stubs window.matchMedia with expected interface', () => {
|
||||
const mq = window.matchMedia('(min-width: 100px)')
|
||||
expect(mq.matches).toBe(false)
|
||||
expect(typeof mq.addListener).toBe('function')
|
||||
expect(typeof mq.removeListener).toBe('function')
|
||||
expect(typeof mq.addEventListener).toBe('function')
|
||||
expect(typeof mq.removeEventListener).toBe('function')
|
||||
})
|
||||
})
|
||||
@@ -1,93 +0,0 @@
|
||||
// Ensure React's act environment flag is set for React 18+ to avoid warnings
|
||||
// This must be set before importing testing utilities.
|
||||
// See: https://github.com/facebook/react/issues/24560#issuecomment-1021997243
|
||||
declare global { var IS_REACT_ACT_ENVIRONMENT: boolean | undefined }
|
||||
globalThis.IS_REACT_ACT_ENVIRONMENT = true
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
import { cleanup } from '@testing-library/react'
|
||||
import { afterEach, vi } from 'vitest'
|
||||
|
||||
// Global mock for react-i18next to return English translations in tests
|
||||
// The import must be done inside the factory since vi.mock is hoisted
|
||||
vi.mock('react-i18next', async () => {
|
||||
// Dynamic import inside the factory ensures translations are loaded
|
||||
const enTranslations = await import('../locales/en/translation.json').then(m => m.default)
|
||||
|
||||
// Helper to get nested translation value by dot-notation key
|
||||
function getTranslation(key: string): string {
|
||||
const keys = key.split('.')
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let result: any = enTranslations
|
||||
for (const k of keys) {
|
||||
if (result && typeof result === 'object' && k in result) {
|
||||
result = result[k]
|
||||
} else {
|
||||
// Key not found, return the key itself
|
||||
return key
|
||||
}
|
||||
}
|
||||
return typeof result === 'string' ? result : key
|
||||
}
|
||||
|
||||
return {
|
||||
useTranslation: () => ({
|
||||
t: (key: string, options?: Record<string, unknown>) => {
|
||||
let result = getTranslation(key)
|
||||
// Handle interpolation: replace {{variable}} with the value from options
|
||||
if (options && typeof result === 'string') {
|
||||
Object.entries(options).forEach(([k, v]) => {
|
||||
result = result.replace(new RegExp(`\\{\\{${k}\\}\\}`, 'g'), String(v))
|
||||
})
|
||||
}
|
||||
return result
|
||||
},
|
||||
i18n: {
|
||||
changeLanguage: vi.fn(),
|
||||
language: 'en',
|
||||
},
|
||||
}),
|
||||
Trans: ({ children }: { children: React.ReactNode }) => children,
|
||||
initReactI18next: { type: '3rdParty', init: () => {} },
|
||||
}
|
||||
})
|
||||
|
||||
// Cleanup after each test
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
})
|
||||
|
||||
// Mock window.matchMedia
|
||||
Object.defineProperty(window, 'matchMedia', {
|
||||
writable: true,
|
||||
value: (query: string) => ({
|
||||
matches: false,
|
||||
media: query,
|
||||
onchange: null,
|
||||
addListener: () => {},
|
||||
removeListener: () => {},
|
||||
addEventListener: () => {},
|
||||
removeEventListener: () => {},
|
||||
dispatchEvent: () => {},
|
||||
}),
|
||||
})
|
||||
|
||||
// Filter noisy React act environment warnings that can appear in some environments
|
||||
const _origConsoleError = console.error
|
||||
console.error = (...args: unknown[]) => {
|
||||
try {
|
||||
const msg = args[0]
|
||||
if (typeof msg === 'string') {
|
||||
if (
|
||||
msg.includes("The current testing environment is not configured to support act(") ||
|
||||
msg.includes('Test connection failed') ||
|
||||
msg.includes('Connection failed')
|
||||
) {
|
||||
return
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// fallthrough to original
|
||||
}
|
||||
_origConsoleError.apply(console, args)
|
||||
}
|
||||
Reference in New Issue
Block a user