From 35115b742dcc730eb32189d5c48bcd9ab28b9483 Mon Sep 17 00:00:00 2001 From: Shefali Date: Mon, 12 Aug 2024 11:02:10 -0700 Subject: [PATCH 1/6] Only as for latest historical telemetry --- src/plugins/charts/bar/BarGraphView.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/charts/bar/BarGraphView.vue b/src/plugins/charts/bar/BarGraphView.vue index aa26dc05d45..f7eadcf3351 100644 --- a/src/plugins/charts/bar/BarGraphView.vue +++ b/src/plugins/charts/bar/BarGraphView.vue @@ -257,7 +257,8 @@ export default { return { end, - start + start, + size: 1 }; }, loadComposition() { @@ -400,6 +401,7 @@ export default { this.openmct.telemetry .request(telemetryObject, options) .then((data) => { + console.log(data); data.forEach((datum) => { this.addDataToGraph(telemetryObject, datum, axisMetadata); }); From 030de4b5eabad4c49d3beffc6c611eda30e58477 Mon Sep 17 00:00:00 2001 From: Shefali Date: Mon, 12 Aug 2024 15:14:27 -0700 Subject: [PATCH 2/6] Add test for size 1 request when a bar graph is loaded --- .../plugins/plot/barGraph.e2e.spec.js | 88 +++++++++++++++++++ src/plugins/charts/bar/BarGraphView.vue | 1 - 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js diff --git a/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js b/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js new file mode 100644 index 00000000000..d7322c78057 --- /dev/null +++ b/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js @@ -0,0 +1,88 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2024, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + +/* + * This test suite is dedicated to testing the Bar Graph component. + */ + +import { v4 as uuid } from 'uuid'; + +import {createDomainObjectWithDefaults} from '../../../../appActions.js'; +import { expect, test } from '../../../../pluginFixtures.js'; + +test.describe('Bar Graph', () => { + let barGraph; + + test.beforeEach(async ({ page }) => { + // Open a browser, navigate to the main page, and wait until all networkevents to resolve + await page.goto('./', { waitUntil: 'domcontentloaded' }); + + // Create the Bar Graph + barGraph = await createDomainObjectWithDefaults(page, { type: 'Graph' }); + }); + + test('Requests a single historical datum', async ({ page }) => { + // Create a sine wave generator within the bar graph + const swg1 = await createDomainObjectWithDefaults(page, { + type: 'Sine Wave Generator', + name: `swg-${uuid()}`, + parent: barGraph.uuid + }); + const getRequestOptionPromise = addTelemetryInterceptor(page); + + // Navigate to the bar graph and verify that + await page.goto(barGraph.url, { waitUntil: 'domcontentloaded' }); + await page.getByRole('tab', { name: 'Config' }).click(); + + const requestOption = await getRequestOptionPromise; + await expect(requestOption).toBe(1); + + }); +}); + + +/** + * Util for returning the size option for telemetry requests + * @param {import('@playwright/test').Page} page + */ +async function addTelemetryInterceptor(page) { + const getRequestOptionPromise = new Promise((resolve) => + page.exposeFunction('getRequestOption', resolve) + ); + + await page.evaluate(async () => { + const requestOptionsChecker = () => { + return { + appliesTo: () => { + return true; + }, + invoke: (request) => { + window.getRequestOption(request.size); + return request; + } + }; + } + window.openmct.telemetry.addRequestInterceptor(requestOptionsChecker()); + }); + + return getRequestOptionPromise; +} diff --git a/src/plugins/charts/bar/BarGraphView.vue b/src/plugins/charts/bar/BarGraphView.vue index f7eadcf3351..410d740a62d 100644 --- a/src/plugins/charts/bar/BarGraphView.vue +++ b/src/plugins/charts/bar/BarGraphView.vue @@ -401,7 +401,6 @@ export default { this.openmct.telemetry .request(telemetryObject, options) .then((data) => { - console.log(data); data.forEach((datum) => { this.addDataToGraph(telemetryObject, datum, axisMetadata); }); From 08a5e1ee7b428ff581225ea77d1be0ffc4fa9c7f Mon Sep 17 00:00:00 2001 From: Shefali Date: Tue, 13 Aug 2024 12:19:05 -0700 Subject: [PATCH 3/6] Use strategy latest instead of size 1 for historical request --- e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js | 6 +++--- src/plugins/charts/bar/BarGraphView.vue | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js b/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js index d7322c78057..b3f737a2f1d 100644 --- a/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js +++ b/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js @@ -29,7 +29,7 @@ import { v4 as uuid } from 'uuid'; import {createDomainObjectWithDefaults} from '../../../../appActions.js'; import { expect, test } from '../../../../pluginFixtures.js'; -test.describe('Bar Graph', () => { +test.describe.only('Bar Graph', () => { let barGraph; test.beforeEach(async ({ page }) => { @@ -54,7 +54,7 @@ test.describe('Bar Graph', () => { await page.getByRole('tab', { name: 'Config' }).click(); const requestOption = await getRequestOptionPromise; - await expect(requestOption).toBe(1); + await expect(requestOption).toBe('latest'); }); }); @@ -76,7 +76,7 @@ async function addTelemetryInterceptor(page) { return true; }, invoke: (request) => { - window.getRequestOption(request.size); + window.getRequestOption(request.strategy); return request; } }; diff --git a/src/plugins/charts/bar/BarGraphView.vue b/src/plugins/charts/bar/BarGraphView.vue index 410d740a62d..c203c8a026f 100644 --- a/src/plugins/charts/bar/BarGraphView.vue +++ b/src/plugins/charts/bar/BarGraphView.vue @@ -258,7 +258,7 @@ export default { return { end, start, - size: 1 + strategy: 'latest' }; }, loadComposition() { From 51a22bb70a026ef4ed4e415d709001be8336faa3 Mon Sep 17 00:00:00 2001 From: Shefali Date: Tue, 13 Aug 2024 12:50:39 -0700 Subject: [PATCH 4/6] Fix linting issues --- .../functional/plugins/plot/barGraph.e2e.spec.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js b/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js index b3f737a2f1d..1ee43c26ca0 100644 --- a/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js +++ b/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js @@ -26,10 +26,10 @@ import { v4 as uuid } from 'uuid'; -import {createDomainObjectWithDefaults} from '../../../../appActions.js'; +import { createDomainObjectWithDefaults } from '../../../../appActions.js'; import { expect, test } from '../../../../pluginFixtures.js'; -test.describe.only('Bar Graph', () => { +test.describe('Bar Graph', () => { let barGraph; test.beforeEach(async ({ page }) => { @@ -42,7 +42,7 @@ test.describe.only('Bar Graph', () => { test('Requests a single historical datum', async ({ page }) => { // Create a sine wave generator within the bar graph - const swg1 = await createDomainObjectWithDefaults(page, { + await createDomainObjectWithDefaults(page, { type: 'Sine Wave Generator', name: `swg-${uuid()}`, parent: barGraph.uuid @@ -55,22 +55,20 @@ test.describe.only('Bar Graph', () => { const requestOption = await getRequestOptionPromise; await expect(requestOption).toBe('latest'); - }); }); - /** * Util for returning the size option for telemetry requests * @param {import('@playwright/test').Page} page */ async function addTelemetryInterceptor(page) { const getRequestOptionPromise = new Promise((resolve) => - page.exposeFunction('getRequestOption', resolve) + page.exposeFunction('getRequestOption', resolve) ); - await page.evaluate(async () => { - const requestOptionsChecker = () => { + await page.evaluate(() => { + function requestOptionsChecker() { return { appliesTo: () => { return true; From 5327575049e3738c340c1249c24e4d2781b081e4 Mon Sep 17 00:00:00 2001 From: Shefali Date: Wed, 28 Aug 2024 10:28:53 -0700 Subject: [PATCH 5/6] Add size and strategy --- .../plugins/plot/barGraph.e2e.spec.js | 18 +++++++++++------- src/plugins/charts/bar/BarGraphView.vue | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js b/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js index 1ee43c26ca0..4aea79546ec 100644 --- a/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js +++ b/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js @@ -47,14 +47,15 @@ test.describe('Bar Graph', () => { name: `swg-${uuid()}`, parent: barGraph.uuid }); - const getRequestOptionPromise = addTelemetryInterceptor(page); + const getRequestOptionsPromise = addTelemetryInterceptor(page); // Navigate to the bar graph and verify that await page.goto(barGraph.url, { waitUntil: 'domcontentloaded' }); await page.getByRole('tab', { name: 'Config' }).click(); - const requestOption = await getRequestOptionPromise; - await expect(requestOption).toBe('latest'); + const requestOptions = await getRequestOptionsPromise; + await expect(requestOptions.strategy).toBe('latest'); + await expect(requestOptions.size).toBe(1); }); }); @@ -63,8 +64,8 @@ test.describe('Bar Graph', () => { * @param {import('@playwright/test').Page} page */ async function addTelemetryInterceptor(page) { - const getRequestOptionPromise = new Promise((resolve) => - page.exposeFunction('getRequestOption', resolve) + const getRequestOptionsPromise = new Promise((resolve) => + page.exposeFunction('getRequestOptions', resolve) ); await page.evaluate(() => { @@ -74,7 +75,10 @@ async function addTelemetryInterceptor(page) { return true; }, invoke: (request) => { - window.getRequestOption(request.strategy); + window.getRequestOptions({ + strategy: request.strategy, + size: request.size + }); return request; } }; @@ -82,5 +86,5 @@ async function addTelemetryInterceptor(page) { window.openmct.telemetry.addRequestInterceptor(requestOptionsChecker()); }); - return getRequestOptionPromise; + return getRequestOptionsPromise; } diff --git a/src/plugins/charts/bar/BarGraphView.vue b/src/plugins/charts/bar/BarGraphView.vue index c203c8a026f..0bc90e3ebb9 100644 --- a/src/plugins/charts/bar/BarGraphView.vue +++ b/src/plugins/charts/bar/BarGraphView.vue @@ -258,6 +258,7 @@ export default { return { end, start, + size: 1, strategy: 'latest' }; }, From b440bf2925ca5dd3c8a6769008f3d03a6c2e0ac0 Mon Sep 17 00:00:00 2001 From: Shefali Date: Wed, 11 Sep 2024 13:27:01 -0700 Subject: [PATCH 6/6] Remove bar graph tests --- .../plugins/plot/barGraph.e2e.spec.js | 90 ------------------- 1 file changed, 90 deletions(-) delete mode 100644 e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js diff --git a/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js b/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js deleted file mode 100644 index 4aea79546ec..00000000000 --- a/e2e/tests/functional/plugins/plot/barGraph.e2e.spec.js +++ /dev/null @@ -1,90 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2024, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT is licensed under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * Open MCT includes source code licensed under additional open source - * licenses. See the Open Source Licenses file (LICENSES.md) included with - * this source code distribution or the Licensing information page available - * at runtime from the About dialog for additional information. - *****************************************************************************/ - -/* - * This test suite is dedicated to testing the Bar Graph component. - */ - -import { v4 as uuid } from 'uuid'; - -import { createDomainObjectWithDefaults } from '../../../../appActions.js'; -import { expect, test } from '../../../../pluginFixtures.js'; - -test.describe('Bar Graph', () => { - let barGraph; - - test.beforeEach(async ({ page }) => { - // Open a browser, navigate to the main page, and wait until all networkevents to resolve - await page.goto('./', { waitUntil: 'domcontentloaded' }); - - // Create the Bar Graph - barGraph = await createDomainObjectWithDefaults(page, { type: 'Graph' }); - }); - - test('Requests a single historical datum', async ({ page }) => { - // Create a sine wave generator within the bar graph - await createDomainObjectWithDefaults(page, { - type: 'Sine Wave Generator', - name: `swg-${uuid()}`, - parent: barGraph.uuid - }); - const getRequestOptionsPromise = addTelemetryInterceptor(page); - - // Navigate to the bar graph and verify that - await page.goto(barGraph.url, { waitUntil: 'domcontentloaded' }); - await page.getByRole('tab', { name: 'Config' }).click(); - - const requestOptions = await getRequestOptionsPromise; - await expect(requestOptions.strategy).toBe('latest'); - await expect(requestOptions.size).toBe(1); - }); -}); - -/** - * Util for returning the size option for telemetry requests - * @param {import('@playwright/test').Page} page - */ -async function addTelemetryInterceptor(page) { - const getRequestOptionsPromise = new Promise((resolve) => - page.exposeFunction('getRequestOptions', resolve) - ); - - await page.evaluate(() => { - function requestOptionsChecker() { - return { - appliesTo: () => { - return true; - }, - invoke: (request) => { - window.getRequestOptions({ - strategy: request.strategy, - size: request.size - }); - return request; - } - }; - } - window.openmct.telemetry.addRequestInterceptor(requestOptionsChecker()); - }); - - return getRequestOptionsPromise; -}