Skip to content

Commit

Permalink
Test to check that bar graph makes requests with size 1 (limit=1). (#470
Browse files Browse the repository at this point in the history
)

* Include Graphs in default plugins installed.
Test to check that bar graph makes requests with size 1 (limit=1).

* Remove unnecessary page.goto.
Move waitForResponse to just before telemetry is added to the graph

* Use request url for checking query parameters

* Small locator changes

* Fix locators

* Standardize request parameter checks

* Update logic to properly detect branch

* update test to match new appActions layout

* add a yamcs appAction file

* remove temp

* update documentation

* Clean up clean

* address review comments

---------

Co-authored-by: John Hill <[email protected]>
  • Loading branch information
shefalijoshi and unlikelyzero authored Sep 26, 2024
1 parent c300270 commit f1b3922
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 8 deletions.
19 changes: 13 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
1 change: 1 addition & 0 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,6 @@ const openmct = window.openmct;
);

openmct.install(openmct.plugins.FaultManagement());
openmct.install(openmct.plugins.BarChart());
}
})();
12 changes: 10 additions & 2 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand All @@ -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`
57 changes: 57 additions & 0 deletions tests/e2e/yamcs/barGraph.e2e.spec.mjs
Original file line number Diff line number Diff line change
@@ -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();
});
});
52 changes: 52 additions & 0 deletions tests/e2e/yamcsAppActions.mjs
Original file line number Diff line number Diff line change
@@ -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
};

0 comments on commit f1b3922

Please sign in to comment.