From 51196530fd1aa8cb65c4eab5e75a24d109c1c85b Mon Sep 17 00:00:00 2001 From: John Hill Date: Thu, 7 Jul 2022 11:04:50 -0700 Subject: [PATCH] No gauge (#5451) * Installed gauge plugin by default * Make gauge part of standard install in e2e suite and add restrictednotebook Co-authored-by: Andrew Henry --- e2e/tests/plugins/gauge/addInitGauge.js | 30 ------------------------- e2e/tests/recycled_storage.json | 22 ------------------ e2e/tests/visual/addInit.visual.spec.js | 24 +++++++++++--------- e2e/tests/visual/default.visual.spec.js | 19 ++++++++++++++++ src/MCT.js | 1 + 5 files changed, 34 insertions(+), 62 deletions(-) delete mode 100644 e2e/tests/plugins/gauge/addInitGauge.js delete mode 100644 e2e/tests/recycled_storage.json diff --git a/e2e/tests/plugins/gauge/addInitGauge.js b/e2e/tests/plugins/gauge/addInitGauge.js deleted file mode 100644 index ced1ada3ec..0000000000 --- a/e2e/tests/plugins/gauge/addInitGauge.js +++ /dev/null @@ -1,30 +0,0 @@ -/***************************************************************************** - * 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 will be called from the test suite with -// await page.addInitScript({ path: path.join(__dirname, 'addInitGauge.js') }); -// it will install the Gauge since it is not installed by default - -document.addEventListener('DOMContentLoaded', () => { - const openmct = window.openmct; - openmct.install(openmct.plugins.Gauge()); -}); diff --git a/e2e/tests/recycled_storage.json b/e2e/tests/recycled_storage.json deleted file mode 100644 index 8d59148b23..0000000000 --- a/e2e/tests/recycled_storage.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "cookies": [], - "origins": [ - { - "origin": "http://localhost:8080", - "localStorage": [ - { - "name": "mct-tree-expanded", - "value": "[]" - }, - { - "name": "tcHistory", - "value": "{\"utc\":[{\"start\":1656473493306,\"end\":1656475293306},{\"start\":1655769110258,\"end\":1655770910258},{\"start\":1652301954635,\"end\":1652303754635}]}" - }, - { - "name": "mct", - "value": "{\"mine\":{\"identifier\":{\"key\":\"mine\",\"namespace\":\"\"},\"name\":\"My Items\",\"type\":\"folder\",\"composition\":[{\"key\":\"f64bea3b-58a7-4586-8c05-8b651e5f0bfd\",\"namespace\":\"\"},{\"key\":\"18ba28bf-152e-4e0f-9b9c-638fb2ade0c3\",\"namespace\":\"\"},{\"key\":\"fa64bd6c-9351-4d94-a54e-e062a93be3b6\",\"namespace\":\"\"}],\"location\":\"ROOT\",\"persisted\":1656475294042,\"modified\":1656475294042},\"f64bea3b-58a7-4586-8c05-8b651e5f0bfd\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"f64bea3b-58a7-4586-8c05-8b651e5f0bfd\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"73f2d9ae-d1f3-4561-b7fc-ecd5df557249\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1652303755999,\"location\":\"mine\",\"persisted\":1652303756002},\"18ba28bf-152e-4e0f-9b9c-638fb2ade0c3\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"18ba28bf-152e-4e0f-9b9c-638fb2ade0c3\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"43cfb4b1-348c-43c0-a681-c4cf53b5335f\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1655770911020,\"location\":\"mine\",\"persisted\":1655770911020},\"fa64bd6c-9351-4d94-a54e-e062a93be3b6\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"fa64bd6c-9351-4d94-a54e-e062a93be3b6\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"26739ce0-9a56-466c-91dd-f08bd9bfc9d7\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1656475294040,\"location\":\"mine\",\"persisted\":1656475294040}}" - } - ] - } - ] -} \ No newline at end of file diff --git a/e2e/tests/visual/addInit.visual.spec.js b/e2e/tests/visual/addInit.visual.spec.js index c47b90e307..a6c3abf0b6 100644 --- a/e2e/tests/visual/addInit.visual.spec.js +++ b/e2e/tests/visual/addInit.visual.spec.js @@ -38,6 +38,8 @@ const sinon = require('sinon'); const VISUAL_GRACE_PERIOD = 5 * 1000; //Lets the application "simmer" before the snapshot is taken +const CUSTOM_NAME = 'CUSTOM_NAME'; + // Snippet from https://github.com/microsoft/playwright/issues/6347#issuecomment-965887758 // Will replace with cy.clock() equivalent test.beforeEach(async ({ context }) => { @@ -52,21 +54,23 @@ test.beforeEach(async ({ context }) => { }); }); -test('Visual - Default Gauge is correct @addInit', async ({ page }) => { - - await page.addInitScript({ path: path.join(__dirname, '../plugins/gauge', './addInitGauge.js') }); +test('Visual - Restricted Notebook is visually correct @addInit', async ({ page }) => { + // eslint-disable-next-line no-undef + await page.addInitScript({ path: path.join(__dirname, '../plugins/notebook', './addRestrictedNotebook.js') }); //Go to baseURL await page.goto('/', { waitUntil: 'networkidle' }); - //Click the Create button await page.click('button:has-text("Create")'); + // Click text=CUSTOM_NAME + await page.click(`text=${CUSTOM_NAME}`); + // Click text=OK + await Promise.all([ + page.waitForNavigation({waitUntil: 'networkidle'}), + page.click('text=OK') + ]); - await page.click('text=Gauge'); - - await page.click('text=OK'); - - // Take a snapshot of the newly created Gauge object + // Take a snapshot of the newly created CUSTOM_NAME notebook await page.waitForTimeout(VISUAL_GRACE_PERIOD); - await percySnapshot(page, 'Default Gauge'); + await percySnapshot(page, 'Restricted Notebook with CUSTOM_NAME'); }); diff --git a/e2e/tests/visual/default.visual.spec.js b/e2e/tests/visual/default.visual.spec.js index e64de2925e..d5c2210ee3 100644 --- a/e2e/tests/visual/default.visual.spec.js +++ b/e2e/tests/visual/default.visual.spec.js @@ -211,3 +211,22 @@ test('Visual - Display Layout Icon is correct', async ({ page }) => { await percySnapshot(page, 'Display Layout Create Menu'); }); + +test('Visual - Default Gauge is correct', async ({ page }) => { + + //Go to baseURL + await page.goto('/', { waitUntil: 'networkidle' }); + + //Click the Create button + await page.click('button:has-text("Create")'); + + await page.click('text=Gauge'); + + await page.click('text=OK'); + + // Take a snapshot of the newly created Gauge object + await page.waitForTimeout(VISUAL_GRACE_PERIOD); + await percySnapshot(page, 'Default Gauge'); + +}); + diff --git a/src/MCT.js b/src/MCT.js index 7fa54e7ad1..8d7f252f31 100644 --- a/src/MCT.js +++ b/src/MCT.js @@ -281,6 +281,7 @@ define([ this.install(this.plugins.ObjectInterceptors()); this.install(this.plugins.DeviceClassifier()); this.install(this.plugins.UserIndicator()); + this.install(this.plugins.Gauge()); } MCT.prototype = Object.create(EventEmitter.prototype);