mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-24 16:03:02 +00:00
fix(share): the user picked to invite shows in the field before it is sent
The share dialog stored the pick as String(value) while its options are keyed by numeric user ids. CustomSelect looked the pick up with a strict comparison, found nothing and left the trigger on its placeholder, although the Invite button was already enabled and the invite went through. The phone opens the same dialog from the Mehr sheet, so it showed the same. CustomSelect now compares the held value and the option values as text, so a caller holding "5" finds the option keyed 5 and the other way round. A held null or undefined still matches nothing. onChange keeps handing back the option value unchanged. No other caller mixes the two kinds today; the place form had worked around the same trap by keying its options as strings, and its comment now says why the string stays. Tests: CustomSelect matches across both kinds and marks the pick in the list, the desktop dialog shows the picked name and clears after the invite, and the phone share sheet does the same through the real dialog. Refs #2478
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// FE-COMP-MEMBERS-001 to FE-COMP-MEMBERS-056
|
||||
// FE-COMP-MEMBERS-001 to FE-COMP-MEMBERS-057
|
||||
import type { Mock } from 'vitest';
|
||||
import { act, render, screen, fireEvent, waitFor } from '../../../tests/helpers/render';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
@@ -725,6 +725,26 @@ describe('TripMembersModal', () => {
|
||||
expect(addToast).toHaveBeenCalledWith('alice added', 'success', undefined);
|
||||
});
|
||||
|
||||
// #2478: the pick showed nowhere, only the Invite button knew about it.
|
||||
it('FE-COMP-MEMBERS-057: the picked user shows in the field before the invite is sent', async () => {
|
||||
const user = userEvent.setup();
|
||||
server.use(http.post('/api/trips/1/members', () => HttpResponse.json({ success: true })));
|
||||
render(<TripMembersModal {...defaultProps} />);
|
||||
|
||||
await screen.findByText('Invite User');
|
||||
const trigger = screen.getByText('Select user…').closest('button') as HTMLButtonElement;
|
||||
await user.click(trigger);
|
||||
await user.click(await screen.findByRole('button', { name: 'alice' }));
|
||||
|
||||
expect(trigger).toHaveTextContent('alice');
|
||||
expect(screen.queryByText('Select user…')).toBeNull();
|
||||
expect(screen.getByRole('button', { name: 'Invite' })).toBeEnabled();
|
||||
|
||||
// Once sent, the field is free for the next pick again.
|
||||
await user.click(screen.getByRole('button', { name: 'Invite' }));
|
||||
await waitFor(() => expect(trigger).toHaveTextContent('Select user…'));
|
||||
});
|
||||
|
||||
it('FE-COMP-MEMBERS-042: transferring ownership reloads the app', async () => {
|
||||
const onClose = vi.fn();
|
||||
const reload = vi.fn();
|
||||
|
||||
Reference in New Issue
Block a user