diff --git a/e2e/tests/functional/plugins/comps/comps.e2e.spec.js b/e2e/tests/functional/plugins/comps/comps.e2e.spec.js new file mode 100644 index 0000000000..4126aca7ca --- /dev/null +++ b/e2e/tests/functional/plugins/comps/comps.e2e.spec.js @@ -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); + }); +}); diff --git a/src/plugins/comps/CompsManager.js b/src/plugins/comps/CompsManager.js index 4b336a8fdd..78f8c7dd12 100644 --- a/src/plugins/comps/CompsManager.js +++ b/src/plugins/comps/CompsManager.js @@ -21,14 +21,6 @@ export default class CompsManager extends EventEmitter { this.clearData = this.clearData.bind(this); } - isValid() { - return this.#domainObject.configuration.comps.valid; - } - - setValid(valid) { - this.#domainObject.configuration.comps.valid = valid; - } - #getNextAlphabeticalParameterName() { const parameters = this.#domainObject.configuration.comps.parameters; const existingNames = new Set(parameters.map((p) => p.name)); @@ -115,7 +107,7 @@ export default class CompsManager extends EventEmitter { } isReady() { - return this.isValid() && this.#loaded; + return this.#loaded; } async load() { diff --git a/src/plugins/comps/CompsTelemetryProvider.js b/src/plugins/comps/CompsTelemetryProvider.js index a6c6fa684b..327f0eb616 100644 --- a/src/plugins/comps/CompsTelemetryProvider.js +++ b/src/plugins/comps/CompsTelemetryProvider.js @@ -61,10 +61,6 @@ export default class CompsTelemetryProvider { this.#openmct, this.#compsManagerPool ); - if (!specificCompsManager.isValid()) { - resolve([]); - return; - } specificCompsManager.load().then(() => { const callbackID = this.#getCallbackID(); const telemetryForComps = specificCompsManager.requestUnderlyingTelemetry(); @@ -169,7 +165,8 @@ export default class CompsTelemetryProvider { } else if (type === 'calculationRequestResult' && this.#requestPromises[callbackID]) { console.debug('📝 Shared worker request message:', event.data); if (error) { - this.#requestPromises[callbackID].reject(error); + console.error('📝 Error calculating request:', event.data); + this.#requestPromises[callbackID].resolve([]); } else { this.#requestPromises[callbackID].resolve(result); } diff --git a/src/plugins/comps/components/CompsView.vue b/src/plugins/comps/components/CompsView.vue index 46a842287c..5dcc55be00 100644 --- a/src/plugins/comps/components/CompsView.vue +++ b/src/plugins/comps/components/CompsView.vue @@ -246,7 +246,13 @@ function applyTestData() { return; } 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; }, {}); try { @@ -254,11 +260,9 @@ function applyTestData() { const formattedData = getValueFormatter().format(testOutput); currentTestOutput.value = formattedData; expressionOutput.value = null; - compsManager.setValid(true); } catch (error) { console.error('👎 Error applying test data', error); currentTestOutput.value = null; - compsManager.setValid(false); expressionOutput.value = error.message; } } diff --git a/src/plugins/comps/plugin.js b/src/plugins/comps/plugin.js index 4bfa62eede..19c1676954 100644 --- a/src/plugins/comps/plugin.js +++ b/src/plugins/comps/plugin.js @@ -39,8 +39,7 @@ export default function CompsPlugin() { domainObject.configuration = { comps: { expression: '', - parameters: [], - valid: false + parameters: [] } }; domainObject.composition = [];