Merge release/2.1.3 into master (#6015)

* Bump version to `2.1.3` (#5973)
* Preserve Gauge configuration changes on create/edit (#5986)
* fix(#5985): deep merge on create/edit properties
- Perform a deep merge of old and new properties on Create/Edit properties actions
* refactor(e2e): improve selector in appActions
* test(e2e): add tests for gauges
- test creating a non-default gauge (checks only for console errors)
- test updating a gauge (checks only for console errors)
* fix(e2e): use pluginFixtures for gauge tests
* fix(e2e): prevent fail if testNotes is undefined
* Make the tree key unique (#5989)

Co-authored-by: Shefali Joshi <simplyrender@gmail.com>
This commit is contained in:
Jesse Mazzella 2022-11-29 17:51:43 -08:00 committed by GitHub
parent be73b0158a
commit 40afb04f0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 20 deletions

View File

@ -72,17 +72,19 @@ async function createDomainObjectWithDefaults(page, { type, name, parent = 'mine
await page.click('button:has-text("Create")'); await page.click('button:has-text("Create")');
// Click the object specified by 'type' // 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' // Modify the name input field of the domain object to accept 'name'
const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]'); const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]');
await nameInput.fill(""); await nameInput.fill("");
await nameInput.fill(name); await nameInput.fill(name);
if (page.testNotes) {
// Fill the "Notes" section with information about the // Fill the "Notes" section with information about the
// currently running test and its project. // currently running test and its project.
const notesInput = page.locator('form[name="mctForm"] #notes-textarea'); const notesInput = page.locator('form[name="mctForm"] #notes-textarea');
await notesInput.fill(page.testNotes); await notesInput.fill(page.testNotes);
}
// Click OK button and wait for Navigate event // Click OK button and wait for Navigate event
await Promise.all([ await Promise.all([

View File

@ -24,22 +24,19 @@
* This test suite is dedicated to testing the Gauge component. * 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 { createDomainObjectWithDefaults } = require('../../../../appActions');
const uuid = require('uuid').v4; const uuid = require('uuid').v4;
test.describe('Gauge', () => { test.describe('Gauge', () => {
let gauge;
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
// Open a browser, navigate to the main page, and wait until all networkevents to resolve // Open a browser, navigate to the main page, and wait until all networkevents to resolve
await page.goto('./', { waitUntil: 'networkidle' }); await page.goto('./', { waitUntil: 'networkidle' });
// Create the gauge
gauge = await createDomainObjectWithDefaults(page, { type: 'Gauge' });
}); });
test('Can add and remove telemetry sources @unstable', async ({ page }) => { 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 editButtonLocator = page.locator('button[title="Edit"]');
const saveButtonLocator = page.locator('button[title="Save"]'); const saveButtonLocator = page.locator('button[title="Save"]');
@ -90,4 +87,38 @@ test.describe('Gauge', () => {
// Verify that the elements pool shows no elements // Verify that the elements pool shows no elements
await expect(page.locator('text="No contained elements"')).toBeVisible(); 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
});
}); });

View File

@ -53,10 +53,7 @@ export default class CreateAction extends PropertiesAction {
const existingValue = this.domainObject[key]; const existingValue = this.domainObject[key];
if (!(existingValue instanceof Array) && (typeof existingValue === 'object')) { if (!(existingValue instanceof Array) && (typeof existingValue === 'object')) {
value = { value = _.merge(existingValue, value);
...existingValue,
...value
};
} }
_.set(this.domainObject, key, value); _.set(this.domainObject, key, value);

View File

@ -22,6 +22,7 @@
import PropertiesAction from './PropertiesAction'; import PropertiesAction from './PropertiesAction';
import CreateWizard from './CreateWizard'; import CreateWizard from './CreateWizard';
import _ from 'lodash';
export default class EditPropertiesAction extends PropertiesAction { export default class EditPropertiesAction extends PropertiesAction {
constructor(openmct) { constructor(openmct) {
@ -61,10 +62,7 @@ export default class EditPropertiesAction extends PropertiesAction {
Object.entries(changes).forEach(([key, value]) => { Object.entries(changes).forEach(([key, value]) => {
const existingValue = this.domainObject[key]; const existingValue = this.domainObject[key];
if (!(Array.isArray(existingValue)) && (typeof existingValue === 'object')) { if (!(Array.isArray(existingValue)) && (typeof existingValue === 'object')) {
value = { value = _.merge(existingValue, value);
...existingValue,
...value
};
} }
this.openmct.objects.mutate(this.domainObject, key, value); this.openmct.objects.mutate(this.domainObject, key, value);

View File

@ -76,7 +76,7 @@
<div :style="childrenHeightStyles"> <div :style="childrenHeightStyles">
<tree-item <tree-item
v-for="(treeItem, index) in visibleItems" v-for="(treeItem, index) in visibleItems"
:key="treeItem.navigationPath" :key="`${treeItem.navigationPath}-${index}`"
:node="treeItem" :node="treeItem"
:is-selector-tree="isSelectorTree" :is-selector-tree="isSelectorTree"
:selected-item="selectedItem" :selected-item="selectedItem"