mirror of
https://github.com/nasa/openmct.git
synced 2024-12-18 20:57:53 +00:00
[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
This commit is contained in:
parent
ea9947cab5
commit
ba4d8a428b
@ -483,7 +483,8 @@
|
|||||||
"countup",
|
"countup",
|
||||||
"darkmatter",
|
"darkmatter",
|
||||||
"Undeletes",
|
"Undeletes",
|
||||||
"SSSZ"
|
"SSSZ",
|
||||||
|
"pageerror"
|
||||||
],
|
],
|
||||||
"dictionaries": ["npm", "softwareTerms", "node", "html", "css", "bash", "en_US", "en-gb", "misc"],
|
"dictionaries": ["npm", "softwareTerms", "node", "html", "css", "bash", "en_US", "en-gb", "misc"],
|
||||||
"ignorePaths": [
|
"ignorePaths": [
|
||||||
|
@ -28,7 +28,9 @@ import { v4 as uuid } from 'uuid';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
createDomainObjectWithDefaults,
|
createDomainObjectWithDefaults,
|
||||||
createExampleTelemetryObject
|
createExampleTelemetryObject,
|
||||||
|
setRealTimeMode,
|
||||||
|
setStartOffset
|
||||||
} from '../../../../appActions.js';
|
} from '../../../../appActions.js';
|
||||||
import { expect, test } from '../../../../pluginFixtures.js';
|
import { expect, test } from '../../../../pluginFixtures.js';
|
||||||
|
|
||||||
@ -166,6 +168,57 @@ test.describe('Gauge', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Gauge does not break when an object is missing', async ({ page }) => {
|
||||||
|
// Set up error listeners
|
||||||
|
const pageErrors = [];
|
||||||
|
|
||||||
|
// Listen for uncaught exceptions
|
||||||
|
page.on('pageerror', (err) => {
|
||||||
|
pageErrors.push(err.message);
|
||||||
|
});
|
||||||
|
|
||||||
|
await setRealTimeMode(page);
|
||||||
|
|
||||||
|
// Create a Gauge
|
||||||
|
const gauge = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Gauge',
|
||||||
|
name: 'Gauge with missing object'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a Sine Wave Generator in the Gauge with a loading delay
|
||||||
|
const missingSWG = await createExampleTelemetryObject(page, gauge.uuid);
|
||||||
|
|
||||||
|
// Remove the object from local storage
|
||||||
|
await page.evaluate(
|
||||||
|
([missingObject]) => {
|
||||||
|
const mct = localStorage.getItem('mct');
|
||||||
|
const mctObjects = JSON.parse(mct);
|
||||||
|
delete mctObjects[missingObject.uuid];
|
||||||
|
localStorage.setItem('mct', JSON.stringify(mctObjects));
|
||||||
|
},
|
||||||
|
[missingSWG]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Verify start bounds
|
||||||
|
await expect(page.getByLabel('Start offset: 00:30:00')).toBeVisible();
|
||||||
|
|
||||||
|
// Nav to the Gauge
|
||||||
|
await page.goto(gauge.url, { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
|
// adjust time bounds and ensure they are updated
|
||||||
|
await setStartOffset(page, {
|
||||||
|
startHours: '00',
|
||||||
|
startMins: '45',
|
||||||
|
startSecs: '00'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Verify start bounds changed
|
||||||
|
await expect(page.getByLabel('Start offset: 00:45:00')).toBeVisible();
|
||||||
|
|
||||||
|
// // Verify no errors were thrown
|
||||||
|
expect(pageErrors).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
test('Gauge enforces composition policy', async ({ page }) => {
|
test('Gauge enforces composition policy', async ({ page }) => {
|
||||||
// Create a Gauge
|
// Create a Gauge
|
||||||
await createDomainObjectWithDefaults(page, {
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
@ -649,6 +649,11 @@ export default {
|
|||||||
},
|
},
|
||||||
request(domainObject = this.telemetryObject) {
|
request(domainObject = this.telemetryObject) {
|
||||||
this.metadata = this.openmct.telemetry.getMetadata(domainObject);
|
this.metadata = this.openmct.telemetry.getMetadata(domainObject);
|
||||||
|
|
||||||
|
if (!this.metadata) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.formats = this.openmct.telemetry.getFormatMap(this.metadata);
|
this.formats = this.openmct.telemetry.getFormatMap(this.metadata);
|
||||||
const LimitEvaluator = this.openmct.telemetry.getLimits(domainObject);
|
const LimitEvaluator = this.openmct.telemetry.getLimits(domainObject);
|
||||||
LimitEvaluator.limits().then(this.updateLimits);
|
LimitEvaluator.limits().then(this.updateLimits);
|
||||||
|
Loading…
Reference in New Issue
Block a user