mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 09:38:54 +00:00
fix: close file picker on outside click and modal dismiss
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// FE-PLANNER-RESMODAL-001 to FE-PLANNER-RESMODAL-093
|
||||
// FE-PLANNER-RESMODAL-001 to FE-PLANNER-RESMODAL-095
|
||||
import { render, screen, waitFor, fireEvent, within } from '../../../tests/helpers/render';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
@@ -558,6 +558,35 @@ describe('ReservationModal', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('FE-PLANNER-RESMODAL-094: an outside pointer closes the file picker while an inside pointer keeps it open', async () => {
|
||||
const res = buildReservation({ id: 5 });
|
||||
const unattachedFile = buildTripFile({ id: 99, original_name: 'invoice.pdf' });
|
||||
|
||||
render(<ReservationModal {...defaultProps} reservation={res} files={[unattachedFile]} />);
|
||||
await userEvent.click(screen.getByRole('button', { name: /Link existing file/i }));
|
||||
|
||||
const pickerItem = screen.getByText('invoice.pdf');
|
||||
fireEvent.pointerDown(pickerItem);
|
||||
expect(screen.getByText('invoice.pdf')).toBeInTheDocument();
|
||||
|
||||
fireEvent.pointerDown(document.body);
|
||||
expect(screen.queryByText('invoice.pdf')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-PLANNER-RESMODAL-095: closing and reopening the modal resets the file picker', async () => {
|
||||
const res = buildReservation({ id: 5 });
|
||||
const unattachedFile = buildTripFile({ id: 99, original_name: 'invoice.pdf' });
|
||||
const { rerender } = render(<ReservationModal {...defaultProps} reservation={res} files={[unattachedFile]} />);
|
||||
|
||||
await userEvent.click(screen.getByRole('button', { name: /Link existing file/i }));
|
||||
expect(screen.getByText('invoice.pdf')).toBeInTheDocument();
|
||||
|
||||
rerender(<ReservationModal {...defaultProps} isOpen={false} reservation={res} files={[unattachedFile]} />);
|
||||
rerender(<ReservationModal {...defaultProps} reservation={res} files={[unattachedFile]} />);
|
||||
|
||||
expect(screen.queryByText('invoice.pdf')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-PLANNER-RESMODAL-040: removing pending file removes it from list', async () => {
|
||||
render(<ReservationModal {...defaultProps} reservation={null} />);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user