diff --git a/e2e/tests/functional/plugins/comps/comps.e2e.spec.js b/e2e/tests/functional/plugins/comps/comps.e2e.spec.js index 4126aca7ca..b708d32df8 100644 --- a/e2e/tests/functional/plugins/comps/comps.e2e.spec.js +++ b/e2e/tests/functional/plugins/comps/comps.e2e.spec.js @@ -19,8 +19,8 @@ * 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'; +import { createDomainObjectWithDefaults, setRealTimeMode } from '../../../../appActions.js'; +import { expect, test } from '../../../../pluginFixtures.js'; test.describe('Comps', () => { test.beforeEach(async ({ page }) => { @@ -28,8 +28,8 @@ test.describe('Comps', () => { await page.goto('./', { waitUntil: 'domcontentloaded' }); }); - test('Can add and remove telemetry sources', async ({ page }) => { - // Create the gauge with defaults + test('Basic Functionality Works', async ({ page }) => { + // Create the comps with defaults const comp = await createDomainObjectWithDefaults(page, { type: 'Derived Telemetry' }); // Create a sine wave generator within the comp @@ -38,6 +38,43 @@ test.describe('Comps', () => { parent: comp.uuid }); + // Check that expressions can be edited await page.goto(comp.url); + await page.getByLabel('Edit Object').click(); + await page.getByPlaceholder('Enter an expression').fill('a*2'); + await page.getByText('Current Output').click(); + await expect(page.getByText('Expression valid')).toBeVisible(); + + // Check that expressions are marked invalid + await page.getByLabel('Reference Name Input for a').fill('b'); + await page.getByText('Current Output').click(); + await expect(page.getByText('Invalid: Undefined symbol a')).toBeVisible(); + + // Check that test data works + await page.getByPlaceholder('Enter an expression').fill('b*2'); + await page.getByLabel('Reference Test Value for b').fill('5'); + await page.getByLabel('Apply Test Data').click(); + let testValue = await page.getByLabel('Current Output Value').textContent(); + expect(testValue).toBe('10'); + + // Check that real data works + await page.getByLabel('Apply Test Data').click(); + await setRealTimeMode(page); + testValue = await page.getByLabel('Current Output Value').textContent(); + expect(testValue).not.toBe('10'); + // should be a number + expect(parseFloat(testValue)).not.toBeNaN(); + + // Check that the comps are saved + await page.getByLabel('Save').click(); + await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(); + const expression = await page.getByLabel('Expression', { exact: true }).textContent(); + expect(expression).toBe('b*2'); + + // Check that comps work after being saved + testValue = await page.getByLabel('Current Output Value').textContent(); + expect(testValue).not.toBe('10'); + // should be a number + expect(parseFloat(testValue)).not.toBeNaN(); }); }); diff --git a/src/plugins/comps/CompsManager.js b/src/plugins/comps/CompsManager.js index 78f8c7dd12..d998ebabd5 100644 --- a/src/plugins/comps/CompsManager.js +++ b/src/plugins/comps/CompsManager.js @@ -119,12 +119,10 @@ export default class CompsManager extends EventEmitter { await Promise.all(this.#telemetryLoadedPromises); this.#telemetryLoadedPromises = []; this.#loaded = true; - console.debug('📦 CompsManager: loaded'); } } async startListeningToUnderlyingTelemetry() { - console.debug('🎉 CompsManager: startListeningToUnderlyingTelemetry'); this.#loaded = false; Object.keys(this.#telemetryCollections).forEach((keyString) => { if (!this.#telemetryCollections[keyString].loaded) { @@ -140,7 +138,6 @@ export default class CompsManager extends EventEmitter { } stopListeningToUnderlyingTelemetry() { - console.debug('🔇 CompsManager: stopListeningToUnderlyingTelemetry'); this.#loaded = false; Object.keys(this.#telemetryCollections).forEach((keyString) => { const specificTelemetryProcessor = this.#telemetryProcessors[keyString]; @@ -162,7 +159,6 @@ export default class CompsManager extends EventEmitter { this.#composition.on('remove', this.#removeTelemetryObject); await this.#composition.load(); } - console.debug(`📢 CompsManager: composition loaded`); } getFullDataFrame(newTelemetry) { @@ -202,7 +198,6 @@ export default class CompsManager extends EventEmitter { } #removeTelemetryObject = (telemetryObjectIdentifier) => { - console.debug('❌ CompsManager: removeTelemetryObject', telemetryObjectIdentifier); const keyString = this.#openmct.objects.makeKeyString(telemetryObjectIdentifier); delete this.#telemetryObjects[keyString]; this.#telemetryCollections[keyString]?.destroy(); @@ -237,7 +232,6 @@ export default class CompsManager extends EventEmitter { }; clearData(telemetryLoadedPromise) { - console.debug('💨 Clear Data fired, need to wait for all telemetry collections to load'); this.#loaded = false; this.#telemetryLoadedPromises.push(telemetryLoadedPromise); } @@ -251,7 +245,6 @@ export default class CompsManager extends EventEmitter { } #addTelemetryObject = (telemetryObject) => { - console.debug(`📢 CompsManager: addTelemetryObject`, telemetryObject); const keyString = this.#openmct.objects.makeKeyString(telemetryObject.identifier); this.#telemetryObjects[keyString] = telemetryObject; this.#telemetryCollections[keyString] = @@ -261,7 +254,6 @@ export default class CompsManager extends EventEmitter { this.#telemetryCollections[keyString].on('clear', this.clearData); const telemetryLoadedPromise = this.#telemetryCollections[keyString].load(); this.#telemetryLoadedPromises.push(telemetryLoadedPromise); - console.debug('📢 CompsManager: loaded telemetry collection', keyString); // check to see if we have a corresponding parameter // if not, add one @@ -271,7 +263,6 @@ export default class CompsManager extends EventEmitter { if (!parameterExists) { this.addParameter(telemetryObject); } - console.debug(`📢 CompsManager: done adding telemetry object`, telemetryObject); }; static getCompsManager(domainObject, openmct, compsManagerPool) { diff --git a/src/plugins/comps/CompsMathWorker.js b/src/plugins/comps/CompsMathWorker.js index 823e87c676..a2ca7ccab3 100644 --- a/src/plugins/comps/CompsMathWorker.js +++ b/src/plugins/comps/CompsMathWorker.js @@ -3,10 +3,8 @@ import { evaluate } from 'mathjs'; // eslint-disable-next-line no-undef onconnect = function (e) { const port = e.ports[0]; - console.debug('🧮 Comps Math Worker connected'); port.onmessage = function (event) { - console.debug('🧮 Comps Math Worker message:', event); const { type, callbackID, telemetryForComps, expression, parameters } = event.data; let responseType = 'unknown'; let error = null; @@ -26,7 +24,6 @@ onconnect = function (e) { } } catch (errorInCalculation) { error = errorInCalculation; - console.error('🧮 Comps Math Worker error:', errorInCalculation); } port.postMessage({ type: responseType, callbackID, result, error }); }; diff --git a/src/plugins/comps/CompsTelemetryProvider.js b/src/plugins/comps/CompsTelemetryProvider.js index 327f0eb616..57519a4b1b 100644 --- a/src/plugins/comps/CompsTelemetryProvider.js +++ b/src/plugins/comps/CompsTelemetryProvider.js @@ -79,10 +79,6 @@ export default class CompsTelemetryProvider { callbackID }; this.#sharedWorker.port.postMessage(payload); - console.debug( - '🧮 Comps Telemetry Provider: sending request request (double request!)', - payload - ); }); }); } @@ -104,7 +100,6 @@ export default class CompsTelemetryProvider { parameters, callbackID }; - console.debug('🧮 Comps Telemetry Provider: sending subscription request', payload); this.#sharedWorker.port.postMessage(payload); } @@ -123,10 +118,6 @@ export default class CompsTelemetryProvider { ); specificCompsManager.on('underlyingTelemetryUpdated', boundComputeOnNewTelemetry); specificCompsManager.startListeningToUnderlyingTelemetry(); - console.debug( - `🧮 Comps Telemetry Provider: subscribed to comps. Now have ${Object.keys(this.#subscriptionCallbacks).length} listener`, - this.#subscriptionCallbacks - ); return () => { specificCompsManager.off('underlyingTelemetryUpdated', boundComputeOnNewTelemetry); delete this.#subscriptionCallbacks[callbackID]; @@ -160,10 +151,8 @@ export default class CompsTelemetryProvider { this.#subscriptionCallbacks[callbackID] && result.length ) { - console.debug('📝 Shared worker subscription message:', event.data); this.#subscriptionCallbacks[callbackID](result); } else if (type === 'calculationRequestResult' && this.#requestPromises[callbackID]) { - console.debug('📝 Shared worker request message:', event.data); if (error) { console.error('📝 Error calculating request:', event.data); this.#requestPromises[callbackID].resolve([]); diff --git a/src/plugins/comps/components/CompsView.vue b/src/plugins/comps/components/CompsView.vue index ccc7f2bacb..80412d0534 100644 --- a/src/plugins/comps/components/CompsView.vue +++ b/src/plugins/comps/components/CompsView.vue @@ -64,6 +64,7 @@