Skip to content

Commit

Permalink
[RAM] Fix flaky edit connector flyout test (#165128)
Browse files Browse the repository at this point in the history
## Summary
Resolves: #157060

Fixes slow running flaky tests by removing the `delay` for the
`userEvent.type` calls. Also remove some unnecessary `act` calls.

### Checklist
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
JiaweiWu authored Aug 29, 2023
1 parent 3e29c18 commit de6b74b
Showing 1 changed file with 34 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,7 @@ describe('EditConnectorFlyout', () => {
});
});

// FLAKY: https://github.com/elastic/kibana/issues/157060
describe.skip('Submitting', () => {
describe('Submitting', () => {
it('updates the connector correctly', async () => {
const { getByTestId } = appMockRenderer.render(
<EditConnectorFlyout
Expand All @@ -410,20 +409,17 @@ describe('EditConnectorFlyout', () => {
expect(getByTestId('test-connector-text-field')).toBeInTheDocument();
});

await act(async () => {
await userEvent.clear(getByTestId('nameInput'));
await userEvent.type(getByTestId('nameInput'), 'My new name', {
delay: 100,
});
await userEvent.type(getByTestId('test-connector-secret-text-field'), 'password', {
delay: 100,
});
});
userEvent.clear(getByTestId('nameInput'));
userEvent.type(getByTestId('nameInput'), 'My new name');
userEvent.type(getByTestId('test-connector-secret-text-field'), 'password');

act(() => {
userEvent.click(getByTestId('edit-connector-flyout-save-btn'));
await waitFor(() => {
expect(getByTestId('nameInput')).toHaveValue('My new name');
expect(getByTestId('test-connector-secret-text-field')).toHaveValue('password');
});

userEvent.click(getByTestId('edit-connector-flyout-save-btn'));

await waitFor(() => {
expect(appMockRenderer.coreStart.http.put).toHaveBeenCalledWith(
'/api/actions/connector/123',
Expand Down Expand Up @@ -461,16 +457,19 @@ describe('EditConnectorFlyout', () => {
});

userEvent.clear(getByTestId('test-connector-text-field'));
await userEvent.type(getByTestId('test-connector-text-field'), 'My updated text field', {
delay: 100,
userEvent.type(getByTestId('test-connector-text-field'), 'My updated text field');

await waitFor(() => {
expect(getByTestId('test-connector-text-field')).toHaveValue('My updated text field');
});

userEvent.clear(getByTestId('nameInput'));
await userEvent.type(getByTestId('nameInput'), 'My test', {
delay: 100,
});
await userEvent.type(getByTestId('test-connector-secret-text-field'), 'password', {
delay: 100,
userEvent.type(getByTestId('nameInput'), 'My test');
userEvent.type(getByTestId('test-connector-secret-text-field'), 'password');

await waitFor(() => {
expect(getByTestId('nameInput')).toHaveValue('My test');
expect(getByTestId('test-connector-secret-text-field')).toHaveValue('password');
});

userEvent.click(getByTestId('edit-connector-flyout-save-btn'));
Expand All @@ -494,20 +493,17 @@ describe('EditConnectorFlyout', () => {
expect(getByTestId('test-connector-text-field')).toBeInTheDocument();
});

await act(async () => {
await userEvent.clear(getByTestId('nameInput'));
await userEvent.type(getByTestId('nameInput'), 'My new name', {
delay: 100,
});
await userEvent.type(getByTestId('test-connector-secret-text-field'), 'password', {
delay: 100,
});
});
userEvent.clear(getByTestId('nameInput'));
userEvent.type(getByTestId('nameInput'), 'My new name');
userEvent.type(getByTestId('test-connector-secret-text-field'), 'password');

act(() => {
userEvent.click(getByTestId('edit-connector-flyout-save-btn'));
await waitFor(() => {
expect(getByTestId('nameInput')).toHaveValue('My new name');
expect(getByTestId('test-connector-secret-text-field')).toHaveValue('password');
});

userEvent.click(getByTestId('edit-connector-flyout-save-btn'));

await waitFor(() => {
expect(appMockRenderer.coreStart.http.put).toHaveBeenCalledWith(
'/api/actions/connector/123',
Expand All @@ -519,9 +515,7 @@ describe('EditConnectorFlyout', () => {

expect(getByText('Changes Saved')).toBeInTheDocument();

act(() => {
userEvent.click(getByTestId('edit-connector-flyout-close-btn'));
});
userEvent.click(getByTestId('edit-connector-flyout-close-btn'));

expect(onClose).toHaveBeenCalled();
expect(onConnectorUpdated).toHaveBeenCalledWith({
Expand Down Expand Up @@ -555,17 +549,15 @@ describe('EditConnectorFlyout', () => {
expect(getByTestId('test-connector-error-text-field')).toBeInTheDocument();
});

await act(async () => {
await userEvent.clear(getByTestId('nameInput'));
await userEvent.type(getByTestId('nameInput'), 'My new name', {
delay: 100,
});
});
userEvent.clear(getByTestId('nameInput'));
userEvent.type(getByTestId('nameInput'), 'My new name');

act(() => {
userEvent.click(getByTestId('edit-connector-flyout-save-btn'));
await waitFor(() => {
expect(getByTestId('nameInput')).toHaveValue('My new name');
});

userEvent.click(getByTestId('edit-connector-flyout-save-btn'));

await waitFor(() => {
expect(getByText('Error on pre submit validator')).toBeInTheDocument();
});
Expand Down

0 comments on commit de6b74b

Please sign in to comment.