mirror of
https://github.com/nasa/openmct.git
synced 2025-01-27 14:49:28 +00:00
Merge branch 'telemetry-comps' of github.com:nasa/openmct into telemetry-comps
This commit is contained in:
commit
1615c36b7e
43
e2e/tests/functional/plugins/comps/comps.e2e.spec.js
Normal file
43
e2e/tests/functional/plugins/comps/comps.e2e.spec.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2024, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
import { createDomainObjectWithDefaults } from '../../../../appActions.js';
|
||||||
|
import { test } from '../../../../pluginFixtures.js';
|
||||||
|
|
||||||
|
test.describe('Comps', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// Open a browser, navigate to the main page, and wait until all networkevents to resolve
|
||||||
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Can add and remove telemetry sources', async ({ page }) => {
|
||||||
|
// Create the gauge with defaults
|
||||||
|
const comp = await createDomainObjectWithDefaults(page, { type: 'Derived Telemetry' });
|
||||||
|
|
||||||
|
// Create a sine wave generator within the comp
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Sine Wave Generator',
|
||||||
|
parent: comp.uuid
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.goto(comp.url);
|
||||||
|
});
|
||||||
|
});
|
@ -21,14 +21,6 @@ export default class CompsManager extends EventEmitter {
|
|||||||
this.clearData = this.clearData.bind(this);
|
this.clearData = this.clearData.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
isValid() {
|
|
||||||
return this.#domainObject.configuration.comps.valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
setValid(valid) {
|
|
||||||
this.#domainObject.configuration.comps.valid = valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
#getNextAlphabeticalParameterName() {
|
#getNextAlphabeticalParameterName() {
|
||||||
const parameters = this.#domainObject.configuration.comps.parameters;
|
const parameters = this.#domainObject.configuration.comps.parameters;
|
||||||
const existingNames = new Set(parameters.map((p) => p.name));
|
const existingNames = new Set(parameters.map((p) => p.name));
|
||||||
@ -115,7 +107,7 @@ export default class CompsManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isReady() {
|
isReady() {
|
||||||
return this.isValid() && this.#loaded;
|
return this.#loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
|
@ -61,10 +61,6 @@ export default class CompsTelemetryProvider {
|
|||||||
this.#openmct,
|
this.#openmct,
|
||||||
this.#compsManagerPool
|
this.#compsManagerPool
|
||||||
);
|
);
|
||||||
if (!specificCompsManager.isValid()) {
|
|
||||||
resolve([]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
specificCompsManager.load().then(() => {
|
specificCompsManager.load().then(() => {
|
||||||
const callbackID = this.#getCallbackID();
|
const callbackID = this.#getCallbackID();
|
||||||
const telemetryForComps = specificCompsManager.requestUnderlyingTelemetry();
|
const telemetryForComps = specificCompsManager.requestUnderlyingTelemetry();
|
||||||
@ -169,7 +165,8 @@ export default class CompsTelemetryProvider {
|
|||||||
} else if (type === 'calculationRequestResult' && this.#requestPromises[callbackID]) {
|
} else if (type === 'calculationRequestResult' && this.#requestPromises[callbackID]) {
|
||||||
console.debug('📝 Shared worker request message:', event.data);
|
console.debug('📝 Shared worker request message:', event.data);
|
||||||
if (error) {
|
if (error) {
|
||||||
this.#requestPromises[callbackID].reject(error);
|
console.error('📝 Error calculating request:', event.data);
|
||||||
|
this.#requestPromises[callbackID].resolve([]);
|
||||||
} else {
|
} else {
|
||||||
this.#requestPromises[callbackID].resolve(result);
|
this.#requestPromises[callbackID].resolve(result);
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,13 @@ function applyTestData() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const scope = parameters.value.reduce((acc, parameter) => {
|
const scope = parameters.value.reduce((acc, parameter) => {
|
||||||
acc[parameter.name] = parameter.testValue;
|
// try to parse the test value as JSON
|
||||||
|
try {
|
||||||
|
const parsedValue = JSON.parse(parameter.testValue);
|
||||||
|
acc[parameter.name] = parsedValue;
|
||||||
|
} catch (error) {
|
||||||
|
acc[parameter.name] = parameter.testValue;
|
||||||
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
try {
|
try {
|
||||||
@ -254,11 +260,9 @@ function applyTestData() {
|
|||||||
const formattedData = getValueFormatter().format(testOutput);
|
const formattedData = getValueFormatter().format(testOutput);
|
||||||
currentTestOutput.value = formattedData;
|
currentTestOutput.value = formattedData;
|
||||||
expressionOutput.value = null;
|
expressionOutput.value = null;
|
||||||
compsManager.setValid(true);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('👎 Error applying test data', error);
|
console.error('👎 Error applying test data', error);
|
||||||
currentTestOutput.value = null;
|
currentTestOutput.value = null;
|
||||||
compsManager.setValid(false);
|
|
||||||
expressionOutput.value = error.message;
|
expressionOutput.value = error.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,7 @@ export default function CompsPlugin() {
|
|||||||
domainObject.configuration = {
|
domainObject.configuration = {
|
||||||
comps: {
|
comps: {
|
||||||
expression: '',
|
expression: '',
|
||||||
parameters: [],
|
parameters: []
|
||||||
valid: false
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
domainObject.composition = [];
|
domainObject.composition = [];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user