This commit is contained in:
parent
2459c6831c
commit
332df381bf
1 changed files with 29 additions and 28 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
import expect from '@kbn/expect';
|
||||
import uuid from 'uuid';
|
||||
import { omit } from 'lodash';
|
||||
import { omit, mapValues } from 'lodash';
|
||||
import moment from 'moment';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
|
@ -210,59 +210,60 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
// Verify content
|
||||
await testSubjects.existOrFail('alertInstancesList');
|
||||
|
||||
const {
|
||||
alertInstances: {
|
||||
['us-central']: {
|
||||
meta: {
|
||||
lastScheduledActions: { date },
|
||||
},
|
||||
},
|
||||
},
|
||||
} = await alerting.alerts.getAlertState(alert.id);
|
||||
const { alertInstances } = await alerting.alerts.getAlertState(alert.id);
|
||||
|
||||
const dateOnAllInstances = moment(date)
|
||||
.utc()
|
||||
.format('D MMM YYYY @ HH:mm:ss');
|
||||
const dateOnAllInstances = mapValues(
|
||||
alertInstances,
|
||||
({
|
||||
meta: {
|
||||
lastScheduledActions: { date },
|
||||
},
|
||||
}) => moment(date).utc()
|
||||
);
|
||||
|
||||
const instancesList = await pageObjects.alertDetailsUI.getAlertInstancesList();
|
||||
expect(instancesList.map(instance => omit(instance, 'duration'))).to.eql([
|
||||
{
|
||||
instance: 'us-central',
|
||||
status: 'Active',
|
||||
start: dateOnAllInstances,
|
||||
start: dateOnAllInstances['us-central'].format('D MMM YYYY @ HH:mm:ss'),
|
||||
},
|
||||
{
|
||||
instance: 'us-east',
|
||||
status: 'Active',
|
||||
start: dateOnAllInstances,
|
||||
start: dateOnAllInstances['us-east'].format('D MMM YYYY @ HH:mm:ss'),
|
||||
},
|
||||
{
|
||||
instance: 'us-west',
|
||||
status: 'Active',
|
||||
start: dateOnAllInstances,
|
||||
start: dateOnAllInstances['us-west'].format('D MMM YYYY @ HH:mm:ss'),
|
||||
},
|
||||
]);
|
||||
|
||||
const durationFromInstanceTillPageLoad = moment.duration(
|
||||
testBeganAt.diff(moment(date).utc())
|
||||
const durationFromInstanceTillPageLoad = mapValues(dateOnAllInstances, date =>
|
||||
moment.duration(testBeganAt.diff(moment(date).utc()))
|
||||
);
|
||||
instancesList
|
||||
.map(alertInstance => alertInstance.duration.split(':').map(part => parseInt(part, 10)))
|
||||
.map(([hours, minutes, seconds]) =>
|
||||
moment.duration({
|
||||
.map(alertInstance => ({
|
||||
id: alertInstance.instance,
|
||||
duration: alertInstance.duration.split(':').map(part => parseInt(part, 10)),
|
||||
}))
|
||||
.map(({ id, duration: [hours, minutes, seconds] }) => ({
|
||||
id,
|
||||
duration: moment.duration({
|
||||
hours,
|
||||
minutes,
|
||||
seconds,
|
||||
})
|
||||
)
|
||||
.forEach(alertInstanceDuration => {
|
||||
}),
|
||||
}))
|
||||
.forEach(({ id, duration }) => {
|
||||
// make sure the duration is within a 10 second range which is
|
||||
// good enough as the alert interval is 1m, so we know it is a fresh value
|
||||
expect(alertInstanceDuration.as('milliseconds')).to.greaterThan(
|
||||
durationFromInstanceTillPageLoad.subtract(1000 * 10).as('milliseconds')
|
||||
expect(duration.as('milliseconds')).to.greaterThan(
|
||||
durationFromInstanceTillPageLoad[id].subtract(1000 * 10).as('milliseconds')
|
||||
);
|
||||
expect(alertInstanceDuration.as('milliseconds')).to.lessThan(
|
||||
durationFromInstanceTillPageLoad.add(1000 * 10).as('milliseconds')
|
||||
expect(duration.as('milliseconds')).to.lessThan(
|
||||
durationFromInstanceTillPageLoad[id].add(1000 * 10).as('milliseconds')
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue