From 10d1f8d42888442f93ab8e166af3de6fd2ad61d1 Mon Sep 17 00:00:00 2001 From: Maurice Date: Sat, 18 Apr 2026 00:25:06 +0200 Subject: [PATCH] test(todo): update add-task tests for toolbar button migration The "Add new task..." button moved from the panel into the shared toolbar and is triggered via addItemSignal. Rewrite the three affected tests to drive that signal through a rerender instead of clicking the removed in-panel button. --- .../components/Todo/TodoListPanel.test.tsx | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/client/src/components/Todo/TodoListPanel.test.tsx b/client/src/components/Todo/TodoListPanel.test.tsx index 7538a663..d5b83d69 100644 --- a/client/src/components/Todo/TodoListPanel.test.tsx +++ b/client/src/components/Todo/TodoListPanel.test.tsx @@ -37,9 +37,10 @@ describe('TodoListPanel', () => { expect(screen.getByText('Buy tickets')).toBeInTheDocument(); }); - it('FE-COMP-TODO-002: shows Add new task button', () => { - render(); - expect(screen.getByText('Add new task...')).toBeInTheDocument(); + it('FE-COMP-TODO-002: raising addItemSignal opens the new task form', async () => { + const { rerender } = render(); + rerender(); + await screen.findByText('Create task'); }); it('FE-COMP-TODO-003: sidebar filter buttons are rendered', () => { @@ -119,11 +120,9 @@ describe('TodoListPanel', () => { expect(screen.getByText(/1 \/ 2 completed/i)).toBeInTheDocument(); }); - it('FE-COMP-TODO-011: clicking Add new task opens detail form', async () => { - const user = userEvent.setup(); - render(); - await user.click(screen.getByText('Add new task...')); - // The detail pane shows "Create task" button + it('FE-COMP-TODO-011: raising addItemSignal opens detail form with Create task button', async () => { + const { rerender } = render(); + rerender(); await screen.findByText('Create task'); }); @@ -398,15 +397,12 @@ describe('TodoListPanel', () => { return HttpResponse.json({ item: buildTodoItem({ id: 99, name: 'Brand New Task' }) }); }), ); - render(); - // Open the new task pane - await user.click(screen.getByText('Add new task...')); - // Wait for "Create task" button to appear + const { rerender } = render(); + // Raising the signal opens the new task pane (simulates the toolbar button click) + rerender(); await screen.findByText('Create task'); - // Type a task name in the autoFocus input (Task name placeholder) const nameInput = screen.getByPlaceholderText('Task name'); await user.type(nameInput, 'Brand New Task'); - // Click the Create task button await user.click(screen.getByText('Create task')); await waitFor(() => expect(postCalled).toBe(true)); });