[Fleet] Fix flaky jest tests (#190778)

Fixes https://github.com/elastic/kibana/issues/189868
Fixes https://github.com/elastic/kibana/issues/189869

## Summary
Fix flaky unit tests. Tested locally and on ci, note that flaky test
runner cannot be used with jest tests.


### Checklist

- [ ] [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

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Cristina Amico 2024-08-20 17:11:56 +02:00 committed by GitHub
parent cf3149e983
commit 96a5df19ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -83,6 +83,8 @@ describe('step select agent policy', () => {
beforeEach(() => {
testRenderer = createFleetTestRendererMock();
useMultipleAgentPoliciesMock.mockReturnValue({ canUseMultipleAgentPolicies: false });
});
afterEach(() => {
updateAgentPoliciesMock.mockReset();
});
@ -110,7 +112,7 @@ describe('step select agent policy', () => {
});
test('should select agent policy by default if one exists', async () => {
useGetAgentPoliciesMock.mockReturnValueOnce({
useGetAgentPoliciesMock.mockReturnValue({
data: { items: [{ id: 'policy-1', name: 'Policy 1' }] },
error: undefined,
isLoading: false,