Files
aiturk-hermes-ide/apps/desktop/src/app/settings/compression-settings.test.tsx
T
yilsem 91ecad8e5c
Server CI and Windows package / verify (push) Successful in 4m47s
Server CI and Windows package / windows-package (push) Successful in 8m47s
Preserve native Codex history and add configurable cross-model compression
Separate encrypted reasoning from actual compaction, stop migration after native return, and retain full history and recent exchanges. Add typed settings, Gemini fallback, verified provider windows, bounded summaries and durable concurrent checkpoints.

Validation: 245 bridge tests plus focused concurrency tests; 71 settings/connection tests; 66 supplementary tests; TypeScript checks; renderer and Electron bundles; real primary/native/fallback summary probes and 700K input acceptance.
2026-10-13 03:36:42 +03:00

38 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
import { afterEach, expect, it, vi } from 'vitest'
import { I18nProvider } from '@/i18n/context'
import defaults from '../../../assets/codex-bridge/compression-defaults.json'
import { CompressionSettingsView } from './compression-settings'
afterEach(() => { cleanup(); delete (window as unknown as { hermesDesktop?: unknown }).hermesDesktop })
it('loads settings, excludes small fallback models, and saves the selected values', async () => {
const state = { settings: defaults, modelsAvailable: true, models: [
{ id: 'ide/small', name: 'Small', window: 32768, source: 'catalog' },
{ id: 'ide/large', name: 'Large', window: 1000000, source: 'catalog' }
] }
const save = vi.fn(async settings => ({ ...state, settings }))
;(window as unknown as { hermesDesktop: unknown }).hermesDesktop = { codexLink: { getCompression: async () => state, setCompression: save } }
render(<I18nProvider configClient={null} initialLocale="tr"><CompressionSettingsView /></I18nProvider>)
const keep = await screen.findByRole('spinbutton', { name: 'Korunan son mesajlaşma sayısı' })
expect((keep as HTMLInputElement).value).toBe('10')
const fallback = screen.getByRole('combobox', { name: 'Yedek sıkıştırıcı (1M)' })
expect(fallback.textContent).not.toContain('Small')
fireEvent.change(keep, { target: { value: '12' } })
fireEvent.change(fallback, { target: { value: 'ide/large' } })
fireEvent.click(screen.getByRole('button', { name: 'Kaydet' }))
await waitFor(() => expect(save).toHaveBeenCalledWith(expect.objectContaining({ keepTurns: 12, fallbackModel: 'ide/large' })))
expect(await screen.findByText('Kaydedildi. Sonraki hazırlıkta uygulanacak.')).toBeTruthy()
})
it('shows a failed save without claiming success', async () => {
const save = vi.fn().mockRejectedValue(new Error('disk unavailable'))
;(window as unknown as { hermesDesktop: unknown }).hermesDesktop = { codexLink: { getCompression: async () => ({ settings: defaults, models: [], modelsAvailable: false }), setCompression: save } }
render(<I18nProvider configClient={null} initialLocale="tr"><CompressionSettingsView /></I18nProvider>)
fireEvent.click(await screen.findByRole('button', { name: 'Kaydet' }))
expect((await screen.findByRole('alert')).textContent).toContain('Kaydedilemedi')
})