From 358394402c04b4530136040139eae45099ee4e8b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 10:32:56 +0000 Subject: [PATCH] Hide Schedule button when more than 1 file selected and update tests Co-authored-by: cadtoolbox <12723486+cadtoolbox@users.noreply.github.com> --- .../__tests__/pages/FileManagerPage.test.tsx | 40 +++++++++++++++++-- frontend/src/pages/FileManagerPage.tsx | 6 +-- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/frontend/src/__tests__/pages/FileManagerPage.test.tsx b/frontend/src/__tests__/pages/FileManagerPage.test.tsx index 66a166353..538cce157 100644 --- a/frontend/src/__tests__/pages/FileManagerPage.test.tsx +++ b/frontend/src/__tests__/pages/FileManagerPage.test.tsx @@ -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(); + + 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(); @@ -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(); }); }); }); diff --git a/frontend/src/pages/FileManagerPage.tsx b/frontend/src/pages/FileManagerPage.tsx index 1f4e7bdc6..3a0a6437e 100644 --- a/frontend/src/pages/FileManagerPage.tsx +++ b/frontend/src/pages/FileManagerPage.tsx @@ -1877,9 +1877,9 @@ export function FileManagerPage() { {t('common.print')} )} - {selectedSlicedFiles.length > 0 && ( + {selectedSlicedFiles.length === 1 && ( )}