From 750b178d5be6cd89b1c077b4bc2369fc2ceb2e86 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 1 Oct 2026 10:43:53 +0200 Subject: [PATCH] test(client): follow the password checklist and the labelled modal close in three suites --- client/src/components/Packing/PackingExportMenu.test.tsx | 4 +++- client/src/pages/AdminPage.test.tsx | 2 +- client/src/pages/LoginPage.test.tsx | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client/src/components/Packing/PackingExportMenu.test.tsx b/client/src/components/Packing/PackingExportMenu.test.tsx index 4f25b869c..f288ae188 100644 --- a/client/src/components/Packing/PackingExportMenu.test.tsx +++ b/client/src/components/Packing/PackingExportMenu.test.tsx @@ -94,7 +94,9 @@ describe('PackingPrintPreview', () => { Object.defineProperty(frame, 'contentWindow', { value: { print }, configurable: true }) await user.click(screen.getByRole('button', { name: 'Print or save as PDF' })) expect(print).toHaveBeenCalledTimes(1) - await user.click(screen.getByRole('button', { name: 'Close' })) + // The modal's X and the preview's own button both close; the footer one is pressed here. + const closeButtons = screen.getAllByRole('button', { name: 'Close' }) + await user.click(closeButtons[closeButtons.length - 1]) expect(onClose).toHaveBeenCalledTimes(1) }) }) diff --git a/client/src/pages/AdminPage.test.tsx b/client/src/pages/AdminPage.test.tsx index 0ee684313..3201cfabb 100644 --- a/client/src/pages/AdminPage.test.tsx +++ b/client/src/pages/AdminPage.test.tsx @@ -301,7 +301,7 @@ describe('AdminPage', () => { fireEvent.change(screen.getByPlaceholderText('Username'), { target: { value: 'newuser' } }); fireEvent.change(screen.getByPlaceholderText('Email'), { target: { value: 'newuser@example.com' } }); - fireEvent.change(screen.getByPlaceholderText('Password'), { target: { value: 'securepassword123' } }); + fireEvent.change(screen.getByPlaceholderText('Password'), { target: { value: 'SecurePassw0rd!23' } }); // The modal footer has a second "Create User" button const createButtons = screen.getAllByRole('button', { name: /create user/i }); diff --git a/client/src/pages/LoginPage.test.tsx b/client/src/pages/LoginPage.test.tsx index 47b26759e..d78530cb8 100644 --- a/client/src/pages/LoginPage.test.tsx +++ b/client/src/pages/LoginPage.test.tsx @@ -388,7 +388,8 @@ describe('LoginPage', () => { await user.click(screen.getByRole('button', { name: /update password/i })); await waitFor(() => { - expect(screen.getByText(/at least 8/i)).toBeInTheDocument(); + // The error, not the checklist line under the field that says the same rule. + expect(screen.getByText('Password must be at least 8 characters')).toBeInTheDocument(); }); }); }); @@ -641,7 +642,8 @@ describe('LoginPage', () => { await user.click(screen.getByRole('button', { name: /create account/i })); await waitFor(() => { - expect(screen.getByText(/at least 8/i)).toBeInTheDocument(); + // The error, not the checklist line under the field that says the same rule. + expect(screen.getByText('Password must be at least 8 characters')).toBeInTheDocument(); }); }); });