|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
knowledge: { |
|
|
knowledge: { |
|
|
key: '@knowledge', |
|
|
key: '@knowledge', |
|
|
shortcut: '@knowledge', |
|
|
|
|
|
|
|
|
shortcut: '@kb', |
|
|
title: 'Search Knowledge', |
|
|
title: 'Search Knowledge', |
|
|
description: 'Search knowledge bases', |
|
|
description: 'Search knowledge bases', |
|
|
search: jest.fn(), |
|
|
search: jest.fn(), |
|
|
|
|
|
|
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@knowledge')).toBeInTheDocument() |
|
|
|
|
|
|
|
|
expect(screen.getByTestId('command-item-@kb')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@plugin')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@plugin')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@node')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@node')).toBeInTheDocument() |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@knowledge')).toBeInTheDocument() |
|
|
|
|
|
|
|
|
expect(screen.getByTestId('command-item-@kb')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@plugin')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@plugin')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@node')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@node')).toBeInTheDocument() |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
expect(screen.queryByTestId('command-item-@app')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@app')).not.toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@knowledge')).toBeInTheDocument() |
|
|
|
|
|
|
|
|
expect(screen.getByTestId('command-item-@kb')).toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@plugin')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@plugin')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@node')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@node')).not.toBeInTheDocument() |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@knowledge')).not.toBeInTheDocument() |
|
|
|
|
|
|
|
|
expect(screen.queryByTestId('command-item-@kb')).not.toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@plugin')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@plugin')).toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@node')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@node')).not.toBeInTheDocument() |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@knowledge')).not.toBeInTheDocument() |
|
|
|
|
|
|
|
|
expect(screen.queryByTestId('command-item-@kb')).not.toBeInTheDocument() |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
it('should match partial strings', () => { |
|
|
it('should match partial strings', () => { |
|
|
|
|
|
|
|
|
<CommandSelector |
|
|
<CommandSelector |
|
|
actions={mockActions} |
|
|
actions={mockActions} |
|
|
onCommandSelect={mockOnCommandSelect} |
|
|
onCommandSelect={mockOnCommandSelect} |
|
|
searchFilter="nowl" |
|
|
|
|
|
|
|
|
searchFilter="od" |
|
|
/>, |
|
|
/>, |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
expect(screen.queryByTestId('command-item-@app')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@app')).not.toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@knowledge')).toBeInTheDocument() |
|
|
|
|
|
|
|
|
expect(screen.queryByTestId('command-item-@kb')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@plugin')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@plugin')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@node')).not.toBeInTheDocument() |
|
|
|
|
|
|
|
|
expect(screen.getByTestId('command-item-@node')).toBeInTheDocument() |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
expect(screen.queryByTestId('command-item-@app')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@app')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@knowledge')).not.toBeInTheDocument() |
|
|
|
|
|
|
|
|
expect(screen.queryByTestId('command-item-@kb')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@plugin')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@plugin')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@node')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@node')).not.toBeInTheDocument() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/>, |
|
|
/>, |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
expect(mockOnCommandValueChange).toHaveBeenCalledWith('@knowledge') |
|
|
|
|
|
|
|
|
expect(mockOnCommandValueChange).toHaveBeenCalledWith('@kb') |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
it('should not call onCommandValueChange if current value still exists', () => { |
|
|
it('should not call onCommandValueChange if current value still exists', () => { |
|
|
|
|
|
|
|
|
/>, |
|
|
/>, |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
const knowledgeItem = screen.getByTestId('command-item-@knowledge') |
|
|
|
|
|
|
|
|
const knowledgeItem = screen.getByTestId('command-item-@kb') |
|
|
fireEvent.click(knowledgeItem) |
|
|
fireEvent.click(knowledgeItem) |
|
|
|
|
|
|
|
|
expect(mockOnCommandSelect).toHaveBeenCalledWith('@knowledge') |
|
|
|
|
|
|
|
|
expect(mockOnCommandSelect).toHaveBeenCalledWith('@kb') |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@knowledge')).toBeInTheDocument() |
|
|
|
|
|
|
|
|
expect(screen.getByTestId('command-item-@kb')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@plugin')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@plugin')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@node')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@node')).toBeInTheDocument() |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@knowledge')).toBeInTheDocument() |
|
|
|
|
|
|
|
|
expect(screen.getByTestId('command-item-@kb')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@plugin')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@plugin')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@node')).toBeInTheDocument() |
|
|
expect(screen.getByTestId('command-item-@node')).toBeInTheDocument() |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
/>, |
|
|
/>, |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
expect(screen.getByTestId('command-item-@knowledge')).toBeInTheDocument() |
|
|
|
|
|
|
|
|
expect(screen.getByTestId('command-item-@kb')).toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@app')).not.toBeInTheDocument() |
|
|
expect(screen.queryByTestId('command-item-@app')).not.toBeInTheDocument() |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |