Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Gauge Plugin] Fix Missing Object handling #7923

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
55 changes: 54 additions & 1 deletion e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import { v4 as uuid } from 'uuid';

import {
createDomainObjectWithDefaults,
createExampleTelemetryObject
createExampleTelemetryObject,
setRealTimeMode,
setStartOffset
} from '../../../../appActions.js';
import { expect, test } from '../../../../pluginFixtures.js';

Expand Down Expand Up @@ -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 }) => {
// Create a Gauge
await createDomainObjectWithDefaults(page, {
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/gauge/components/GaugeComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,11 @@
},
request(domainObject = this.telemetryObject) {
this.metadata = this.openmct.telemetry.getMetadata(domainObject);

if (!this.metadata) {
return;

Check warning on line 654 in src/plugins/gauge/components/GaugeComponent.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/gauge/components/GaugeComponent.vue#L654

Added line #L654 was not covered by tests
}

this.formats = this.openmct.telemetry.getFormatMap(this.metadata);
const LimitEvaluator = this.openmct.telemetry.getLimits(domainObject);
LimitEvaluator.limits().then(this.updateLimits);
Expand Down
Loading