Merge remote-tracking branch 'khalidadil/extend-conditional' into combined-rodap-stuff

This commit is contained in:
Scott Bell 2024-09-30 16:53:32 +02:00
commit a6cdf5490e
5 changed files with 82 additions and 13 deletions

View File

@ -116,6 +116,22 @@ async function createDomainObjectWithDefaults(page, { type, name, parent = 'mine
}; };
} }
/**
* Retrieves the properties of an OpenMCT domain object by its identifier.
*
* @param {import('@playwright/test').Page} page - The Playwright page object.
* @param {string | identifier - The identifier or UUID of the domain object.
* @returns {Promise<Object>} An object containing the properties of the domain object.
*/
async function getDomainObject(page, identifier) {
const domainObject = await page.evaluate(async (objIdentifier) => {
const object = await window.openmct.objects.get(objIdentifier);
return object;
}, identifier);
return domainObject;
}
/** /**
* Generate a notification with the given options. * Generate a notification with the given options.
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
@ -636,6 +652,7 @@ export {
createPlanFromJSON, createPlanFromJSON,
expandEntireTree, expandEntireTree,
getCanvasPixels, getCanvasPixels,
getDomainObject,
navigateToObjectWithFixedTimeBounds, navigateToObjectWithFixedTimeBounds,
navigateToObjectWithRealTime, navigateToObjectWithRealTime,
setEndOffset, setEndOffset,

View File

@ -29,7 +29,8 @@ import { fileURLToPath } from 'url';
import { import {
createDomainObjectWithDefaults, createDomainObjectWithDefaults,
createExampleTelemetryObject createExampleTelemetryObject,
getDomainObject
} from '../../../../appActions.js'; } from '../../../../appActions.js';
import { expect, test } from '../../../../pluginFixtures.js'; import { expect, test } from '../../../../pluginFixtures.js';
@ -468,6 +469,34 @@ test.describe('Basic Condition Set Use', () => {
description: 'https://github.com/nasa/openmct/issues/7484' description: 'https://github.com/nasa/openmct/issues/7484'
}); });
}); });
test('should toggle shouldFetchHistorical property in inspector', async ({ page }) => {
await page.goto(conditionSet.url);
await page.getByLabel('Edit Object').click();
await page.getByRole('tab', { name: 'Config' }).click();
let toggleSwitch = page.getByLabel('condition-historical-toggle');
const initialState = await toggleSwitch.isChecked();
expect(initialState).toBe(false);
await toggleSwitch.click();
let toggledState = await toggleSwitch.isChecked();
expect(toggledState).toBe(true);
await page.click('button[title="Save"]');
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
let conditionSetObject = await getDomainObject(page, conditionSet.uuid);
expect(conditionSetObject.configuration.shouldFetchHistorical).toBe(true);
await page.getByLabel('Edit Object').click();
await page.getByRole('tab', { name: 'Config' }).click();
toggleSwitch = page.getByLabel('condition-historical-toggle');
await toggleSwitch.click();
toggledState = await toggleSwitch.isChecked();
expect(toggledState).toBe(false);
await page.click('button[title="Save"]');
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
conditionSetObject = await getDomainObject(page, conditionSet.uuid);
expect(conditionSetObject.configuration.shouldFetchHistorical).toBe(false);
});
}); });
test.describe('Condition Set Composition', () => { test.describe('Condition Set Composition', () => {

View File

@ -474,14 +474,15 @@ export default class ConditionManager extends EventEmitter {
}); });
} }
emitConditionSetResult(currentCondition, timestamp, outputValue) { emitConditionSetResult(currentCondition, timestamp, outputValue, result) {
this.emit( this.emit(
'conditionSetResultUpdated', 'conditionSetResultUpdated',
Object.assign( Object.assign(
{ {
output: outputValue,
id: this.conditionSetDomainObject.identifier, id: this.conditionSetDomainObject.identifier,
conditionId: currentCondition.id conditionId: currentCondition.id,
output: outputValue,
result
}, },
timestamp timestamp
) )
@ -509,6 +510,10 @@ export default class ConditionManager extends EventEmitter {
async processCondition(timestamp, telemetryObject, telemetryData) { async processCondition(timestamp, telemetryObject, telemetryData) {
const currentCondition = this.getCurrentCondition(); const currentCondition = this.getCurrentCondition();
const conditionDetails = this.conditions.filter(
(condition) => condition.id === currentCondition.id
)?.[0];
const conditionResult = currentCondition?.isDefault ? false : conditionDetails?.result;
let telemetryValue = currentCondition.configuration.output; let telemetryValue = currentCondition.configuration.output;
if (currentCondition?.configuration?.outputTelemetry) { if (currentCondition?.configuration?.outputTelemetry) {
const selectedOutputIdentifier = currentCondition?.configuration?.outputTelemetry; const selectedOutputIdentifier = currentCondition?.configuration?.outputTelemetry;
@ -539,7 +544,7 @@ export default class ConditionManager extends EventEmitter {
} }
} }
this.emitConditionSetResult(currentCondition, timestamp, telemetryValue); this.emitConditionSetResult(currentCondition, timestamp, telemetryValue, conditionResult);
} }
getTestData(metadatum) { getTestData(metadatum) {

View File

@ -50,12 +50,23 @@ export default class ConditionSetMetadataProvider {
}; };
}); });
const resultEnum = [
{
string: 'true',
value: true
},
{
string: 'false',
value: false
}
];
return { return {
values: this.getDomains().concat([ values: this.getDomains().concat([
{ {
key: 'state', key: 'output',
source: 'output', source: 'output',
name: 'State', name: 'Value',
format: 'enum', format: 'enum',
enumerations: enumerations, enumerations: enumerations,
hints: { hints: {
@ -63,9 +74,11 @@ export default class ConditionSetMetadataProvider {
} }
}, },
{ {
key: 'output', key: 'result',
name: 'Value', source: 'result',
format: 'string', name: 'Result',
format: 'enum',
enumerations: resultEnum,
hints: { hints: {
range: 2 range: 2
} }

View File

@ -43,6 +43,7 @@ export default class HistoricalTelemetryProvider {
const conditionConfiguration = conditionCollectionMap.get(condition.id)?.configuration; const conditionConfiguration = conditionCollectionMap.get(condition.id)?.configuration;
const { outputTelemetry, outputMetadata } = conditionConfiguration; const { outputTelemetry, outputMetadata } = conditionConfiguration;
let output = {}; let output = {};
output.result = true;
if (outputTelemetry) { if (outputTelemetry) {
const outputTelemetryID = this.openmct.objects.makeKeyString(outputTelemetry); const outputTelemetryID = this.openmct.objects.makeKeyString(outputTelemetry);
const outputTelemetryData = telemetryData.get(outputTelemetryID); const outputTelemetryData = telemetryData.get(outputTelemetryID);
@ -203,9 +204,11 @@ export default class HistoricalTelemetryProvider {
const { outputTelemetry, outputMetadata, output } = conditionConfiguration; const { outputTelemetry, outputMetadata, output } = conditionConfiguration;
if (isDefault) { if (isDefault) {
const conditionOutput = { const conditionOutput = {
condition,
telemetry: null, telemetry: null,
value: output, value: output,
condition result: false,
isDefault: true
}; };
outputTelemetryDateMap.set(timestamp, conditionOutput); outputTelemetryDateMap.set(timestamp, conditionOutput);
} }
@ -274,12 +277,14 @@ export default class HistoricalTelemetryProvider {
const outputTelemetryList = []; const outputTelemetryList = [];
const domainObject = this.conditionSetDomainObject; const domainObject = this.conditionSetDomainObject;
outputTelemetryMap.forEach((outputMetadata, timestamp) => { outputTelemetryMap.forEach((outputMetadata, timestamp) => {
const { condition, telemetry, value } = outputMetadata; const { condition, telemetry, value, result, isDefault } = outputMetadata;
outputTelemetryList.push({ outputTelemetryList.push({
conditionId: condition.id, conditionId: condition.id,
id: domainObject.identifier, id: domainObject.identifier,
output: value, output: value,
utc: timestamp utc: timestamp,
result,
isDefault
}); });
}); });
return outputTelemetryList; return outputTelemetryList;