Skip to content

Commit

Permalink
updated the failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
georgianaonoleata1904 committed Oct 24, 2024
1 parent 5910adf commit 9976f60
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import {
import { ConnectorsDropdown } from './connectors_dropdown';
import { connectors, actionTypes } from './__mock__';
import { ConnectorTypes } from '../../../common/types/domain';
import userEvent from '@testing-library/user-event';

describe('Connectors', () => {
let wrapper: ReactWrapper;
let appMockRender: AppMockRenderer;
const onChangeConnector = jest.fn();
const handleShowEditFlyout = jest.fn();
const onAddNewConnector = jest.fn();

const props: Props = {
actionTypes,
Expand All @@ -38,6 +40,7 @@ describe('Connectors', () => {
onChangeConnector,
selectedConnector: { id: 'none', type: ConnectorTypes.none },
updateConnectorDisabled: false,
onAddNewConnector,
};

beforeAll(() => {
Expand Down Expand Up @@ -104,12 +107,16 @@ describe('Connectors', () => {
});

it('shows the add connector button', () => {
wrapper.find('button[data-test-subj="dropdown-connectors"]').simulate('click');
wrapper.update();
appMockRender.render(<Connectors {...props} />);

expect(
wrapper.find('button[data-test-subj="dropdown-connector-add-connector"]').exists()
).toBeTruthy();
expect(screen.getByTestId('add-new-connector')).toBeInTheDocument();
});

it('shows the add connector flyout when the button is clicked', async () => {
appMockRender.render(<Connectors {...props} />);

await userEvent.click(screen.getByTestId('add-new-connector'));
expect(onAddNewConnector).toHaveBeenCalled();
});

it('the text of the update button is shown correctly', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ const ConnectorsComponent: React.FC<Props> = ({
label={dropDownLabel}
data-test-subj="case-connectors-form-row"
labelAppend={
<EuiButtonEmpty size="xs" onClick={onAddNewConnector}>
<EuiButtonEmpty
size="xs"
data-test-subj="add-new-connector"
onClick={onAddNewConnector}
>
{i18n.ADD_CONNECTOR}
</EuiButtonEmpty>
}
Expand Down

0 comments on commit 9976f60

Please sign in to comment.