mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-01 20:36:21 -05:00
Fixing error where focusing on an empty Directory search would throw an error.
This commit is contained in:
parent
bf1ec42cc7
commit
16070e98b3
3 changed files with 30 additions and 4 deletions
|
|
@ -99,6 +99,29 @@ describe('DirectorySearch', () => {
|
|||
expect(input).toBeDisabled();
|
||||
});
|
||||
|
||||
it('renders the dropdown without crashing when directoryName is null', async () => {
|
||||
// An unset form field (e.g. the new Channel page) passes a null value. With
|
||||
// isDir=false a "New Directory" result is built from directoryName; if that title is
|
||||
// null, Semantic UI's Search crashes reading null.length when the menu opens.
|
||||
setMockHookState({
|
||||
directories: [],
|
||||
channelDirectories: [],
|
||||
domainDirectories: [],
|
||||
isDir: false,
|
||||
directoryName: null,
|
||||
});
|
||||
|
||||
render(<DirectorySearch onSelect={mockOnSelect} value={null}/>);
|
||||
|
||||
const input = screen.getByPlaceholderText(/search directory names/i);
|
||||
// Opening the menu (as Tab/focus does in the browser) must not throw.
|
||||
await userEvent.click(input);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/New Directory/i)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('displays with required indicator', () => {
|
||||
const {container} = render(
|
||||
<DirectorySearch onSelect={mockOnSelect} value="" required/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue