Hide Schedule button when more than 1 file selected and update tests

Co-authored-by: cadtoolbox <12723486+cadtoolbox@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-04 10:32:56 +00:00
co-authored by cadtoolbox
parent c695d69c75
commit 358394402c
2 changed files with 40 additions and 6 deletions
@@ -77,6 +77,20 @@ const mockFiles = [
duplicate_count: 2,
created_at: '2024-01-02T00:00:00Z',
},
{
id: 3,
filename: 'cube.gcode.3mf',
file_path: '/library/cube.gcode.3mf',
file_size: 2048576,
file_type: '3mf',
folder_id: null,
thumbnail_path: '/thumbnails/3.png',
print_name: 'Cube',
print_time_seconds: 1800,
print_count: 2,
duplicate_count: 0,
created_at: '2024-01-03T00:00:00Z',
},
];
const mockStats = {
@@ -460,7 +474,26 @@ describe('FileManagerPage', () => {
});
describe('schedule print', () => {
it('shows schedule print button for sliced files', async () => {
it('shows schedule print button when one sliced file is selected', async () => {
const user = userEvent.setup();
render(<FileManagerPage />);
await waitFor(() => {
expect(screen.getByText('Benchy')).toBeInTheDocument();
});
// Select a sliced file (benchy.gcode.3mf) by clicking on its card
const fileCard = screen.getByText('Benchy').closest('div[class*="cursor-pointer"]');
if (fileCard) {
await user.click(fileCard);
}
await waitFor(() => {
expect(screen.getByText(/Schedule/)).toBeInTheDocument();
});
});
it('hides schedule print button when multiple files are selected', async () => {
const user = userEvent.setup();
render(<FileManagerPage />);
@@ -468,11 +501,12 @@ describe('FileManagerPage', () => {
expect(screen.getByText('Select All')).toBeInTheDocument();
});
// Select a sliced file (benchy.gcode.3mf)
// Select all files
await user.click(screen.getByText('Select All'));
await waitFor(() => {
expect(screen.getByText(/Schedule/)).toBeInTheDocument();
// Schedule button should not be present when multiple files are selected
expect(screen.queryByText(/Schedule/)).not.toBeInTheDocument();
});
});
});
+3 -3
View File
@@ -1877,9 +1877,9 @@ export function FileManagerPage() {
<span className="hidden sm:inline">{t('common.print')}</span>
</Button>
)}
{selectedSlicedFiles.length > 0 && (
{selectedSlicedFiles.length === 1 && (
<Button
variant={selectedSlicedFiles.length === 1 ? 'secondary' : 'primary'}
variant="secondary"
size="sm"
// Note: Schedule dialog (PrintModal) is designed for single file at a time
// but supports scheduling to multiple printers. This provides more control
@@ -1889,7 +1889,7 @@ export function FileManagerPage() {
title={!hasPermission('queue:create') ? t('fileManager.noPermissionAddToQueue') : undefined}
>
<Clock className="w-4 h-4 sm:mr-1" />
<span className="hidden sm:inline">{`${t('fileManager.schedulePrint')}${selectedSlicedFiles.length < selectedFiles.length ? ` (${selectedSlicedFiles.length})` : ''}`}</span>
<span className="hidden sm:inline">{t('fileManager.schedulePrint')}</span>
</Button>
)}
<Button