optimize register error tip
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import App from '../../App';
|
||||
import { uploadService } from '../../lib/uploadService';
|
||||
|
||||
const { useAuthMock } = vi.hoisted(() => ({
|
||||
useAuthMock: vi.fn(),
|
||||
@@ -57,7 +58,7 @@ vi.mock('../../components/LeftSidebar', () => ({
|
||||
}));
|
||||
|
||||
vi.mock('../../components/FilePreview', () => ({
|
||||
default: () => <div>preview</div>,
|
||||
default: ({ file }: { file: { id: string } | null }) => <div>{file ? `preview:${file.id}` : 'preview-empty'}</div>,
|
||||
}));
|
||||
|
||||
vi.mock('../../components/ResultPanel', () => ({
|
||||
@@ -110,3 +111,48 @@ describe('App anonymous usage limit', () => {
|
||||
expect(screen.queryByText('upload-modal')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('App initial selection', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
localStorage.clear();
|
||||
localStorage.setItem('hasSeenGuide', 'true');
|
||||
});
|
||||
|
||||
it('does not auto-select the first history record on initial load', async () => {
|
||||
useAuthMock.mockReturnValue({
|
||||
user: { id: 'u1' },
|
||||
initializing: false,
|
||||
});
|
||||
|
||||
vi.mocked(uploadService.getTaskList).mockResolvedValue({
|
||||
total: 1,
|
||||
task_list: [
|
||||
{
|
||||
task_id: 'task-1',
|
||||
file_name: 'sample.png',
|
||||
status: 2,
|
||||
origin_url: 'https://example.com/sample.png',
|
||||
task_type: 'FORMULA',
|
||||
created_at: '2026-03-06T00:00:00Z',
|
||||
latex: '',
|
||||
markdown: 'content',
|
||||
mathml: '',
|
||||
mml: '',
|
||||
image_blob: '',
|
||||
docx_url: '',
|
||||
pdf_url: '',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
render(<App />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(uploadService.getTaskList).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
expect(screen.getByText('preview-empty')).toBeInTheDocument();
|
||||
expect(screen.queryByText('preview:task-1')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user