Skip to content

Commit

Permalink
Merge branch 'master' into mct7343-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
unlikelyzero authored Sep 26, 2024
2 parents b5f9d47 + f1b3922 commit 12fca7b
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 14 deletions.
26 changes: 14 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.PHONY: all clone-quickstart install-quickstart start-quickstart install-openmct-yamcs sanity-test build-example test-getopensource test-e2e clean

all: clone-quickstart install-quickstart install-openmct-yamcs sanity-test build-example test-e2e
test-all: clone-quickstart install-quickstart install-openmct-yamcs sanity-test build-example test-e2e

start: clone-quickstart install-quickstart install-openmct-yamcs sanity-test build-example start-openmct
start-all: clone-quickstart install-quickstart install-openmct-yamcs sanity-test build-example start-openmct

clone-quickstart:
@echo "Running target: clone-quickstart"
Expand All @@ -21,11 +21,9 @@ start-quickstart:
@echo "Running target: start-quickstart"
@cd quickstart/docker && $(MAKE) all

restart-quickstart:
reset-quickstart:
@echo "Running target: reset-quickstart"
@cd quickstart/docker && $(MAKE) yamcs-down
@cd quickstart/docker && $(MAKE) simulator-down
@cd quickstart/docker && $(MAKE) all
@cd quickstart/docker && $(MAKE) yamcs-simulator-restart

install-openmct-yamcs:
@echo "Running target: install-openmct-yamcs"
Expand All @@ -35,11 +33,11 @@ sanity-test:
@echo "Running target: sanity-test"
npm run wait-for-yamcs

build-example:
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 @@ -59,9 +57,13 @@ test-e2e:
clean:
@echo "Running target: clean"
npm run clean
if [ -d "quickstart" ]; then \
echo "Ran npm run clean."
@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' does not exist."; \
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 12fca7b

Please sign in to comment.