Files
openmct/example/faultManagement/utils.js
Jamie V 57f3d4eba0 [Fault Management] New Example Provider, Unit and e2e tests (#5579)
* added unit tests for fault management plugin

* modified the example fault provider to work out of the box

* updating for new e2e folder structure

* part of the e2e tests

* WIP

* Imagery thumbnail regression fixes - 5327 (#5569)

* Add an active class to thumbnail to indicate current focused image

* Differentiate bg color between real-time and fixed

* scrollIntoView inline: center

* Added watcher for bounds change to trigger thumbnail scroll

* Resolve merge conflict with requestHistory change to telemetry collection

* Split thumbnail into sub component

* Monitor isFixed value to unpause playback status

* updated search to include name, namespace and description added some more e2e tests

* added rest of e2e tests

* fixed my init script, had to disable lint for no-force because it was not working without it, saw online this may be a pw bug

* fix: removing maelstrom theme from application (#5600)

* added some tests for no faults

* visual tests

* added visual tests for fault management

* created utils file for shared functionality between function and visual tests

* updating to 2.0.8

* tryin to remove imagery changes from master

* trying to trigger a refresh

* tryin to refresh

* updated search to include name, namespace and description added some more e2e tests

* added rest of e2e tests

* fix: removing maelstrom theme from application (#5600)

* fixed my init script, had to disable lint for no-force because it was not working without it, saw online this may be a pw bug

* added some tests for no faults

* visual tests

* added visual tests for fault management

* created utils file for shared functionality between function and visual tests

* updating to 2.0.8

* no clue

* still no clue

* removing imports and chaning to requires

* updating utils file to work with require

* fixing paths

* fixing a test I had messed up when adding static exmaple faults

* ONE LAST PATH FIX... hopefully

* typo in files fix

* fix folder typo

* thought I got this one, but apparently not, well I did now! who is laughing now!?

Co-authored-by: Michael Rogers <contact@mhrogers.com>
Co-authored-by: Vitor Henckel <vitor@henckel.com.br>
2022-08-15 14:09:23 -07:00

77 lines
1.9 KiB
JavaScript

const SEVERITIES = ['WATCH', 'WARNING', 'CRITICAL'];
const NAMESPACE = '/Example/fault-';
const getRandom = {
severity: () => SEVERITIES[Math.floor(Math.random() * 3)],
value: () => Math.random() + Math.floor(Math.random() * 21) - 10,
fault: (num, staticFaults) => {
let val = getRandom.value();
let severity = getRandom.severity();
let time = Date.now() - num;
if (staticFaults) {
let severityIndex = num > 3 ? num % 3 : num;
val = num;
severity = SEVERITIES[severityIndex - 1];
time = num;
}
return {
type: num,
fault: {
acknowledged: false,
currentValueInfo: {
value: val,
rangeCondition: severity,
monitoringResult: severity
},
id: `id-${num}`,
name: `Example Fault ${num}`,
namespace: NAMESPACE + num,
seqNum: 0,
severity: severity,
shelved: false,
shortDescription: '',
triggerTime: time,
triggerValueInfo: {
value: val,
rangeCondition: severity,
monitoringResult: severity
}
}
};
}
};
function shelveFault(fault, opts = {
shelved: true,
comment: '',
shelveDuration: 90000
}) {
fault.shelved = true;
setTimeout(() => {
fault.shelved = false;
}, opts.shelveDuration);
}
function acknowledgeFault(fault) {
fault.acknowledged = true;
}
function randomFaults(staticFaults, count = 5) {
let faults = [];
for (let x = 1, y = count + 1; x < y; x++) {
faults.push(getRandom.fault(x, staticFaults));
}
return faults;
}
export default {
randomFaults,
shelveFault,
acknowledgeFault
};