Files
um-react/src/features/file-listing/__tests__/FileRow.test.tsx
T
鲁树人 d424837e66 feat: integrate platform capabilities for enhanced download management
- Refactored `DownloadAll` component to utilize platform capabilities for download types, improving flexibility in handling various download methods.
- Introduced `buildEnabledDownloadModes` function to determine available download modes based on user settings and platform capabilities.
- Updated `FileRow` and `PanelGeneral` components to conditionally render download options based on platform capabilities.
- Added tests for new functionalities in `DownloadAll`, `FileRow`, and `PanelGeneral` to ensure correct behavior under different platform conditions.
- Enhanced error handling for unsupported download methods, providing clearer feedback to users.
2026-11-01 11:32:04 +09:00

34 lines
1.3 KiB
TypeScript

import { createBrowserProvider } from '~/platform/browser/BrowserProvider';
import { renderWithProviders, screen } from '~/test-utils/test-helper';
import { untouchedFile } from './__fixture__/file-list';
import { FileRow } from '../FileRow';
import { completedFile } from './__fixture__/file-list';
test('should render basic title (ready)', () => {
renderWithProviders(<FileRow id="file://ready" file={untouchedFile} />);
expect(screen.getAllByTestId('file-row')).toHaveLength(1);
expect(screen.getByTestId('audio-meta-song-name')).toHaveTextContent('ready');
});
test('should render basic title (done)', () => {
renderWithProviders(<FileRow id="file://done" file={completedFile} />);
expect(screen.getAllByTestId('file-row')).toHaveLength(1);
expect(screen.getByTestId('audio-download')).toBeInTheDocument();
});
test('hides single-file download when platform has no downloadTypes', () => {
const platform = createBrowserProvider({
crypto: {
request: () => Promise.resolve(null as never),
enqueueDecrypt: () => Promise.reject(new Error('unused')),
},
downloadTypes: [],
});
renderWithProviders(<FileRow id="file://done" file={completedFile} />, { platform });
expect(screen.queryByTestId('audio-download')).not.toBeInTheDocument();
});