diff --git a/x-pack/test/detection_engine_api_integration/basic/tests/open_close_signals.ts b/x-pack/test/detection_engine_api_integration/basic/tests/open_close_signals.ts index 992685c969639..a84d9845085e0 100644 --- a/x-pack/test/detection_engine_api_integration/basic/tests/open_close_signals.ts +++ b/x-pack/test/detection_engine_api_integration/basic/tests/open_close_signals.ts @@ -79,7 +79,7 @@ export default ({ getService }: FtrProviderContext) => { it('should be able to execute and get 10 signals', async () => { const rule = { ...getSimpleRule(), from: '1900-01-01T00:00:00.000Z', query: '*:*' }; await createRule(supertest, rule); - await waitForSignalsToBePresent(supertest); + await waitForSignalsToBePresent(supertest, 10); const signalsOpen = await getAllSignals(supertest); expect(signalsOpen.hits.hits.length).equal(10); }); @@ -102,7 +102,7 @@ export default ({ getService }: FtrProviderContext) => { it('should be able to get a count of 10 closed signals when closing 10', async () => { const rule = { ...getSimpleRule(), from: '1900-01-01T00:00:00.000Z', query: '*:*' }; await createRule(supertest, rule); - await waitForSignalsToBePresent(supertest); + await waitForSignalsToBePresent(supertest, 10); const signalsOpen = await getAllSignals(supertest); const signalIds = signalsOpen.hits.hits.map((signal) => signal._id); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts index 3cb2356e9e1b5..ae4ff41c509ea 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts @@ -435,7 +435,7 @@ export default ({ getService }: FtrProviderContext) => { ], }; await createRule(supertest, ruleWithException); - await waitForSignalsToBePresent(supertest); + await waitForSignalsToBePresent(supertest, 10); const signalsOpen = await getAllSignals(supertest); expect(signalsOpen.hits.hits.length).equal(10); }); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts index 0c425f46232b0..498c607121760 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts @@ -120,7 +120,7 @@ export default ({ getService }: FtrProviderContext) => { }; await createRule(supertest, rule); - await waitForSignalsToBePresent(supertest); + await waitForSignalsToBePresent(supertest, 10); const signalsOpen = await getAllSignals(supertest); expect(signalsOpen.hits.hits.length).equal(10); }); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts index 6e08ee1dbe2ce..d2a3e86526db4 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts @@ -78,7 +78,7 @@ export default ({ getService }: FtrProviderContext) => { it('should be able to execute and get 10 signals', async () => { const rule = { ...getSimpleRule(), from: '1900-01-01T00:00:00.000Z', query: '*:*' }; await createRule(supertest, rule); - await waitForSignalsToBePresent(supertest); + await waitForSignalsToBePresent(supertest, 10); const signalsOpen = await getAllSignals(supertest); expect(signalsOpen.hits.hits.length).equal(10); }); @@ -101,7 +101,7 @@ export default ({ getService }: FtrProviderContext) => { it('should be able to get a count of 10 closed signals when closing 10', async () => { const rule = { ...getSimpleRule(), from: '1900-01-01T00:00:00.000Z', query: '*:*' }; await createRule(supertest, rule); - await waitForSignalsToBePresent(supertest); + await waitForSignalsToBePresent(supertest, 10); const signalsOpen = await getAllSignals(supertest); const signalIds = signalsOpen.hits.hits.map((signal) => signal._id); @@ -124,7 +124,7 @@ export default ({ getService }: FtrProviderContext) => { expect(signalsClosed.hits.hits.length).to.equal(10); }); - it('should be able close 10 signals immediately and they all should be closed', async () => { + it('should be able close signals immediately and they all should be closed', async () => { const rule = { ...getSimpleRule(), from: '1900-01-01T00:00:00.000Z', query: '*:*' }; await createRule(supertest, rule); await waitForSignalsToBePresent(supertest); diff --git a/x-pack/test/detection_engine_api_integration/utils.ts b/x-pack/test/detection_engine_api_integration/utils.ts index 94fbd728be312..05a0f73dd0dc4 100644 --- a/x-pack/test/detection_engine_api_integration/utils.ts +++ b/x-pack/test/detection_engine_api_integration/utils.ts @@ -794,11 +794,14 @@ export const waitForRuleSuccess = async ( }; /** - * Waits for the signal hits to be greater than zero before continuing + * Waits for the signal hits to be greater than the supplied number + * before continuing with a default of at least one signal * @param supertest Deps + * @param numberOfSignals The number of signals to wait for, default is 1 */ export const waitForSignalsToBePresent = async ( - supertest: SuperTest + supertest: SuperTest, + numberOfSignals = 1 ): Promise => { await waitFor(async () => { const { @@ -808,7 +811,7 @@ export const waitForSignalsToBePresent = async ( .set('kbn-xsrf', 'true') .send(getQueryAllSignals()) .expect(200); - return signalsOpen.hits.hits.length > 0; + return signalsOpen.hits.hits.length >= numberOfSignals; }); };