From 3986a12c11108077f0488fcce4b26847f80da680 Mon Sep 17 00:00:00 2001 From: Charles Hacskaylo Date: Wed, 3 Aug 2022 18:23:01 -0700 Subject: [PATCH 01/11] Closes #5536, #5538 - Significant changes to code flow for better handling of missing telemetry values; closes #5538. - Changes to flow to handle range display when updating composition and when ranges are set by limits. - Added `GaugeCompositionPolicy.js`; closes #5536. --- src/plugins/gauge/GaugeCompositionPolicy.js | 27 ++++++++++++++ src/plugins/gauge/GaugePlugin.js | 2 ++ src/plugins/gauge/components/Gauge.vue | 40 +++++++++++++-------- 3 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 src/plugins/gauge/GaugeCompositionPolicy.js diff --git a/src/plugins/gauge/GaugeCompositionPolicy.js b/src/plugins/gauge/GaugeCompositionPolicy.js new file mode 100644 index 00000000000..1e5ddb55cc6 --- /dev/null +++ b/src/plugins/gauge/GaugeCompositionPolicy.js @@ -0,0 +1,27 @@ +export default function GaugeCompositionPolicy(openmct) { + function hasNumericTelemetry(domainObject) { + const hasTelemetry = openmct.telemetry.isTelemetryObject(domainObject); + if (!hasTelemetry) { + return false; + } + + let metadata = openmct.telemetry.getMetadata(domainObject); + + return metadata.values().length > 0 && hasDomainAndRange(metadata); + } + + function hasDomainAndRange(metadata) { + return (metadata.valuesForHints(['range']).length > 0 + && metadata.valuesForHints(['domain']).length > 0); + } + + return { + allow: function (parent, child) { + if (parent.type === 'gauge') { + return hasNumericTelemetry(child); + } + + return true; + } + }; +} diff --git a/src/plugins/gauge/GaugePlugin.js b/src/plugins/gauge/GaugePlugin.js index 441e53cd572..5cdf989c080 100644 --- a/src/plugins/gauge/GaugePlugin.js +++ b/src/plugins/gauge/GaugePlugin.js @@ -22,6 +22,7 @@ import GaugeViewProvider from './GaugeViewProvider'; import GaugeFormController from './components/GaugeFormController.vue'; +import GaugeCompositionPolicy from "./GaugeCompositionPolicy"; import Vue from 'vue'; export const GAUGE_TYPES = [ @@ -182,6 +183,7 @@ export default function () { } ] }); + openmct.composition.addPolicy(new GaugeCompositionPolicy(openmct).allow); }; function getGaugeFormController(openmct) { diff --git a/src/plugins/gauge/components/Gauge.vue b/src/plugins/gauge/components/Gauge.vue index 2d250158eb0..0bcb1cc445a 100644 --- a/src/plugins/gauge/components/Gauge.vue +++ b/src/plugins/gauge/components/Gauge.vue @@ -404,10 +404,13 @@ export default { return VIEWBOX_STR.replace('X', this.digits * DIGITS_RATIO); }, rangeFontSize() { + let RANGE_CHARS_MAX = 3; const CHAR_THRESHOLD = 3; const START_PERC = 8.5; const REDUCE_PERC = 0.8; - const RANGE_CHARS_MAX = Math.max(this.rangeLow.toString().length, this.rangeHigh.toString().length); + if (this.rangeLow && this.rangeHigh) { + RANGE_CHARS_MAX = Math.max(this.rangeLow.toString().length, this.rangeHigh.toString().length); + } return this.fontSizeFromChars(RANGE_CHARS_MAX, CHAR_THRESHOLD, START_PERC, REDUCE_PERC); }, @@ -617,11 +620,13 @@ export default { this.curVal = DEFAULT_CURRENT_VALUE; this.formats = null; - this.limitHigh = ''; - this.limitLow = ''; this.metadata = null; - this.rangeHigh = null; - this.rangeLow = null; + if (this.isUseTelemetryLimits) { + this.limitHigh = ''; + this.limitLow = ''; + this.rangeHigh = null; + this.rangeLow = null; + } this.valueKey = null; }, request(domainObject = this.telemetryObject) { @@ -659,7 +664,7 @@ export default { }, updateLimits(telemetryLimit) { if (!telemetryLimit || !this.domainObject.configuration.gaugeController.isUseTelemetryLimits) { - return; + return; } let limits = { @@ -678,7 +683,6 @@ export default { limits = telemetryLimit.WATCH; } else { this.openmct.notifications.error('No limits definition for given telemetry, hiding low and high limits'); - this.displayMinMax = false; this.limitHigh = ''; this.limitLow = ''; @@ -694,25 +698,33 @@ export default { }, updateValue(datum) { this.datum = datum; + let val = DEFAULT_CURRENT_VALUE; if (this.isRendering) { return; } - const { start, end } = this.openmct.time.bounds(); - const parsedValue = this.timeFormatter.parse(this.datum); + if (this.datum !== undefined) { + const { + start, + end + } = this.openmct.time.bounds(); + const parsedValue = this.timeFormatter.parse(this.datum); + + const beforeStartOfBounds = parsedValue < start; + const afterEndOfBounds = parsedValue > end; + if (afterEndOfBounds || beforeStartOfBounds) { + return; + } - const beforeStartOfBounds = parsedValue < start; - const afterEndOfBounds = parsedValue > end; - if (afterEndOfBounds || beforeStartOfBounds) { - return; + val = this.round(this.formats[this.valueKey].format(this.datum), this.precision); } this.isRendering = true; requestAnimationFrame(() => { this.isRendering = false; - this.curVal = this.round(this.formats[this.valueKey].format(this.datum), this.precision); + this.curVal = val; }); }, valToPercent(vValue) { From 06058c4d23fb083d0d8dd6426988f7f8664bc02f Mon Sep 17 00:00:00 2001 From: Charles Hacskaylo Date: Thu, 4 Aug 2022 11:09:49 -0700 Subject: [PATCH 02/11] Closes #5536, #5538 - Code cleanup, linting. --- src/plugins/gauge/GaugePlugin.js | 2 +- src/plugins/gauge/components/Gauge.vue | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/gauge/GaugePlugin.js b/src/plugins/gauge/GaugePlugin.js index 5cdf989c080..49f02ae13b0 100644 --- a/src/plugins/gauge/GaugePlugin.js +++ b/src/plugins/gauge/GaugePlugin.js @@ -183,7 +183,7 @@ export default function () { } ] }); - openmct.composition.addPolicy(new GaugeCompositionPolicy(openmct).allow); + openmct.composition.addPolicy(new GaugeCompositionPolicy(openmct).allow); }; function getGaugeFormController(openmct) { diff --git a/src/plugins/gauge/components/Gauge.vue b/src/plugins/gauge/components/Gauge.vue index 0bcb1cc445a..9f9fca9ac12 100644 --- a/src/plugins/gauge/components/Gauge.vue +++ b/src/plugins/gauge/components/Gauge.vue @@ -408,6 +408,7 @@ export default { const CHAR_THRESHOLD = 3; const START_PERC = 8.5; const REDUCE_PERC = 0.8; + if (this.rangeLow && this.rangeHigh) { RANGE_CHARS_MAX = Math.max(this.rangeLow.toString().length, this.rangeHigh.toString().length); } @@ -627,6 +628,7 @@ export default { this.rangeHigh = null; this.rangeLow = null; } + this.valueKey = null; }, request(domainObject = this.telemetryObject) { @@ -664,7 +666,7 @@ export default { }, updateLimits(telemetryLimit) { if (!telemetryLimit || !this.domainObject.configuration.gaugeController.isUseTelemetryLimits) { - return; + return; } let limits = { From f19c0c33124ab81be9d7abc67c823e190c53cea9 Mon Sep 17 00:00:00 2001 From: Charles Hacskaylo Date: Thu, 26 Oct 2023 11:25:54 -0700 Subject: [PATCH 03/11] Closes #5538 - Linting fixes. --- src/plugins/gauge/components/GaugeComponent.vue | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/plugins/gauge/components/GaugeComponent.vue b/src/plugins/gauge/components/GaugeComponent.vue index d9b66116f5e..ff618563d54 100644 --- a/src/plugins/gauge/components/GaugeComponent.vue +++ b/src/plugins/gauge/components/GaugeComponent.vue @@ -332,7 +332,7 @@ import stalenessMixin from '@/ui/mixins/staleness-mixin'; import tooltipHelpers from '../../../api/tooltips/tooltipMixins'; -import {DIAL_VALUE_DEG_OFFSET, getLimitDegree} from '../gauge-limit-util'; +import { DIAL_VALUE_DEG_OFFSET, getLimitDegree } from '../gauge-limit-util'; const LIMIT_PADDING_IN_PERCENT = 10; const DEFAULT_CURRENT_VALUE = '--'; @@ -402,8 +402,7 @@ export default { const CHAR_THRESHOLD = 3; const START_PERC = 8.5; const REDUCE_PERC = 0.8; - const RANGE_CHARS_MAX = (this.rangeLow && this.rangeHigh) ? - Math.max(this.rangeLow.toString().length, this.rangeHigh.toString().length) : CHAR_THRESHOLD; + const RANGE_CHARS_MAX = (this.rangeLow && this.rangeHigh) ? Math.max(this.rangeLow.toString().length, this.rangeHigh.toString().length) : CHAR_THRESHOLD; return this.fontSizeFromChars(RANGE_CHARS_MAX, CHAR_THRESHOLD, START_PERC, REDUCE_PERC); }, @@ -518,7 +517,7 @@ export default { }, timeFormatter() { const timeSystem = this.activeTimeSystem; - const metadataValue = this.metadata.value(timeSystem.key) || {format: timeSystem.key}; + const metadataValue = this.metadata.value(timeSystem.key) || { format: timeSystem.key }; return this.openmct.telemetry.getValueFormatter(metadataValue); } @@ -717,10 +716,7 @@ export default { return; } - const { - start, - end - } = this.openmct.time.bounds(); + const { start, end } = this.openmct.time.bounds(); const parsedValue = this.timeFormatter.parse(this.datum); const beforeStartOfBounds = parsedValue < start; @@ -749,7 +745,7 @@ export default { return this.round(((this.rangeHigh - vValue) / (this.rangeHigh - this.rangeLow)) * 100, 2); }, async showToolTip() { - const {CENTER} = this.openmct.tooltips.TOOLTIP_LOCATIONS; + const { CENTER } = this.openmct.tooltips.TOOLTIP_LOCATIONS; this.buildToolTip(await this.getTelemetryPathString(), CENTER, 'gauge'); } } From 300100a6b8cf81cf32063d3c3af6de41c4b4edaa Mon Sep 17 00:00:00 2001 From: Charles Hacskaylo Date: Mon, 6 Nov 2023 15:56:02 -0800 Subject: [PATCH 04/11] Closes #5538 - Added test for 'Gauge does not display NaN when data not available'. --- .../plugins/gauge/gauge.e2e.spec.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js index bfc4464d507..d710bfab0a6 100644 --- a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js +++ b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js @@ -133,4 +133,24 @@ test.describe('Gauge', () => { // TODO: Verify changes in the UI }); + + test('Gauge does not display NaN when data not available', async ({ page }) => { + // Create a Gauge + await page.getByRole('button', { name: ' Create ' }).click(); + await page.getByRole('menuitem', { name: ' Gauge' }).click(); + await page.getByLabel('Save').click(); // Save button in Create dialog + await page.getByLabel('Save').click(); // Save button in edit mode + await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(); + + // Create a Sine Wave Generator in the Gauge with a loading delay + await page.getByRole('button', { name: ' Create ' }).click(); + await page.getByRole('menuitem', { name: ' Sine Wave Generator' }).click(); + await page.getByRole('dialog').locator('div').filter({ hasText: 'Loading Delay (ms)' }).nth(3).click(); + await page.getByLabel('Loading Delay (ms)').fill('5000'); + await page.getByLabel('Save').click(); + await page.getByLabel('Expand My Items folder').click(); + await page.getByRole('treeitem', { name: 'Expand Unnamed Gauge gauge  Unnamed Gauge' }).locator('a').click(); + const gaugeNoDataText = await page.locator('.js-dial-current-value tspan').textContent(); + expect(gaugeNoDataText).toBe('--'); + }); }); From 8979ed35ce0baf0eb1a56d63fd57c82eb543de73 Mon Sep 17 00:00:00 2001 From: Charles Hacskaylo Date: Mon, 6 Nov 2023 16:07:33 -0800 Subject: [PATCH 05/11] Closes #5538 - Refined test. --- e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js index d710bfab0a6..471736af354 100644 --- a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js +++ b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js @@ -135,12 +135,7 @@ test.describe('Gauge', () => { }); test('Gauge does not display NaN when data not available', async ({ page }) => { - // Create a Gauge - await page.getByRole('button', { name: ' Create ' }).click(); - await page.getByRole('menuitem', { name: ' Gauge' }).click(); - await page.getByLabel('Save').click(); // Save button in Create dialog - await page.getByLabel('Save').click(); // Save button in edit mode - await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(); + const gauge = await createDomainObjectWithDefaults(page, { type: 'Gauge', name: 'Unnamed Gauge' }); // Create a Sine Wave Generator in the Gauge with a loading delay await page.getByRole('button', { name: ' Create ' }).click(); From cf409526cd8a00246a34351805a5aa539b5ee0ec Mon Sep 17 00:00:00 2001 From: Charles Hacskaylo Date: Mon, 6 Nov 2023 16:21:44 -0800 Subject: [PATCH 06/11] Closes #5538 - Refined 'NaN' test. - Added test for 'Gauge enforces composition policy'; --- .../plugins/gauge/gauge.e2e.spec.js | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js index 471736af354..a8238e2bf6d 100644 --- a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js +++ b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js @@ -135,17 +135,34 @@ test.describe('Gauge', () => { }); test('Gauge does not display NaN when data not available', async ({ page }) => { - const gauge = await createDomainObjectWithDefaults(page, { type: 'Gauge', name: 'Unnamed Gauge' }); + // Create a Gauge + await createDomainObjectWithDefaults(page, { type: 'Gauge', name: 'Unnamed Gauge' }); // Create a Sine Wave Generator in the Gauge with a loading delay await page.getByRole('button', { name: ' Create ' }).click(); await page.getByRole('menuitem', { name: ' Sine Wave Generator' }).click(); await page.getByRole('dialog').locator('div').filter({ hasText: 'Loading Delay (ms)' }).nth(3).click(); await page.getByLabel('Loading Delay (ms)').fill('5000'); - await page.getByLabel('Save').click(); + await page.locator('[aria-label="Save"]').click(); await page.getByLabel('Expand My Items folder').click(); await page.getByRole('treeitem', { name: 'Expand Unnamed Gauge gauge  Unnamed Gauge' }).locator('a').click(); const gaugeNoDataText = await page.locator('.js-dial-current-value tspan').textContent(); expect(gaugeNoDataText).toBe('--'); }); + + test('Gauge enforces composition policy', async ({ page }) => { + // Create a Gauge + await createDomainObjectWithDefaults(page, { type: 'Gauge', name: 'Unnamed Gauge' }); + + // Try to create a Folder into the Gauge. Should be disallowed. + await page.getByRole('button', { name: ' Create ' }).click(); + await page.getByRole('menuitem', { name: ' Folder' }).click(); + await expect(page.locator('[aria-label="Save"]')).toBeDisabled(); + await page.getByLabel('Cancel').click(); + + // Try to create a Display Layout into the Gauge. Should be disallowed. + await page.getByRole('button', { name: ' Create ' }).click(); + await page.getByRole('menuitem', { name: ' Display Layout' }).click(); + await expect(page.locator('[aria-label="Save"]')).toBeDisabled(); + }); }); From fb49b0be5ef19de75520cf9d518060521ef62c4a Mon Sep 17 00:00:00 2001 From: Charles Hacskaylo Date: Mon, 6 Nov 2023 17:06:41 -0800 Subject: [PATCH 07/11] Closes #5538 - Fix linting issues. --- .../plugins/gauge/gauge.e2e.spec.js | 22 ++++++++-- src/plugins/gauge/GaugeCompositionPolicy.js | 42 ++++++++++--------- src/plugins/gauge/GaugePlugin.js | 5 ++- .../gauge/components/GaugeComponent.vue | 11 +++-- 4 files changed, 50 insertions(+), 30 deletions(-) diff --git a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js index a8238e2bf6d..8d9d7e4f409 100644 --- a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js +++ b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js @@ -136,23 +136,37 @@ test.describe('Gauge', () => { test('Gauge does not display NaN when data not available', async ({ page }) => { // Create a Gauge - await createDomainObjectWithDefaults(page, { type: 'Gauge', name: 'Unnamed Gauge' }); + await createDomainObjectWithDefaults(page, { + type: 'Gauge', + name: 'Unnamed Gauge' + }); // Create a Sine Wave Generator in the Gauge with a loading delay await page.getByRole('button', { name: ' Create ' }).click(); await page.getByRole('menuitem', { name: ' Sine Wave Generator' }).click(); - await page.getByRole('dialog').locator('div').filter({ hasText: 'Loading Delay (ms)' }).nth(3).click(); + await page + .getByRole('dialog') + .locator('div') + .filter({ hasText: 'Loading Delay (ms)' }) + .nth(3) + .click(); await page.getByLabel('Loading Delay (ms)').fill('5000'); await page.locator('[aria-label="Save"]').click(); await page.getByLabel('Expand My Items folder').click(); - await page.getByRole('treeitem', { name: 'Expand Unnamed Gauge gauge  Unnamed Gauge' }).locator('a').click(); + await page + .getByRole('treeitem', { name: 'Expand Unnamed Gauge gauge  Unnamed Gauge' }) + .locator('a') + .click(); const gaugeNoDataText = await page.locator('.js-dial-current-value tspan').textContent(); expect(gaugeNoDataText).toBe('--'); }); test('Gauge enforces composition policy', async ({ page }) => { // Create a Gauge - await createDomainObjectWithDefaults(page, { type: 'Gauge', name: 'Unnamed Gauge' }); + await createDomainObjectWithDefaults(page, { + type: 'Gauge', + name: 'Unnamed Gauge' + }); // Try to create a Folder into the Gauge. Should be disallowed. await page.getByRole('button', { name: ' Create ' }).click(); diff --git a/src/plugins/gauge/GaugeCompositionPolicy.js b/src/plugins/gauge/GaugeCompositionPolicy.js index 1e5ddb55cc6..469464fe975 100644 --- a/src/plugins/gauge/GaugeCompositionPolicy.js +++ b/src/plugins/gauge/GaugeCompositionPolicy.js @@ -1,27 +1,29 @@ export default function GaugeCompositionPolicy(openmct) { - function hasNumericTelemetry(domainObject) { - const hasTelemetry = openmct.telemetry.isTelemetryObject(domainObject); - if (!hasTelemetry) { - return false; - } + function hasNumericTelemetry(domainObject) { + const hasTelemetry = openmct.telemetry.isTelemetryObject(domainObject); + if (!hasTelemetry) { + return false; + } - let metadata = openmct.telemetry.getMetadata(domainObject); + let metadata = openmct.telemetry.getMetadata(domainObject); - return metadata.values().length > 0 && hasDomainAndRange(metadata); - } + return metadata.values().length > 0 && hasDomainAndRange(metadata); + } - function hasDomainAndRange(metadata) { - return (metadata.valuesForHints(['range']).length > 0 - && metadata.valuesForHints(['domain']).length > 0); - } + function hasDomainAndRange(metadata) { + return ( + metadata.valuesForHints(['range']).length > 0 && + metadata.valuesForHints(['domain']).length > 0 + ); + } - return { - allow: function (parent, child) { - if (parent.type === 'gauge') { - return hasNumericTelemetry(child); - } + return { + allow: function (parent, child) { + if (parent.type === 'gauge') { + return hasNumericTelemetry(child); + } - return true; - } - }; + return true; + } + }; } diff --git a/src/plugins/gauge/GaugePlugin.js b/src/plugins/gauge/GaugePlugin.js index 3b009dcfe66..7069e823c54 100644 --- a/src/plugins/gauge/GaugePlugin.js +++ b/src/plugins/gauge/GaugePlugin.js @@ -23,8 +23,8 @@ import mount from 'utils/mount'; import GaugeFormController from './components/GaugeFormController.vue'; +import GaugeCompositionPolicy from './GaugeCompositionPolicy'; import GaugeViewProvider from './GaugeViewProvider'; -import GaugeCompositionPolicy from "./GaugeCompositionPolicy"; export const GAUGE_TYPES = [ ['Filled Dial', 'dial-filled'], @@ -189,7 +189,8 @@ export default function () { onChange }; }, - template: `` + template: ` + ` }, { app: openmct.app, diff --git a/src/plugins/gauge/components/GaugeComponent.vue b/src/plugins/gauge/components/GaugeComponent.vue index 1894c2bcac1..bd62322ea70 100644 --- a/src/plugins/gauge/components/GaugeComponent.vue +++ b/src/plugins/gauge/components/GaugeComponent.vue @@ -45,7 +45,7 @@ - + - + - + Date: Tue, 7 Nov 2023 15:42:10 -0800 Subject: [PATCH 08/11] Closes #5538 - Suggested changes from PR review. --- .../plugins/gauge/gauge.e2e.spec.js | 51 ++++++++++--------- src/plugins/gauge/GaugeCompositionPolicy.js | 24 ++++++++- 2 files changed, 51 insertions(+), 24 deletions(-) diff --git a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js index 8d9d7e4f409..2db7804cec9 100644 --- a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js +++ b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js @@ -25,7 +25,10 @@ */ const { test, expect } = require('../../../../pluginFixtures'); -const { createDomainObjectWithDefaults } = require('../../../../appActions'); +const { + createDomainObjectWithDefaults, + createExampleTelemetryObject +} = require('../../../../appActions'); const uuid = require('uuid').v4; test.describe('Gauge', () => { @@ -136,27 +139,29 @@ test.describe('Gauge', () => { test('Gauge does not display NaN when data not available', async ({ page }) => { // Create a Gauge - await createDomainObjectWithDefaults(page, { - type: 'Gauge', - name: 'Unnamed Gauge' + const gauge = await createDomainObjectWithDefaults(page, { + type: 'Gauge' }); // Create a Sine Wave Generator in the Gauge with a loading delay - await page.getByRole('button', { name: ' Create ' }).click(); - await page.getByRole('menuitem', { name: ' Sine Wave Generator' }).click(); - await page - .getByRole('dialog') - .locator('div') - .filter({ hasText: 'Loading Delay (ms)' }) - .nth(3) - .click(); - await page.getByLabel('Loading Delay (ms)').fill('5000'); - await page.locator('[aria-label="Save"]').click(); - await page.getByLabel('Expand My Items folder').click(); - await page - .getByRole('treeitem', { name: 'Expand Unnamed Gauge gauge  Unnamed Gauge' }) - .locator('a') - .click(); + const swgWith5sDelay = await createExampleTelemetryObject(page, gauge.uuid); + + await page.goto(swgWith5sDelay.url); + await page.getByTitle('More options').click(); + await page.getByRole('menuitem', { name: /Edit Properties.../ }).click(); + + //Edit Example Telemetry Object to include 5s loading Delay + await page.locator('[aria-label="Loading Delay \\(ms\\)"]').fill('5000'); + + await Promise.all([ + page.waitForNavigation(), + page.locator('text=OK').click(), + //Wait for Save Banner to appear + page.waitForSelector('.c-message-banner__message') + ]); + + // Nav to the Gauge + await page.goto(gauge.url); const gaugeNoDataText = await page.locator('.js-dial-current-value tspan').textContent(); expect(gaugeNoDataText).toBe('--'); }); @@ -169,14 +174,14 @@ test.describe('Gauge', () => { }); // Try to create a Folder into the Gauge. Should be disallowed. - await page.getByRole('button', { name: ' Create ' }).click(); - await page.getByRole('menuitem', { name: ' Folder' }).click(); + await page.getByRole('button', { name: /Create/ }).click(); + await page.getByRole('menuitem', { name: /Folder/ }).click(); await expect(page.locator('[aria-label="Save"]')).toBeDisabled(); await page.getByLabel('Cancel').click(); // Try to create a Display Layout into the Gauge. Should be disallowed. - await page.getByRole('button', { name: ' Create ' }).click(); - await page.getByRole('menuitem', { name: ' Display Layout' }).click(); + await page.getByRole('button', { name: /Create/ }).click(); + await page.getByRole('menuitem', { name: /Display Layout/ }).click(); await expect(page.locator('[aria-label="Save"]')).toBeDisabled(); }); }); diff --git a/src/plugins/gauge/GaugeCompositionPolicy.js b/src/plugins/gauge/GaugeCompositionPolicy.js index 469464fe975..7a80e61fac8 100644 --- a/src/plugins/gauge/GaugeCompositionPolicy.js +++ b/src/plugins/gauge/GaugeCompositionPolicy.js @@ -1,3 +1,25 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2023, 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. + *****************************************************************************/ + export default function GaugeCompositionPolicy(openmct) { function hasNumericTelemetry(domainObject) { const hasTelemetry = openmct.telemetry.isTelemetryObject(domainObject); @@ -5,7 +27,7 @@ export default function GaugeCompositionPolicy(openmct) { return false; } - let metadata = openmct.telemetry.getMetadata(domainObject); + const metadata = openmct.telemetry.getMetadata(domainObject); return metadata.values().length > 0 && hasDomainAndRange(metadata); } From 5ddbdaf94a9d688056551409b3fa918f04c14ad4 Mon Sep 17 00:00:00 2001 From: Charles Hacskaylo Date: Tue, 7 Nov 2023 15:43:03 -0800 Subject: [PATCH 09/11] Closes #5538 - Suggested changes from PR review. --- src/plugins/gauge/GaugePlugin.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/gauge/GaugePlugin.js b/src/plugins/gauge/GaugePlugin.js index 7069e823c54..6c11cd0f9cb 100644 --- a/src/plugins/gauge/GaugePlugin.js +++ b/src/plugins/gauge/GaugePlugin.js @@ -189,8 +189,7 @@ export default function () { onChange }; }, - template: ` - ` + template: `` }, { app: openmct.app, From 1f58050fad5f84f14ff34e49e2bbeeee7cf6089a Mon Sep 17 00:00:00 2001 From: Charles Hacskaylo Date: Thu, 16 Nov 2023 10:12:31 -0800 Subject: [PATCH 10/11] Update e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js Co-authored-by: Jesse Mazzella --- e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js index 2db7804cec9..83d62d93c51 100644 --- a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js +++ b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js @@ -153,12 +153,10 @@ test.describe('Gauge', () => { //Edit Example Telemetry Object to include 5s loading Delay await page.locator('[aria-label="Loading Delay \\(ms\\)"]').fill('5000'); - await Promise.all([ - page.waitForNavigation(), - page.locator('text=OK').click(), - //Wait for Save Banner to appear - page.waitForSelector('.c-message-banner__message') - ]); + await page.getByRole('button', { name: 'Save' }).click(); + + // Wait until the URL is updated + await page.waitForURL(`**/${gauge.uuid}/*`); // Nav to the Gauge await page.goto(gauge.url); From ac1a10500e74b15cbaef31c20dee689282132771 Mon Sep 17 00:00:00 2001 From: Jesse Mazzella Date: Thu, 16 Nov 2023 10:21:46 -0800 Subject: [PATCH 11/11] chore: lint:fix --- e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js index 83d62d93c51..619876cd5da 100644 --- a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js +++ b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js @@ -153,10 +153,10 @@ test.describe('Gauge', () => { //Edit Example Telemetry Object to include 5s loading Delay await page.locator('[aria-label="Loading Delay \\(ms\\)"]').fill('5000'); - await page.getByRole('button', { name: 'Save' }).click(); + await page.getByRole('button', { name: 'Save' }).click(); - // Wait until the URL is updated - await page.waitForURL(`**/${gauge.uuid}/*`); + // Wait until the URL is updated + await page.waitForURL(`**/${gauge.uuid}/*`); // Nav to the Gauge await page.goto(gauge.url);