[Alerts] fix failing executionStatus function test with null deref (#79809)
resolves https://github.com/elastic/kibana/issues/79248 Added some additional checks for potential null/undefined objects before dereferencing them.
This commit is contained in:
parent
0bd345c1a1
commit
3bbd679afe
|
@ -19,8 +19,7 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||||
export default function executionStatusAlertTests({ getService }: FtrProviderContext) {
|
export default function executionStatusAlertTests({ getService }: FtrProviderContext) {
|
||||||
const supertest = getService('supertest');
|
const supertest = getService('supertest');
|
||||||
|
|
||||||
// Failing: See https://github.com/elastic/kibana/issues/79248
|
describe('executionStatus', () => {
|
||||||
describe.skip('executionStatus', () => {
|
|
||||||
const objectRemover = new ObjectRemover(supertest);
|
const objectRemover = new ObjectRemover(supertest);
|
||||||
|
|
||||||
after(async () => await objectRemover.removeAll());
|
after(async () => await objectRemover.removeAll());
|
||||||
|
@ -257,14 +256,16 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
|
||||||
`${getUrlPrefix(Spaces.space1.id)}/api/alerts/alert/${id}`
|
`${getUrlPrefix(Spaces.space1.id)}/api/alerts/alert/${id}`
|
||||||
);
|
);
|
||||||
expect(response.status).to.eql(200);
|
expect(response.status).to.eql(200);
|
||||||
const { status } = response.body.executionStatus;
|
|
||||||
|
const { executionStatus } = response.body || {};
|
||||||
|
const { status } = executionStatus || {};
|
||||||
|
|
||||||
const message = `waitForStatus(${Array.from(statuses)}): got ${JSON.stringify(
|
const message = `waitForStatus(${Array.from(statuses)}): got ${JSON.stringify(
|
||||||
response.body.executionStatus
|
executionStatus
|
||||||
)}`;
|
)}`;
|
||||||
|
|
||||||
if (statuses.has(status)) {
|
if (statuses.has(status)) {
|
||||||
return response.body.executionStatus;
|
return executionStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
@ -288,13 +289,14 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
|
||||||
const response = await supertest.get(`${getUrlPrefix(Spaces.space1.id)}/${findUri}`);
|
const response = await supertest.get(`${getUrlPrefix(Spaces.space1.id)}/${findUri}`);
|
||||||
|
|
||||||
expect(response.status).to.eql(200);
|
expect(response.status).to.eql(200);
|
||||||
const { executionStatus } = response.body.data.find((obj: any) => obj.id === id);
|
const { executionStatus } = response.body.data.find((obj: any) => obj.id === id) || {};
|
||||||
|
const { status } = executionStatus || {};
|
||||||
|
|
||||||
const message = `waitForFindStatus(${Array.from(statuses)}): got ${JSON.stringify(
|
const message = `waitForFindStatus(${Array.from(statuses)}): got ${JSON.stringify(
|
||||||
executionStatus
|
executionStatus
|
||||||
)}`;
|
)}`;
|
||||||
|
|
||||||
if (statuses.has(executionStatus.status)) {
|
if (statuses.has(status)) {
|
||||||
return executionStatus;
|
return executionStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,6 +309,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
|
||||||
}
|
}
|
||||||
|
|
||||||
function expectErrorExecutionStatus(executionStatus: Record<string, any>, startDate: number) {
|
function expectErrorExecutionStatus(executionStatus: Record<string, any>, startDate: number) {
|
||||||
|
expect(executionStatus).to.be.ok();
|
||||||
expect(executionStatus.status).to.equal('error');
|
expect(executionStatus.status).to.equal('error');
|
||||||
|
|
||||||
const statusDate = Date.parse(executionStatus.lastExecutionDate);
|
const statusDate = Date.parse(executionStatus.lastExecutionDate);
|
||||||
|
|
Loading…
Reference in a new issue