[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) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
// Failing: See https://github.com/elastic/kibana/issues/79248
|
||||
describe.skip('executionStatus', () => {
|
||||
describe('executionStatus', () => {
|
||||
const objectRemover = new ObjectRemover(supertest);
|
||||
|
||||
after(async () => await objectRemover.removeAll());
|
||||
|
@ -257,14 +256,16 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
|
|||
`${getUrlPrefix(Spaces.space1.id)}/api/alerts/alert/${id}`
|
||||
);
|
||||
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(
|
||||
response.body.executionStatus
|
||||
executionStatus
|
||||
)}`;
|
||||
|
||||
if (statuses.has(status)) {
|
||||
return response.body.executionStatus;
|
||||
return executionStatus;
|
||||
}
|
||||
|
||||
// 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}`);
|
||||
|
||||
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(
|
||||
executionStatus
|
||||
)}`;
|
||||
|
||||
if (statuses.has(executionStatus.status)) {
|
||||
if (statuses.has(status)) {
|
||||
return executionStatus;
|
||||
}
|
||||
|
||||
|
@ -307,6 +309,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon
|
|||
}
|
||||
|
||||
function expectErrorExecutionStatus(executionStatus: Record<string, any>, startDate: number) {
|
||||
expect(executionStatus).to.be.ok();
|
||||
expect(executionStatus.status).to.equal('error');
|
||||
|
||||
const statusDate = Date.parse(executionStatus.lastExecutionDate);
|
||||
|
|
Loading…
Reference in a new issue