From c74f4ab06ae2c4d27d7dcbdb465d86292cb4398a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Pyntt=C3=A4ri?= Date: Fri, 6 Sep 2024 08:51:16 +0300 Subject: [PATCH] Fixing tests --- frontend/src/components/BottomDrawer/BottomDrawer.tsx | 3 ++- frontend/src/components/CurrentBooking/AlterBookingDrawer.tsx | 1 + .../DurationTimePickerDrawer.test.tsx | 2 +- .../DurationTimePickerDrawer/DurationTimePickerDrawer.tsx | 1 + .../StartingTimePickerDrawer.test.tsx | 2 +- frontend/src/components/util/TimeLeft.test.tsx | 4 ++-- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/BottomDrawer/BottomDrawer.tsx b/frontend/src/components/BottomDrawer/BottomDrawer.tsx index 7078a87..e3d6bbe 100644 --- a/frontend/src/components/BottomDrawer/BottomDrawer.tsx +++ b/frontend/src/components/BottomDrawer/BottomDrawer.tsx @@ -84,6 +84,7 @@ interface Props { disableSwipeToOpen: boolean; mounted?: boolean; zindex?: number; + testId?: string; } const BottomDrawer = (props: Props) => { @@ -162,7 +163,7 @@ const BottomDrawer = (props: Props) => { }} /> { toggle={toggle} disableSwipeToOpen={true} zindex={1200} + testId={'BookingDrawer'} > { const hour1 = getByText(hours, '01'); fireEvent.click(hour1); - const btn = screen.getByRole('button'); + const btn = screen.getByTestId('set-duration-button'); fireEvent.click(btn); diff --git a/frontend/src/components/DurationTimePickerDrawer/DurationTimePickerDrawer.tsx b/frontend/src/components/DurationTimePickerDrawer/DurationTimePickerDrawer.tsx index 34df77d..4f3c931 100644 --- a/frontend/src/components/DurationTimePickerDrawer/DurationTimePickerDrawer.tsx +++ b/frontend/src/components/DurationTimePickerDrawer/DurationTimePickerDrawer.tsx @@ -100,6 +100,7 @@ const DurationTimePickerDrawer = (props: DurationTimePickerDrawerProps) => { handleSetDuration()} > Confirm diff --git a/frontend/src/components/StartingTimePickerDrawer/StartingTimePickerDrawer.test.tsx b/frontend/src/components/StartingTimePickerDrawer/StartingTimePickerDrawer.test.tsx index d8aa54d..636acc8 100644 --- a/frontend/src/components/StartingTimePickerDrawer/StartingTimePickerDrawer.test.tsx +++ b/frontend/src/components/StartingTimePickerDrawer/StartingTimePickerDrawer.test.tsx @@ -99,7 +99,7 @@ describe('Starting time selection from drawer', () => { const hour = getByText(hours, (h < 10 ? '0' : '') + h.toString()); fireEvent.click(hour); - const btn = screen.getAllByRole('button')[1]; + const btn = screen.getByTestId('ConfirmStartingTimeButton'); fireEvent.click(btn); expect(testObj.setExpandTimePickerDrawer).toBeCalledTimes(1); diff --git a/frontend/src/components/util/TimeLeft.test.tsx b/frontend/src/components/util/TimeLeft.test.tsx index 7ff61ef..cb0da97 100644 --- a/frontend/src/components/util/TimeLeft.test.tsx +++ b/frontend/src/components/util/TimeLeft.test.tsx @@ -24,7 +24,7 @@ describe('TimeLeft', () => { const timeLeftValue = await screen.findByTestId('TimeLeftTest'); await waitFor(() => - expect(timeLeftValue).toHaveTextContent('Time Left: 1 h 29 min') + expect(timeLeftValue).toHaveTextContent('1 h 29 min') ); }); @@ -41,7 +41,7 @@ describe('TimeLeft', () => { const timeLeftValue = await screen.findByTestId('TimeLeftTest'); await waitFor(() => - expect(timeLeftValue).toHaveTextContent(/Time Left: 4[45] min/) + expect(timeLeftValue).toHaveTextContent(/4[45] min/) ); }); });