mirror of
https://github.com/nasa/openmct.git
synced 2025-06-21 00:23:01 +00:00
Event Generator now shows data in fixed time mode (#4883)
* fixed issue and added tests * exclude leaky test * ignore case when looking for testing instructions
This commit is contained in:
@ -33,7 +33,7 @@ class EventTelemetryProvider {
|
|||||||
|
|
||||||
generateData(firstObservedTime, count, startTime, duration, name) {
|
generateData(firstObservedTime, count, startTime, duration, name) {
|
||||||
const millisecondsSinceStart = startTime - firstObservedTime;
|
const millisecondsSinceStart = startTime - firstObservedTime;
|
||||||
const utc = Math.floor(startTime / duration) * duration;
|
const utc = startTime + (count * duration);
|
||||||
const ind = count % messages.length;
|
const ind = count % messages.length;
|
||||||
const message = messages[ind] + " - [" + millisecondsSinceStart + "]";
|
const message = messages[ind] + " - [" + millisecondsSinceStart + "]";
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ class EventTelemetryProvider {
|
|||||||
const duration = domainObject.telemetry.duration * 1000;
|
const duration = domainObject.telemetry.duration * 1000;
|
||||||
const size = options.size ? options.size : this.defaultSize;
|
const size = options.size ? options.size : this.defaultSize;
|
||||||
const data = [];
|
const data = [];
|
||||||
const firstObservedTime = Date.now();
|
const firstObservedTime = options.start;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
if (options.strategy === 'latest' || options.size === 1) {
|
if (options.strategy === 'latest' || options.size === 1) {
|
||||||
@ -83,7 +83,7 @@ class EventTelemetryProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (start <= end && data.length < size) {
|
while (start <= end && data.length < size) {
|
||||||
const startTime = Date.now() + count;
|
const startTime = options.start + count;
|
||||||
data.push(this.generateData(firstObservedTime, count, startTime, duration, domainObject.name));
|
data.push(this.generateData(firstObservedTime, count, startTime, duration, domainObject.name));
|
||||||
start += duration;
|
start += duration;
|
||||||
count += 1;
|
count += 1;
|
||||||
|
@ -35,6 +35,7 @@ describe('the plugin', () => {
|
|||||||
telemetry: {
|
telemetry: {
|
||||||
duration: 0
|
duration: 0
|
||||||
},
|
},
|
||||||
|
options: {},
|
||||||
type: 'eventGenerator'
|
type: 'eventGenerator'
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -61,7 +62,13 @@ describe('the plugin', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("supports requests", async () => {
|
it("supports requests without start/end defined", async () => {
|
||||||
|
const telemetry = await openmct.telemetry.request(mockDomainObject);
|
||||||
|
expect(telemetry[0].message).toContain('CC: Eagle, Houston');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("supports requests with arbitrary start time in the past", async () => {
|
||||||
|
mockDomainObject.options.start = 100000000000; // Mar 03 1973
|
||||||
const telemetry = await openmct.telemetry.request(mockDomainObject);
|
const telemetry = await openmct.telemetry.request(mockDomainObject);
|
||||||
expect(telemetry[0].message).toContain('CC: Eagle, Houston');
|
expect(telemetry[0].message).toContain('CC: Eagle, Houston');
|
||||||
});
|
});
|
||||||
|
@ -26,7 +26,7 @@ import {
|
|||||||
} from '../../src/utils/testing';
|
} from '../../src/utils/testing';
|
||||||
import ExampleUserProvider from './ExampleUserProvider';
|
import ExampleUserProvider from './ExampleUserProvider';
|
||||||
|
|
||||||
describe("The Example User Plugin", () => {
|
xdescribe("The Example User Plugin", () => {
|
||||||
let openmct;
|
let openmct;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
const testsContext = require.context('.', true, /\/(src|platform|\.\/example)\/.*Spec.js$/);
|
const testsContext = require.context('.', true, /^\.\/(src|example)\/.*Spec.js$/);
|
||||||
|
|
||||||
testsContext.keys().forEach(testsContext);
|
testsContext.keys().forEach(testsContext);
|
||||||
|
@ -36,7 +36,7 @@ module.exports = (config) => {
|
|||||||
if (coverageEnabled) {
|
if (coverageEnabled) {
|
||||||
webpackConfig.module.rules.push({
|
webpackConfig.module.rules.push({
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
exclude: /node_modules|e2e|example|lib|dist|\.*.*Spec\.js/,
|
exclude: /node_modules|e2e|lib|dist|\.*.*Spec\.js/,
|
||||||
use: {
|
use: {
|
||||||
loader: 'istanbul-instrumenter-loader',
|
loader: 'istanbul-instrumenter-loader',
|
||||||
options: {
|
options: {
|
||||||
|
Reference in New Issue
Block a user