diff --git a/e2e/appActions.js b/e2e/appActions.js index bc1b1a212a..2464d2df44 100644 --- a/e2e/appActions.js +++ b/e2e/appActions.js @@ -72,17 +72,19 @@ async function createDomainObjectWithDefaults(page, { type, name, parent = 'mine await page.click('button:has-text("Create")'); // Click the object specified by 'type' - await page.click(`li:text("${type}")`); + await page.click(`li[role='menuitem']:text("${type}")`); // Modify the name input field of the domain object to accept 'name' const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]'); await nameInput.fill(""); await nameInput.fill(name); - // Fill the "Notes" section with information about the - // currently running test and its project. - const notesInput = page.locator('form[name="mctForm"] #notes-textarea'); - await notesInput.fill(page.testNotes); + if (page.testNotes) { + // Fill the "Notes" section with information about the + // currently running test and its project. + const notesInput = page.locator('form[name="mctForm"] #notes-textarea'); + await notesInput.fill(page.testNotes); + } // Click OK button and wait for Navigate event await Promise.all([ diff --git a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js index 1e36449a54..ba7cb2d556 100644 --- a/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js +++ b/e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js @@ -24,22 +24,19 @@ * This test suite is dedicated to testing the Gauge component. */ -const { test, expect } = require('../../../../baseFixtures'); +const { test, expect } = require('../../../../pluginFixtures'); const { createDomainObjectWithDefaults } = require('../../../../appActions'); const uuid = require('uuid').v4; test.describe('Gauge', () => { - let gauge; - test.beforeEach(async ({ page }) => { // Open a browser, navigate to the main page, and wait until all networkevents to resolve await page.goto('./', { waitUntil: 'networkidle' }); - - // Create the gauge - gauge = await createDomainObjectWithDefaults(page, { type: 'Gauge' }); }); test('Can add and remove telemetry sources @unstable', async ({ page }) => { + // Create the gauge with defaults + const gauge = await createDomainObjectWithDefaults(page, { type: 'Gauge' }); const editButtonLocator = page.locator('button[title="Edit"]'); const saveButtonLocator = page.locator('button[title="Save"]'); @@ -90,4 +87,38 @@ test.describe('Gauge', () => { // Verify that the elements pool shows no elements await expect(page.locator('text="No contained elements"')).toBeVisible(); }); + test('Can create a non-default Gauge', async ({ page }) => { + test.info().annotations.push({ + type: 'issue', + description: 'https://github.com/nasa/openmct/issues/5356' + }); + //Click the Create button + await page.click('button:has-text("Create")'); + + // Click the object specified by 'type' + await page.click(`li[role='menuitem']:text("Gauge")`); + // FIXME: We need better selectors for these custom form controls + const displayCurrentValueSwitch = page.locator('.c-toggle-switch__slider >> nth=0'); + await displayCurrentValueSwitch.setChecked(false); + await page.click('button[aria-label="Save"]'); + + // TODO: Verify changes in the UI + }); + test('Can edit a single Gauge-specific property', async ({ page }) => { + test.info().annotations.push({ + type: 'issue', + description: 'https://github.com/nasa/openmct/issues/5985' + }); + + // Create the gauge with defaults + await createDomainObjectWithDefaults(page, { type: 'Gauge' }); + await page.click('button[title="More options"]'); + await page.click('li[role="menuitem"]:has-text("Edit Properties")'); + // FIXME: We need better selectors for these custom form controls + const displayCurrentValueSwitch = page.locator('.c-toggle-switch__slider >> nth=0'); + await displayCurrentValueSwitch.setChecked(false); + await page.click('button[aria-label="Save"]'); + + // TODO: Verify changes in the UI + }); }); diff --git a/src/plugins/formActions/CreateAction.js b/src/plugins/formActions/CreateAction.js index f43b523e61..b0b8a0a800 100644 --- a/src/plugins/formActions/CreateAction.js +++ b/src/plugins/formActions/CreateAction.js @@ -53,10 +53,7 @@ export default class CreateAction extends PropertiesAction { const existingValue = this.domainObject[key]; if (!(existingValue instanceof Array) && (typeof existingValue === 'object')) { - value = { - ...existingValue, - ...value - }; + value = _.merge(existingValue, value); } _.set(this.domainObject, key, value); diff --git a/src/plugins/formActions/EditPropertiesAction.js b/src/plugins/formActions/EditPropertiesAction.js index eb4dec2e43..5a18605184 100644 --- a/src/plugins/formActions/EditPropertiesAction.js +++ b/src/plugins/formActions/EditPropertiesAction.js @@ -22,6 +22,7 @@ import PropertiesAction from './PropertiesAction'; import CreateWizard from './CreateWizard'; +import _ from 'lodash'; export default class EditPropertiesAction extends PropertiesAction { constructor(openmct) { @@ -61,10 +62,7 @@ export default class EditPropertiesAction extends PropertiesAction { Object.entries(changes).forEach(([key, value]) => { const existingValue = this.domainObject[key]; if (!(Array.isArray(existingValue)) && (typeof existingValue === 'object')) { - value = { - ...existingValue, - ...value - }; + value = _.merge(existingValue, value); } this.openmct.objects.mutate(this.domainObject, key, value); diff --git a/src/ui/layout/mct-tree.vue b/src/ui/layout/mct-tree.vue index 34ed409295..40e32c8e14 100644 --- a/src/ui/layout/mct-tree.vue +++ b/src/ui/layout/mct-tree.vue @@ -76,7 +76,7 @@