Skip to content

Commit 860c13d

Browse files
jvigliottaakhenry
authored andcommitted
[Gauge Plugin] Fix Missing Object handling (#7923)
* checking if the metadata exists before acting on it * added a test to catch missing object errors in gauges * remove waitForTimeout and add in check for time conductor successful start offset update * hardening the test by checking for the time before the time change * add "pageerror" to cspell
1 parent 057a5f9 commit 860c13d

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

.cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@
483483
"countup",
484484
"darkmatter",
485485
"Undeletes",
486-
"SSSZ"
486+
"SSSZ",
487+
"pageerror"
487488
],
488489
"dictionaries": ["npm", "softwareTerms", "node", "html", "css", "bash", "en_US", "en-gb", "misc"],
489490
"ignorePaths": [

e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ import { v4 as uuid } from 'uuid';
2828

2929
import {
3030
createDomainObjectWithDefaults,
31-
createExampleTelemetryObject
31+
createExampleTelemetryObject,
32+
setRealTimeMode,
33+
setStartOffset
3234
} from '../../../../appActions.js';
3335
import { expect, test } from '../../../../pluginFixtures.js';
3436

@@ -166,6 +168,57 @@ test.describe('Gauge', () => {
166168
);
167169
});
168170

171+
test('Gauge does not break when an object is missing', async ({ page }) => {
172+
// Set up error listeners
173+
const pageErrors = [];
174+
175+
// Listen for uncaught exceptions
176+
page.on('pageerror', (err) => {
177+
pageErrors.push(err.message);
178+
});
179+
180+
await setRealTimeMode(page);
181+
182+
// Create a Gauge
183+
const gauge = await createDomainObjectWithDefaults(page, {
184+
type: 'Gauge',
185+
name: 'Gauge with missing object'
186+
});
187+
188+
// Create a Sine Wave Generator in the Gauge with a loading delay
189+
const missingSWG = await createExampleTelemetryObject(page, gauge.uuid);
190+
191+
// Remove the object from local storage
192+
await page.evaluate(
193+
([missingObject]) => {
194+
const mct = localStorage.getItem('mct');
195+
const mctObjects = JSON.parse(mct);
196+
delete mctObjects[missingObject.uuid];
197+
localStorage.setItem('mct', JSON.stringify(mctObjects));
198+
},
199+
[missingSWG]
200+
);
201+
202+
// Verify start bounds
203+
await expect(page.getByLabel('Start offset: 00:30:00')).toBeVisible();
204+
205+
// Nav to the Gauge
206+
await page.goto(gauge.url, { waitUntil: 'domcontentloaded' });
207+
208+
// adjust time bounds and ensure they are updated
209+
await setStartOffset(page, {
210+
startHours: '00',
211+
startMins: '45',
212+
startSecs: '00'
213+
});
214+
215+
// Verify start bounds changed
216+
await expect(page.getByLabel('Start offset: 00:45:00')).toBeVisible();
217+
218+
// // Verify no errors were thrown
219+
expect(pageErrors).toHaveLength(0);
220+
});
221+
169222
test('Gauge enforces composition policy', async ({ page }) => {
170223
// Create a Gauge
171224
await createDomainObjectWithDefaults(page, {

src/plugins/gauge/components/GaugeComponent.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,11 @@ export default {
649649
},
650650
request(domainObject = this.telemetryObject) {
651651
this.metadata = this.openmct.telemetry.getMetadata(domainObject);
652+
653+
if (!this.metadata) {
654+
return;
655+
}
656+
652657
this.formats = this.openmct.telemetry.getFormatMap(this.metadata);
653658
const LimitEvaluator = this.openmct.telemetry.getLimits(domainObject);
654659
LimitEvaluator.limits().then(this.updateLimits);

0 commit comments

Comments
 (0)