Skip to content

Commit

Permalink
Fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
villepynttari committed Sep 6, 2024
1 parent 933ae2e commit c74f4ab
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion frontend/src/components/BottomDrawer/BottomDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ interface Props {
disableSwipeToOpen: boolean;
mounted?: boolean;
zindex?: number;
testId?: string;
}

const BottomDrawer = (props: Props) => {
Expand Down Expand Up @@ -162,7 +163,7 @@ const BottomDrawer = (props: Props) => {
}}
/>
<Drawer
data-testid="BottomDrawer"
data-testid={props.testId || 'BottomDrawer'}
anchor="bottom"
open={isOpen}
onClose={toggleDrawer(false)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ const AlterBookingDrawer = (props: Props) => {
toggle={toggle}
disableSwipeToOpen={true}
zindex={1200}
testId={'BookingDrawer'}
>
<Box
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('Duration selection from picker', () => {
const hour1 = getByText(hours, '01');
fireEvent.click(hour1);

const btn = screen.getByRole('button');
const btn = screen.getByTestId('set-duration-button');

fireEvent.click(btn);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const DurationTimePickerDrawer = (props: DurationTimePickerDrawerProps) => {
<Row>
<DrawerButtonPrimary
aria-label="confirm"
data-testid={'set-duration-button'}
onClick={() => handleSetDuration()}
>
Confirm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/util/TimeLeft.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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')
);
});

Expand All @@ -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/)
);
});
});

0 comments on commit c74f4ab

Please sign in to comment.