mirror of
https://git.um-react.app/um/um-react.git
synced 2026-11-25 06:46:59 +00:00
- 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.
26 lines
933 B
TypeScript
26 lines
933 B
TypeScript
import { DownloadAll } from '~/components/DownloadAll';
|
|
import { createBrowserProvider } from '~/platform/browser/BrowserProvider';
|
|
import { renderWithProviders, screen } from '~/test-utils/test-helper';
|
|
|
|
test('hides download-all control when platform has no downloadTypes', () => {
|
|
const platform = createBrowserProvider({
|
|
crypto: {
|
|
request: () => Promise.resolve(null as never),
|
|
enqueueDecrypt: () => Promise.reject(new Error('unused')),
|
|
},
|
|
downloadTypes: [],
|
|
});
|
|
|
|
renderWithProviders(<DownloadAll />, { platform });
|
|
|
|
expect(screen.queryByTitle('下载全部')).not.toBeInTheDocument();
|
|
expect(document.getElementById('downloadAll')).toBeNull();
|
|
});
|
|
|
|
test('renders download-all control when PackZip is available', () => {
|
|
renderWithProviders(<DownloadAll />);
|
|
|
|
expect(screen.getByTitle('下载全部')).toBeInTheDocument();
|
|
expect(document.getElementById('downloadAll')).not.toBeNull();
|
|
});
|