[8.x] [ResponseOps][Cases]Fix unit tests for React@18 (#207072) (#207848)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ResponseOps][Cases]Fix unit tests for React@18
(#207072)](https://github.com/elastic/kibana/pull/207072)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Georgiana-Andreea
Onoleață","email":"georgiana.onoleata@elastic.co"},"sourceCommit":{"committedDate":"2025-01-22T14:48:32Z","message":"[ResponseOps][Cases]Fix
unit tests for React@18 (#207072)\n\nCloses
https://github.com/elastic/kibana/issues/206954\r\n\r\n##
Summary\r\n\r\n-
fixed\r\n\r\n-\r\n[[job]](01946ec2-e5bc-40be-98f8-d9fec8226ede)\r\nJest
Tests / ConnectorForm calls onChange when the form is
invalid","sha":"f4ff699a82253b036f51367da2e09dc04483b60d","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Feature:Cases","backport:prev-minor","testing","v8.18.0"],"title":"[ResponseOps][Cases]Fix
unit tests for
React@18","number":207072,"url":"https://github.com/elastic/kibana/pull/207072","mergeCommit":{"message":"[ResponseOps][Cases]Fix
unit tests for React@18 (#207072)\n\nCloses
https://github.com/elastic/kibana/issues/206954\r\n\r\n##
Summary\r\n\r\n-
fixed\r\n\r\n-\r\n[[job]](01946ec2-e5bc-40be-98f8-d9fec8226ede)\r\nJest
Tests / ConnectorForm calls onChange when the form is
invalid","sha":"f4ff699a82253b036f51367da2e09dc04483b60d"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/207072","number":207072,"mergeCommit":{"message":"[ResponseOps][Cases]Fix
unit tests for React@18 (#207072)\n\nCloses
https://github.com/elastic/kibana/issues/206954\r\n\r\n##
Summary\r\n\r\n-
fixed\r\n\r\n-\r\n[[job]](01946ec2-e5bc-40be-98f8-d9fec8226ede)\r\nJest
Tests / ConnectorForm calls onChange when the form is
invalid","sha":"f4ff699a82253b036f51367da2e09dc04483b60d"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Georgiana-Andreea Onoleață <georgiana.onoleata@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2025-01-23 10:55:01 +11:00 committed by GitHub
parent 3fde9d6ae9
commit fbc7d7f6e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -102,21 +102,21 @@ describe('ConnectorForm', () => {
/>
);
expect(result.getByTestId('nameInput')).toBeInTheDocument();
expect(await result.findByTestId('nameInput')).toBeInTheDocument();
await act(async () => {
const submit = onChange.mock.calls[0][0].submit;
await submit();
});
await waitFor(() => expect(onChange).toHaveBeenCalled());
expect(onChange).toHaveBeenCalledWith({
isSubmitted: false,
isSubmitting: false,
isValid: false,
preSubmitValidator: expect.anything(),
submit: expect.anything(),
await waitFor(() => {
expect(onChange).toHaveBeenCalledWith({
isSubmitted: true,
isSubmitting: false,
isValid: false,
preSubmitValidator: expect.anything(),
submit: expect.anything(),
});
});
});