diff --git a/e2e/tests/functional/plugins/preview/preview.e2e.spec.js b/e2e/tests/functional/plugins/preview/preview.e2e.spec.js deleted file mode 100644 index 6251a002cb5b..000000000000 --- a/e2e/tests/functional/plugins/preview/preview.e2e.spec.js +++ /dev/null @@ -1,33 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2024, 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. - *****************************************************************************/ -/* - * This test suite is dedicated to testing the preview plugin. - */ - -import { test } from '../../../../pluginFixtures.js'; - -test.describe('Preview mode', () => { - test.fixme('all context menu items are available for a telemetry table', async ({ page }) => { - // compare the context menu options when viewing a telemetry table directly - // vs when it is presented in preview mode (e.g. edit mode is enabled and the table is clicked on from the tree) - }); -}); diff --git a/e2e/tests/functional/plugins/styling/flexLayoutStyling.e2e.spec.js b/e2e/tests/functional/plugins/styling/flexLayoutStyling.e2e.spec.js index 0f1f3890527e..6431066effa1 100644 --- a/e2e/tests/functional/plugins/styling/flexLayoutStyling.e2e.spec.js +++ b/e2e/tests/functional/plugins/styling/flexLayoutStyling.e2e.spec.js @@ -35,7 +35,7 @@ const defaultFrameBorderColor = '#e6b8af'; //default border color const defaultBorderTargetColor = '#acacac'; const defaultTextColor = '#acacac'; // default text color const inheritedColor = '#acacac'; // inherited from the body style -const pukeGreen = '#6aa84f'; //Ugliest green known to man +const pukeGreen = '#6aa84f'; //Ugliest green known to man 🤮 const NO_STYLE_RGBA = 'rgba(0, 0, 0, 0)'; //default background color value test.describe('Flexible Layout styling', () => { @@ -411,4 +411,39 @@ test.describe('Flexible Layout styling', () => { page.getByLabel('StackedPlot1 Frame').getByLabel('Stacked Plot Style Target') ); }); + + test('Styling, and then canceling reverts to previous style', async ({ page }) => { + test.info().annotations.push({ + type: 'issue', + description: 'https://github.com/nasa/openmct/issues/7233' + }); + + await page.goto(flexibleLayout.url); + + await page.getByLabel('Edit Object').click(); + await page.getByRole('tab', { name: 'Styles' }).click(); + await setStyles( + page, + setBorderColor, + setBackgroundColor, + setTextColor, + page.getByLabel('Flexible Layout Column') + ); + await page.getByLabel('Cancel Editing').click(); + await page.getByRole('button', { name: 'OK', exact: true }).click(); + await checkStyles( + hexToRGB(defaultBorderTargetColor), + NO_STYLE_RGBA, + hexToRGB(inheritedColor), + page.getByLabel('Flexible Layout Column') + ); + + await page.reload(); + await checkStyles( + hexToRGB(defaultBorderTargetColor), + NO_STYLE_RGBA, + hexToRGB(inheritedColor), + page.getByLabel('Flexible Layout Column') + ); + }); }); diff --git a/e2e/tests/functional/plugins/telemetryTable/preview.e2e.spec.js b/e2e/tests/functional/plugins/telemetryTable/preview.e2e.spec.js new file mode 100644 index 000000000000..e7d98f38a059 --- /dev/null +++ b/e2e/tests/functional/plugins/telemetryTable/preview.e2e.spec.js @@ -0,0 +1,73 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2024, 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. + *****************************************************************************/ +/* + * This test suite is dedicated to testing the preview plugin. + */ + +import { createDomainObjectWithDefaults, expandEntireTree } from '../../../../appActions.js'; +import { expect, test } from '../../../../pluginFixtures.js'; + +test.describe('Preview mode', () => { + test('all context menu items are available for a telemetry table', async ({ page }) => { + await page.goto('./', { waitUntil: 'domcontentloaded' }); + // Create a Display Layout + const displayLayout = await createDomainObjectWithDefaults(page, { + type: 'Display Layout' + }); + // Create a Telemetry Table + const telemetryTable = await createDomainObjectWithDefaults(page, { + type: 'Telemetry Table', + parent: displayLayout.uuid + }); + // Create a Sinewave Generator + await createDomainObjectWithDefaults(page, { + type: 'Sine Wave Generator', + parent: telemetryTable.uuid + }); + + await page.goto(displayLayout.url); + await page.getByLabel('View menu items').click(); + await expect(page.getByLabel('Export Marked Rows')).toBeVisible(); + + await page.getByRole('menuitem', { name: 'Large View' }).click(); + await page.getByLabel('Overlay').getByLabel('More actions').click(); + await expect(page.getByLabel('Export Table Data')).toBeVisible(); + await expect(page.getByLabel('Export Marked Rows')).toBeVisible(); + await page.getByRole('menuitem', { name: 'Pause' }).click(); + await page.getByLabel('Close').click(); + + await expandEntireTree(page); + + await page.getByLabel('Edit Object').click(); + + const treePane = page.getByRole('tree', { + name: 'Main Tree' + }); + const telemetryTableTreeItem = treePane.getByRole('treeitem', { + name: new RegExp(telemetryTable.name) + }); + await telemetryTableTreeItem.locator('a').click(); + await page.getByLabel('Overlay').getByLabel('More actions').click(); + await expect(page.getByLabel('Export Table Data')).toBeVisible(); + await expect(page.getByLabel('Export Marked Rows')).toBeVisible(); + }); +}); diff --git a/src/api/objects/ObjectAPI.js b/src/api/objects/ObjectAPI.js index 750784b98c71..d28d19360542 100644 --- a/src/api/objects/ObjectAPI.js +++ b/src/api/objects/ObjectAPI.js @@ -696,10 +696,12 @@ export default class ObjectAPI { /** * Updates a domain object based on its latest persisted state. Note that this will mutate the provided object. * @param {module:openmct.DomainObject} domainObject an object to refresh from its persistence store + * @param {boolean} [forceRemote=false] defaults to false. If true, will skip cached and + * dirty/in-transaction objects use and the provider.get method * @returns {Promise} the provided object, updated to reflect the latest persisted state of the object. */ - async refresh(domainObject) { - const refreshedObject = await this.get(domainObject.identifier); + async refresh(domainObject, forceRemote = false) { + const refreshedObject = await this.get(domainObject.identifier, null, forceRemote); if (domainObject.isMutable) { domainObject.$refresh(refreshedObject); diff --git a/src/api/objects/ObjectAPISpec.js b/src/api/objects/ObjectAPISpec.js index 22b778df2d59..249e29071e14 100644 --- a/src/api/objects/ObjectAPISpec.js +++ b/src/api/objects/ObjectAPISpec.js @@ -362,7 +362,7 @@ describe('The Object API', () => { expect(objectAPI.get).not.toHaveBeenCalled(); return objectAPI.refresh(testObject).then(() => { - expect(objectAPI.get).toHaveBeenCalledWith(testObject.identifier); + expect(objectAPI.get).toHaveBeenCalledWith(testObject.identifier, null, false); expect(testObject.otherAttribute).toEqual(OTHER_ATTRIBUTE_VALUE); expect(testObject.newAttribute).toEqual(NEW_ATTRIBUTE_VALUE); diff --git a/src/api/objects/Transaction.js b/src/api/objects/Transaction.js index fc4cee2cdd4c..4a51b20b786b 100644 --- a/src/api/objects/Transaction.js +++ b/src/api/objects/Transaction.js @@ -47,9 +47,9 @@ export default class Transaction { return Promise.all(promiseArray); } - createDirtyObjectPromise(object, action) { + createDirtyObjectPromise(object, action, ...args) { return new Promise((resolve, reject) => { - action(object) + action(object, ...args) .then((success) => { const key = this.objectAPI.makeKeyString(object.identifier); @@ -75,10 +75,10 @@ export default class Transaction { _clear() { const promiseArray = []; - const refresh = this.objectAPI.refresh.bind(this.objectAPI); + const action = (obj) => this.objectAPI.refresh(obj, true); Object.values(this.dirtyObjects).forEach((object) => { - promiseArray.push(this.createDirtyObjectPromise(object, refresh)); + promiseArray.push(this.createDirtyObjectPromise(object, action)); }); return Promise.all(promiseArray); diff --git a/src/ui/preview/PreviewContainer.vue b/src/ui/preview/PreviewContainer.vue index b33130d78134..f37cbe7b1483 100644 --- a/src/ui/preview/PreviewContainer.vue +++ b/src/ui/preview/PreviewContainer.vue @@ -35,6 +35,8 @@