Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Nov 5, 2021
1 parent 8e06246 commit 9a5aa4d
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/

import * as React from 'react';
// eslint-disable-next-line @kbn/eslint/module_migration
import { ThemeProvider } from 'styled-components';
import { mountWithIntl, nextTick } from '@kbn/test/jest';

import ActionsConnectorsList from './actions_connectors_list';
Expand Down Expand Up @@ -458,3 +460,80 @@ describe('actions_connectors_list component with disabled items', () => {
);
});
});

describe('actions_connectors_list component with deprecated connectors', () => {
let wrapper: ReactWrapper<any>;

async function setup() {
loadAllActions.mockResolvedValueOnce([
{
id: '1',
actionTypeId: '.servicenow',
description: 'My test',
referencedByCount: 1,
config: { usesTableApi: true },
},
{
id: '2',
actionTypeId: '.servicenow-sir',
description: 'My test 2',
referencedByCount: 1,
config: { usesTableApi: true },
},
]);
loadActionTypes.mockResolvedValueOnce([
{
id: 'test',
name: '.servicenow',
enabled: false,
enabledInConfig: false,
enabledInLicense: true,
},
{
id: 'test2',
name: '.servicenow-sir',
enabled: false,
enabledInConfig: true,
enabledInLicense: false,
},
]);

const [
{
application: { capabilities },
},
] = await mocks.getStartServices();

// eslint-disable-next-line react-hooks/rules-of-hooks
useKibanaMock().services.application.capabilities = {
...capabilities,
actions: {
show: true,
save: true,
delete: true,
},
};
// eslint-disable-next-line react-hooks/rules-of-hooks
useKibanaMock().services.actionTypeRegistry = actionTypeRegistry;
wrapper = mountWithIntl(
<ThemeProvider theme={() => ({ eui: { euiSizeS: '15px' }, darkMode: true })}>
<ActionsConnectorsList />
</ThemeProvider>
);

// Wait for active space to resolve before requesting the component to update
await act(async () => {
await nextTick();
wrapper.update();
});

expect(loadAllActions).toHaveBeenCalled();
}

it('shows the warning icon', async () => {
await setup();
expect(wrapper.find('EuiInMemoryTable')).toHaveLength(1);
expect(wrapper.find('EuiTableRow')).toHaveLength(2);
expect(wrapper.find('.euiToolTipAnchor [aria-label="Warning"]').exists()).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ const ActionsConnectorsList: React.FunctionComponent = () => {
* Issue: https://github.com/elastic/kibana/issues/114507
*/
const hasSNApplication =
itemConfig?.actionTypeId === '.servicenow' ||
itemConfig?.actionTypeId === '.servicenow-sir';
item?.actionTypeId === '.servicenow' || item?.actionTypeId === '.servicenow-sir';

const showDeprecatedTooltip = hasSNApplication && itemConfig?.usesTableApi;

Expand Down

0 comments on commit 9a5aa4d

Please sign in to comment.