diff --git a/Makefile b/Makefile index 63d7297c..5e97e14a 100644 --- a/Makefile +++ b/Makefile @@ -33,11 +33,11 @@ sanity-test: @echo "Running target: sanity-test" npm run wait-for-yamcs -build-example: #This will run buid example based on the current branch of openmct-yamcs and fallback to master +build-example: #This will run build example based on the current branch of openmct-yamcs and fallback to master @echo "Running target: build-example" - @current_branch=$(shell git rev-parse --abbrev-ref HEAD) - @echo "Current branch of openmct-yamcs: $$current_branch checking if it exists in openmct repository" - @if git ls-remote --exit-code --heads https://github.com/nasa/openmct.git refs/heads/$$current_branch; then \ + current_branch=$(shell git rev-parse --abbrev-ref HEAD); \ + echo "Current branch of openmct-yamcs: $$current_branch checking if it exists in openmct repository"; \ + if git ls-remote --exit-code --heads https://github.com/nasa/openmct.git refs/heads/$$current_branch; then \ echo "Branch $$current_branch exists in openmct repository. Running build:example:currentbranch"; \ npm run build:example:currentbranch || { echo "Failed to run build:example:currentbranch"; exit 1; }; \ else \ @@ -58,5 +58,12 @@ clean: @echo "Running target: clean" npm run clean echo "Ran npm run clean." - rm -rf quickstart - echo "Removed 'quickstart' directory." + @if [ -d "quickstart/docker" ]; then \ + echo "Directory 'quickstart/docker' exists. Running make clean in quickstart/docker."; \ + cd quickstart/docker && $(MAKE) clean; \ + cd ../..; \ + rm -rf quickstart; \ + echo "Removed 'quickstart' directory."; \ + else \ + echo "Directory 'quickstart/docker' does not exist. Skipping."; \ + fi diff --git a/example/index.js b/example/index.js index 449faf90..a0c47f03 100644 --- a/example/index.js +++ b/example/index.js @@ -105,5 +105,6 @@ const openmct = window.openmct; ); openmct.install(openmct.plugins.FaultManagement()); + openmct.install(openmct.plugins.BarChart()); } })(); diff --git a/tests/README.md b/tests/README.md index 2d1c1041..c180b9cd 100644 --- a/tests/README.md +++ b/tests/README.md @@ -4,6 +4,14 @@ This project is using Open MCT's e2e-as-a-dependency model. To learn more, pleas ## How to Run Locally +** Note: if you are running the tests to match a specific branch of openmct, you will need to run `npm run build:example:currentbranch` ** + +### Makefile + +1. `make test-all` + +### Manually + To run the tests, we recommend the following workflow which bridges two separate github repos: yamcs/quickstart and openmct-yamcs (this one). @@ -14,5 +22,5 @@ yamcs/quickstart and openmct-yamcs (this one). 5. `npm install` in openmct-yamcs 6. Sanity test that yamcs is up with `npm run wait-for-yamcs` in openmct-yamcs 7. `npm run test:getopensource` -8. `npm run build:example` or `npm run build:example:master` -9. `npm run test:e2e:watch` +8. `npm run build:example` or `npm run build:example:master` or `npm run build:example:currentbranch` +9. `npm run test:e2e:watch` \ No newline at end of file diff --git a/tests/e2e/yamcs/barGraph.e2e.spec.mjs b/tests/e2e/yamcs/barGraph.e2e.spec.mjs new file mode 100644 index 00000000..bf2fb12d --- /dev/null +++ b/tests/e2e/yamcs/barGraph.e2e.spec.mjs @@ -0,0 +1,57 @@ +/***************************************************************************** + * 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 { pluginFixtures, appActions } from 'openmct-e2e'; +import { searchAndLinkTelemetryToObject } from '../yamcsAppActions.mjs'; +const { test, expect } = pluginFixtures; +const { createDomainObjectWithDefaults } = appActions; + +test.describe('Bar Graph @yamcs', () => { + let barGraph; + let historicalGet; + + 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 Bar Graph + barGraph = await createDomainObjectWithDefaults(page, { type: 'Graph', name: 'Bar Graph' }); + // Enter edit mode for the overlay plot + await searchAndLinkTelemetryToObject(page, 'Magnetometer', barGraph.name); + }); + + test('Requests a single historical datum', async ({ page }) => { + + //http://localhost:9000/yamcs-proxy/api/archive/myproject/parameters/myproject/Magnetometer?start=2024-09-25T14%3A08%3A46.244Z&stop=2024-09-25T14%3A38%3A46.245Z&limit=1&order=desc + historicalGet = page.waitForRequest(/.*\/api\/.*\/parameters.*limit=1&order=desc$/); + + await page.goto(barGraph.url, { waitUntil: 'networkidle' }); + + await historicalGet; + + await expect(page.getByRole('main').getByText(barGraph.name)).toBeVisible(); + }); +}); diff --git a/tests/e2e/yamcsAppActions.mjs b/tests/e2e/yamcsAppActions.mjs new file mode 100644 index 00000000..436ee182 --- /dev/null +++ b/tests/e2e/yamcsAppActions.mjs @@ -0,0 +1,52 @@ +/***************************************************************************** + * 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. + *****************************************************************************/ + +/** + * The fixtures in this file are to be used to consolidate common actions performed by the + * various test suites. The goal is only to avoid duplication of code across test suites and not to abstract + * away the underlying functionality of the application. For more about the App Action pattern, see /e2e/README.md) + * + * For example, if two functions are nearly identical in + * timer.e2e.spec.js and notebook.e2e.spec.js, that function should be generalized and moved into this file. + */ + +/** + * Search for telemetry and link it to an object. objectName should come from the domainObject.name function. + * @param {import('@playwright/test').Page} page + * @param {string} parameterName + * @param {string} objectName + */ +async function searchAndLinkTelemetryToObject(page, parameterName, objectName) { + await page.getByRole('searchbox', { name: 'Search Input' }).click(); + await page.getByRole('searchbox', { name: 'Search Input' }).fill(parameterName); + await page.getByLabel(`${parameterName} yamcs.aggregate result`).getByText(parameterName).click(); + await page.getByLabel('More actions').click(); + await page.getByLabel('Create Link').click(); + await page.getByLabel('Modal Overlay').getByLabel('Search Input').click(); + await page.getByLabel('Modal Overlay').getByLabel('Search Input').fill(objectName); + await page.getByLabel('Navigate to Bar Graph').click(); + await page.getByText('Ok').click(); +} + +export { + searchAndLinkTelemetryToObject +};