Files
DeepTutor/web/tests/book-library-error.spec.tsx
Bingxi Zhao (Frank) da856ad670 release: v1.6.9
Ship folder-based workspaces and data migration, daily practice, redesigned
provider and model settings, and streaming conversation improvements.
Synchronize README translations and document the archive/permanent-delete
upgrade behavior in assets/releases/ver1-6-9.md.

Reduce initial JavaScript by deduplicating English resources and loading
animation features after hydration. Keep the existing route size budgets.
Update regression fixtures and browser audits for scoped URLs and the new
settings and learning interfaces.
2026-09-21 02:30:40 +08:00

27 lines
925 B
TypeScript

import React from 'react'
import { fireEvent, render, screen } from '@testing-library/react'
import { expect, it, vi } from 'vitest'
import BookLibrary from '@/app/(workspace)/learning/books/components/BookLibrary'
vi.mock('react-i18next', () => ({
useTranslation: () => ({ t: (key: string) => key, i18n: { language: 'en' } }),
}))
it('a failed book list offers retry without claiming the library is empty', () => {
const retry = vi.fn()
render(
<BookLibrary
books={[]}
loading={false}
error="Failed to load books"
onRetry={retry}
canCreate={false}
onNewBook={vi.fn()}
onSelectBook={vi.fn()}
onDeleteBook={vi.fn()}
/>
)
expect(screen.getByRole('alert')).toHaveTextContent('Failed to load books')
expect(screen.queryByText('No books yet')).toBeNull()
fireEvent.click(screen.getByRole('button', { name: 'Retry' }))
expect(retry).toHaveBeenCalledOnce()
})