[Fleet] Fix tag creation (#138603)

This commit is contained in:
Nicolas Chaulet 2022-08-11 10:14:13 -04:00 committed by GitHub
parent b0cd6f7079
commit cee2689116
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View file

@ -108,6 +108,27 @@ describe('TagsAddRemove', () => {
);
});
it('should show allow to add new tag when agent do not have any tags', () => {
allTags = [];
selectedTags = [];
const result = renderComponent('agent1');
const searchInput = result.getByTestId('addRemoveTags');
fireEvent.input(searchInput, {
target: { value: 'tag' },
});
fireEvent.click(result.getByTestId('createTagBtn'));
expect(mockUpdateTags).toHaveBeenCalledWith(
'agent1',
['tag'],
expect.anything(),
'Tag created',
'Tag creation failed'
);
});
it('should add new tag when not found in search and button clicked', () => {
const result = renderComponent('agent1');
const searchInput = result.getByRole('combobox');

View file

@ -212,7 +212,7 @@ export const TagsAddRemove: React.FC<Props> = ({
</Fragment>
)}
</EuiSelectable>
{!isExactMatch && labels.length && searchValue !== '' ? createTagButton : null}
{(!isExactMatch || labels.length === 0) && searchValue !== '' ? createTagButton : null}
</EuiWrappingPopover>
</>
);