Last active
July 12, 2022 14:55
-
-
Save Hiestaa/78f5a680211c602e6cf7d35f3fd6c762 to your computer and use it in GitHub Desktop.
Alarm Triggers Parser Test Suite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const LAG = 3 * 60 * 1000; | |
const GAP = 10 * 1000; | |
dataReceived = function () { | |
}; | |
function startTime() { | |
return new Date(Date.now() - LAG).toISOString(); | |
} | |
function endTime() { | |
return new Date(Date.now() + 120 * 1000 - LAG).toISOString(); | |
} | |
function fakeTransactions() { | |
let timerCount = 1; | |
setTimeout(fakeMotionBasicTest, (timerCount++) * GAP); | |
setTimeout(fakeMotionBasicTestWithDetails, (timerCount++) * GAP); | |
setTimeout(fakeMotionBasicTestShouldFailInvalidDetailsWithNoTripwireSubtype, (timerCount++) * GAP); | |
setTimeout(fakeMotionTripwireTest, (timerCount++) * GAP); | |
setTimeout(fakeMotionTripwireTestNoDetails, (timerCount++) * GAP); | |
setTimeout(fakeDoorSensorShouldFailMissingSubtype, (timerCount++) * GAP); | |
setTimeout(fakeDoorSensorShouldFailWrongSubtype, (timerCount++) * GAP); | |
setTimeout(fakeDoorSensorNoDetails, (timerCount++) * GAP); | |
setTimeout(fakeDoorSensorWithDetails, (timerCount++) * GAP); | |
setTimeout(fakeDoorSensorShouldFailWrongDetailsField, (timerCount++) * GAP); | |
setTimeout(fakeDoorSensorShouldFailWrongDetailsValue, (timerCount++) * GAP); | |
setTimeout(fakePanicButton, (timerCount++) * GAP); | |
setTimeout(fakePanicButtonWithDetails, (timerCount++) * GAP); | |
setTimeout(fakePanicButtonShouldFailWrongDetailsValue, (timerCount++) * GAP); | |
setTimeout(fakePanicButtonShouldFailWrongDetailsField, (timerCount++) * GAP); | |
setTimeout(fakeDTMFPin, (timerCount++) * GAP); | |
setTimeout(fakeDTMFPinWithDetails, (timerCount++) * GAP); | |
setTimeout(fakeDTMFPinShouldFailWrongDetailsValue, (timerCount++) * GAP); | |
setTimeout(fakeDTMFPinShouldFailWrongDetailsField, (timerCount++) * GAP); | |
setTimeout(fakeTestAlarm, (timerCount++) * GAP); | |
setTimeout(fakeTestAlarmWithDetails, (timerCount++) * GAP); | |
setTimeout(fakeTestAlarmShouldFailInvalidDetails, (timerCount++) * GAP); | |
} | |
function fakeMotionBasicTest() { | |
console.log(`[Alarm Triggers Test Suite] Fake Motion Basic Test`); | |
postTransaction({ | |
title: `Fake Motion Basic Test`, | |
type: 'motion', | |
isAlarm: true, | |
transactionId: Math.random().toString(), | |
startTimeLocal: startTime(), | |
endTime: endTime(), | |
details: { | |
}, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeMotionBasicTestWithDetails() { | |
console.log('[Alarm Triggers Test Suite] Fake Motion Basic Test With Details'); | |
postTransaction({ | |
title: `Fake Motion Basic Test With Details`, | |
type: 'motion', | |
isAlarm: true, | |
transactionId: Math.random().toString(), | |
startTimeLocal: startTime(), | |
endTimeLocal: endTime(), | |
details: { | |
"externalId": 'no clue', | |
"Receipt": `Dummy Motion 120s`, | |
"localTime": 1234, | |
"Stream ID": "whatever", | |
"duration_sec": 120, | |
"Light motion detected": 0.8, | |
"People count": 1, | |
"People count (avg)": 2, | |
"People count (max)": 3, | |
"Vehicle count": 4, | |
"Vehicle count (avg)": 5, | |
"Vehicle count (max)": 6, | |
}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeMotionBasicTestShouldFailInvalidDetailsWithNoTripwireSubtype() { | |
console.log('[Alarm Triggers Test Suite] Fake Motion Basic Test Should Fail Invalid Details With No Tripwire Subtype'); | |
postTransaction({ | |
title: `Fake Motion Basic Test Should Fail Invalid Details With No Tripwire Subtype`, | |
type: 'motion', | |
isAlarm: true, | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: { | |
"externalId": 'no clue', | |
"Receipt": `Dummy Motion 120s`, | |
"localTime": 1234, | |
"Stream ID": "whatever", | |
"Direction": "Entry", | |
"Camera Type": "Whatever", | |
"Current Occupancy": 1 | |
}, | |
creator: 'me', | |
isRealtime: true, | |
// cameras: [], | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeMotionTripwireTest() { | |
console.log('[Alarm Triggers Test Suite] Fake Motion Tripwire Test'); | |
postTransaction({ | |
title: `Fake Motion Tripwire Test`, | |
type: 'motion', | |
isAlarm: true, | |
subtype: 'tripwire', | |
transactionId: Math.random().toString(), | |
// dataSource: 'dummy', | |
startTime: startTime(), | |
endTime: endTime(), | |
details: { | |
"externalId": 'no clue', | |
"Receipt": `Dummy Motion 120s`, | |
"localTime": 1234, | |
"Stream ID": "whatever", | |
"People count": 10, | |
"Direction": "Entry", | |
"Camera Type": "Whatever", | |
"Current Occupancy": 1 | |
}, | |
creator: 'me', | |
isRealtime: true, | |
// cameras: [], | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeMotionTripwireTestNoDetails() { | |
console.log('[Alarm Triggers Test Suite] Fake Motion Tripwire Test No Details'); | |
postTransaction({ | |
title: `Fake Motion Tripwire Test No Details`, | |
type: 'motion', | |
isAlarm: true, | |
subtype: 'tripwire', | |
transactionId: Math.random().toString(), | |
// dataSource: 'dummy', | |
startTime: startTime(), | |
endTime: endTime(), | |
details: {}, | |
creator: 'me', | |
isRealtime: true, | |
// cameras: [], | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeDoorSensorShouldFailMissingSubtype() { | |
console.log('[Alarm Triggers Test Suite] Fake Door Sensor Should Fail Missing Subtype'); | |
postTransaction({ | |
title: `Fake Door Sensor Should Fail Missing Subtype`, | |
type: 'bookmark', | |
isAlarm: true, | |
// subtype: 'door sensor', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: {}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeDoorSensorShouldFailWrongSubtype() { | |
console.log('[Alarm Triggers Test Suite] Fake Door Sensor Should Fail Wrong Subtype'); | |
postTransaction({ | |
title: `Fake Door Sensor Should Fail Wrong Subtype`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'door sensor!', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: {}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeDoorSensorNoDetails() { | |
console.log('[Alarm Triggers Test Suite] Fake Door Sensor No Details'); | |
postTransaction({ | |
title: `Fake Door Sensor No Details`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'door-sensor', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: {}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeDoorSensorWithDetails() { | |
console.log('[Alarm Triggers Test Suite] Fake Door Sensor With Details'); | |
postTransaction({ | |
title: `Fake Door Sensor With Details`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'door-sensor', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: { | |
"Door State": "Open" | |
}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeDoorSensorShouldFailWrongDetailsField() { | |
console.log('[Alarm Triggers Test Suite] Fake Door Sensor Should Fail Wrong Details Field'); | |
postTransaction({ | |
title: `Fake Door Sensor Should Fail Wrong Details Field`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'door-sensor', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: { | |
"Yooo": "Mama" | |
}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeDoorSensorShouldFailWrongDetailsValue() { | |
console.log('[Alarm Triggers Test Suite] Fake Door Sensor Should Fail Wrong Details value'); | |
postTransaction({ | |
title: `Fake Door Sensor Should Fail Wrong Details value`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'door-sensor', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: { | |
"Door State": "Mama" | |
}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakePanicButton() { | |
console.log('[Alarm Triggers Test Suite] Fake Panic Button'); | |
postTransaction({ | |
title: `Fake Panic Button`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'panic-button', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: { | |
}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakePanicButtonWithDetails() { | |
console.log('[Alarm Triggers Test Suite] Fake Panic Button With Details'); | |
postTransaction({ | |
title: `Fake Panic Button With Details`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'panic-button', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: { | |
Duration: 120000 | |
}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakePanicButtonShouldFailWrongDetailsValue() { | |
console.log('[Alarm Triggers Test Suite] Fake Panic Button Should Fail Wrong Details Value'); | |
postTransaction({ | |
title: `Fake Panic Button Should Fail Wrong Details Value`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'panic-button', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: { | |
Duration: 'hey' | |
}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakePanicButtonShouldFailWrongDetailsField() { | |
console.log('[Alarm Triggers Test Suite] Fake Panic Button Should Fail Wrong Details Field'); | |
postTransaction({ | |
title: `Fake Panic Button Should Fail Wrong Details Field`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'panic-button', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: { | |
Hey: 'Mama' | |
}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeDTMFPin() { | |
console.log('[Alarm Triggers Test Suite] Fake DTMF PIN'); | |
postTransaction({ | |
title: `Fake DTMF PIN`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'dtmf-pin', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: { | |
}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeDTMFPinWithDetails() { | |
console.log('[Alarm Triggers Test Suite] Fake DTMF PIN With Details'); | |
postTransaction({ | |
title: `Fake DTMF PIN With Details`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'dtmf-pin', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: { | |
"Pin Correctness": 'valid' | |
}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeDTMFPinShouldFailWrongDetailsValue() { | |
console.log('[Alarm Triggers Test Suite] Fake DTMF Pin Should Fail Wrong Details Value'); | |
postTransaction({ | |
title: `Fake DTMF Pin Should Fail Wrong Details Value`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'dtmf-pin', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: { | |
"Pin Correctness": 'wrong' | |
}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeDTMFPinShouldFailWrongDetailsField() { | |
console.log('[Alarm Triggers Test Suite] Fake DTMF PIN Should Fail Wrong Details Field'); | |
postTransaction({ | |
title: `Fake DTMF PIN Should Fail Wrong Details Field`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'dtmf-pin', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: { | |
Hey: 'Mama' | |
}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeTestAlarm() { | |
console.log('[Alarm Triggers Test Suite] Fake Test Alarm No Details'); | |
postTransaction({ | |
title: `Fake Test Alarm No Details`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'TEST-ALARM', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: { | |
}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeTestAlarmWithDetails() { | |
console.log('[Alarm Triggers Test Suite] Fake Test Alarm Wih Details'); | |
postTransaction({ | |
title: `Fake Test Alarm With Details`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'TEST-ALARM', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
subtitle: "Test Alarm @ Dummy Store", | |
endTime: endTime(), | |
details: { | |
description: "Parser-Based Test Alarm", | |
favourite: false, | |
}, | |
tags: [ | |
'excludeFromCount' | |
], | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
function fakeTestAlarmShouldFailInvalidDetails() { | |
console.log('[Alarm Triggers Test Suite] Fake Test Alarm Should Fail Invalid Details'); | |
postTransaction({ | |
title: `Fake Test Alarm Should Fail Invalid Details`, | |
type: 'bookmark', | |
isAlarm: true, | |
subtype: 'TEST-ALARM', | |
transactionId: Math.random().toString(), | |
startTime: startTime(), | |
endTime: endTime(), | |
details: { | |
description: "Parser-Based Test Alarm", | |
favourite: false, | |
invalid: 'property', | |
}, | |
creator: 'me', | |
isRealtime: true, | |
cameras: ['4sWsyRdxVnidiP6G', '9NUzVQUE1NZ11b8X'] | |
}, { | |
postProcessMetadata: metadata.EVENT && metadata.EVENT.postProcessMetadata | |
}); | |
} | |
fakeTransactions(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment