Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18c3de5255 | ||
|
|
adce5cad7c | ||
|
|
ae357bde2f | ||
|
|
e70bcc414c | ||
|
|
7bb4a136d7 | ||
|
|
8af3b4309f | ||
|
|
bed3d83fd7 | ||
|
|
efda42cf6d | ||
|
|
e8ee5b3fc9 | ||
|
|
393cb9767f | ||
|
|
8b5daad65c | ||
|
|
fabfecdb3e | ||
|
|
a2d8b13204 | ||
|
|
4b14d2d6d2 | ||
|
|
d545124942 | ||
|
|
6abdbfdff0 | ||
|
|
500e655476 | ||
|
|
5e1f026db2 | ||
|
|
d9efae98c8 | ||
|
|
091f6406a8 | ||
|
|
42a0e503cc | ||
|
|
4697352f60 | ||
|
|
015c764ab3 | ||
|
|
8fe465d9fc | ||
|
|
9c1368885a | ||
|
|
391c0b2e7c | ||
|
|
2ae061dbcd |
14
.github/dependabot.yml
vendored
@@ -13,11 +13,17 @@ updates:
|
||||
- "pr:daveit"
|
||||
- "pr:platform"
|
||||
ignore:
|
||||
- dependency-name: "@playwright/test" #We have to source the playwright container which is not detected by Dependabot
|
||||
- dependency-name: "playwright-core" #We have to source the playwright container which is not detected by Dependabot
|
||||
- dependency-name: "@babel/eslint-parser" #Lots of noise in these type patch releases.
|
||||
#We have to source the playwright container which is not detected by Dependabot
|
||||
- dependency-name: "@playwright/test"
|
||||
- dependency-name: "playwright-core"
|
||||
#Lots of noise in these type patch releases.
|
||||
- dependency-name: "@babel/eslint-parser"
|
||||
update-types: ["version-update:semver-patch"]
|
||||
- dependency-name: "eslint-plugin-vue" #Lots of noise in these type patch releases.
|
||||
- dependency-name: "eslint-plugin-vue"
|
||||
update-types: ["version-update:semver-patch"]
|
||||
- dependency-name: "babel-loader"
|
||||
update-types: ["version-update:semver-patch"]
|
||||
- dependency-name: "sinon"
|
||||
update-types: ["version-update:semver-patch"]
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
|
||||
8
.github/workflows/npm-prerelease.yml
vendored
@@ -16,7 +16,11 @@ jobs:
|
||||
with:
|
||||
node-version: 16
|
||||
- run: npm install
|
||||
- run: npm test
|
||||
- run: |
|
||||
echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
|
||||
npm whoami
|
||||
npm publish --access=public --tag unstable openmct
|
||||
# - run: npm test
|
||||
|
||||
publish-npm-prerelease:
|
||||
needs: build
|
||||
@@ -28,6 +32,6 @@ jobs:
|
||||
node-version: 16
|
||||
registry-url: https://registry.npmjs.org/
|
||||
- run: npm install
|
||||
- run: npm publish --access public --tag unstable
|
||||
- run: npm publish --access=public --tag unstable
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
@@ -21,4 +21,10 @@
|
||||
!copyright-notice.html
|
||||
!index.html
|
||||
!openmct.js
|
||||
!SECURITY.md
|
||||
!SECURITY.md
|
||||
|
||||
# Add e2e tests to npm package
|
||||
!/e2e/**/*
|
||||
|
||||
# ... except our test-data folder files.
|
||||
/e2e/test-data/*.json
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
*/
|
||||
|
||||
const Buffer = require('buffer').Buffer;
|
||||
const genUuid = require('uuid').v4;
|
||||
|
||||
/**
|
||||
* This common function creates a domain object with the default options. It is the preferred way of creating objects
|
||||
@@ -56,6 +57,10 @@ const Buffer = require('buffer').Buffer;
|
||||
* @returns {Promise<CreatedObjectInfo>} An object containing information about the newly created domain object.
|
||||
*/
|
||||
async function createDomainObjectWithDefaults(page, { type, name, parent = 'mine' }) {
|
||||
if (!name) {
|
||||
name = `${type}:${genUuid()}`;
|
||||
}
|
||||
|
||||
const parentUrl = await getHashUrlToDomainObject(page, parent);
|
||||
|
||||
// Navigate to the parent object. This is necessary to create the object
|
||||
@@ -67,13 +72,18 @@ 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'
|
||||
if (name) {
|
||||
const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]');
|
||||
await nameInput.fill("");
|
||||
await nameInput.fill(name);
|
||||
const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]');
|
||||
await nameInput.fill("");
|
||||
await nameInput.fill(name);
|
||||
|
||||
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
|
||||
@@ -96,8 +106,8 @@ async function createDomainObjectWithDefaults(page, { type, name, parent = 'mine
|
||||
}
|
||||
|
||||
return {
|
||||
name: name || `Unnamed ${type}`,
|
||||
uuid: uuid,
|
||||
name,
|
||||
uuid,
|
||||
url: objectUrl
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
const { createDomainObjectWithDefaults } = require('../appActions');
|
||||
|
||||
const NOTEBOOK_DROP_AREA = '.c-notebook__drag-area';
|
||||
|
||||
/**
|
||||
@@ -38,24 +40,17 @@ async function enterTextEntry(page, text) {
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
*/
|
||||
async function dragAndDropEmbed(page, myItemsFolderName) {
|
||||
// Click button:has-text("Create")
|
||||
await page.locator('button:has-text("Create")').click();
|
||||
// Click li:has-text("Sine Wave Generator")
|
||||
await page.locator('li:has-text("Sine Wave Generator")').click();
|
||||
// Click form[name="mctForm"] >> text=My Items
|
||||
await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
|
||||
// Click text=OK
|
||||
await page.locator('text=OK').click();
|
||||
// Click text=Open MCT My Items >> span >> nth=3
|
||||
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
|
||||
// Click text=Unnamed CUSTOM_NAME
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
page.locator('text=Unnamed CUSTOM_NAME').click()
|
||||
]);
|
||||
|
||||
await page.dragAndDrop('text=UNNAMED SINE WAVE GENERATOR', NOTEBOOK_DROP_AREA);
|
||||
async function dragAndDropEmbed(page, notebookObject) {
|
||||
// Create example telemetry object
|
||||
const swg = await createDomainObjectWithDefaults(page, {
|
||||
type: "Sine Wave Generator"
|
||||
});
|
||||
// Navigate to notebook
|
||||
await page.goto(notebookObject.url);
|
||||
// Expand the tree to reveal the notebook
|
||||
await page.click('button[title="Show selected item in tree"]');
|
||||
// Drag and drop the SWG into the notebook
|
||||
await page.dragAndDrop(`text=${swg.name}`, NOTEBOOK_DROP_AREA);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
|
||||
@@ -126,13 +126,21 @@ exports.test = test.extend({
|
||||
// This should follow in the Project's configuration. Can be set to 'snow' in playwright config.js
|
||||
theme: [theme, { option: true }],
|
||||
// eslint-disable-next-line no-shadow
|
||||
page: async ({ page, theme }, use) => {
|
||||
page: async ({ page, theme }, use, testInfo) => {
|
||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
||||
if (theme === 'snow') {
|
||||
//inject snow theme
|
||||
await page.addInitScript({ path: path.join(__dirname, './helper', './useSnowTheme.js') });
|
||||
}
|
||||
|
||||
// Attach info about the currently running test and its project.
|
||||
// This will be used by appActions to fill in the created
|
||||
// domain object's notes.
|
||||
page.testNotes = [
|
||||
`${testInfo.titlePath.join('\n')}`,
|
||||
`${testInfo.project.name}`
|
||||
].join('\n');
|
||||
|
||||
await use(page);
|
||||
},
|
||||
myItemsFolderName: [myItemsFolderName, { option: true }],
|
||||
@@ -140,22 +148,5 @@ exports.test = test.extend({
|
||||
openmctConfig: async ({ myItemsFolderName }, use) => {
|
||||
await use({ myItemsFolderName });
|
||||
}
|
||||
// objectCreateOptions: [objectCreateOptions, {option: true}],
|
||||
// eslint-disable-next-line no-shadow
|
||||
// domainObject: [async ({ page, objectCreateOptions }, use) => {
|
||||
// // FIXME: This is a false-positive caused by a bug in the eslint-plugin-playwright rule.
|
||||
// // eslint-disable-next-line playwright/no-conditional-in-test
|
||||
// if (objectCreateOptions === null) {
|
||||
// await use(page);
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
// //Go to baseURL
|
||||
// await page.goto('./', { waitUntil: 'networkidle' });
|
||||
|
||||
// const uuid = await getOrCreateDomainObject(page, objectCreateOptions);
|
||||
// await use({ uuid });
|
||||
// }, { auto: true }]
|
||||
});
|
||||
exports.expect = expect;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
const { test, expect } = require('../../baseFixtures.js');
|
||||
const { test, expect } = require('../../pluginFixtures.js');
|
||||
const { createDomainObjectWithDefaults } = require('../../appActions.js');
|
||||
|
||||
test.describe('AppActions', () => {
|
||||
@@ -50,11 +50,11 @@ test.describe('AppActions', () => {
|
||||
});
|
||||
|
||||
await page.goto(timer1.url, { waitUntil: 'networkidle' });
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Timer Foo');
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer1.name);
|
||||
await page.goto(timer2.url, { waitUntil: 'networkidle' });
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Timer Bar');
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer2.name);
|
||||
await page.goto(timer3.url, { waitUntil: 'networkidle' });
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Timer Baz');
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer3.name);
|
||||
});
|
||||
|
||||
await test.step('Create multiple nested objects in a row', async () => {
|
||||
@@ -74,11 +74,11 @@ test.describe('AppActions', () => {
|
||||
parent: folder2.uuid
|
||||
});
|
||||
await page.goto(folder1.url, { waitUntil: 'networkidle' });
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Folder Foo');
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(folder1.name);
|
||||
await page.goto(folder2.url, { waitUntil: 'networkidle' });
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Folder Bar');
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(folder2.name);
|
||||
await page.goto(folder3.url, { waitUntil: 'networkidle' });
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Folder Baz');
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(folder3.name);
|
||||
|
||||
expect(folder1.url).toBe(`${e2eFolder.url}/${folder1.uuid}`);
|
||||
expect(folder2.url).toBe(`${e2eFolder.url}/${folder1.uuid}/${folder2.uuid}`);
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
*/
|
||||
|
||||
// Structure: Some standard Imports. Please update the required pathing.
|
||||
const { test, expect } = require('../../baseFixtures');
|
||||
const { test, expect } = require('../../pluginFixtures');
|
||||
const { createDomainObjectWithDefaults } = require('../../appActions');
|
||||
|
||||
/**
|
||||
@@ -144,5 +144,5 @@ async function renameTimerFrom3DotMenu(page, timerUrl, newNameForTimer) {
|
||||
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(newNameForTimer);
|
||||
|
||||
// Click Ok button to Save
|
||||
await page.locator('text=OK').click();
|
||||
await page.locator('button:has-text("OK")').click();
|
||||
}
|
||||
|
||||
@@ -43,14 +43,14 @@ test('Generate Visual Test Data @localStorage', async ({ page, context }) => {
|
||||
await page.locator('button:has-text("Create")').click();
|
||||
|
||||
// add sine wave generator with defaults
|
||||
await page.locator('li:has-text("Sine Wave Generator")').click();
|
||||
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
|
||||
|
||||
//Add a 5000 ms Delay
|
||||
await page.locator('[aria-label="Loading Delay \\(ms\\)"]').fill('5000');
|
||||
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
page.locator('text=OK').click(),
|
||||
page.locator('button:has-text("OK")').click(),
|
||||
//Wait for Save Banner to appear
|
||||
page.waitForSelector('.c-message-banner__message')
|
||||
]);
|
||||
@@ -58,7 +58,7 @@ test('Generate Visual Test Data @localStorage', async ({ page, context }) => {
|
||||
// focus the overlay plot
|
||||
await page.goto(overlayPlot.url);
|
||||
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Overlay Plot');
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText(overlayPlot.name);
|
||||
//Save localStorage for future test execution
|
||||
await context.storageState({ path: './e2e/test-data/VisualTestData_storage.json' });
|
||||
});
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const { test, expect } = require('../../baseFixtures');
|
||||
const { test, expect } = require('../../pluginFixtures');
|
||||
|
||||
test.describe("CouchDB Status Indicator @couchdb", () => {
|
||||
test.use({ failOnConsoleError: false });
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
This test suite is dedicated to tests which verify the basic operations surrounding the example event generator.
|
||||
*/
|
||||
|
||||
const { test, expect } = require('../../../baseFixtures');
|
||||
const { test, expect } = require('../../../pluginFixtures');
|
||||
const { createDomainObjectWithDefaults } = require('../../../appActions');
|
||||
|
||||
test.describe('Example Event Generator CRUD Operations', () => {
|
||||
|
||||
@@ -96,7 +96,7 @@ test.describe('Sine Wave Generator', () => {
|
||||
//Click text=OK
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
page.click('text=OK')
|
||||
page.click('button:has-text("OK")')
|
||||
]);
|
||||
|
||||
// Verify that the Sine Wave Generator is displayed and correct
|
||||
|
||||
@@ -25,6 +25,7 @@ This test suite is dedicated to tests which verify form functionality in isolati
|
||||
*/
|
||||
|
||||
const { test, expect } = require('../../baseFixtures');
|
||||
const { createDomainObjectWithDefaults } = require('../../appActions');
|
||||
const path = require('path');
|
||||
|
||||
const TEST_FOLDER = 'test folder';
|
||||
@@ -43,7 +44,7 @@ test.describe('Form Validation Behavior', () => {
|
||||
await page.press('text=Properties Title Notes >> input[type="text"]', 'Tab');
|
||||
|
||||
//Required Field Form Validation
|
||||
await expect(page.locator('text=OK')).toBeDisabled();
|
||||
await expect(page.locator('button:has-text("OK")')).toBeDisabled();
|
||||
await expect(page.locator('.c-form-row__state-indicator').first()).toHaveClass(/invalid/);
|
||||
|
||||
//Correct Form Validation for missing title and trigger validation with 'Tab'
|
||||
@@ -52,13 +53,13 @@ test.describe('Form Validation Behavior', () => {
|
||||
await page.press('text=Properties Title Notes >> input[type="text"]', 'Tab');
|
||||
|
||||
//Required Field Form Validation is corrected
|
||||
await expect(page.locator('text=OK')).toBeEnabled();
|
||||
await expect(page.locator('button:has-text("OK")')).toBeEnabled();
|
||||
await expect(page.locator('.c-form-row__state-indicator').first()).not.toHaveClass(/invalid/);
|
||||
|
||||
//Finish Creating Domain Object
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
page.click('text=OK')
|
||||
page.click('button:has-text("OK")')
|
||||
]);
|
||||
|
||||
//Verify that the Domain Object has been created with the corrected title property
|
||||
@@ -91,6 +92,44 @@ test.describe('Persistence operations @addInit', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Persistence operations @couchdb', () => {
|
||||
test.use({ failOnConsoleError: false });
|
||||
test('Editing object properties should generate a single persistence operation', async ({ page }) => {
|
||||
test.info().annotations.push({
|
||||
type: 'issue',
|
||||
description: 'https://github.com/nasa/openmct/issues/5616'
|
||||
});
|
||||
|
||||
await page.goto('./', { waitUntil: 'networkidle' });
|
||||
|
||||
// Create a new 'Clock' object with default settings
|
||||
const clock = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Clock'
|
||||
});
|
||||
|
||||
// Count all persistence operations (PUT requests) for this specific object
|
||||
let putRequestCount = 0;
|
||||
page.on('request', req => {
|
||||
if (req.method() === 'PUT' && req.url().endsWith(clock.uuid)) {
|
||||
putRequestCount += 1;
|
||||
}
|
||||
});
|
||||
|
||||
// Open the edit form for the clock object
|
||||
await page.click('button[title="More options"]');
|
||||
await page.click('li[title="Edit properties of this object."]');
|
||||
|
||||
// Modify the display format from default 12hr -> 24hr and click 'Save'
|
||||
await page.locator('select[aria-label="12 or 24 hour clock"]').selectOption({ value: 'clock24' });
|
||||
await page.click('button[aria-label="Save"]');
|
||||
|
||||
await expect.poll(() => putRequestCount, {
|
||||
message: 'Verify a single PUT request was made to persist the object',
|
||||
timeout: 1000
|
||||
}).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Form Correctness by Object Type', () => {
|
||||
test.fixme('Verify correct behavior of number object (SWG)', async ({page}) => {});
|
||||
test.fixme('Verify correct behavior of number object Timer', async ({page}) => {});
|
||||
|
||||
@@ -81,7 +81,7 @@ test.describe('Move & link item tests', () => {
|
||||
await page.locator('li.icon-move').click();
|
||||
await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
|
||||
|
||||
await page.locator('text=OK').click();
|
||||
await page.locator('button:has-text("OK")').click();
|
||||
|
||||
// Expect that Child Folder is in My Items, the root folder
|
||||
expect(page.locator(`text=${myItemsFolderName} >> nth=0:has(text=Child Folder)`)).toBeTruthy();
|
||||
@@ -95,11 +95,11 @@ test.describe('Move & link item tests', () => {
|
||||
// Create Telemetry Table
|
||||
let telemetryTable = 'Test Telemetry Table';
|
||||
await page.locator('button:has-text("Create")').click();
|
||||
await page.locator('li:has-text("Telemetry Table")').click();
|
||||
await page.locator('li[role="menuitem"]:has-text("Telemetry Table")').click();
|
||||
await page.locator('text=Properties Title Notes >> input[type="text"]').click();
|
||||
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(telemetryTable);
|
||||
|
||||
await page.locator('text=OK').click();
|
||||
await page.locator('button:has-text("OK")').click();
|
||||
|
||||
// Finish editing and save Telemetry Table
|
||||
await page.locator('.c-button--menu.c-button--major.icon-save').click();
|
||||
@@ -108,7 +108,7 @@ test.describe('Move & link item tests', () => {
|
||||
// Create New Folder Basic Domain Object
|
||||
let folder = 'Test Folder';
|
||||
await page.locator('button:has-text("Create")').click();
|
||||
await page.locator('li:has-text("Folder")').click();
|
||||
await page.locator('li[role="menuitem"]:has-text("Folder")').click();
|
||||
await page.locator('text=Properties Title Notes >> input[type="text"]').click();
|
||||
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(folder);
|
||||
|
||||
@@ -120,7 +120,7 @@ test.describe('Move & link item tests', () => {
|
||||
|
||||
// Continue test regardless of assertion and create it in My Items
|
||||
await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
|
||||
await page.locator('text=OK').click();
|
||||
await page.locator('button:has-text("OK")').click();
|
||||
|
||||
// Open My Items
|
||||
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
|
||||
@@ -196,7 +196,7 @@ test.describe('Move & link item tests', () => {
|
||||
await page.locator('li.icon-link').click();
|
||||
await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
|
||||
|
||||
await page.locator('text=OK').click();
|
||||
await page.locator('button:has-text("OK")').click();
|
||||
|
||||
// Expect that Child Folder is in My Items, the root folder
|
||||
expect(page.locator(`text=${myItemsFolderName} >> nth=0:has(text=Child Folder)`)).toBeTruthy();
|
||||
|
||||
@@ -40,11 +40,11 @@ test.describe.serial('Condition Set CRUD Operations on @localStorage', () => {
|
||||
await page.goto('./', { waitUntil: 'networkidle' });
|
||||
await page.click('button:has-text("Create")');
|
||||
|
||||
await page.locator('li:has-text("Condition Set")').click();
|
||||
await page.locator('li[role="menuitem"]:has-text("Condition Set")').click();
|
||||
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
page.click('text=OK')
|
||||
page.click('button:has-text("OK")')
|
||||
]);
|
||||
|
||||
//Save localStorage for future test execution
|
||||
@@ -163,9 +163,9 @@ test.describe.serial('Condition Set CRUD Operations on @localStorage', () => {
|
||||
// Click hamburger button
|
||||
await page.locator('[title="More options"]').click();
|
||||
|
||||
// Click text=Remove
|
||||
await page.locator('text=Remove').click();
|
||||
await page.locator('text=OK').click();
|
||||
// Click 'Remove' and press OK
|
||||
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||
await page.locator('button:has-text("OK")').click();
|
||||
|
||||
//Expect Unnamed Condition Set to be removed in Main View
|
||||
const numberOfConditionSetsAtEnd = await page.locator('a:has-text("Unnamed Condition Set Condition Set")').count();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
const { test, expect } = require('../../../../pluginFixtures');
|
||||
const { createDomainObjectWithDefaults, setStartOffset, setFixedTimeMode, setRealTimeMode } = require('../../../../appActions');
|
||||
|
||||
test.describe('Testing Display Layout @unstable', () => {
|
||||
test.describe('Display Layout', () => {
|
||||
let sineWaveObject;
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('./', { waitUntil: 'networkidle' });
|
||||
@@ -55,12 +55,12 @@ test.describe('Testing Display Layout @unstable', () => {
|
||||
// On getting data, check if the value found in the Display Layout is the most recent value
|
||||
// from the Sine Wave Generator
|
||||
const getTelemValuePromise = await subscribeToTelemetry(page, sineWaveObject.uuid);
|
||||
const formattedTelemetryValue = await getTelemValuePromise;
|
||||
const formattedTelemetryValue = getTelemValuePromise;
|
||||
const displayLayoutValuePromise = await page.waitForSelector(`text="${formattedTelemetryValue}"`);
|
||||
const displayLayoutValue = await displayLayoutValuePromise.textContent();
|
||||
const trimmedDisplayValue = displayLayoutValue.trim();
|
||||
|
||||
await expect(trimmedDisplayValue).toBe(formattedTelemetryValue);
|
||||
expect(trimmedDisplayValue).toBe(formattedTelemetryValue);
|
||||
});
|
||||
test('alpha-numeric widget telemetry value exactly matches latest telemetry value received in fixed time', async ({ page }) => {
|
||||
// Create a Display Layout
|
||||
@@ -86,12 +86,12 @@ test.describe('Testing Display Layout @unstable', () => {
|
||||
|
||||
// On getting data, check if the value found in the Display Layout is the most recent value
|
||||
// from the Sine Wave Generator
|
||||
const formattedTelemetryValue = await getTelemValuePromise;
|
||||
const formattedTelemetryValue = getTelemValuePromise;
|
||||
const displayLayoutValuePromise = await page.waitForSelector(`text="${formattedTelemetryValue}"`);
|
||||
const displayLayoutValue = await displayLayoutValuePromise.textContent();
|
||||
const trimmedDisplayValue = displayLayoutValue.trim();
|
||||
|
||||
await expect(trimmedDisplayValue).toBe(formattedTelemetryValue);
|
||||
expect(trimmedDisplayValue).toBe(formattedTelemetryValue);
|
||||
});
|
||||
test('items in a display layout can be removed with object tree context menu when viewing the display layout', async ({ page }) => {
|
||||
// Create a Display Layout
|
||||
@@ -116,16 +116,20 @@ test.describe('Testing Display Layout @unstable', () => {
|
||||
|
||||
// Bring up context menu and remove
|
||||
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').first().click({ button: 'right' });
|
||||
await page.locator('text=Remove').click();
|
||||
await page.locator('text=OK').click();
|
||||
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||
await page.locator('button:has-text("OK")').click();
|
||||
|
||||
// delete
|
||||
|
||||
expect.soft(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0);
|
||||
expect(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0);
|
||||
});
|
||||
test('items in a display layout can be removed with object tree context menu when viewing another item', async ({ page }) => {
|
||||
test.info().annotations.push({
|
||||
type: 'issue',
|
||||
description: 'https://github.com/nasa/openmct/issues/3117'
|
||||
});
|
||||
// Create a Display Layout
|
||||
await createDomainObjectWithDefaults(page, {
|
||||
const displayLayout = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Display Layout',
|
||||
name: "Test Display Layout"
|
||||
});
|
||||
@@ -144,18 +148,18 @@ test.describe('Testing Display Layout @unstable', () => {
|
||||
// Expand the Display Layout so we can remove the sine wave generator
|
||||
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
|
||||
|
||||
// Click the original Sine Wave Generator to navigate away from the Display Layout
|
||||
await page.locator('.c-tree__item .c-tree__item__name:text("Test Sine Wave Generator")').click();
|
||||
// Go to the original Sine Wave Generator to navigate away from the Display Layout
|
||||
await page.goto(sineWaveObject.url);
|
||||
|
||||
// Bring up context menu and remove
|
||||
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').click({ button: 'right' });
|
||||
await page.locator('text=Remove').click();
|
||||
await page.locator('text=OK').click();
|
||||
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||
await page.locator('button:has-text("OK")').click();
|
||||
|
||||
// navigate back to the display layout to confirm it has been removed
|
||||
await page.locator('.c-tree__item .c-tree__item__name:text("Test Display Layout")').click();
|
||||
await page.goto(displayLayout.url);
|
||||
|
||||
expect.soft(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0);
|
||||
expect(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -23,12 +23,13 @@
|
||||
const { test, expect } = require('../../../../pluginFixtures');
|
||||
const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||
|
||||
test.describe('Testing Flexible Layout @unstable', () => {
|
||||
test.describe('Flexible Layout', () => {
|
||||
let sineWaveObject;
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('./', { waitUntil: 'networkidle' });
|
||||
|
||||
// Create Sine Wave Generator
|
||||
await createDomainObjectWithDefaults(page, {
|
||||
sineWaveObject = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Sine Wave Generator',
|
||||
name: "Test Sine Wave Generator"
|
||||
});
|
||||
@@ -54,13 +55,81 @@ test.describe('Testing Flexible Layout @unstable', () => {
|
||||
await page.dragAndDrop('text=Test Sine Wave Generator', '.c-fl__container.is-empty');
|
||||
await page.dragAndDrop('text=Test Clock', '.c-fl__container.is-empty');
|
||||
// Check that panes can be dragged while Flexible Layout is in Edit mode
|
||||
let dragWrapper = await page.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper').first();
|
||||
let dragWrapper = page.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper').first();
|
||||
await expect(dragWrapper).toHaveAttribute('draggable', 'true');
|
||||
// Save Flexible Layout
|
||||
await page.locator('button[title="Save"]').click();
|
||||
await page.locator('text=Save and Finish Editing').click();
|
||||
// Check that panes are not draggable while Flexible Layout is in Browse mode
|
||||
dragWrapper = await page.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper').first();
|
||||
dragWrapper = page.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper').first();
|
||||
await expect(dragWrapper).toHaveAttribute('draggable', 'false');
|
||||
});
|
||||
test('items in a flexible layout can be removed with object tree context menu when viewing the flexible layout', async ({ page }) => {
|
||||
// Create a Display Layout
|
||||
await createDomainObjectWithDefaults(page, {
|
||||
type: 'Flexible Layout',
|
||||
name: "Test Flexible Layout"
|
||||
});
|
||||
// Edit Flexible Layout
|
||||
await page.locator('[title="Edit"]').click();
|
||||
|
||||
// Expand the 'My Items' folder in the left tree
|
||||
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').first().click();
|
||||
// Add the Sine Wave Generator to the Flexible Layout and save changes
|
||||
await page.dragAndDrop('text=Test Sine Wave Generator', '.c-fl__container.is-empty');
|
||||
await page.locator('button[title="Save"]').click();
|
||||
await page.locator('text=Save and Finish Editing').click();
|
||||
|
||||
expect.soft(await page.locator('.c-fl-container__frame').count()).toEqual(1);
|
||||
|
||||
// Expand the Flexible Layout so we can remove the sine wave generator
|
||||
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
|
||||
|
||||
// Bring up context menu and remove
|
||||
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').first().click({ button: 'right' });
|
||||
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||
await page.locator('button:has-text("OK")').click();
|
||||
|
||||
// Verify that the item has been removed from the layout
|
||||
expect(await page.locator('.c-fl-container__frame').count()).toEqual(0);
|
||||
});
|
||||
test('items in a flexible layout can be removed with object tree context menu when viewing another item', async ({ page }) => {
|
||||
test.info().annotations.push({
|
||||
type: 'issue',
|
||||
description: 'https://github.com/nasa/openmct/issues/3117'
|
||||
});
|
||||
// Create a Flexible Layout
|
||||
const flexibleLayout = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Flexible Layout',
|
||||
name: "Test Flexible Layout"
|
||||
});
|
||||
// Edit Flexible Layout
|
||||
await page.locator('[title="Edit"]').click();
|
||||
|
||||
// Expand the 'My Items' folder in the left tree
|
||||
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
|
||||
// Add the Sine Wave Generator to the Flexible Layout and save changes
|
||||
await page.dragAndDrop('text=Test Sine Wave Generator', '.c-fl__container.is-empty');
|
||||
await page.locator('button[title="Save"]').click();
|
||||
await page.locator('text=Save and Finish Editing').click();
|
||||
|
||||
expect.soft(await page.locator('.c-fl-container__frame').count()).toEqual(1);
|
||||
|
||||
// Expand the Flexible Layout so we can remove the sine wave generator
|
||||
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
|
||||
|
||||
// Go to the original Sine Wave Generator to navigate away from the Flexible Layout
|
||||
await page.goto(sineWaveObject.url);
|
||||
|
||||
// Bring up context menu and remove
|
||||
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').click({ button: 'right' });
|
||||
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||
await page.locator('button:has-text("OK")').click();
|
||||
|
||||
// navigate back to the display layout to confirm it has been removed
|
||||
await page.goto(flexibleLayout.url);
|
||||
|
||||
// Verify that the item has been removed from the layout
|
||||
expect(await page.locator('.c-fl-container__frame').count()).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
124
e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js
Normal file
@@ -0,0 +1,124 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2022, 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 Gauge component.
|
||||
*/
|
||||
|
||||
const { test, expect } = require('../../../../pluginFixtures');
|
||||
const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||
const uuid = require('uuid').v4;
|
||||
|
||||
test.describe('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' });
|
||||
});
|
||||
|
||||
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"]');
|
||||
|
||||
// Create a sine wave generator within the gauge
|
||||
const swg1 = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Sine Wave Generator',
|
||||
name: `swg-${uuid()}`,
|
||||
parent: gauge.uuid
|
||||
});
|
||||
|
||||
// Navigate to the gauge and verify that
|
||||
// the SWG appears in the elements pool
|
||||
await page.goto(gauge.url);
|
||||
await editButtonLocator.click();
|
||||
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeVisible();
|
||||
await saveButtonLocator.click();
|
||||
await page.locator('li[title="Save and Finish Editing"]').click();
|
||||
|
||||
// Create another sine wave generator within the gauge
|
||||
const swg2 = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Sine Wave Generator',
|
||||
name: `swg-${uuid()}`,
|
||||
parent: gauge.uuid
|
||||
});
|
||||
|
||||
// Verify that the 'Replace telemetry source' modal appears and accept it
|
||||
await expect.soft(page.locator('text=This action will replace the current telemetry source. Do you want to continue?')).toBeVisible();
|
||||
await page.click('text=Ok');
|
||||
|
||||
// Navigate to the gauge and verify that the new SWG
|
||||
// appears in the elements pool and the old one is gone
|
||||
await page.goto(gauge.url);
|
||||
await editButtonLocator.click();
|
||||
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeHidden();
|
||||
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg2.name}`)).toBeVisible();
|
||||
await saveButtonLocator.click();
|
||||
|
||||
// Right click on the new SWG in the elements pool and delete it
|
||||
await page.locator(`#inspector-elements-tree >> text=${swg2.name}`).click({
|
||||
button: 'right'
|
||||
});
|
||||
await page.locator('li[title="Remove this object from its containing object."]').click();
|
||||
|
||||
// Verify that the 'Remove object' confirmation modal appears and accept it
|
||||
await expect.soft(page.locator('text=Warning! This action will remove this object. Are you sure you want to continue?')).toBeVisible();
|
||||
await page.click('text=Ok');
|
||||
|
||||
// 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
|
||||
});
|
||||
});
|
||||
@@ -40,10 +40,10 @@ test.describe('Example Imagery Object', () => {
|
||||
await page.goto('./', { waitUntil: 'networkidle' });
|
||||
|
||||
// Create a default 'Example Imagery' object
|
||||
await createDomainObjectWithDefaults(page, { type: 'Example Imagery' });
|
||||
const exampleImagery = await createDomainObjectWithDefaults(page, { type: 'Example Imagery' });
|
||||
|
||||
// Verify that the created object is focused
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Example Imagery');
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText(exampleImagery.name);
|
||||
await page.locator(backgroundImageSelector).hover({trial: true});
|
||||
});
|
||||
|
||||
@@ -188,7 +188,7 @@ test.describe('Example Imagery in Display Layout', () => {
|
||||
await page.click('button:has-text("Create")');
|
||||
|
||||
// Click text=Example Imagery
|
||||
await page.click('text=Example Imagery');
|
||||
await page.click('li[role="menuitem"]:has-text("Example Imagery")');
|
||||
|
||||
// Clear and set Image load delay to minimum value
|
||||
await page.locator('input[type="number"]').fill('');
|
||||
@@ -197,7 +197,7 @@ test.describe('Example Imagery in Display Layout', () => {
|
||||
// Click text=OK
|
||||
await Promise.all([
|
||||
page.waitForNavigation({waitUntil: 'networkidle'}),
|
||||
page.click('text=OK'),
|
||||
page.click('button:has-text("OK")'),
|
||||
//Wait for Save Banner to appear
|
||||
page.waitForSelector('.c-message-banner__message')
|
||||
]);
|
||||
@@ -275,7 +275,7 @@ test.describe('Example Imagery in Flexible layout', () => {
|
||||
await page.click('button:has-text("Create")');
|
||||
|
||||
// Click text=Example Imagery
|
||||
await page.click('text=Example Imagery');
|
||||
await page.click('li[role="menuitem"]:has-text("Example Imagery")');
|
||||
|
||||
// Clear and set Image load delay to minimum value
|
||||
await page.locator('input[type="number"]').fill('');
|
||||
@@ -284,7 +284,7 @@ test.describe('Example Imagery in Flexible layout', () => {
|
||||
// Click text=OK
|
||||
await Promise.all([
|
||||
page.waitForNavigation({waitUntil: 'networkidle'}),
|
||||
page.click('text=OK'),
|
||||
page.click('button:has-text("OK")'),
|
||||
//Wait for Save Banner to appear
|
||||
page.waitForSelector('.c-message-banner__message')
|
||||
]);
|
||||
@@ -317,7 +317,7 @@ test.describe('Example Imagery in Tabs View', () => {
|
||||
await page.click('button:has-text("Create")');
|
||||
|
||||
// Click text=Example Imagery
|
||||
await page.click('text=Example Imagery');
|
||||
await page.click('li[role="menuitem"]:has-text("Example Imagery")');
|
||||
|
||||
// Clear and set Image load delay to minimum value
|
||||
await page.locator('input[type="number"]').fill('');
|
||||
@@ -326,7 +326,7 @@ test.describe('Example Imagery in Tabs View', () => {
|
||||
// Click text=OK
|
||||
await Promise.all([
|
||||
page.waitForNavigation({waitUntil: 'networkidle'}),
|
||||
page.click('text=OK'),
|
||||
page.click('button:has-text("OK")'),
|
||||
//Wait for Save Banner to appear
|
||||
page.waitForSelector('.c-message-banner__message')
|
||||
]);
|
||||
|
||||
@@ -26,7 +26,7 @@ This test suite is dedicated to tests which verify the basic operations surround
|
||||
|
||||
// FIXME: Remove this eslint exception once tests are implemented
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { test, expect } = require('../../../../baseFixtures');
|
||||
const { test, expect } = require('../../../../pluginFixtures');
|
||||
const { expandTreePaneItemByName, createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||
const nbUtils = require('../../../../helper/notebookUtils');
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
This test suite is dedicated to tests which verify the basic operations surrounding Notebooks with CouchDB.
|
||||
*/
|
||||
|
||||
const { test, expect } = require('../../../../baseFixtures');
|
||||
const { test, expect } = require('../../../../pluginFixtures');
|
||||
const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||
|
||||
test.describe('Notebook Tests with CouchDB @couchdb', () => {
|
||||
|
||||
@@ -36,27 +36,27 @@ test.describe('Restricted Notebook', () => {
|
||||
});
|
||||
|
||||
test('Can be renamed @addInit', async ({ page }) => {
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText(`Unnamed ${CUSTOM_NAME}`);
|
||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText(`${notebook.name}`);
|
||||
});
|
||||
|
||||
test('Can be deleted if there are no locked pages @addInit', async ({ page, openmctConfig }) => {
|
||||
test('Can be deleted if there are no locked pages @addInit', async ({ page }) => {
|
||||
await openObjectTreeContextMenu(page, notebook.url);
|
||||
|
||||
const menuOptions = page.locator('.c-menu ul');
|
||||
await expect.soft(menuOptions).toContainText('Remove');
|
||||
|
||||
const restrictedNotebookTreeObject = page.locator(`a:has-text("Unnamed ${CUSTOM_NAME}")`);
|
||||
const restrictedNotebookTreeObject = page.locator(`a:has-text("${notebook.name}")`);
|
||||
|
||||
// notebook tree object exists
|
||||
expect.soft(await restrictedNotebookTreeObject.count()).toEqual(1);
|
||||
|
||||
// Click Remove Text
|
||||
await page.locator('text=Remove').click();
|
||||
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||
|
||||
// Click 'OK' on confirmation window and wait for save banner to appear
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
page.locator('text=OK').click(),
|
||||
page.locator('button:has-text("OK")').click(),
|
||||
page.waitForSelector('.c-message-banner__message')
|
||||
]);
|
||||
|
||||
@@ -134,7 +134,7 @@ test.describe('Restricted Notebook with at least one entry and with the page loc
|
||||
// Click text=Ok
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
page.locator('text=Ok').click()
|
||||
page.locator('button:has-text("OK")').click()
|
||||
]);
|
||||
|
||||
// deleted page, should no longer exist
|
||||
@@ -145,10 +145,9 @@ test.describe('Restricted Notebook with at least one entry and with the page loc
|
||||
|
||||
test.describe('Restricted Notebook with a page locked and with an embed @addInit', () => {
|
||||
|
||||
test.beforeEach(async ({ page, openmctConfig }) => {
|
||||
const { myItemsFolderName } = openmctConfig;
|
||||
await startAndAddRestrictedNotebookObject(page);
|
||||
await nbUtils.dragAndDropEmbed(page, myItemsFolderName);
|
||||
test.beforeEach(async ({ page }) => {
|
||||
const notebook = await startAndAddRestrictedNotebookObject(page);
|
||||
await nbUtils.dragAndDropEmbed(page, notebook);
|
||||
});
|
||||
|
||||
test('Allows embeds to be deleted if page unlocked @addInit', async ({ page }) => {
|
||||
|
||||
@@ -36,7 +36,7 @@ async function createNotebookAndEntry(page, iterations = 1) {
|
||||
//Go to baseURL
|
||||
await page.goto('./', { waitUntil: 'networkidle' });
|
||||
|
||||
createDomainObjectWithDefaults(page, { type: 'Notebook' });
|
||||
const notebook = createDomainObjectWithDefaults(page, { type: 'Notebook' });
|
||||
|
||||
for (let iteration = 0; iteration < iterations; iteration++) {
|
||||
// Create an entry
|
||||
@@ -45,6 +45,8 @@ async function createNotebookAndEntry(page, iterations = 1) {
|
||||
await page.locator(entryLocator).click();
|
||||
await page.locator(entryLocator).fill(`Entry ${iteration}`);
|
||||
}
|
||||
|
||||
return notebook;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +55,7 @@ async function createNotebookAndEntry(page, iterations = 1) {
|
||||
* @param {number} [iterations = 1] - the number of entries (and tags) to create
|
||||
*/
|
||||
async function createNotebookEntryAndTags(page, iterations = 1) {
|
||||
await createNotebookAndEntry(page, iterations);
|
||||
const notebook = await createNotebookAndEntry(page, iterations);
|
||||
|
||||
for (let iteration = 0; iteration < iterations; iteration++) {
|
||||
// Hover and click "Add Tag" button
|
||||
@@ -75,6 +77,8 @@ async function createNotebookEntryAndTags(page, iterations = 1) {
|
||||
// Select the "Science" tag
|
||||
await page.locator('[aria-label="Autocomplete Options"] >> text=Science').click();
|
||||
}
|
||||
|
||||
return notebook;
|
||||
}
|
||||
|
||||
test.describe('Tagging in Notebooks @addInit', () => {
|
||||
@@ -173,10 +177,10 @@ test.describe('Tagging in Notebooks @addInit', () => {
|
||||
//Go to baseURL
|
||||
await page.goto('./', { waitUntil: 'networkidle' });
|
||||
|
||||
await createDomainObjectWithDefaults(page, { type: 'Clock' });
|
||||
const clock = await createDomainObjectWithDefaults(page, { type: 'Clock' });
|
||||
|
||||
const ITERATIONS = 4;
|
||||
await createNotebookEntryAndTags(page, ITERATIONS);
|
||||
const notebook = await createNotebookEntryAndTags(page, ITERATIONS);
|
||||
|
||||
for (let iteration = 0; iteration < ITERATIONS; iteration++) {
|
||||
const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`;
|
||||
@@ -189,11 +193,11 @@ test.describe('Tagging in Notebooks @addInit', () => {
|
||||
page.goto('./#/browse/mine?hideTree=false'),
|
||||
page.click('.c-disclosure-triangle')
|
||||
]);
|
||||
// Click Unnamed Clock
|
||||
await page.click('text="Unnamed Clock"');
|
||||
// Click Clock
|
||||
await page.click(`text=${clock.name}`);
|
||||
|
||||
// Click Unnamed Notebook
|
||||
await page.click('text="Unnamed Notebook"');
|
||||
// Click Notebook
|
||||
await page.click(`text=${notebook.name}`);
|
||||
|
||||
for (let iteration = 0; iteration < ITERATIONS; iteration++) {
|
||||
const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`;
|
||||
@@ -207,14 +211,13 @@ test.describe('Tagging in Notebooks @addInit', () => {
|
||||
page.waitForLoadState('networkidle')
|
||||
]);
|
||||
|
||||
// Click Unnamed Notebook
|
||||
await page.click('text="Unnamed Notebook"');
|
||||
// Click Notebook
|
||||
await page.click(`text="${notebook.name}"`);
|
||||
|
||||
for (let iteration = 0; iteration < ITERATIONS; iteration++) {
|
||||
const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`;
|
||||
await expect(page.locator(entryLocator)).toContainText("Science");
|
||||
await expect(page.locator(entryLocator)).toContainText("Driving");
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -110,10 +110,10 @@ async function createSinewaveOverlayPlot(page, myItemsFolderName) {
|
||||
await page.locator('button:has-text("Create")').click();
|
||||
|
||||
// add overlay plot with defaults
|
||||
await page.locator('li:has-text("Overlay Plot")').click();
|
||||
await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click();
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
page.locator('text=OK').click(),
|
||||
page.locator('button:has-text("OK")').click(),
|
||||
//Wait for Save Banner to appear1
|
||||
page.waitForSelector('.c-message-banner__message')
|
||||
]);
|
||||
@@ -129,10 +129,10 @@ async function createSinewaveOverlayPlot(page, myItemsFolderName) {
|
||||
await page.locator('button:has-text("Create")').click();
|
||||
|
||||
// add sine wave generator with defaults
|
||||
await page.locator('li:has-text("Sine Wave Generator")').click();
|
||||
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
page.locator('text=OK').click(),
|
||||
page.locator('button:has-text("OK")').click(),
|
||||
//Wait for Save Banner to appear1
|
||||
page.waitForSelector('.c-message-banner__message')
|
||||
]);
|
||||
|
||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 21 KiB |
@@ -88,10 +88,10 @@ async function makeOverlayPlot(page, myItemsFolderName) {
|
||||
// create overlay plot
|
||||
|
||||
await page.locator('button.c-create-button').click();
|
||||
await page.locator('li:has-text("Overlay Plot")').click();
|
||||
await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click();
|
||||
await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
||||
page.locator('text=OK').click(),
|
||||
page.locator('button:has-text("OK")').click(),
|
||||
//Wait for Save Banner to appear
|
||||
page.waitForSelector('.c-message-banner__message')
|
||||
]);
|
||||
@@ -106,7 +106,7 @@ async function makeOverlayPlot(page, myItemsFolderName) {
|
||||
// create a sinewave generator
|
||||
|
||||
await page.locator('button.c-create-button').click();
|
||||
await page.locator('li:has-text("Sine Wave Generator")').click();
|
||||
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
|
||||
|
||||
// set amplitude to 6, offset 4, period 2
|
||||
|
||||
@@ -123,7 +123,7 @@ async function makeOverlayPlot(page, myItemsFolderName) {
|
||||
|
||||
await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
||||
page.locator('text=OK').click(),
|
||||
page.locator('button:has-text("OK")').click(),
|
||||
//Wait for Save Banner to appear
|
||||
page.waitForSelector('.c-message-banner__message')
|
||||
]);
|
||||
|
||||
@@ -88,11 +88,11 @@ async function makeStackedPlot(page, myItemsFolderName) {
|
||||
|
||||
// create stacked plot
|
||||
await page.locator('button.c-create-button').click();
|
||||
await page.locator('li:has-text("Stacked Plot")').click();
|
||||
await page.locator('li[role="menuitem"]:has-text("Stacked Plot")').click();
|
||||
|
||||
await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
||||
page.locator('text=OK').click(),
|
||||
page.locator('button:has-text("OK")').click(),
|
||||
//Wait for Save Banner to appear
|
||||
page.waitForSelector('.c-message-banner__message')
|
||||
]);
|
||||
@@ -146,11 +146,11 @@ async function saveStackedPlot(page) {
|
||||
async function createSineWaveGenerator(page) {
|
||||
//Create sine wave generator
|
||||
await page.locator('button.c-create-button').click();
|
||||
await page.locator('li:has-text("Sine Wave Generator")').click();
|
||||
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
|
||||
|
||||
await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
||||
page.locator('text=OK').click(),
|
||||
page.locator('button:has-text("OK")').click(),
|
||||
//Wait for Save Banner to appear
|
||||
page.waitForSelector('.c-message-banner__message')
|
||||
]);
|
||||
|
||||
@@ -68,10 +68,10 @@ async function makeOverlayPlot(page) {
|
||||
// create overlay plot
|
||||
|
||||
await page.locator('button.c-create-button').click();
|
||||
await page.locator('li:has-text("Overlay Plot")').click();
|
||||
await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click();
|
||||
await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
||||
page.locator('text=OK').click(),
|
||||
page.locator('button:has-text("OK")').click(),
|
||||
//Wait for Save Banner to appear
|
||||
page.waitForSelector('.c-message-banner__message')
|
||||
]);
|
||||
@@ -86,13 +86,13 @@ async function makeOverlayPlot(page) {
|
||||
// create a sinewave generator
|
||||
|
||||
await page.locator('button.c-create-button').click();
|
||||
await page.locator('li:has-text("Sine Wave Generator")').click();
|
||||
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
|
||||
|
||||
// Click OK to make generator
|
||||
|
||||
await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
||||
page.locator('text=OK').click(),
|
||||
page.locator('button:has-text("OK")').click(),
|
||||
//Wait for Save Banner to appear
|
||||
page.waitForSelector('.c-message-banner__message')
|
||||
]);
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const { test, expect } = require('../../../../baseFixtures');
|
||||
const { test, expect } = require('../../../../pluginFixtures');
|
||||
const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||
|
||||
test.describe('Plot Integrity Testing @unstable', () => {
|
||||
|
||||
93
e2e/tests/functional/plugins/plot/scatterPlot.e2e.spec.js
Normal file
@@ -0,0 +1,93 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2022, 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 Scatter Plot component.
|
||||
*/
|
||||
|
||||
const { test, expect } = require('../../../../pluginFixtures');
|
||||
const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||
const uuid = require('uuid').v4;
|
||||
|
||||
test.describe('Scatter Plot', () => {
|
||||
let scatterPlot;
|
||||
|
||||
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 Scatter Plot
|
||||
scatterPlot = await createDomainObjectWithDefaults(page, { type: 'Scatter Plot' });
|
||||
});
|
||||
|
||||
test('Can add and remove telemetry sources', async ({ page }) => {
|
||||
const editButtonLocator = page.locator('button[title="Edit"]');
|
||||
const saveButtonLocator = page.locator('button[title="Save"]');
|
||||
|
||||
// Create a sine wave generator within the scatter plot
|
||||
const swg1 = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Sine Wave Generator',
|
||||
name: `swg-${uuid()}`,
|
||||
parent: scatterPlot.uuid
|
||||
});
|
||||
|
||||
// Navigate to the scatter plot and verify that
|
||||
// the SWG appears in the elements pool
|
||||
await page.goto(scatterPlot.url);
|
||||
await editButtonLocator.click();
|
||||
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeVisible();
|
||||
await saveButtonLocator.click();
|
||||
await page.locator('li[title="Save and Finish Editing"]').click();
|
||||
|
||||
// Create another sine wave generator within the scatter plot
|
||||
const swg2 = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Sine Wave Generator',
|
||||
name: `swg-${uuid()}`,
|
||||
parent: scatterPlot.uuid
|
||||
});
|
||||
|
||||
// Verify that the 'Replace telemetry source' modal appears and accept it
|
||||
await expect.soft(page.locator('text=This action will replace the current telemetry source. Do you want to continue?')).toBeVisible();
|
||||
await page.click('text=Ok');
|
||||
|
||||
// Navigate to the scatter plot and verify that the new SWG
|
||||
// appears in the elements pool and the old one is gone
|
||||
await page.goto(scatterPlot.url);
|
||||
await editButtonLocator.click();
|
||||
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeHidden();
|
||||
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg2.name}`)).toBeVisible();
|
||||
await saveButtonLocator.click();
|
||||
|
||||
// Right click on the new SWG in the elements pool and delete it
|
||||
await page.locator(`#inspector-elements-tree >> text=${swg2.name}`).click({
|
||||
button: 'right'
|
||||
});
|
||||
await page.locator('li[title="Remove this object from its containing object."]').click();
|
||||
|
||||
// Verify that the 'Remove object' confirmation modal appears and accept it
|
||||
await expect.soft(page.locator('text=Warning! This action will remove this object. Are you sure you want to continue?')).toBeVisible();
|
||||
await page.click('text=Ok');
|
||||
|
||||
// Verify that the elements pool shows no elements
|
||||
await expect(page.locator('text="No contained elements"')).toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -20,7 +20,7 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
const { test, expect } = require('../../../../baseFixtures');
|
||||
const { test, expect } = require('../../../../pluginFixtures');
|
||||
const { setFixedTimeMode, setRealTimeMode, setStartOffset, setEndOffset } = require('../../../../appActions');
|
||||
|
||||
test.describe('Time conductor operations', () => {
|
||||
|
||||
@@ -30,7 +30,7 @@ test.describe('Timer', () => {
|
||||
timer = await createDomainObjectWithDefaults(page, { type: 'timer' });
|
||||
});
|
||||
|
||||
test('Can perform actions on the Timer', async ({ page, openmctConfig }) => {
|
||||
test('Can perform actions on the Timer', async ({ page }) => {
|
||||
test.info().annotations.push({
|
||||
type: 'issue',
|
||||
description: 'https://github.com/nasa/openmct/issues/4313'
|
||||
|
||||
@@ -31,7 +31,7 @@ test.describe('Grand Search', () => {
|
||||
test('Can search for objects, and subsequent search dropdown behaves properly', async ({ page, openmctConfig }) => {
|
||||
const { myItemsFolderName } = openmctConfig;
|
||||
|
||||
await createObjectsForSearch(page, myItemsFolderName);
|
||||
const createdObjects = await createObjectsForSearch(page);
|
||||
|
||||
// Click [aria-label="OpenMCT Search"] input[type="search"]
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||
@@ -41,8 +41,8 @@ test.describe('Grand Search', () => {
|
||||
await expect(page.locator('[aria-label="Search Result"] >> nth=1')).toContainText(`Clock B ${myItemsFolderName} Red Folder Blue Folder`);
|
||||
await expect(page.locator('[aria-label="Search Result"] >> nth=2')).toContainText(`Clock C ${myItemsFolderName} Red Folder Blue Folder`);
|
||||
await expect(page.locator('[aria-label="Search Result"] >> nth=3')).toContainText(`Clock D ${myItemsFolderName} Red Folder Blue Folder`);
|
||||
// Click text=Elements >> nth=0
|
||||
await page.locator('text=Elements').first().click();
|
||||
// Click the Elements pool to dismiss the search menu
|
||||
await page.locator('.l-pane__label:has-text("Elements")').click();
|
||||
await expect(page.locator('[aria-label="Search Result"] >> nth=0')).toBeHidden();
|
||||
|
||||
await page.locator('[aria-label="OpenMCT Search"] [aria-label="Search Input"]').click();
|
||||
@@ -77,7 +77,7 @@ test.describe('Grand Search', () => {
|
||||
await expect(page.locator('.is-object-type-clock')).toBeVisible();
|
||||
|
||||
await page.locator('[aria-label="OpenMCT Search"] [aria-label="Search Input"]').fill('Disp');
|
||||
await expect(page.locator('[aria-label="Search Result"] >> nth=0')).toContainText('Unnamed Display Layout');
|
||||
await expect(page.locator('[aria-label="Search Result"] >> nth=0')).toContainText(createdObjects.displayLayout.name);
|
||||
await expect(page.locator('[aria-label="Search Result"] >> nth=0')).not.toContainText('Folder');
|
||||
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Clock C');
|
||||
@@ -185,7 +185,7 @@ async function createFolderObject(page, folderName) {
|
||||
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(folderName);
|
||||
|
||||
// Create folder object
|
||||
await page.locator('text=OK').click();
|
||||
await page.locator('button:has-text("OK")').click();
|
||||
}
|
||||
|
||||
async function waitForSearchCompletion(page) {
|
||||
@@ -197,75 +197,56 @@ async function waitForSearchCompletion(page) {
|
||||
* Creates some domain objects for searching
|
||||
* @param {import('@playwright/test').Page} page
|
||||
*/
|
||||
async function createObjectsForSearch(page, myItemsFolderName) {
|
||||
async function createObjectsForSearch(page) {
|
||||
//Go to baseURL
|
||||
await page.goto('./', { waitUntil: 'networkidle' });
|
||||
|
||||
await page.locator('button:has-text("Create")').click();
|
||||
await page.locator('li:has-text("Folder") >> nth=1').click();
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
await page.locator('text=Properties Title Notes >> input[type="text"]').fill('Red Folder'),
|
||||
await page.locator(`text=Save In Open MCT ${myItemsFolderName} >> span`).nth(3).click(),
|
||||
page.locator('button:has-text("OK")').click()
|
||||
]);
|
||||
const redFolder = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Folder',
|
||||
name: 'Red Folder'
|
||||
});
|
||||
|
||||
await page.locator('button:has-text("Create")').click();
|
||||
await page.locator('li:has-text("Folder") >> nth=2').click();
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
await page.locator('text=Properties Title Notes >> input[type="text"]').fill('Blue Folder'),
|
||||
await page.locator('form[name="mctForm"] >> text=Red Folder').click(),
|
||||
page.locator('button:has-text("OK")').click()
|
||||
]);
|
||||
const blueFolder = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Folder',
|
||||
name: 'Blue Folder',
|
||||
parent: redFolder.uuid
|
||||
});
|
||||
|
||||
await page.locator('button:has-text("Create")').click();
|
||||
await page.locator('li[title="A digital clock that uses system time and supports a variety of display formats and timezones."]').click();
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
await page.locator('text=Properties Title Notes >> input[type="text"] >> nth=0').fill('Clock A'),
|
||||
await page.locator('form[name="mctForm"] >> text=Blue Folder').click(),
|
||||
page.locator('button:has-text("OK")').click()
|
||||
]);
|
||||
const clockA = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Clock',
|
||||
name: 'Clock A',
|
||||
parent: blueFolder.uuid
|
||||
});
|
||||
const clockB = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Clock',
|
||||
name: 'Clock B',
|
||||
parent: blueFolder.uuid
|
||||
});
|
||||
const clockC = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Clock',
|
||||
name: 'Clock C',
|
||||
parent: blueFolder.uuid
|
||||
});
|
||||
const clockD = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Clock',
|
||||
name: 'Clock D',
|
||||
parent: blueFolder.uuid
|
||||
});
|
||||
|
||||
await page.locator('button:has-text("Create")').click();
|
||||
await page.locator('li[title="A digital clock that uses system time and supports a variety of display formats and timezones."]').click();
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
await page.locator('text=Properties Title Notes >> input[type="text"] >> nth=0').fill('Clock B'),
|
||||
await page.locator('form[name="mctForm"] >> text=Blue Folder').click(),
|
||||
page.locator('button:has-text("OK")').click()
|
||||
]);
|
||||
const displayLayout = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Display Layout'
|
||||
});
|
||||
|
||||
await page.locator('button:has-text("Create")').click();
|
||||
await page.locator('li[title="A digital clock that uses system time and supports a variety of display formats and timezones."]').click();
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
await page.locator('text=Properties Title Notes >> input[type="text"] >> nth=0').fill('Clock C'),
|
||||
await page.locator('form[name="mctForm"] >> text=Blue Folder').click(),
|
||||
page.locator('button:has-text("OK")').click()
|
||||
]);
|
||||
// Go back into edit mode for the display layout
|
||||
await page.locator('button[title="Edit"]').click();
|
||||
|
||||
await page.locator('button:has-text("Create")').click();
|
||||
await page.locator('li[title="A digital clock that uses system time and supports a variety of display formats and timezones."]').click();
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
await page.locator('text=Properties Title Notes >> input[type="text"] >> nth=0').fill('Clock D'),
|
||||
await page.locator('form[name="mctForm"] >> text=Blue Folder').click(),
|
||||
page.locator('button:has-text("OK")').click()
|
||||
]);
|
||||
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
page.locator(`a:has-text("${myItemsFolderName}") >> nth=0`).click()
|
||||
]);
|
||||
// Click button:has-text("Create")
|
||||
await page.locator('button:has-text("Create")').click();
|
||||
// Click li:has-text("Notebook")
|
||||
await page.locator('li:has-text("Display Layout")').click();
|
||||
// Click button:has-text("OK")
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
page.locator('button:has-text("OK")').click()
|
||||
]);
|
||||
return {
|
||||
redFolder,
|
||||
blueFolder,
|
||||
clockA,
|
||||
clockB,
|
||||
clockC,
|
||||
clockD,
|
||||
displayLayout
|
||||
};
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ test.describe('Performance tests', () => {
|
||||
await page.setInputFiles('#fileElem', filePath);
|
||||
|
||||
// Click text=OK
|
||||
await page.locator('text=OK').click();
|
||||
await page.locator('button:has-text("OK")').click();
|
||||
|
||||
await expect(page.locator('a:has-text("Performance Display Layout Display Layout")')).toBeVisible();
|
||||
|
||||
|
||||
23
package.json
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"name": "openmct",
|
||||
"version": "2.1.2-SNAPSHOT",
|
||||
"version": "2.1.3",
|
||||
"description": "The Open MCT core platform",
|
||||
"devDependencies": {
|
||||
"@babel/eslint-parser": "7.18.9",
|
||||
"@braintree/sanitize-url": "6.0.0",
|
||||
"@percy/cli": "1.11.0",
|
||||
"@percy/cli": "1.13.0",
|
||||
"@percy/playwright": "1.0.4",
|
||||
"@playwright/test": "1.25.2",
|
||||
"@types/jasmine": "4.3.0",
|
||||
"@types/lodash": "4.14.186",
|
||||
"babel-loader": "8.2.5",
|
||||
"@types/lodash": "4.14.188",
|
||||
"babel-loader": "9.0.0",
|
||||
"babel-plugin-istanbul": "6.1.1",
|
||||
"codecov": "3.8.3",
|
||||
"comma-separated-values": "3.6.4",
|
||||
@@ -19,17 +19,17 @@
|
||||
"d3-axis": "3.0.0",
|
||||
"d3-scale": "3.3.0",
|
||||
"d3-selection": "3.0.0",
|
||||
"eslint": "8.25.0",
|
||||
"eslint": "8.27.0",
|
||||
"eslint-plugin-compat": "4.0.2",
|
||||
"eslint-plugin-playwright": "0.11.2",
|
||||
"eslint-plugin-vue": "9.6.0",
|
||||
"eslint-plugin-vue": "9.7.0",
|
||||
"eslint-plugin-you-dont-need-lodash-underscore": "6.12.0",
|
||||
"eventemitter3": "1.2.0",
|
||||
"file-saver": "2.0.5",
|
||||
"git-rev-sync": "3.0.2",
|
||||
"html2canvas": "1.4.1",
|
||||
"imports-loader": "4.0.1",
|
||||
"jasmine-core": "4.4.0",
|
||||
"jasmine-core": "4.5.0",
|
||||
"karma": "6.3.20",
|
||||
"karma-chrome-launcher": "3.1.1",
|
||||
"karma-cli": "2.0.0",
|
||||
@@ -45,7 +45,7 @@
|
||||
"mini-css-extract-plugin": "2.6.1",
|
||||
"moment": "2.29.4",
|
||||
"moment-duration-format": "2.3.2",
|
||||
"moment-timezone": "0.5.37",
|
||||
"moment-timezone": "0.5.38",
|
||||
"nyc": "15.1.0",
|
||||
"painterro": "1.2.78",
|
||||
"playwright-core": "1.25.2",
|
||||
@@ -53,9 +53,9 @@
|
||||
"plotly.js-gl2d-dist": "2.14.0",
|
||||
"printj": "1.3.1",
|
||||
"resolve-url-loader": "5.0.0",
|
||||
"sass": "1.55.0",
|
||||
"sass": "1.56.1",
|
||||
"sass-loader": "13.0.2",
|
||||
"sinon": "14.0.0",
|
||||
"sinon": "14.0.1",
|
||||
"style-loader": "^3.3.1",
|
||||
"typescript": "4.8.4",
|
||||
"uuid": "9.0.0",
|
||||
@@ -114,6 +114,5 @@
|
||||
"ios_saf > 15"
|
||||
],
|
||||
"author": "",
|
||||
"license": "Apache-2.0",
|
||||
"private": true
|
||||
"license": "Apache-2.0"
|
||||
}
|
||||
|
||||
@@ -56,17 +56,12 @@ export default class Editor extends EventEmitter {
|
||||
* Save any unsaved changes from this editing session. This will
|
||||
* end the current transaction.
|
||||
*/
|
||||
save() {
|
||||
async save() {
|
||||
const transaction = this.openmct.objects.getActiveTransaction();
|
||||
|
||||
return transaction.commit()
|
||||
.then(() => {
|
||||
this.editing = false;
|
||||
this.emit('isEditing', false);
|
||||
this.openmct.objects.endTransaction();
|
||||
}).catch(error => {
|
||||
throw error;
|
||||
});
|
||||
await transaction.commit();
|
||||
this.editing = false;
|
||||
this.emit('isEditing', false);
|
||||
this.openmct.objects.endTransaction();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,13 +23,11 @@
|
||||
import FormController from './FormController';
|
||||
import FormProperties from './components/FormProperties.vue';
|
||||
|
||||
import EventEmitter from 'EventEmitter';
|
||||
import Vue from 'vue';
|
||||
import _ from 'lodash';
|
||||
|
||||
export default class FormsAPI extends EventEmitter {
|
||||
export default class FormsAPI {
|
||||
constructor(openmct) {
|
||||
super();
|
||||
|
||||
this.openmct = openmct;
|
||||
this.formController = new FormController(openmct);
|
||||
}
|
||||
@@ -92,29 +90,75 @@ export default class FormsAPI extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Show form inside an Overlay dialog with given form structure
|
||||
* @public
|
||||
* @param {Array<Section>} formStructure a form structure, array of section
|
||||
* @param {Object} options
|
||||
* @property {function} onChange a callback function when any changes detected
|
||||
*/
|
||||
showForm(formStructure, {
|
||||
onChange
|
||||
} = {}) {
|
||||
let overlay;
|
||||
|
||||
const self = this;
|
||||
|
||||
const overlayEl = document.createElement('div');
|
||||
overlayEl.classList.add('u-contents');
|
||||
|
||||
overlay = self.openmct.overlays.overlay({
|
||||
element: overlayEl,
|
||||
size: 'dialog'
|
||||
});
|
||||
|
||||
let formSave;
|
||||
let formCancel;
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
formSave = resolve;
|
||||
formCancel = reject;
|
||||
});
|
||||
|
||||
this.showCustomForm(formStructure, {
|
||||
element: overlayEl,
|
||||
onChange
|
||||
})
|
||||
.then((response) => {
|
||||
overlay.dismiss();
|
||||
formSave(response);
|
||||
})
|
||||
.catch((response) => {
|
||||
overlay.dismiss();
|
||||
formCancel(response);
|
||||
});
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show form as a child of the element provided with given form structure
|
||||
*
|
||||
* @public
|
||||
* @param {Array<Section>} formStructure a form structure, array of section
|
||||
* @param {Object} options
|
||||
* @property {HTMLElement} element Parent Element to render a Form
|
||||
* @property {function} onChange a callback function when any changes detected
|
||||
* @property {function} onSave a callback function when form is submitted
|
||||
* @property {function} onDismiss a callback function when form is dismissed
|
||||
*/
|
||||
showForm(formStructure, {
|
||||
showCustomForm(formStructure, {
|
||||
element,
|
||||
onChange
|
||||
} = {}) {
|
||||
const changes = {};
|
||||
let overlay;
|
||||
let onDismiss;
|
||||
let onSave;
|
||||
if (element === undefined) {
|
||||
throw Error('Required element parameter not provided');
|
||||
}
|
||||
|
||||
const self = this;
|
||||
|
||||
const changes = {};
|
||||
let formSave;
|
||||
let formCancel;
|
||||
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
onSave = onFormAction(resolve);
|
||||
onDismiss = onFormAction(reject);
|
||||
formSave = onFormAction(resolve);
|
||||
formCancel = onFormAction(reject);
|
||||
});
|
||||
|
||||
const vm = new Vue({
|
||||
@@ -126,26 +170,17 @@ export default class FormsAPI extends EventEmitter {
|
||||
return {
|
||||
formStructure,
|
||||
onChange: onFormPropertyChange,
|
||||
onDismiss,
|
||||
onSave
|
||||
onCancel: formCancel,
|
||||
onSave: formSave
|
||||
};
|
||||
},
|
||||
template: '<FormProperties :model="formStructure" @onChange="onChange" @onDismiss="onDismiss" @onSave="onSave"></FormProperties>'
|
||||
template: '<FormProperties :model="formStructure" @onChange="onChange" @onCancel="onCancel" @onSave="onSave"></FormProperties>'
|
||||
}).$mount();
|
||||
|
||||
const formElement = vm.$el;
|
||||
if (element) {
|
||||
element.append(formElement);
|
||||
} else {
|
||||
overlay = self.openmct.overlays.overlay({
|
||||
element: vm.$el,
|
||||
size: 'dialog',
|
||||
onDestroy: () => vm.$destroy()
|
||||
});
|
||||
}
|
||||
element.append(formElement);
|
||||
|
||||
function onFormPropertyChange(data) {
|
||||
self.emit('onFormPropertyChange', data);
|
||||
if (onChange) {
|
||||
onChange(data);
|
||||
}
|
||||
@@ -158,17 +193,14 @@ export default class FormsAPI extends EventEmitter {
|
||||
key = property.join('.');
|
||||
}
|
||||
|
||||
changes[key] = data.value;
|
||||
_.set(changes, key, data.value);
|
||||
}
|
||||
}
|
||||
|
||||
function onFormAction(callback) {
|
||||
return () => {
|
||||
if (element) {
|
||||
formElement.remove();
|
||||
} else {
|
||||
overlay.dismiss();
|
||||
}
|
||||
formElement.remove();
|
||||
vm.$destroy();
|
||||
|
||||
if (callback) {
|
||||
callback(changes);
|
||||
|
||||
@@ -133,7 +133,7 @@ describe('The Forms API', () => {
|
||||
});
|
||||
|
||||
it('when container element is provided', (done) => {
|
||||
openmct.forms.showForm(formStructure, { element }).catch(() => {
|
||||
openmct.forms.showCustomForm(formStructure, { element }).catch(() => {
|
||||
done();
|
||||
});
|
||||
const titleElement = element.querySelector('.c-overlay__dialog-title');
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
tabindex="0"
|
||||
class="c-button js-cancel-button"
|
||||
aria-label="Cancel"
|
||||
@click="onDismiss"
|
||||
@click="onCancel"
|
||||
>
|
||||
{{ cancelLabel }}
|
||||
</button>
|
||||
@@ -164,8 +164,8 @@ export default {
|
||||
|
||||
this.$emit('onChange', data);
|
||||
},
|
||||
onDismiss() {
|
||||
this.$emit('onDismiss');
|
||||
onCancel() {
|
||||
this.$emit('onCancel');
|
||||
},
|
||||
onSave() {
|
||||
this.$emit('onSave');
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
v-model="selected"
|
||||
required="model.required"
|
||||
name="mctControl"
|
||||
:aria-label="model.ariaLabel || model.name"
|
||||
@change="onChange($event)"
|
||||
>
|
||||
<option
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
:class="model.cssClass"
|
||||
>
|
||||
<textarea
|
||||
:id="`${model.key}-textarea`"
|
||||
v-model="field"
|
||||
type="text"
|
||||
:size="model.size"
|
||||
|
||||
@@ -3,39 +3,52 @@
|
||||
class="c-menu"
|
||||
:class="options.menuClass"
|
||||
>
|
||||
<ul v-if="options.actions.length && options.actions[0].length">
|
||||
<ul
|
||||
v-if="options.actions.length && options.actions[0].length"
|
||||
role="menu"
|
||||
>
|
||||
<template
|
||||
v-for="(actionGroups, index) in options.actions"
|
||||
>
|
||||
<li
|
||||
v-for="action in actionGroups"
|
||||
:key="action.name"
|
||||
:class="[action.cssClass, action.isDisabled ? 'disabled' : '']"
|
||||
:title="action.description"
|
||||
:data-testid="action.testId || false"
|
||||
@click="action.onItemClicked"
|
||||
>
|
||||
{{ action.name }}
|
||||
</li>
|
||||
<div
|
||||
v-if="index !== options.actions.length - 1"
|
||||
:key="index"
|
||||
class="c-menu__section-separator"
|
||||
role="group"
|
||||
>
|
||||
</div>
|
||||
<li
|
||||
v-if="actionGroups.length === 0"
|
||||
:key="index"
|
||||
>
|
||||
No actions defined.
|
||||
</li>
|
||||
</template>
|
||||
<li
|
||||
v-for="action in actionGroups"
|
||||
:key="action.name"
|
||||
role="menuitem"
|
||||
:class="[action.cssClass, action.isDisabled ? 'disabled' : '']"
|
||||
:title="action.description"
|
||||
:data-testid="action.testId || false"
|
||||
@click="action.onItemClicked"
|
||||
>
|
||||
{{ action.name }}
|
||||
</li>
|
||||
<div
|
||||
v-if="index !== options.actions.length - 1"
|
||||
:key="index"
|
||||
role="separator"
|
||||
class="c-menu__section-separator"
|
||||
>
|
||||
</div>
|
||||
<li
|
||||
v-if="actionGroups.length === 0"
|
||||
:key="index"
|
||||
>
|
||||
No actions defined.
|
||||
</li>
|
||||
</div></template>
|
||||
</ul>
|
||||
|
||||
<ul v-else>
|
||||
<ul
|
||||
v-else
|
||||
role="menu"
|
||||
>
|
||||
<li
|
||||
v-for="action in options.actions"
|
||||
:key="action.name"
|
||||
role="menuitem"
|
||||
:class="[action.cssClass, action.isDisabled ? 'disabled' : '']"
|
||||
:title="action.description"
|
||||
:data-testid="action.testId || false"
|
||||
|
||||
@@ -5,45 +5,54 @@
|
||||
>
|
||||
<ul
|
||||
v-if="options.actions.length && options.actions[0].length"
|
||||
role="menu"
|
||||
class="c-super-menu__menu"
|
||||
>
|
||||
<template
|
||||
v-for="(actionGroups, index) in options.actions"
|
||||
>
|
||||
<li
|
||||
v-for="action in actionGroups"
|
||||
:key="action.name"
|
||||
:class="[action.cssClass, action.isDisabled ? 'disabled' : '']"
|
||||
:title="action.description"
|
||||
:data-testid="action.testId || false"
|
||||
@click="action.onItemClicked"
|
||||
@mouseover="toggleItemDescription(action)"
|
||||
@mouseleave="toggleItemDescription()"
|
||||
>
|
||||
{{ action.name }}
|
||||
</li>
|
||||
<div
|
||||
v-if="index !== options.actions.length - 1"
|
||||
:key="index"
|
||||
class="c-menu__section-separator"
|
||||
role="group"
|
||||
>
|
||||
</div>
|
||||
<li
|
||||
v-if="actionGroups.length === 0"
|
||||
:key="index"
|
||||
>
|
||||
No actions defined.
|
||||
</li>
|
||||
</template>
|
||||
<li
|
||||
v-for="action in actionGroups"
|
||||
:key="action.name"
|
||||
role="menuitem"
|
||||
:class="[action.cssClass, action.isDisabled ? 'disabled' : '']"
|
||||
:title="action.description"
|
||||
:data-testid="action.testId || false"
|
||||
@click="action.onItemClicked"
|
||||
@mouseover="toggleItemDescription(action)"
|
||||
@mouseleave="toggleItemDescription()"
|
||||
>
|
||||
{{ action.name }}
|
||||
</li>
|
||||
<div
|
||||
v-if="index !== options.actions.length - 1"
|
||||
:key="index"
|
||||
role="separator"
|
||||
class="c-menu__section-separator"
|
||||
>
|
||||
</div>
|
||||
<li
|
||||
v-if="actionGroups.length === 0"
|
||||
:key="index"
|
||||
>
|
||||
No actions defined.
|
||||
</li>
|
||||
</div></template>
|
||||
</ul>
|
||||
|
||||
<ul
|
||||
v-else
|
||||
class="c-super-menu__menu"
|
||||
role="menu"
|
||||
>
|
||||
<li
|
||||
v-for="action in options.actions"
|
||||
:key="action.name"
|
||||
role="menuitem"
|
||||
:class="action.cssClass"
|
||||
:title="action.description"
|
||||
:data-testid="action.testId || false"
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
const DEFAULT_INTERCEPTOR_PRIORITY = 0;
|
||||
export default class InterceptorRegistry {
|
||||
/**
|
||||
* A InterceptorRegistry maintains the definitions for different interceptors that may be invoked on domain objects.
|
||||
@@ -45,7 +46,6 @@ export default class InterceptorRegistry {
|
||||
* @memberof module:openmct.InterceptorRegistry#
|
||||
*/
|
||||
addInterceptor(interceptorDef) {
|
||||
//TODO: sort by priority
|
||||
this.interceptors.push(interceptorDef);
|
||||
}
|
||||
|
||||
@@ -56,10 +56,18 @@ export default class InterceptorRegistry {
|
||||
* @memberof module:openmct.InterceptorRegistry#
|
||||
*/
|
||||
getInterceptors(identifier, object) {
|
||||
|
||||
function byPriority(interceptorA, interceptorB) {
|
||||
let priorityA = interceptorA.priority ?? DEFAULT_INTERCEPTOR_PRIORITY;
|
||||
let priorityB = interceptorB.priority ?? DEFAULT_INTERCEPTOR_PRIORITY;
|
||||
|
||||
return priorityB - priorityA;
|
||||
}
|
||||
|
||||
return this.interceptors.filter(interceptor => {
|
||||
return typeof interceptor.appliesTo === 'function'
|
||||
&& interceptor.appliesTo(identifier, object);
|
||||
});
|
||||
}).sort(byPriority);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -75,11 +75,7 @@ class MutableDomainObject {
|
||||
return eventOff;
|
||||
}
|
||||
$set(path, value) {
|
||||
_.set(this, path, value);
|
||||
|
||||
if (path !== 'persisted' && path !== 'modified') {
|
||||
_.set(this, 'modified', Date.now());
|
||||
}
|
||||
MutableDomainObject.mutateObject(this, path, value);
|
||||
|
||||
//Emit secret synchronization event first, so that all objects are in sync before subsequent events fired.
|
||||
this._globalEventEmitter.emit(qualifiedEventName(this, '$_synchronize_model'), this);
|
||||
@@ -136,8 +132,11 @@ class MutableDomainObject {
|
||||
}
|
||||
|
||||
static mutateObject(object, path, value) {
|
||||
if (path !== 'persisted') {
|
||||
_.set(object, 'modified', Date.now());
|
||||
}
|
||||
|
||||
_.set(object, path, value);
|
||||
_.set(object, 'modified', Date.now());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -357,13 +357,13 @@ export default class ObjectAPI {
|
||||
async save(domainObject) {
|
||||
const provider = this.getProvider(domainObject.identifier);
|
||||
let result;
|
||||
let lastPersistedTime;
|
||||
|
||||
if (!this.isPersistable(domainObject.identifier)) {
|
||||
result = Promise.reject('Object provider does not support saving');
|
||||
} else if (this.#hasAlreadyBeenPersisted(domainObject)) {
|
||||
result = Promise.resolve(true);
|
||||
} else {
|
||||
const persistedTime = Date.now();
|
||||
const username = await this.#getCurrentUsername();
|
||||
const isNewObject = domainObject.persisted === undefined;
|
||||
let savedResolve;
|
||||
@@ -375,15 +375,23 @@ export default class ObjectAPI {
|
||||
savedReject = reject;
|
||||
});
|
||||
|
||||
this.#mutate(domainObject, 'persisted', persistedTime);
|
||||
this.#mutate(domainObject, 'modifiedBy', username);
|
||||
|
||||
if (isNewObject) {
|
||||
this.#mutate(domainObject, 'created', persistedTime);
|
||||
this.#mutate(domainObject, 'createdBy', username);
|
||||
|
||||
const createdTime = Date.now();
|
||||
this.#mutate(domainObject, 'created', createdTime);
|
||||
|
||||
const persistedTime = Date.now();
|
||||
this.#mutate(domainObject, 'persisted', persistedTime);
|
||||
|
||||
savedObjectPromise = provider.create(domainObject);
|
||||
} else {
|
||||
lastPersistedTime = domainObject.persisted;
|
||||
const persistedTime = Date.now();
|
||||
this.#mutate(domainObject, 'persisted', persistedTime);
|
||||
|
||||
savedObjectPromise = provider.update(domainObject);
|
||||
}
|
||||
|
||||
@@ -391,6 +399,10 @@ export default class ObjectAPI {
|
||||
savedObjectPromise.then(response => {
|
||||
savedResolve(response);
|
||||
}).catch((error) => {
|
||||
if (lastPersistedTime !== undefined) {
|
||||
this.#mutate(domainObject, 'persisted', lastPersistedTime);
|
||||
}
|
||||
|
||||
savedReject(error);
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -94,6 +94,35 @@ describe("The Object API", () => {
|
||||
expect(mockProvider.create).not.toHaveBeenCalled();
|
||||
expect(mockProvider.update).toHaveBeenCalled();
|
||||
});
|
||||
describe("the persisted timestamp for existing objects", () => {
|
||||
let persistedTimestamp;
|
||||
beforeEach(() => {
|
||||
persistedTimestamp = Date.now() - FIFTEEN_MINUTES;
|
||||
mockDomainObject.persisted = persistedTimestamp;
|
||||
mockDomainObject.modified = Date.now();
|
||||
});
|
||||
|
||||
it("is updated", async () => {
|
||||
await objectAPI.save(mockDomainObject);
|
||||
expect(mockDomainObject.persisted).toBeDefined();
|
||||
expect(mockDomainObject.persisted > persistedTimestamp).toBe(true);
|
||||
});
|
||||
it("is >= modified timestamp", async () => {
|
||||
await objectAPI.save(mockDomainObject);
|
||||
expect(mockDomainObject.persisted >= mockDomainObject.modified).toBe(true);
|
||||
});
|
||||
});
|
||||
describe("the persisted timestamp for new objects", () => {
|
||||
it("is updated", async () => {
|
||||
await objectAPI.save(mockDomainObject);
|
||||
expect(mockDomainObject.persisted).toBeDefined();
|
||||
});
|
||||
it("is >= modified timestamp", async () => {
|
||||
await objectAPI.save(mockDomainObject);
|
||||
expect(mockDomainObject.persisted >= mockDomainObject.modified).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it("Sets the current user for 'createdBy' on new objects", async () => {
|
||||
await objectAPI.save(mockDomainObject);
|
||||
expect(mockDomainObject.createdBy).toBe(USERNAME);
|
||||
|
||||
@@ -17,6 +17,7 @@ class Overlay extends EventEmitter {
|
||||
dismissable = true,
|
||||
element,
|
||||
onDestroy,
|
||||
onDismiss,
|
||||
size
|
||||
} = {}) {
|
||||
super();
|
||||
@@ -32,7 +33,7 @@ class Overlay extends EventEmitter {
|
||||
OverlayComponent: OverlayComponent
|
||||
},
|
||||
provide: {
|
||||
dismiss: this.dismiss.bind(this),
|
||||
dismiss: this.notifyAndDismiss.bind(this),
|
||||
element,
|
||||
buttons,
|
||||
dismissable: this.dismissable
|
||||
@@ -43,6 +44,10 @@ class Overlay extends EventEmitter {
|
||||
if (onDestroy) {
|
||||
this.once('destroy', onDestroy);
|
||||
}
|
||||
|
||||
if (onDismiss) {
|
||||
this.once('dismiss', onDismiss);
|
||||
}
|
||||
}
|
||||
|
||||
dismiss() {
|
||||
@@ -51,6 +56,12 @@ class Overlay extends EventEmitter {
|
||||
this.component.$destroy();
|
||||
}
|
||||
|
||||
//Ensures that any callers are notified that the overlay is dismissed
|
||||
notifyAndDismiss() {
|
||||
this.emit('dismiss');
|
||||
this.dismiss();
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
**/
|
||||
|
||||
@@ -55,7 +55,7 @@ class OverlayAPI {
|
||||
dismissLastOverlay() {
|
||||
let lastOverlay = this.activeOverlays[this.activeOverlays.length - 1];
|
||||
if (lastOverlay && lastOverlay.dismissable) {
|
||||
lastOverlay.dismiss();
|
||||
lastOverlay.notifyAndDismiss();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,11 +112,7 @@ export default {
|
||||
}
|
||||
},
|
||||
removeFromComposition(telemetryObject) {
|
||||
let composition = this.domainObject.composition.filter(id =>
|
||||
!this.openmct.objects.areIdsEqual(id, telemetryObject.identifier)
|
||||
);
|
||||
|
||||
this.openmct.objects.mutate(this.domainObject, 'composition', composition);
|
||||
this.composition.remove(telemetryObject);
|
||||
},
|
||||
addTelemetryObject(telemetryObject) {
|
||||
// grab information we need from the added telmetry object
|
||||
|
||||
@@ -104,10 +104,14 @@ export default {
|
||||
this.$set(this.plotSeries, this.plotSeries.length, series);
|
||||
this.setAxesLabels();
|
||||
},
|
||||
removeSeries(series) {
|
||||
const index = this.plotSeries.findIndex(plotSeries => this.openmct.objects.areIdsEqual(series.identifier, plotSeries.identifier));
|
||||
if (index !== undefined) {
|
||||
this.$delete(this.plotSeries, index);
|
||||
removeSeries(seriesKey) {
|
||||
const seriesIndex = this.plotSeries.findIndex(
|
||||
plotSeries => this.openmct.objects.areIdsEqual(seriesKey, plotSeries.identifier)
|
||||
);
|
||||
|
||||
const foundSeries = seriesIndex > -1;
|
||||
if (foundSeries) {
|
||||
this.$delete(this.plotSeries, seriesIndex);
|
||||
this.setAxesLabels();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -68,6 +68,7 @@ export default function ClockPlugin(options) {
|
||||
]
|
||||
},
|
||||
{
|
||||
ariaLabel: "12 or 24 hour clock",
|
||||
control: 'select',
|
||||
options: [
|
||||
{
|
||||
|
||||
@@ -583,6 +583,7 @@ define(['lodash'], function (_) {
|
||||
domainObject: selectedParent,
|
||||
icon: "icon-object",
|
||||
title: "Merge into a telemetry table or plot",
|
||||
label: "View type",
|
||||
options: APPLICABLE_VIEWS['telemetry-view-multi'],
|
||||
method: function (option) {
|
||||
displayLayoutContext.mergeMultipleTelemetryViews(selection, option.value);
|
||||
|
||||
@@ -245,6 +245,9 @@ export default {
|
||||
});
|
||||
this.gridDimensions = [wMax * this.gridSize[0], hMax * this.gridSize[1]];
|
||||
},
|
||||
clearSelection() {
|
||||
this.$el.click();
|
||||
},
|
||||
watchDisplayResize() {
|
||||
const resizeObserver = new ResizeObserver(() => this.updateGrid());
|
||||
|
||||
@@ -478,7 +481,7 @@ export default {
|
||||
});
|
||||
_.pullAt(this.layoutItems, indices);
|
||||
this.mutate("configuration.items", this.layoutItems);
|
||||
this.$el.click();
|
||||
this.clearSelection();
|
||||
},
|
||||
untrackItem(item) {
|
||||
if (!item.identifier) {
|
||||
@@ -504,15 +507,11 @@ export default {
|
||||
}
|
||||
|
||||
if (!telemetryViewCount && !objectViewCount) {
|
||||
this.removeFromComposition(keyString);
|
||||
this.removeFromComposition(item);
|
||||
}
|
||||
},
|
||||
removeFromComposition(keyString) {
|
||||
let composition = this.domainObject.composition ? this.domainObject.composition : [];
|
||||
composition = composition.filter(identifier => {
|
||||
return this.openmct.objects.makeKeyString(identifier) !== keyString;
|
||||
});
|
||||
this.mutate("composition", composition);
|
||||
removeFromComposition(item) {
|
||||
this.composition.remove(item);
|
||||
},
|
||||
initializeItems() {
|
||||
this.telemetryViewMap = {};
|
||||
@@ -529,7 +528,10 @@ export default {
|
||||
}
|
||||
});
|
||||
|
||||
this.startTransaction();
|
||||
removedItems.forEach(this.removeFromConfiguration);
|
||||
|
||||
return this.endTransaction();
|
||||
},
|
||||
isItemAlreadyTracked(child) {
|
||||
let found = false;
|
||||
@@ -590,7 +592,7 @@ export default {
|
||||
}
|
||||
});
|
||||
this.mutate("configuration.items", layoutItems);
|
||||
this.$el.click();
|
||||
this.clearSelection();
|
||||
},
|
||||
orderItem(position, selectedItems) {
|
||||
let delta = ORDERS[position];
|
||||
@@ -773,7 +775,7 @@ export default {
|
||||
this.$nextTick(() => {
|
||||
this.openmct.objects.mutate(this.domainObject, "configuration.items", this.layoutItems);
|
||||
this.openmct.objects.mutate(this.domainObject, "configuration.objectStyles", objectStyles);
|
||||
this.$el.click(); //clear selection;
|
||||
this.clearSelection();
|
||||
|
||||
newDomainObjectsArray.forEach(domainObject => {
|
||||
this.composition.add(domainObject);
|
||||
@@ -867,6 +869,20 @@ export default {
|
||||
this.removeItem(selection);
|
||||
this.initSelectIndex = this.layoutItems.length - 1; //restore selection
|
||||
},
|
||||
startTransaction() {
|
||||
if (!this.openmct.objects.isTransactionActive()) {
|
||||
this.transaction = this.openmct.objects.startTransaction();
|
||||
}
|
||||
},
|
||||
async endTransaction() {
|
||||
if (!this.transaction) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.transaction.commit();
|
||||
this.openmct.objects.endTransaction();
|
||||
this.transaction = null;
|
||||
},
|
||||
toggleGrid() {
|
||||
this.showGrid = !this.showGrid;
|
||||
},
|
||||
|
||||
@@ -185,10 +185,24 @@ export default {
|
||||
this.composition.off('add', this.addFrame);
|
||||
},
|
||||
methods: {
|
||||
containsObject(identifier) {
|
||||
if ('composition' in this.domainObject) {
|
||||
return this.domainObject.composition
|
||||
.some(childId => this.openmct.objects.areIdsEqual(childId, identifier));
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
buildIdentifierMap() {
|
||||
this.containers.forEach(container => {
|
||||
container.frames.forEach(frame => {
|
||||
let keystring = this.openmct.objects.makeKeyString(frame.domainObjectIdentifier);
|
||||
if (!this.containsObject(frame.domainObjectIdentifier)) {
|
||||
this.removeChildObject(frame.domainObjectIdentifier);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const keystring = this.openmct.objects.makeKeyString(frame.domainObjectIdentifier);
|
||||
this.identifierMap[keystring] = true;
|
||||
});
|
||||
});
|
||||
@@ -296,11 +310,14 @@ export default {
|
||||
}
|
||||
},
|
||||
persist(index) {
|
||||
this.startTransaction();
|
||||
if (index) {
|
||||
this.openmct.objects.mutate(this.domainObject, `configuration.containers[${index}]`, this.containers[index]);
|
||||
} else {
|
||||
this.openmct.objects.mutate(this.domainObject, 'configuration.containers', this.containers);
|
||||
}
|
||||
|
||||
return this.endTransaction();
|
||||
},
|
||||
startContainerResizing(index) {
|
||||
let beforeContainer = this.containers[index];
|
||||
@@ -366,6 +383,20 @@ export default {
|
||||
});
|
||||
|
||||
this.persist();
|
||||
},
|
||||
startTransaction() {
|
||||
if (!this.openmct.objects.isTransactionActive()) {
|
||||
this.transaction = this.openmct.objects.startTransaction();
|
||||
}
|
||||
},
|
||||
async endTransaction() {
|
||||
if (!this.transaction) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.transaction.commit();
|
||||
this.openmct.objects.endTransaction();
|
||||
this.transaction = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -24,6 +24,7 @@ import PropertiesAction from './PropertiesAction';
|
||||
import CreateWizard from './CreateWizard';
|
||||
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import _ from 'lodash';
|
||||
|
||||
export default class CreateAction extends PropertiesAction {
|
||||
constructor(openmct, type, parentDomainObject) {
|
||||
@@ -50,19 +51,12 @@ export default class CreateAction extends PropertiesAction {
|
||||
return;
|
||||
}
|
||||
|
||||
const properties = key.split('.');
|
||||
let object = this.domainObject;
|
||||
const propertiesLength = properties.length;
|
||||
properties.forEach((property, index) => {
|
||||
const isComplexProperty = propertiesLength > 1 && index !== propertiesLength - 1;
|
||||
if (isComplexProperty && object[property] !== null) {
|
||||
object = object[property];
|
||||
} else {
|
||||
object[property] = value;
|
||||
}
|
||||
});
|
||||
const existingValue = this.domainObject[key];
|
||||
if (!(existingValue instanceof Array) && (typeof existingValue === 'object')) {
|
||||
value = _.merge(existingValue, value);
|
||||
}
|
||||
|
||||
object = value;
|
||||
_.set(this.domainObject, key, value);
|
||||
});
|
||||
|
||||
const parentDomainObject = parentDomainObjectPath[0];
|
||||
@@ -94,6 +88,12 @@ export default class CreateAction extends PropertiesAction {
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_onCancel() {
|
||||
//do Nothing
|
||||
}
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
@@ -151,6 +151,7 @@ export default class CreateAction extends PropertiesAction {
|
||||
formStructure.title = 'Create a New ' + definition.name;
|
||||
|
||||
this.openmct.forms.showForm(formStructure)
|
||||
.then(this._onSave.bind(this));
|
||||
.then(this._onSave.bind(this))
|
||||
.catch(this._onCancel.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
import PropertiesAction from './PropertiesAction';
|
||||
import CreateWizard from './CreateWizard';
|
||||
import _ from 'lodash';
|
||||
|
||||
export default class EditPropertiesAction extends PropertiesAction {
|
||||
constructor(openmct) {
|
||||
super(openmct);
|
||||
@@ -51,25 +53,23 @@ export default class EditPropertiesAction extends PropertiesAction {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_onSave(changes) {
|
||||
async _onSave(changes) {
|
||||
if (!this.openmct.objects.isTransactionActive()) {
|
||||
this.openmct.objects.startTransaction();
|
||||
}
|
||||
|
||||
try {
|
||||
Object.entries(changes).forEach(([key, value]) => {
|
||||
const properties = key.split('.');
|
||||
let object = this.domainObject;
|
||||
const propertiesLength = properties.length;
|
||||
properties.forEach((property, index) => {
|
||||
const isComplexProperty = propertiesLength > 1 && index !== propertiesLength - 1;
|
||||
if (isComplexProperty && object[property] !== null) {
|
||||
object = object[property];
|
||||
} else {
|
||||
object[property] = value;
|
||||
}
|
||||
});
|
||||
const existingValue = this.domainObject[key];
|
||||
if (!(Array.isArray(existingValue)) && (typeof existingValue === 'object')) {
|
||||
value = _.merge(existingValue, value);
|
||||
}
|
||||
|
||||
object = value;
|
||||
this.openmct.objects.mutate(this.domainObject, key, value);
|
||||
this.openmct.notifications.info('Save successful');
|
||||
});
|
||||
const transaction = this.openmct.objects.getActiveTransaction();
|
||||
await transaction.commit();
|
||||
this.openmct.objects.endTransaction();
|
||||
} catch (error) {
|
||||
this.openmct.notifications.error('Error saving objects');
|
||||
console.error(error);
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
createOpenMct,
|
||||
resetApplicationState
|
||||
} from 'utils/testing';
|
||||
import Vue from 'vue';
|
||||
|
||||
import { debounce } from 'lodash';
|
||||
|
||||
@@ -101,10 +102,15 @@ describe('EditPropertiesAction plugin', () => {
|
||||
composition: []
|
||||
};
|
||||
|
||||
const deBouncedFormChange = debounce(handleFormPropertyChange, 500);
|
||||
openmct.forms.on('onFormPropertyChange', deBouncedFormChange);
|
||||
editPropertiesAction.invoke([domainObject])
|
||||
.then(() => {
|
||||
done();
|
||||
})
|
||||
.catch(() => {
|
||||
done();
|
||||
});
|
||||
|
||||
function handleFormPropertyChange(data) {
|
||||
Vue.nextTick(() => {
|
||||
const form = document.querySelector('.js-form');
|
||||
const title = form.querySelector('input');
|
||||
expect(title.value).toEqual(domainObject.name);
|
||||
@@ -118,17 +124,7 @@ describe('EditPropertiesAction plugin', () => {
|
||||
|
||||
const clickEvent = createMouseEvent('click');
|
||||
buttons[1].dispatchEvent(clickEvent);
|
||||
|
||||
openmct.forms.off('onFormPropertyChange', deBouncedFormChange);
|
||||
}
|
||||
|
||||
editPropertiesAction.invoke([domainObject])
|
||||
.then(() => {
|
||||
done();
|
||||
})
|
||||
.catch(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('edit properties action saves changes', (done) => {
|
||||
@@ -159,11 +155,9 @@ describe('EditPropertiesAction plugin', () => {
|
||||
const deBouncedCallback = debounce(callback, 300);
|
||||
unObserve = openmct.objects.observe(domainObject, '*', deBouncedCallback);
|
||||
|
||||
let changed = false;
|
||||
const deBouncedFormChange = debounce(handleFormPropertyChange, 500);
|
||||
openmct.forms.on('onFormPropertyChange', deBouncedFormChange);
|
||||
editPropertiesAction.invoke([domainObject]);
|
||||
|
||||
function handleFormPropertyChange(data) {
|
||||
Vue.nextTick(() => {
|
||||
const form = document.querySelector('.js-form');
|
||||
const title = form.querySelector('input');
|
||||
const notes = form.querySelector('textArea');
|
||||
@@ -172,27 +166,18 @@ describe('EditPropertiesAction plugin', () => {
|
||||
expect(buttons[0].textContent.trim()).toEqual('OK');
|
||||
expect(buttons[1].textContent.trim()).toEqual('Cancel');
|
||||
|
||||
if (!changed) {
|
||||
expect(title.value).toEqual(domainObject.name);
|
||||
expect(notes.value).toEqual(domainObject.notes);
|
||||
expect(title.value).toEqual(domainObject.name);
|
||||
expect(notes.value).toEqual(domainObject.notes);
|
||||
|
||||
// change input field value and dispatch event for it
|
||||
title.focus();
|
||||
title.value = newName;
|
||||
title.dispatchEvent(new Event('input'));
|
||||
title.blur();
|
||||
// change input field value and dispatch event for it
|
||||
title.focus();
|
||||
title.value = newName;
|
||||
title.dispatchEvent(new Event('input'));
|
||||
title.blur();
|
||||
|
||||
changed = true;
|
||||
} else {
|
||||
// click ok to save form changes
|
||||
const clickEvent = createMouseEvent('click');
|
||||
buttons[0].dispatchEvent(clickEvent);
|
||||
|
||||
openmct.forms.off('onFormPropertyChange', deBouncedFormChange);
|
||||
}
|
||||
}
|
||||
|
||||
editPropertiesAction.invoke([domainObject]);
|
||||
const clickEvent = createMouseEvent('click');
|
||||
buttons[0].dispatchEvent(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('edit properties action discards changes', (done) => {
|
||||
@@ -217,7 +202,6 @@ describe('EditPropertiesAction plugin', () => {
|
||||
})
|
||||
.catch(() => {
|
||||
expect(domainObject.name).toEqual(name);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
@@ -598,11 +598,7 @@ export default {
|
||||
return this.round(((vPercent / 100) * 270) + DIAL_VALUE_DEG_OFFSET, 2);
|
||||
},
|
||||
removeFromComposition(telemetryObject = this.telemetryObject) {
|
||||
let composition = this.domainObject.composition.filter(id =>
|
||||
!this.openmct.objects.areIdsEqual(id, telemetryObject.identifier)
|
||||
);
|
||||
|
||||
this.openmct.objects.mutate(this.domainObject, 'composition', composition);
|
||||
this.composition.remove(telemetryObject);
|
||||
},
|
||||
refreshData(bounds, isTick) {
|
||||
if (!isTick) {
|
||||
|
||||
@@ -100,6 +100,7 @@ export default {
|
||||
components: {
|
||||
ToggleSwitch
|
||||
},
|
||||
inject: ["openmct"],
|
||||
props: {
|
||||
model: {
|
||||
type: Object,
|
||||
@@ -107,11 +108,10 @@ export default {
|
||||
}
|
||||
},
|
||||
data() {
|
||||
this.changes = {};
|
||||
|
||||
return {
|
||||
isUseTelemetryLimits: this.model.value.isUseTelemetryLimits,
|
||||
isDisplayMinMax: this.model.value.isDisplayMinMax,
|
||||
isDisplayCurVal: this.model.value.isDisplayCurVal,
|
||||
isDisplayUnits: this.model.value.isDisplayUnits,
|
||||
limitHigh: this.model.value.limitHigh,
|
||||
limitLow: this.model.value.limitLow,
|
||||
max: this.model.value.max,
|
||||
@@ -120,24 +120,15 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
onChange(event) {
|
||||
const data = {
|
||||
model: this.model,
|
||||
value: {
|
||||
gaugeType: this.model.value.gaugeType,
|
||||
isDisplayMinMax: this.isDisplayMinMax,
|
||||
isDisplayCurVal: this.isDisplayCurVal,
|
||||
isDisplayUnits: this.isDisplayUnits,
|
||||
isUseTelemetryLimits: this.isUseTelemetryLimits,
|
||||
limitLow: this.limitLow,
|
||||
limitHigh: this.limitHigh,
|
||||
max: this.max,
|
||||
min: this.min,
|
||||
precision: this.model.value.precision
|
||||
}
|
||||
let data = {
|
||||
model: {}
|
||||
};
|
||||
|
||||
if (event) {
|
||||
const target = event.target;
|
||||
const property = target.dataset.fieldName;
|
||||
data.model.property = Array.from(this.model.property).concat([property]);
|
||||
data.value = this[property];
|
||||
const targetIndicator = target.parentElement.querySelector('.req-indicator');
|
||||
if (targetIndicator.classList.contains('req')) {
|
||||
targetIndicator.classList.add('visited');
|
||||
@@ -160,13 +151,13 @@ export default {
|
||||
},
|
||||
toggleUseTelemetryLimits() {
|
||||
this.isUseTelemetryLimits = !this.isUseTelemetryLimits;
|
||||
|
||||
this.onChange();
|
||||
},
|
||||
toggleMinMax() {
|
||||
this.isDisplayMinMax = !this.isDisplayMinMax;
|
||||
|
||||
this.onChange();
|
||||
const data = {
|
||||
model: {
|
||||
property: Array.from(this.model.property).concat(['isUseTelemetryLimits'])
|
||||
},
|
||||
value: this.isUseTelemetryLimits
|
||||
};
|
||||
this.$emit('onChange', data);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -37,14 +37,15 @@ function myItemsInterceptor(openmct, identifierObject, name) {
|
||||
return identifier.key === MY_ITEMS_KEY;
|
||||
},
|
||||
invoke: (identifier, object) => {
|
||||
if (openmct.objects.isMissing(object)) {
|
||||
if (!object || openmct.objects.isMissing(object)) {
|
||||
openmct.objects.save(myItemsModel);
|
||||
|
||||
return myItemsModel;
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
},
|
||||
priority: openmct.priority.HIGH
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -889,37 +889,21 @@ export default {
|
||||
this.syncUrlWithPageAndSection();
|
||||
this.filterAndSortEntries();
|
||||
},
|
||||
activeTransaction() {
|
||||
return this.openmct.objects.getActiveTransaction();
|
||||
},
|
||||
startTransaction() {
|
||||
if (!this.openmct.editor.isEditing()) {
|
||||
this.openmct.objects.startTransaction();
|
||||
if (!this.openmct.objects.isTransactionActive()) {
|
||||
this.transaction = this.openmct.objects.startTransaction();
|
||||
}
|
||||
},
|
||||
saveTransaction() {
|
||||
const transaction = this.activeTransaction();
|
||||
|
||||
if (!transaction || this.openmct.editor.isEditing()) {
|
||||
return;
|
||||
async saveTransaction() {
|
||||
if (this.transaction !== undefined) {
|
||||
await this.transaction.commit();
|
||||
this.openmct.objects.endTransaction();
|
||||
}
|
||||
|
||||
return transaction.commit()
|
||||
.catch(error => {
|
||||
throw error;
|
||||
}).finally(() => {
|
||||
this.openmct.objects.endTransaction();
|
||||
});
|
||||
},
|
||||
cancelTransaction() {
|
||||
if (!this.openmct.editor.isEditing()) {
|
||||
const transaction = this.activeTransaction();
|
||||
transaction.cancel()
|
||||
.catch(error => {
|
||||
throw error;
|
||||
}).finally(() => {
|
||||
this.openmct.objects.endTransaction();
|
||||
});
|
||||
async cancelTransaction() {
|
||||
if (this.transaction !== undefined) {
|
||||
await this.transaction.cancel();
|
||||
this.openmct.objects.endTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,11 +129,13 @@ export default {
|
||||
|
||||
this.timeContext.on("timeSystem", this.setScaleAndPlotActivities);
|
||||
this.timeContext.on("bounds", this.updateViewBounds);
|
||||
this.timeContext.on("clock", this.updateBounds);
|
||||
},
|
||||
stopFollowingTimeContext() {
|
||||
if (this.timeContext) {
|
||||
this.timeContext.off("timeSystem", this.setScaleAndPlotActivities);
|
||||
this.timeContext.off("bounds", this.updateViewBounds);
|
||||
this.timeContext.off("clock", this.updateBounds);
|
||||
}
|
||||
},
|
||||
observeForChanges(mutatedObject) {
|
||||
@@ -142,10 +144,15 @@ export default {
|
||||
},
|
||||
resize() {
|
||||
let clientWidth = this.getClientWidth();
|
||||
let clientHeight = this.getClientHeight();
|
||||
if (clientWidth !== this.width) {
|
||||
this.setDimensions();
|
||||
this.updateViewBounds();
|
||||
}
|
||||
|
||||
if (clientHeight !== this.height) {
|
||||
this.setDimensions();
|
||||
}
|
||||
},
|
||||
getClientWidth() {
|
||||
let clientWidth = this.$refs.plan.clientWidth;
|
||||
@@ -160,9 +167,27 @@ export default {
|
||||
|
||||
return clientWidth - 200;
|
||||
},
|
||||
getClientHeight() {
|
||||
let clientHeight = this.$refs.plan.clientHeight;
|
||||
|
||||
if (!clientHeight) {
|
||||
//this is a hack - need a better way to find the parent of this component
|
||||
let parent = this.openmct.layout.$refs.browseObject.$el;
|
||||
if (parent) {
|
||||
clientHeight = parent.getBoundingClientRect().height;
|
||||
}
|
||||
}
|
||||
|
||||
return clientHeight;
|
||||
},
|
||||
getPlanData(domainObject) {
|
||||
this.planData = getValidatedData(domainObject);
|
||||
},
|
||||
updateBounds(clock) {
|
||||
if (clock === undefined) {
|
||||
this.viewBounds = Object.create(this.timeContext.bounds());
|
||||
}
|
||||
},
|
||||
updateViewBounds(bounds) {
|
||||
if (bounds) {
|
||||
this.viewBounds = Object.create(bounds);
|
||||
@@ -191,10 +216,8 @@ export default {
|
||||
activities.forEach(activity => activity.remove());
|
||||
},
|
||||
setDimensions() {
|
||||
const planHolder = this.$refs.plan;
|
||||
this.width = this.getClientWidth();
|
||||
|
||||
this.height = Math.round(planHolder.getBoundingClientRect().height);
|
||||
this.height = this.getClientHeight();
|
||||
},
|
||||
setScale(timeSystem) {
|
||||
if (!this.width) {
|
||||
|
||||
@@ -1192,11 +1192,15 @@ export default {
|
||||
this.$emit('statusUpdated', status);
|
||||
},
|
||||
handleWindowResize() {
|
||||
const newOffsetWidth = this.$parent.$refs.plotWrapper.offsetWidth;
|
||||
const { plotWrapper } = this.$parent.$refs;
|
||||
if (!plotWrapper) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newOffsetWidth = plotWrapper.offsetWidth;
|
||||
//we ignore when width gets smaller
|
||||
const offsetChange = newOffsetWidth - this.offsetWidth;
|
||||
if (this.$parent.$refs.plotWrapper
|
||||
&& offsetChange > OFFSET_THRESHOLD) {
|
||||
if (offsetChange > OFFSET_THRESHOLD) {
|
||||
this.offsetWidth = newOffsetWidth;
|
||||
this.config.series.models.forEach(this.loadSeriesData, this);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ export default class RemoveAction {
|
||||
this.openmct = openmct;
|
||||
|
||||
this.removeFromComposition = this.removeFromComposition.bind(this); // for access to private transaction variable
|
||||
this.#transaction = null;
|
||||
}
|
||||
|
||||
async invoke(objectPath) {
|
||||
@@ -152,16 +153,13 @@ export default class RemoveAction {
|
||||
}
|
||||
}
|
||||
|
||||
saveTransaction() {
|
||||
async saveTransaction() {
|
||||
if (!this.#transaction) {
|
||||
return;
|
||||
}
|
||||
|
||||
return this.#transaction.commit()
|
||||
.catch(error => {
|
||||
throw error;
|
||||
}).finally(() => {
|
||||
this.openmct.objects.endTransaction();
|
||||
});
|
||||
await this.#transaction.commit();
|
||||
this.openmct.objects.endTransaction();
|
||||
this.#transaction = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,8 @@ describe("The Remove Action plugin", () => {
|
||||
spyOn(removeAction, 'removeFromComposition').and.callThrough();
|
||||
spyOn(removeAction, 'inNavigationPath').and.returnValue(false);
|
||||
spyOn(openmct.objects, 'mutate').and.callThrough();
|
||||
spyOn(openmct.objects, 'startTransaction').and.callThrough();
|
||||
spyOn(openmct.objects, 'endTransaction').and.callThrough();
|
||||
removeAction.removeFromComposition(parentObject, childObject);
|
||||
});
|
||||
|
||||
@@ -90,6 +92,17 @@ describe("The Remove Action plugin", () => {
|
||||
expect(openmct.objects.mutate).toHaveBeenCalled();
|
||||
expect(openmct.objects.mutate.calls.argsFor(0)[0]).toEqual(parentObject);
|
||||
});
|
||||
|
||||
it("it should start a transaction", () => {
|
||||
expect(openmct.objects.startTransaction).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("it should end the transaction", (done) => {
|
||||
setTimeout(() => {
|
||||
expect(openmct.objects.endTransaction).toHaveBeenCalled();
|
||||
done();
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when determining the object is applicable", () => {
|
||||
|
||||
@@ -124,12 +124,10 @@ export default {
|
||||
};
|
||||
|
||||
this.items.push(item);
|
||||
this.updateContentHeight();
|
||||
},
|
||||
removeItem(identifier) {
|
||||
let index = this.items.findIndex(item => this.openmct.objects.areIdsEqual(identifier, item.domainObject.identifier));
|
||||
this.items.splice(index, 1);
|
||||
this.updateContentHeight();
|
||||
},
|
||||
reorder(reorderPlan) {
|
||||
let oldItems = this.items.slice();
|
||||
@@ -138,7 +136,23 @@ export default {
|
||||
});
|
||||
},
|
||||
updateContentHeight() {
|
||||
this.height = Math.round(this.$refs.contentHolder.getBoundingClientRect().height);
|
||||
const clientHeight = this.getClientHeight();
|
||||
if (this.height !== clientHeight) {
|
||||
this.height = clientHeight;
|
||||
}
|
||||
},
|
||||
getClientHeight() {
|
||||
let clientHeight = this.$refs.contentHolder.getBoundingClientRect().height;
|
||||
|
||||
if (!clientHeight) {
|
||||
//this is a hack - need a better way to find the parent of this component
|
||||
let parent = this.openmct.layout.$refs.browseObject.$el;
|
||||
if (parent) {
|
||||
clientHeight = parent.getBoundingClientRect().height;
|
||||
}
|
||||
}
|
||||
|
||||
return clientHeight;
|
||||
},
|
||||
getTimeSystems() {
|
||||
const timeSystems = this.openmct.time.getAllTimeSystems();
|
||||
@@ -155,7 +169,9 @@ export default {
|
||||
//TODO: Some kind of translation via an offset? of current bounds to target timeSystem
|
||||
return currentBounds;
|
||||
},
|
||||
updateViewBounds(bounds) {
|
||||
updateViewBounds() {
|
||||
const bounds = this.timeContext.bounds();
|
||||
this.updateContentHeight();
|
||||
let currentTimeSystem = this.timeSystems.find(item => item.timeSystem.key === this.openmct.time.timeSystem().key);
|
||||
if (currentTimeSystem) {
|
||||
currentTimeSystem.bounds = bounds;
|
||||
@@ -166,12 +182,14 @@ export default {
|
||||
|
||||
this.timeContext = this.openmct.time.getContextForView(this.objectPath);
|
||||
this.getTimeSystems();
|
||||
this.updateViewBounds(this.timeContext.bounds());
|
||||
this.updateViewBounds();
|
||||
this.timeContext.on('bounds', this.updateViewBounds);
|
||||
this.timeContext.on('clock', this.updateViewBounds);
|
||||
},
|
||||
stopFollowingTimeContext() {
|
||||
if (this.timeContext) {
|
||||
this.timeContext.off('bounds', this.updateViewBounds);
|
||||
this.timeContext.off('clock', this.updateViewBounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import EventEmitter from "EventEmitter";
|
||||
|
||||
describe('the plugin', function () {
|
||||
let objectDef;
|
||||
let appHolder;
|
||||
let element;
|
||||
let child;
|
||||
let openmct;
|
||||
@@ -92,6 +93,10 @@ describe('the plugin', function () {
|
||||
};
|
||||
|
||||
beforeEach((done) => {
|
||||
appHolder = document.createElement('div');
|
||||
appHolder.style.width = '640px';
|
||||
appHolder.style.height = '480px';
|
||||
|
||||
mockObjectPath = [
|
||||
{
|
||||
name: 'mock folder',
|
||||
@@ -133,7 +138,7 @@ describe('the plugin', function () {
|
||||
element.appendChild(child);
|
||||
|
||||
openmct.on('start', done);
|
||||
openmct.startHeadless();
|
||||
openmct.start(appHolder);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -167,7 +172,7 @@ describe('the plugin', function () {
|
||||
|
||||
const applicableViews = openmct.objectViews.get(testViewObject, mockObjectPath);
|
||||
timelineView = applicableViews.find((viewProvider) => viewProvider.key === 'time-strip.view');
|
||||
let view = timelineView.view(testViewObject, element);
|
||||
let view = timelineView.view(testViewObject, mockObjectPath);
|
||||
view.show(child, true);
|
||||
|
||||
return Vue.nextTick();
|
||||
@@ -245,7 +250,7 @@ describe('the plugin', function () {
|
||||
beforeEach(done => {
|
||||
const applicableViews = openmct.objectViews.get(testViewObject, mockObjectPath);
|
||||
timelineView = applicableViews.find((viewProvider) => viewProvider.key === 'time-strip.view');
|
||||
let view = timelineView.view(testViewObject, element);
|
||||
let view = timelineView.view(testViewObject, mockObjectPath);
|
||||
view.show(child, true);
|
||||
|
||||
Vue.nextTick(done);
|
||||
@@ -281,7 +286,7 @@ describe('the plugin', function () {
|
||||
beforeEach((done) => {
|
||||
const applicableViews = openmct.objectViews.get(testViewObject2, mockObjectPath);
|
||||
timelineView = applicableViews.find((viewProvider) => viewProvider.key === 'time-strip.view');
|
||||
let view = timelineView.view(testViewObject2, element);
|
||||
let view = timelineView.view(testViewObject2, mockObjectPath);
|
||||
view.show(child, true);
|
||||
|
||||
Vue.nextTick(done);
|
||||
|
||||
@@ -94,15 +94,13 @@ export default {
|
||||
if (this.openmct.time.clock() === undefined) {
|
||||
let nowMarker = document.querySelector('.nowMarker');
|
||||
if (nowMarker) {
|
||||
nowMarker.parentNode.removeChild(nowMarker);
|
||||
nowMarker.classList.add('hidden');
|
||||
}
|
||||
} else {
|
||||
let nowMarker = document.querySelector('.nowMarker');
|
||||
if (nowMarker) {
|
||||
const svgEl = d3Selection.select(this.svgElement).node();
|
||||
let height = svgEl.style('height').replace('px', '');
|
||||
height = Number(height) + this.contentHeight;
|
||||
nowMarker.style.height = height + 'px';
|
||||
nowMarker.classList.remove('hidden');
|
||||
nowMarker.style.height = this.contentHeight + 'px';
|
||||
const now = this.xScale(Date.now());
|
||||
nowMarker.style.left = now + this.offset + 'px';
|
||||
}
|
||||
|
||||
@@ -32,6 +32,10 @@
|
||||
z-index: 10;
|
||||
background: gray;
|
||||
|
||||
&.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
& .icon-arrow-down {
|
||||
font-size: large;
|
||||
position: absolute;
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
<div :style="childrenHeightStyles">
|
||||
<tree-item
|
||||
v-for="(treeItem, index) in visibleItems"
|
||||
:key="treeItem.navigationPath"
|
||||
:key="`${treeItem.navigationPath}-${index}`"
|
||||
:node="treeItem"
|
||||
:is-selector-tree="isSelectorTree"
|
||||
:selected-item="selectedItem"
|
||||
|
||||