diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/patch_cases.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/patch_cases.ts index 6b370117c447a..e2a7512940250 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/patch_cases.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/patch_cases.ts @@ -805,7 +805,7 @@ export default ({ getService }: FtrProviderContext): void => { const signals = await getSignalsByIds(supertest, [id]); const alert = signals.hits.hits[0]; - expect(alert._source.signal.status).eql('open'); + expect(alert._source?.signal.status).eql('open'); const caseUpdated = await createComment({ supertest, @@ -846,7 +846,7 @@ export default ({ getService }: FtrProviderContext): void => { .send(getQuerySignalIds([alert._id])) .expect(200); - expect(updatedAlert.hits.hits[0]._source.signal.status).eql('in-progress'); + expect(updatedAlert.hits.hits[0]._source?.signal.status).eql('in-progress'); }); it('does NOT updates alert status when the status is updated and syncAlerts=false', async () => { @@ -863,7 +863,7 @@ export default ({ getService }: FtrProviderContext): void => { const signals = await getSignalsByIds(supertest, [id]); const alert = signals.hits.hits[0]; - expect(alert._source.signal.status).eql('open'); + expect(alert._source?.signal.status).eql('open'); const caseUpdated = await createComment({ supertest, @@ -899,7 +899,7 @@ export default ({ getService }: FtrProviderContext): void => { .send(getQuerySignalIds([alert._id])) .expect(200); - expect(updatedAlert.hits.hits[0]._source.signal.status).eql('open'); + expect(updatedAlert.hits.hits[0]._source?.signal.status).eql('open'); }); it('it updates alert status when syncAlerts is turned on', async () => { @@ -916,7 +916,7 @@ export default ({ getService }: FtrProviderContext): void => { const signals = await getSignalsByIds(supertest, [id]); const alert = signals.hits.hits[0]; - expect(alert._source.signal.status).eql('open'); + expect(alert._source?.signal.status).eql('open'); const caseUpdated = await createComment({ supertest, @@ -970,7 +970,7 @@ export default ({ getService }: FtrProviderContext): void => { .send(getQuerySignalIds([alert._id])) .expect(200); - expect(updatedAlert.hits.hits[0]._source.signal.status).eql('in-progress'); + expect(updatedAlert.hits.hits[0]._source?.signal.status).eql('in-progress'); }); it('it does NOT updates alert status when syncAlerts is turned off', async () => { @@ -983,7 +983,7 @@ export default ({ getService }: FtrProviderContext): void => { const signals = await getSignalsByIds(supertest, [id]); const alert = signals.hits.hits[0]; - expect(alert._source.signal.status).eql('open'); + expect(alert._source?.signal.status).eql('open'); const caseUpdated = await createComment({ supertest, diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/comments/post_comment.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/comments/post_comment.ts index f22ce54de193a..ecd05a2717e08 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/comments/post_comment.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/comments/post_comment.ts @@ -369,7 +369,7 @@ export default ({ getService }: FtrProviderContext): void => { const signals = await getSignalsByIds(supertest, [id]); const alert = signals.hits.hits[0]; - expect(alert._source.signal.status).eql('open'); + expect(alert._source?.signal.status).eql('open'); await createComment({ supertest, @@ -424,7 +424,7 @@ export default ({ getService }: FtrProviderContext): void => { const signals = await getSignalsByIds(supertest, [id]); const alert = signals.hits.hits[0]; - expect(alert._source.signal.status).eql('open'); + expect(alert._source?.signal.status).eql('open'); await createComment({ supertest, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_ml.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_ml.ts index d371a11ba595f..a03bd07c86020 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_ml.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_ml.ts @@ -100,6 +100,10 @@ export default ({ getService }: FtrProviderContext) => { const signalsOpen = await getOpenSignals(supertest, es, createdRule); expect(signalsOpen.hits.hits.length).eql(1); const signal = signalsOpen.hits.hits[0]; + if (!signal._source) { + return expect(signal._source).to.be.ok(); + } + expect(signal._source).eql({ '@timestamp': signal._source['@timestamp'], actual: [1],