Download desktop/src/components/shared/UpdateChecker.test.tsx from chenbhao/codev: direct link, hf CLI and curl.
- Browser
- Download file 2.32 kB
-
https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/components/shared/UpdateChecker.test.tsx
- Command line
-
hf download hf://chenbhao/codev@e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/components/shared/UpdateChecker.test.tsx
-
curl -L -o UpdateChecker.test.tsx https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/components/shared/UpdateChecker.test.tsx
2.32 kB
| import { beforeEach, describe, expect, it, vi } from 'vitest' | |
| import { render, screen } from '@testing-library/react' | |
| import '@testing-library/jest-dom' | |
| import { UpdateChecker } from './UpdateChecker' | |
| import { useSettingsStore } from '../../stores/settingsStore' | |
| import { useUpdateStore } from '../../stores/updateStore' | |
| describe('UpdateChecker', () => { | |
| beforeEach(() => { | |
| useSettingsStore.setState({ locale: 'en' }) | |
| Object.defineProperty(window, '__TAURI__', { | |
| value: {}, | |
| configurable: true, | |
| }) | |
| useUpdateStore.setState({ | |
| status: 'available', | |
| availableVersion: '0.1.5', | |
| releaseNotes: '# Versper AI Claw v0.1.5\n\n[Release notes](https://example.com/releases/v0.1.5)', | |
| progressPercent: 0, | |
| downloadedBytes: 0, | |
| totalBytes: null, | |
| error: null, | |
| checkedAt: null, | |
| shouldPrompt: true, | |
| initialize: vi.fn().mockResolvedValue(undefined), | |
| checkForUpdates: vi.fn().mockResolvedValue(null), | |
| installUpdate: vi.fn().mockResolvedValue(undefined), | |
| dismissPrompt: vi.fn(), | |
| }) | |
| }) | |
| it('renders markdown release notes in the update prompt', () => { | |
| render(<UpdateChecker />) | |
| expect(screen.getByText('v0.1.5 available')).toBeInTheDocument() | |
| expect(screen.getByRole('heading', { name: 'Versper AI Claw v0.1.5' })).toBeInTheDocument() | |
| const link = screen.getByRole('link', { name: 'Release notes' }) | |
| expect(link).toHaveAttribute('href', 'https://example.com/releases/v0.1.5') | |
| expect(link).toHaveAttribute('target', '_blank') | |
| }) | |
| it('shows downloaded bytes when the updater does not provide total size', () => { | |
| useUpdateStore.setState({ | |
| status: 'downloading', | |
| availableVersion: '0.1.5', | |
| releaseNotes: '# Versper AI Claw v0.1.5', | |
| progressPercent: 0, | |
| downloadedBytes: 1536, | |
| totalBytes: null, | |
| error: null, | |
| checkedAt: null, | |
| shouldPrompt: true, | |
| initialize: vi.fn().mockResolvedValue(undefined), | |
| checkForUpdates: vi.fn().mockResolvedValue(null), | |
| installUpdate: vi.fn().mockResolvedValue(undefined), | |
| dismissPrompt: vi.fn(), | |
| }) | |
| render(<UpdateChecker />) | |
| expect(screen.getByText('Downloading update... 1.5 KB downloaded')).toBeInTheDocument() | |
| expect(screen.queryByText(/0%/)).not.toBeInTheDocument() | |
| }) | |
| }) | |