Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cases] Fixes configuration page flaky tests #118521

Merged
merged 1 commit into from
Nov 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,21 @@ const useConnectorsMock = useConnectors as jest.Mock;
const useCaseConfigureMock = useCaseConfigure as jest.Mock;
const useGetUrlSearchMock = jest.fn();
const useActionTypesMock = useActionTypes as jest.Mock;
const getAddConnectorFlyoutMock = jest.fn();
const getEditConnectorFlyoutMock = jest.fn();

describe('ConfigureCases', () => {
beforeAll(() => {
useKibanaMock().services.triggersActionsUi.actionTypeRegistry.get = jest.fn().mockReturnValue({
actionTypeTitle: '.servicenow',
iconClass: 'logoSecurity',
});

useKibanaMock().services.triggersActionsUi.getAddConnectorFlyout =
getAddConnectorFlyoutMock.mockReturnValue(<div data-test-subj="add-connector-flyout" />);

useKibanaMock().services.triggersActionsUi.getEditConnectorFlyout =
getEditConnectorFlyoutMock.mockReturnValue(<div data-test-subj="edit-connector-flyout" />);
});

beforeEach(() => {
Expand All @@ -72,12 +80,12 @@ describe('ConfigureCases', () => {
expect(wrapper.find('[data-test-subj="closure-options-radio-group"]').exists()).toBeTruthy();
});

test('it does NOT render the ConnectorAddFlyout', () => {
expect(wrapper.find('ConnectorAddFlyout').exists()).toBeFalsy();
test('it does NOT render the add connector flyout', () => {
expect(wrapper.find('[data-test-subj="add-connector-flyout"]').exists()).toBeFalsy();
});

test('it does NOT render the ConnectorEditFlyout', () => {
expect(wrapper.find('ConnectorEditFlyout').exists()).toBeFalsy();
test('it does NOT render the edit connector flyout"]', () => {
expect(wrapper.find('[data-test-subj="edit-connector-flyout"]').exists()).toBeFalsy();
});

test('it does NOT render the EuiCallOut', () => {
Expand Down Expand Up @@ -176,8 +184,8 @@ describe('ConfigureCases', () => {
expect(wrapper.find(ClosureOptions).prop('closureTypeSelected')).toBe('close-by-user');

// Flyouts
expect(wrapper.find('ConnectorAddFlyout').exists()).toBe(false);
expect(wrapper.find('ConnectorEditFlyout').exists()).toBe(false);
expect(wrapper.find('[data-test-subj="add-connector-flyout"]').exists()).toBe(false);
expect(wrapper.find('[data-test-subj="edit-connector-flyout"]').exists()).toBe(false);
});

test('it disables correctly when the user cannot crud', () => {
Expand Down Expand Up @@ -541,21 +549,25 @@ describe('ConfigureCases', () => {

await waitFor(() => {
wrapper.update();
expect(wrapper.find('ConnectorAddFlyout').exists()).toBe(true);
expect(wrapper.find('ConnectorAddFlyout').prop('actionTypes')).toEqual([
expect.objectContaining({
id: '.servicenow',
}),
expect.objectContaining({
id: '.jira',
}),
expect.objectContaining({
id: '.resilient',
}),
expect(wrapper.find('[data-test-subj="add-connector-flyout"]').exists()).toBe(true);
expect(getAddConnectorFlyoutMock).toHaveBeenCalledWith(
expect.objectContaining({
id: '.servicenow-sir',
}),
]);
actionTypes: [
expect.objectContaining({
id: '.servicenow',
}),
expect.objectContaining({
id: '.jira',
}),
expect.objectContaining({
id: '.resilient',
}),
expect.objectContaining({
id: '.servicenow-sir',
}),
],
})
);
});
});

Expand Down Expand Up @@ -588,8 +600,10 @@ describe('ConfigureCases', () => {

await waitFor(() => {
wrapper.update();
expect(wrapper.find('ConnectorEditFlyout').exists()).toBe(true);
expect(wrapper.find('ConnectorEditFlyout').prop('initialConnector')).toEqual(connectors[1]);
expect(wrapper.find('[data-test-subj="edit-connector-flyout"]').exists()).toBe(true);
expect(getEditConnectorFlyoutMock).toHaveBeenCalledWith(
expect.objectContaining({ initialConnector: connectors[1] })
);
});

expect(
Expand Down