Compare commits
33 Commits
v3.2.0
...
mct7322-a1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86c2662148 | ||
|
|
f0f3733ac1 | ||
|
|
f5d57374fb | ||
|
|
715a44864e | ||
|
|
0d97675a0a | ||
|
|
ec910dcbdc | ||
|
|
0ce36c8297 | ||
|
|
3fccac0bfc | ||
|
|
2675220452 | ||
|
|
4075a31d96 | ||
|
|
7f95325816 | ||
|
|
e07ba61c4c | ||
|
|
97bffc554f | ||
|
|
250db8d7f9 | ||
|
|
3520a929a9 | ||
|
|
800b03ad60 | ||
|
|
902ed0274a | ||
|
|
9ed8d4f5a5 | ||
|
|
93e5219917 | ||
|
|
2d9c0414f7 | ||
|
|
a3e0a0f694 | ||
|
|
5ec155c7ce | ||
|
|
cfb190fb68 | ||
|
|
72e0621ecd | ||
|
|
e7b9481aa9 | ||
|
|
2dc1388737 | ||
|
|
41bee3111c | ||
|
|
97cb783c4b | ||
|
|
39a31617b8 | ||
|
|
415b65237b | ||
|
|
28bfc90036 | ||
|
|
7ce3ed5597 | ||
|
|
b9ae461b7d |
@@ -120,15 +120,13 @@ jobs:
|
||||
- generate_and_store_version_and_filesystem_artifacts
|
||||
e2e-test:
|
||||
parameters:
|
||||
node-version:
|
||||
type: string
|
||||
suite: #stable or full
|
||||
type: string
|
||||
executor: pw-focal-development
|
||||
parallelism: 4
|
||||
parallelism: 6
|
||||
steps:
|
||||
- build_and_install:
|
||||
node-version: <<parameters.node-version>>
|
||||
node-version: lts/hydrogen
|
||||
- when: #Only install chrome-beta when running the 'full' suite to save $$$
|
||||
condition:
|
||||
equal: ['full', <<parameters.suite>>]
|
||||
@@ -155,13 +153,10 @@ jobs:
|
||||
steps:
|
||||
- generate_and_store_version_and_filesystem_artifacts
|
||||
e2e-couchdb:
|
||||
parameters:
|
||||
node-version:
|
||||
type: string
|
||||
executor: ubuntu
|
||||
steps:
|
||||
- build_and_install:
|
||||
node-version: <<parameters.node-version>>
|
||||
node-version: lts/hydrogen
|
||||
- run: npx playwright@1.39.0 install #Necessary for bare ubuntu machine
|
||||
- run: |
|
||||
export $(cat src/plugins/persistence/couch/.env.ci | xargs)
|
||||
@@ -189,15 +184,28 @@ jobs:
|
||||
equal: [42, 42] # Always generate version artifacts regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2
|
||||
steps:
|
||||
- generate_and_store_version_and_filesystem_artifacts
|
||||
perf-test:
|
||||
parameters:
|
||||
node-version:
|
||||
type: string
|
||||
mem-test:
|
||||
executor: pw-focal-development
|
||||
steps:
|
||||
- build_and_install:
|
||||
node-version: <<parameters.node-version>>
|
||||
node-version: lts/hydrogen
|
||||
- run: npm run test:perf:memory
|
||||
- store_test_results:
|
||||
path: test-results/results.xml
|
||||
- store_artifacts:
|
||||
path: test-results
|
||||
- store_artifacts:
|
||||
path: html-test-results
|
||||
- when:
|
||||
condition:
|
||||
equal: [42, 42] # Always run codecov reports regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2
|
||||
steps:
|
||||
- generate_and_store_version_and_filesystem_artifacts
|
||||
perf-test:
|
||||
executor: pw-focal-development
|
||||
steps:
|
||||
- build_and_install:
|
||||
node-version: lts/hydrogen
|
||||
- run: npm run test:perf:localhost
|
||||
- run: npm run test:perf:contract
|
||||
- store_test_results:
|
||||
@@ -211,16 +219,14 @@ jobs:
|
||||
equal: [42, 42] # Always run codecov reports regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2
|
||||
steps:
|
||||
- generate_and_store_version_and_filesystem_artifacts
|
||||
visual-test:
|
||||
visual-a11y-tests:
|
||||
parameters:
|
||||
node-version:
|
||||
type: string
|
||||
suite:
|
||||
type: string # ci or full
|
||||
executor: pw-focal-development
|
||||
steps:
|
||||
- build_and_install:
|
||||
node-version: <<parameters.node-version>>
|
||||
node-version: lts/hydrogen
|
||||
- run: npm run test:e2e:visual:<<parameters.suite>>
|
||||
- store_test_results:
|
||||
path: test-results/results.xml
|
||||
@@ -237,27 +243,25 @@ workflows:
|
||||
overall-circleci-commit-status: #These jobs run on every commit
|
||||
jobs:
|
||||
- lint:
|
||||
name: node16-lint
|
||||
node-version: lts/gallium
|
||||
name: node20-lint
|
||||
node-version: lts/iron
|
||||
- unit-test:
|
||||
name: node18-chrome
|
||||
node-version: lts/hydrogen
|
||||
- e2e-test:
|
||||
name: e2e-stable
|
||||
node-version: lts/hydrogen
|
||||
suite: stable
|
||||
- perf-test:
|
||||
node-version: lts/hydrogen
|
||||
- visual-test:
|
||||
- mem-test
|
||||
- perf-test
|
||||
- visual-a11y-tests:
|
||||
name: visual-test-ci
|
||||
suite: ci
|
||||
node-version: lts/hydrogen
|
||||
|
||||
the-nightly: #These jobs do not run on PRs, but against master at night
|
||||
jobs:
|
||||
- unit-test:
|
||||
name: node16-chrome-nightly
|
||||
node-version: lts/gallium
|
||||
name: node20-chrome-nightly
|
||||
node-version: lts/iron
|
||||
- unit-test:
|
||||
name: node18-chrome
|
||||
node-version: lts/hydrogen
|
||||
@@ -265,16 +269,13 @@ workflows:
|
||||
node-version: lts/hydrogen
|
||||
- e2e-test:
|
||||
name: e2e-full-nightly
|
||||
node-version: lts/hydrogen
|
||||
suite: full
|
||||
- perf-test:
|
||||
node-version: lts/hydrogen
|
||||
- visual-test:
|
||||
- mem-test
|
||||
- perf-test
|
||||
- visual-a11y-tests:
|
||||
name: visual-test-nightly
|
||||
suite: full
|
||||
node-version: lts/hydrogen
|
||||
- e2e-couchdb:
|
||||
node-version: lts/hydrogen
|
||||
- e2e-couchdb
|
||||
triggers:
|
||||
- schedule:
|
||||
cron: '0 0 * * *'
|
||||
|
||||
@@ -490,7 +490,8 @@
|
||||
"Blockquotes",
|
||||
"oger",
|
||||
"lcovonly",
|
||||
"gcov"
|
||||
"gcov",
|
||||
"WCAG"
|
||||
],
|
||||
"dictionaries": ["npm", "softwareTerms", "node", "html", "css", "bash", "en_US"],
|
||||
"ignorePaths": [
|
||||
|
||||
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -8,14 +8,16 @@ Closes <!--- Insert Issue Number(s) this PR addresses. Start by typing # will op
|
||||
|
||||
* [ ] Have you followed the guidelines in our [Contributing document](https://github.com/nasa/openmct/blob/master/CONTRIBUTING.md)?
|
||||
* [ ] Have you checked to ensure there aren't other open [Pull Requests](https://github.com/nasa/openmct/pulls) for the same update/change?
|
||||
* [ ] Is this a notable change that will require a special callout in the release notes [Notable Change](../docs/src/process/release.md) ? For example, will this break compatibility with existing APIs or projects which source these plugins?
|
||||
* [ ] Is this change backwards compatible? For example, developers won't need to change how they are calling the API or how they've extended core plugins such as Tables or Plots.
|
||||
|
||||
### Author Checklist
|
||||
|
||||
* [ ] Changes address original issue?
|
||||
* [ ] Tests included and/or updated with changes?
|
||||
* [ ] Command line build passes?
|
||||
* [ ] Has this been smoke tested?
|
||||
* [ ] Have you associated this PR with a `type:` label? Note: this is not necessarily the same as the original issue.
|
||||
* [ ] Have you associated a milestone with this PR? Note: leave blank if unsure.
|
||||
* [ ] Is this a breaking change to be called out in the release notes?
|
||||
* [ ] Testing instructions included in associated issue OR is this a dependency/testcase change?
|
||||
|
||||
### Reviewer Checklist
|
||||
@@ -25,5 +27,3 @@ Closes <!--- Insert Issue Number(s) this PR addresses. Start by typing # will op
|
||||
* [ ] Changes appear not to be breaking changes?
|
||||
* [ ] Appropriate automated tests included?
|
||||
* [ ] Code style and in-line documentation are appropriate?
|
||||
* [ ] Has associated issue been labelled unverified? (only applicable if this PR closes the issue)
|
||||
* [ ] Has associated issue been labelled bug? (only applicable if this PR is for a bug fix)
|
||||
|
||||
5
.github/release.yml
vendored
5
.github/release.yml
vendored
@@ -1,8 +1,5 @@
|
||||
changelog:
|
||||
categories:
|
||||
- title: 💥 Notable Changes
|
||||
labels:
|
||||
- notable_change
|
||||
- title: 🏕 Features
|
||||
labels:
|
||||
- type:feature
|
||||
@@ -23,4 +20,4 @@ changelog:
|
||||
- dependencies
|
||||
- title: 🐛 Bug Fixes
|
||||
labels:
|
||||
- "*"
|
||||
- '*'
|
||||
|
||||
6
.github/workflows/codeql-analysis.yml
vendored
6
.github/workflows/codeql-analysis.yml
vendored
@@ -31,14 +31,14 @@ jobs:
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
config-file: ./.github/codeql/codeql-config.yml
|
||||
languages: javascript
|
||||
queries: security-and-quality
|
||||
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
uses: github/codeql-action/autobuild@v3
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
uses: github/codeql-action/analyze@v3
|
||||
|
||||
2
.github/workflows/pr-platform.yml
vendored
2
.github/workflows/pr-platform.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
node_version:
|
||||
- lts/gallium
|
||||
- lts/iron
|
||||
- lts/hydrogen
|
||||
architecture:
|
||||
- x64
|
||||
|
||||
22
.github/workflows/prcop.yml
vendored
22
.github/workflows/prcop.yml
vendored
@@ -3,17 +3,17 @@ name: PRCop
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- labeled
|
||||
- unlabeled
|
||||
- opened
|
||||
- reopened
|
||||
- edited
|
||||
- synchronize
|
||||
- ready_for_review
|
||||
- review_requested
|
||||
- review_request_removed
|
||||
- edited
|
||||
pull_request_review_comment:
|
||||
types:
|
||||
- created
|
||||
|
||||
env:
|
||||
LABELS: ${{ join( github.event.pull_request.labels.*.name, ' ' ) }}
|
||||
jobs:
|
||||
prcop:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -24,3 +24,15 @@ jobs:
|
||||
with:
|
||||
config-file: '.github/workflows/prcop-config.json'
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
check-type-label:
|
||||
name: Check type Label
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- if: contains( env.LABELS, 'type:' ) == false
|
||||
run: exit 1
|
||||
check-milestone:
|
||||
name: Check Milestone
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- if: github.event.pull_request.milestone == null && contains( env.LABELS, 'no milestone' ) == false
|
||||
run: exit 1
|
||||
|
||||
@@ -69,10 +69,9 @@ const config = {
|
||||
csv: 'comma-separated-values',
|
||||
EventEmitter: 'eventemitter3',
|
||||
bourbon: 'bourbon.scss',
|
||||
'plotly-basic': 'plotly.js-basic-dist',
|
||||
'plotly-gl2d': 'plotly.js-gl2d-dist',
|
||||
'd3-scale': path.join(projectRootDir, 'node_modules/d3-scale/dist/d3-scale.min.js'),
|
||||
printj: path.join(projectRootDir, 'node_modules/printj/dist/printj.min.js'),
|
||||
'plotly-basic': 'plotly.js-basic-dist-min',
|
||||
'plotly-gl2d': 'plotly.js-gl2d-dist-min',
|
||||
printj: 'printj/printj.mjs',
|
||||
styles: path.join(projectRootDir, 'src/styles'),
|
||||
MCT: path.join(projectRootDir, 'src/MCT'),
|
||||
testUtils: path.join(projectRootDir, 'src/utils/testUtils.js'),
|
||||
|
||||
6
API.md
6
API.md
@@ -1315,17 +1315,19 @@ The show function is responsible for the rendering of a view. An [Intersection O
|
||||
|
||||
### Implementing Visibility-Based Rendering
|
||||
|
||||
The `renderWhenVisible` function is passed to the show function as a required part of the `viewOptions` object. This function should be used for all rendering logic that would otherwise be executed within a `requestAnimationFrame` call. When called, `renderWhenVisible` will either execute the provided function immediately (via `requestAnimationFrame`) if the view is currently visible, or defer its execution until the view becomes visible.
|
||||
The `renderWhenVisible` function is passed to the show function as part of the `viewOptions` object. This function can be used for all rendering logic that would otherwise be executed within a `requestAnimationFrame` call. When called, `renderWhenVisible` will either execute the provided function immediately (via `requestAnimationFrame`) if the view is currently visible, or defer its execution until the view becomes visible.
|
||||
|
||||
Additionally, `renderWhenVisible` returns a boolean value indicating whether the provided function was executed immediately (`true`) or deferred (`false`).
|
||||
|
||||
Monitoring of visibility begins after the first call to `renderWhenVisible` is made.
|
||||
|
||||
Here’s the signature for the show function:
|
||||
|
||||
`show(element, isEditing, viewOptions)`
|
||||
|
||||
* `element` (HTMLElement) - The DOM element where the view should be rendered.
|
||||
* `isEditing` (boolean) - Indicates whether the view is in editing mode.
|
||||
* `viewOptions` (Object) - A required object with configuration options for the view, including:
|
||||
* `viewOptions` (Object) - An object with configuration options for the view, including:
|
||||
* `renderWhenVisible` (Function) - This function wraps the `requestAnimationFrame` and only triggers the provided render logic when the view is visible in the viewport.
|
||||
|
||||
### Example
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Open MCT [](http://www.apache.org/licenses/LICENSE-2.0) [](https://codecov.io/gh/nasa/openmct) [](https://percy.io/b2e34b17/openmct) [](https://www.npmjs.com/package/openmct)
|
||||
# Open MCT [](http://www.apache.org/licenses/LICENSE-2.0) [](https://codecov.io/gh/nasa/openmct) [](https://percy.io/b2e34b17/openmct) [](https://www.npmjs.com/package/openmct) 
|
||||
|
||||
Open MCT (Open Mission Control Technologies) is a next-generation mission control framework for visualization of data on desktop and mobile devices. It is developed at NASA's Ames Research Center, and is being used by NASA for data analysis of spacecraft missions, as well as planning and operation of experimental rover systems. As a generalizable and open source framework, Open MCT could be used as the basis for building applications for planning, operation, and analysis of any systems producing telemetry data.
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
|
||||
# Release of NASA Open MCT NPM Package
|
||||
|
||||
This document outlines the process and key considerations for releasing a new version of the NASA Open MCT project as an NPM (Node Package Manager) package.
|
||||
|
||||
## 1. Pre-requisites
|
||||
|
||||
Before releasing a new version of the NASA Open MCT NPM package, ensure all dependencies are updated, and comprehensive tests are performed. This ensures compatibility and performance of the Open MCT within the Node.js ecosystem.
|
||||
|
||||
## 2. Versioning
|
||||
|
||||
Versioning is a critical step for package release. The Open MCT team follows [Semantic Versioning (SemVer)](https://semver.org) that consists of three major components: MAJOR.MINOR.PATCH. These ensure a structured process for updating, bug fixes, backward compatibility, and software progress.
|
||||
|
||||
## 3. Changelog Maintenance
|
||||
|
||||
A comprehensive changelog file, `CHANGELOG.md`, documents any changes, adding a high level of transparencies for anyone desiring to look into the status of new and past progress. It includes the summation of any major new enhancements, changes, bug fixes, and the credits to the users responsible for each unique progress.
|
||||
|
||||
## 4. Notable Changes Labels on GitHub PRs
|
||||
|
||||
For the Open MCT package, we leverage GitHub's Pull Request (PR) mechanisms extensively, with three important PR labels dedicated to signifying 'notable_changes':
|
||||
|
||||
- **Breaking Change** Highlights the integration of changes that are suspected to break, or without a doubt will break, backward compatibility. These should signal to users the upgrade might be seamless only if dependency and integration factors are properly managed, if not, one should expect to manage atypical technical snags.
|
||||
- **API change** Signifies when a contribution makes any complete or under layer changes to the communication or its supporting access processes. This label flags required see-through insight on how the web-based control panel sees and manipulates any value and or network logs.
|
||||
- **Default Behavior Change:** In the incident an update either adjusts a form to or integrates a not previously kept setting or plugin. i.e. autoscale is enabled by default when working with plots.
|
||||
|
||||
## 6. Community & Contributions
|
||||
|
||||
A flat community and the rounded center are kept in continuous celebration, with the given station open for two open-specifying dialogues, research, and all-for development probing. State the ownership for a handed looped, a welcome for even structure-core and architectural draft and impend.
|
||||
|
||||
Thank you for your collaboration and commitment to moving the project onto a text big club.
|
||||
@@ -21,4 +21,8 @@ snapshot:
|
||||
/* Embedded timestamp in notebooks */
|
||||
.c-ne__embed__time{
|
||||
opacity: 0 !important;
|
||||
}
|
||||
/* Time Conductor Start Time */
|
||||
.c-compact-tc__setting-value{
|
||||
opacity: 0 !important;
|
||||
}
|
||||
@@ -21,4 +21,8 @@ snapshot:
|
||||
/* Embedded timestamp in notebooks */
|
||||
.c-ne__embed__time{
|
||||
opacity: 0 !important;
|
||||
}
|
||||
/* Time Conductor Start Time */
|
||||
.c-compact-tc__setting-value{
|
||||
opacity: 0 !important;
|
||||
}
|
||||
@@ -51,11 +51,13 @@ Next, you should walk through our implementation of Playwright in Open MCT:
|
||||
|
||||
## Types of e2e Testing
|
||||
|
||||
e2e testing describes the layer at which a test is performed without prescribing the assertions which are made. Generally, when writing an e2e test, we have three choices to make on an assertion strategy:
|
||||
e2e testing describes the layer at which a test is performed without prescribing the assertions which are made. Generally, when writing an e2e test, we have five choices to make on an assertion strategy:
|
||||
|
||||
1. Functional - Verifies the functional correctness of the application. Sometimes interchanged with e2e or regression testing.
|
||||
2. Visual - Verifies the "look and feel" of the application and can only detect _undesirable changes when compared to a previous baseline_.
|
||||
3. Snapshot - Similar to Visual in that it captures the "look" of the application and can only detect _undesirable changes when compared to a previous baseline_. **Generally not preferred due to advanced setup necessary.**
|
||||
4. Accessibility - Verifies that the application meets the accessibility standards defined by the [WCAG organization](https://www.w3.org/WAI/standards-guidelines/wcag/).
|
||||
5. Performance - Verifies that application provides a performant experience. Like Snapshot testing, these tests are generally not recommended due to their difficulty in providing a consistent result.
|
||||
|
||||
When choosing between the different testing strategies, think only about the assertion that is made at the end of the series of test steps. "I want to verify that the Timer plugin functions correctly" vs "I want to verify that the Timer plugin does not look different than originally designed".
|
||||
|
||||
@@ -132,6 +134,35 @@ npm install
|
||||
npm run test:e2e:updatesnapshots
|
||||
```
|
||||
|
||||
## Automated Accessibility (a11y) Testing
|
||||
|
||||
Open MCT incorporates accessibility testing through two primary methods to ensure its compliance with accessibility standards:
|
||||
|
||||
1. **Usage of Playwright's Locator Strategy**: Open MCT utilizes Playwright's locator strategy, specifically the [page.getByRole('') function](https://playwright.dev/docs/api/class-framelocator#frame-locator-get-by-role), to ensure that web elements are accessible via assistive technologies. This approach focuses on the accessibility of elements rather than full adherence to a11y guidelines, which is covered in the second method.
|
||||
|
||||
2. **Enforcing a11y Guidelines with Playwright Axe Plugin**: To rigorously enforce a11y guideline compliance, Open MCT employs the [playwright axe plugin](https://playwright.dev/docs/accessibility-testing). This is achieved through the `scanForA11yViolations` function within the visual testing suite. This method not only benefits from the existing coverage of the visual tests but also targets specific a11y issues, such as `color-contrast` violations, which are particularly pertinent in the context of visual testing.
|
||||
|
||||
### a11y Standards (WCAG and Section 508)
|
||||
|
||||
Playwright axe supports a wide range of [WCAG Standards](https://playwright.dev/docs/accessibility-testing#scanning-for-wcag-violations) to test against. Open MCT is testing against the [Section 508](https://www.section508.gov/test/testing-overview/) accessibility guidelines with the intent to support higher standards over time. As of 2024, Section508 requirements now map completely to WCAG 2.0 AA. In the future, Section 508 requirements may map to WCAG 2.1 AA.
|
||||
|
||||
### Reading an a11y test failure
|
||||
|
||||
When an a11y test fails, the result must be interpreted in the html test report or the a11y report json artifact stored in the `/test-results/` folder. The json structure should be parsed for `"violations"` by `"id"` and identified `"target"`. Example provided for the 'color-contrast-enhanced' violation.
|
||||
|
||||
```json
|
||||
"violations":
|
||||
{
|
||||
"id": "color-contrast-enhanced",
|
||||
"impact": "serious",
|
||||
"html": "<span class=\"label c-indicator__label\">0 Snapshots <button aria-label=\"Show Snapshots\">Show</button></span>",
|
||||
"target": [
|
||||
".s-status-off > .label.c-indicator__label"
|
||||
],
|
||||
"failureSummary": "Fix any of the following:\n Element has insufficient color contrast of 6.51 (foreground color: #aaaaaa, background color: #262626, font size: 8.1pt (10.8px), font weight: normal). Expected contrast ratio of 7:1"
|
||||
}
|
||||
```
|
||||
|
||||
## Performance Testing
|
||||
|
||||
The open source performance tests function in three ways which match their naming and folder structure:
|
||||
@@ -142,6 +173,8 @@ The open source performance tests function in three ways which match their namin
|
||||
|
||||
These tests are expected to become blocking and gating with assertions as we extend the capabilities of Playwright.
|
||||
|
||||
In addition to the explicit definition of performance tests, we also ensure that our test timeout timing is "tight" to catch performance regressions detectable by action timeouts. i.e. [Notebooks load much slower than they used to #6459](https://github.com/nasa/openmct/issues/6459)
|
||||
|
||||
## Test Architecture and CI
|
||||
|
||||
### Architecture
|
||||
@@ -161,8 +194,8 @@ Our file structure follows the type of type of testing being excercised at the e
|
||||
|`./tests/performance/` | Performance tests which should be run on every commit.|
|
||||
|`./tests/performance/contract/` | A subset of performance tests which are designed to provide a contract between the open source tests which are run on every commit and the downstream tests which are run post merge and with other frameworks.|
|
||||
|`./tests/performance/memory` | A subset of performance tests which are designed to test for memory leaks.|
|
||||
|`./tests/visual/` | Visual tests.|
|
||||
|`./tests/visual/component/` | Visual tests which are only run against a single component.|
|
||||
|`./tests/visual-a11y/` | Visual tests and accessibility tests.|
|
||||
|`./tests/visual-a11y/component/` | Visual and accessibility tests which are only run against a single component.|
|
||||
|`./appActions.js` | Contains common methods which can be leveraged by test case authors to quickly move through the application when writing new tests.|
|
||||
|`./baseFixture.js` | Contains base fixtures which only extend default `@playwright/test` functionality. The expectation is that these fixtures will be removed as the native Playwright API improves|
|
||||
|
||||
@@ -180,7 +213,7 @@ Open MCT is leveraging the [config file](https://playwright.dev/docs/test-config
|
||||
|`./playwright-local.config.js` | Used when running locally|
|
||||
|`./playwright-performance.config.js` | Used when running performance tests in CI or locally|
|
||||
|`./playwright-performance-devmode.config.js` | Used when running performance tests in CI or locally|
|
||||
|`./playwright-visual.config.js` | Used to run the visual tests in CI or locally|
|
||||
|`./playwright-visual-a11y.config.js` | Used to run the visual and a11y tests in CI or locally|
|
||||
|
||||
#### Test Tags
|
||||
|
||||
@@ -191,6 +224,7 @@ Current list of test tags:
|
||||
|Test Tag|Description|
|
||||
|:-:|-|
|
||||
|`@ipad` | Test case or test suite is compatible with Playwright's iPad support and Open MCT's read-only mobile view (i.e. no create button).|
|
||||
|`@a11y` | Test case or test suite to execute playwright-axe accessibility checks and generate a11y reports.|
|
||||
|`@gds` | Denotes a GDS Test Case used in the VIPER Mission.|
|
||||
|`@addInit` | Initializes the browser with an injected and artificial state. Useful for loading non-default plugins. Likely will not work outside of `npm start`.|
|
||||
|`@localStorage` | Captures or generates session storage to manipulate browser state. Useful for excluding in tests which require a persistent backend (i.e. CouchDB). See [note](#utilizing-localstorage)|
|
||||
@@ -216,7 +250,7 @@ CircleCI
|
||||
- Stable e2e tests against ubuntu and chrome
|
||||
- Performance tests against ubuntu and chrome
|
||||
- e2e tests are linted
|
||||
- Visual tests are run in a single resolution on the default `espresso` theme
|
||||
- Visual and a11y tests are run in a single resolution on the default `espresso` theme
|
||||
|
||||
#### 2. Per-Merge Testing
|
||||
|
||||
@@ -232,7 +266,7 @@ Nightly Testing in Circle CI
|
||||
- Full e2e suite against ubuntu and chrome, firefox, and an MMOC resolution profile
|
||||
- Performance tests against ubuntu and chrome
|
||||
- CouchDB suite
|
||||
- Visual Tests are run in the full profile
|
||||
- Visual and a11y Tests are run in the full profile
|
||||
|
||||
Github Actions / Workflow
|
||||
|
||||
@@ -405,7 +439,7 @@ By adhering to this principle, we can create tests that are both robust and refl
|
||||
5. **Hide the Tree and Inspector**: Generally, your test will not require comparisons involving the tree and inspector. These aspects are covered in component-specific tests (explained below). To exclude them from the comparison by default, navigate to the root of the main view with the tree and inspector hidden:
|
||||
- `await page.goto('./#/browse/mine?hideTree=true&hideInspector=true')`
|
||||
|
||||
6. **Component-Specific Tests**: If you wish to focus on a particular component, use the `/visual/component/` folder and limit the scope of the comparison to that component. For instance:
|
||||
6. **Component-Specific Tests**: If you wish to focus on a particular component, use the `/visual-a11y/component/` folder and limit the scope of the comparison to that component. For instance:
|
||||
```js
|
||||
await percySnapshot(page, `Tree Pane w/ single level expanded (theme: ${theme})`, {
|
||||
scope: treePane
|
||||
|
||||
97
e2e/avpFixtures.js
Normal file
97
e2e/avpFixtures.js
Normal file
@@ -0,0 +1,97 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2023, 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.
|
||||
*****************************************************************************/
|
||||
|
||||
/**
|
||||
* avpFixtures.js
|
||||
*
|
||||
* @file This module provides custom fixtures specifically tailored for Accessibility, Visual, and Performance (AVP) tests.
|
||||
* These fixtures extend the base functionality of the Playwright fixtures and appActions, and are designed to be
|
||||
* generalized across all plugins. They offer functionalities like scanning for accessibility violations, integrating
|
||||
* with axe-core, and more.
|
||||
*
|
||||
* IMPORTANT NOTE: This fixture file is not intended to be extended further by other fixtures. If you find yourself
|
||||
* needing to do so, please consult the documentation and consider creating a specialized fixture or modifying the
|
||||
* existing ones.
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { test, expect } = require('./pluginFixtures');
|
||||
const AxeBuilder = require('@axe-core/playwright').default;
|
||||
|
||||
// Constants for repeated values
|
||||
const TEST_RESULTS_DIR = './test-results';
|
||||
|
||||
/**
|
||||
* Scans for accessibility violations on a page and writes a report to disk if violations are found.
|
||||
* Automatically asserts that no violations should be present.
|
||||
*
|
||||
* @typedef {object} GenerateReportOptions
|
||||
* @property {string} [reportName] - The name for the report file.
|
||||
*
|
||||
* @param {import('playwright').Page} page - The page object from Playwright.
|
||||
* @param {string} testCaseName - The name of the test case.
|
||||
* @param {GenerateReportOptions} [options={}] - The options for the report generation.
|
||||
*
|
||||
* @returns {Promise<object|null>} Returns the accessibility scan results if violations are found,
|
||||
* otherwise returns null.
|
||||
*/
|
||||
/* eslint-disable no-undef */
|
||||
exports.scanForA11yViolations = async function (page, testCaseName, options = {}) {
|
||||
const builder = new AxeBuilder({ page });
|
||||
builder.withTags(['wcag2aa']);
|
||||
// https://github.com/dequelabs/axe-core/blob/develop/doc/rule-descriptions.md
|
||||
builder.disableRules(['color-contrast']);
|
||||
const accessibilityScanResults = await builder.analyze();
|
||||
|
||||
// Assert that no violations should be present
|
||||
expect(
|
||||
accessibilityScanResults.violations,
|
||||
`Accessibility violations found in test case: ${testCaseName}`
|
||||
).toEqual([]);
|
||||
|
||||
// Check if there are any violations
|
||||
if (accessibilityScanResults.violations.length > 0) {
|
||||
let reportName = options.reportName || testCaseName;
|
||||
let sanitizedReportName = reportName.replace(/\//g, '_');
|
||||
const reportPath = path.join(TEST_RESULTS_DIR, `${sanitizedReportName}.json`);
|
||||
|
||||
try {
|
||||
if (!fs.existsSync(TEST_RESULTS_DIR)) {
|
||||
fs.mkdirSync(TEST_RESULTS_DIR);
|
||||
}
|
||||
|
||||
fs.writeFileSync(reportPath, JSON.stringify(accessibilityScanResults, null, 2));
|
||||
console.log(`Accessibility report with violations saved successfully as ${reportPath}`);
|
||||
return accessibilityScanResults;
|
||||
} catch (err) {
|
||||
console.error(`Error writing the accessibility report to file ${reportPath}:`, err);
|
||||
throw err;
|
||||
}
|
||||
} else {
|
||||
console.log('No accessibility violations found, no report generated.');
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
exports.expect = expect;
|
||||
exports.test = test;
|
||||
30
e2e/helper/addInitDataVisualization.js
Normal file
30
e2e/helper/addInitDataVisualization.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2023, 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 should be used to install the Example User
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const openmct = window.openmct;
|
||||
openmct.install(openmct.plugins.example.ExampleDataVisualizationSourcePlugin());
|
||||
openmct.install(
|
||||
openmct.plugins.InspectorDataVisualization({ type: 'exampleDataVisualizationSource' })
|
||||
);
|
||||
});
|
||||
@@ -81,6 +81,30 @@ function activitiesWithinTimeBounds(start1, end1, start2, end2) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the swim lanes / groups in the plan view matches the order of
|
||||
* groups in the plan data.
|
||||
* @param {import('@playwright/test').Page} page the page
|
||||
* @param {object} plan The raw plan json to assert against
|
||||
* @param {string} objectUrl The URL of the object to assert against (plan or gantt chart)
|
||||
*/
|
||||
export async function assertPlanOrderedSwimLanes(page, plan, objectUrl) {
|
||||
// Switch to the plan view
|
||||
await page.goto(`${objectUrl}?view=plan.view`);
|
||||
const planGroups = await page
|
||||
.locator('.c-plan__contents > div > .c-swimlane__lane-label .c-object-label__name')
|
||||
.all();
|
||||
|
||||
const groups = plan.Groups;
|
||||
|
||||
for (let i = 0; i < groups.length; i++) {
|
||||
// Assert that the order of groups in the plan view matches the order of
|
||||
// groups in the plan data
|
||||
const groupName = await planGroups[i].innerText();
|
||||
expect(groupName).toEqual(groups[i].name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to the plan view, switch to fixed time mode,
|
||||
* and set the bounds to span all activities.
|
||||
@@ -110,3 +134,23 @@ export async function setDraftStatusForPlan(page, plan) {
|
||||
await window.openmct.status.set(planObject.uuid, 'draft');
|
||||
}, plan);
|
||||
}
|
||||
|
||||
export async function addPlanGetInterceptor(page) {
|
||||
await page.waitForLoadState('load');
|
||||
await page.evaluate(async () => {
|
||||
await window.openmct.objects.addGetInterceptor({
|
||||
appliesTo: (identifier, domainObject) => {
|
||||
return domainObject && domainObject.type === 'plan';
|
||||
},
|
||||
invoke: (identifier, object) => {
|
||||
if (object) {
|
||||
object.sourceMap = {
|
||||
orderedGroups: 'Groups'
|
||||
};
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
189
e2e/helper/plotTagsUtils.js
Normal file
189
e2e/helper/plotTagsUtils.js
Normal file
@@ -0,0 +1,189 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2023, 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.
|
||||
*****************************************************************************/
|
||||
|
||||
import { expect } from '../pluginFixtures';
|
||||
const { waitForPlotsToRender } = require('../appActions');
|
||||
|
||||
/**
|
||||
* Given a canvas and a set of points, tags the points on the canvas.
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {HTMLCanvasElement} canvas a telemetry item with a plot
|
||||
* @param {Number} xEnd a telemetry item with a plot
|
||||
* @param {Number} yEnd a telemetry item with a plot
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export async function createTags({ page, canvas, xEnd = 700, yEnd = 520 }) {
|
||||
await canvas.hover({ trial: true });
|
||||
|
||||
//Alt+Shift Drag Start to select some points to tag
|
||||
await page.keyboard.down('Alt');
|
||||
await page.keyboard.down('Shift');
|
||||
|
||||
await canvas.dragTo(canvas, {
|
||||
sourcePosition: {
|
||||
x: 1,
|
||||
y: 1
|
||||
},
|
||||
targetPosition: {
|
||||
x: xEnd,
|
||||
y: yEnd
|
||||
}
|
||||
});
|
||||
|
||||
//Alt Drag End
|
||||
await page.keyboard.up('Alt');
|
||||
await page.keyboard.up('Shift');
|
||||
|
||||
//Wait for canvas to stabilize.
|
||||
await canvas.hover({ trial: true });
|
||||
|
||||
// add some tags
|
||||
await page.getByText('Annotations').click();
|
||||
await page.getByRole('button', { name: /Add Tag/ }).click();
|
||||
await page.getByPlaceholder('Type to select tag').click();
|
||||
await page.getByText('Driving').click();
|
||||
|
||||
await page.getByRole('button', { name: /Add Tag/ }).click();
|
||||
await page.getByPlaceholder('Type to select tag').click();
|
||||
await page.getByText('Science').click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a telemetry item (e.g., a Sine Wave Generator) with a plot, tests that the plot can be tagged.
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {import('../../../../appActions').CreatedObjectInfo} telemetryItem a telemetry item with a plot
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export async function testTelemetryItem(page, telemetryItem) {
|
||||
// Check that telemetry item also received the tag
|
||||
await page.goto(telemetryItem.url);
|
||||
|
||||
await expect(page.getByText('No tags to display for this item')).toBeVisible();
|
||||
|
||||
const canvas = page.locator('canvas').nth(1);
|
||||
//Wait for canvas to stabilize.
|
||||
await waitForPlotsToRender(page);
|
||||
|
||||
await expect(canvas).toBeInViewport();
|
||||
await canvas.hover({ trial: true });
|
||||
|
||||
// click on the tagged plot point
|
||||
await canvas.click({
|
||||
position: {
|
||||
x: 100,
|
||||
y: 100
|
||||
}
|
||||
});
|
||||
|
||||
await expect(page.getByText('Science')).toBeVisible();
|
||||
await expect(page.getByText('Driving')).toBeHidden();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a page, tests that tags are searchable, deletable, and persist across reloads.
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export async function basicTagsTests(page) {
|
||||
// Search for Driving
|
||||
await page.getByRole('searchbox', { name: 'Search Input' }).click();
|
||||
|
||||
// Clicking elsewhere should cause annotation selection to be cleared
|
||||
await expect(page.getByText('No tags to display for this item')).toBeVisible();
|
||||
//
|
||||
await page.getByRole('searchbox', { name: 'Search Input' }).fill('driv');
|
||||
|
||||
// Always click on the first Sine Wave result
|
||||
await page
|
||||
.getByLabel('Search Result')
|
||||
.getByText(/Sine Wave/)
|
||||
.first()
|
||||
.click();
|
||||
|
||||
// Delete Driving Tag
|
||||
await page.hover('[aria-label="Tag"]:has-text("Driving")');
|
||||
await page.locator('[aria-label="Remove tag Driving"]').click();
|
||||
|
||||
// Search for Science Tag
|
||||
await page.getByRole('searchbox', { name: 'Search Input' }).click();
|
||||
await page.getByRole('searchbox', { name: 'Search Input' }).fill('sc');
|
||||
|
||||
//Expect Science Tag to be present and and Driving Tags to be deleted
|
||||
await expect(page.getByLabel('Search Result').first()).toContainText('Science');
|
||||
await expect(page.getByLabel('Search Result').first()).not.toContainText('Driving');
|
||||
|
||||
// Search for Driving Tag and expect nothing found
|
||||
await page.getByRole('searchbox', { name: 'Search Input' }).click();
|
||||
await page.getByRole('searchbox', { name: 'Search Input' }).fill('driv');
|
||||
await expect(page.getByText('No results found')).toBeVisible();
|
||||
|
||||
await page.reload({ waitUntil: 'domcontentloaded' });
|
||||
|
||||
await waitForPlotsToRender(page);
|
||||
|
||||
//Navigate to the Inspector and check that all tags have been removed
|
||||
await expect(page.getByRole('tab', { name: 'Annotations' })).not.toHaveClass(/is-current/);
|
||||
await page.getByRole('tab', { name: 'Annotations' }).click();
|
||||
await expect(page.getByRole('tab', { name: 'Annotations' })).toHaveClass(/is-current/);
|
||||
await expect(page.getByText('No tags to display for this item')).toBeVisible();
|
||||
|
||||
const canvas = page.locator('canvas').nth(1);
|
||||
// click on the tagged plot point
|
||||
await canvas.click({
|
||||
position: {
|
||||
x: 100,
|
||||
y: 100
|
||||
}
|
||||
});
|
||||
|
||||
//Expect Science to be visible but Driving to be hidden
|
||||
await expect(page.getByText('Science')).toBeVisible();
|
||||
await expect(page.getByText('Driving')).toBeHidden();
|
||||
|
||||
//Click elsewhere
|
||||
await page.locator('body').click();
|
||||
//Click on tagged plot point again
|
||||
await canvas.click({
|
||||
position: {
|
||||
x: 100,
|
||||
y: 100
|
||||
}
|
||||
});
|
||||
|
||||
// Add Driving Tag again
|
||||
await page.getByText('Annotations').click();
|
||||
await page.getByRole('button', { name: /Add Tag/ }).click();
|
||||
await page.getByPlaceholder('Type to select tag').click();
|
||||
await page.getByText('Driving').click();
|
||||
|
||||
//Science and Driving Tags should be visible
|
||||
await expect(page.getByText('Science')).toBeVisible();
|
||||
await expect(page.getByText('Driving')).toBeVisible();
|
||||
|
||||
// Delete Driving Tag again
|
||||
await page.hover('[aria-label="Tag"]:has-text("Driving")');
|
||||
await page.locator('[aria-label="Remove tag Driving"]').click();
|
||||
|
||||
//Science Tag should be visible and Driving Tag should be hidden
|
||||
await expect(page.getByText('Science')).toBeVisible();
|
||||
await expect(page.getByText('Driving')).toBeHidden();
|
||||
}
|
||||
@@ -17,7 +17,7 @@ const config = {
|
||||
command: 'npm run start:coverage',
|
||||
url: 'http://localhost:8080/#',
|
||||
timeout: 200 * 1000,
|
||||
reuseExistingServer: false
|
||||
reuseExistingServer: true //This was originally disabled to prevent differences in local debugging vs. CI. However, it significantly speeds up local debugging.
|
||||
},
|
||||
maxFailures: MAX_FAILURES, //Limits failures to 5 to reduce CI Waste
|
||||
workers: NUM_WORKERS, //Limit to 2 for CircleCI Agent
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/** @type {import('@playwright/test').PlaywrightTestConfig<{ theme: string }>} */
|
||||
const config = {
|
||||
retries: 0, // Visual tests should never retry due to snapshot comparison errors. Leaving as a shim
|
||||
testDir: 'tests/visual',
|
||||
testDir: 'tests/visual-a11y',
|
||||
testMatch: '**/*.visual.spec.js', // only run visual tests
|
||||
timeout: 60 * 1000,
|
||||
workers: 1, //Lower stress on Circle CI Agent for Visual tests https://github.com/percy/cli/discussions/1067
|
||||
54
e2e/test-data/examplePlans/ExamplePlanWithOrderedLanes.json
Normal file
54
e2e/test-data/examplePlans/ExamplePlanWithOrderedLanes.json
Normal file
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"Groups": [
|
||||
{
|
||||
"name": "Group 1"
|
||||
},
|
||||
{
|
||||
"name": "Group 2"
|
||||
}
|
||||
],
|
||||
"Group 2": [
|
||||
{
|
||||
"name": "Past event 3",
|
||||
"start": 1660493208000,
|
||||
"end": 1660503981000,
|
||||
"type": "Group 2",
|
||||
"color": "orange",
|
||||
"textColor": "white"
|
||||
},
|
||||
{
|
||||
"name": "Past event 4",
|
||||
"start": 1660579608000,
|
||||
"end": 1660624108000,
|
||||
"type": "Group 2",
|
||||
"color": "orange",
|
||||
"textColor": "white"
|
||||
},
|
||||
{
|
||||
"name": "Past event 5",
|
||||
"start": 1660666008000,
|
||||
"end": 1660681529000,
|
||||
"type": "Group 2",
|
||||
"color": "orange",
|
||||
"textColor": "white"
|
||||
}
|
||||
],
|
||||
"Group 1": [
|
||||
{
|
||||
"name": "Past event 1",
|
||||
"start": 1660320408000,
|
||||
"end": 1660343797000,
|
||||
"type": "Group 1",
|
||||
"color": "orange",
|
||||
"textColor": "white"
|
||||
},
|
||||
{
|
||||
"name": "Past event 2",
|
||||
"start": 1660406808000,
|
||||
"end": 1660429160000,
|
||||
"type": "Group 1",
|
||||
"color": "orange",
|
||||
"textColor": "white"
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -21,8 +21,13 @@
|
||||
*****************************************************************************/
|
||||
const { test } = require('../../../pluginFixtures');
|
||||
const { createPlanFromJSON } = require('../../../appActions');
|
||||
const { addPlanGetInterceptor } = require('../../../helper/planningUtils.js');
|
||||
const testPlan1 = require('../../../test-data/examplePlans/ExamplePlan_Small1.json');
|
||||
const { assertPlanActivities } = require('../../../helper/planningUtils');
|
||||
const testPlanWithOrderedLanes = require('../../../test-data/examplePlans/ExamplePlanWithOrderedLanes.json');
|
||||
const {
|
||||
assertPlanActivities,
|
||||
assertPlanOrderedSwimLanes
|
||||
} = require('../../../helper/planningUtils');
|
||||
|
||||
test.describe('Plan', () => {
|
||||
let plan;
|
||||
@@ -36,4 +41,14 @@ test.describe('Plan', () => {
|
||||
test('Displays all plan events', async ({ page }) => {
|
||||
await assertPlanActivities(page, testPlan1, plan.url);
|
||||
});
|
||||
|
||||
test('Displays plans with ordered swim lanes configuration', async ({ page }) => {
|
||||
// Add configuration for swim lanes
|
||||
await addPlanGetInterceptor(page);
|
||||
// Create the plan
|
||||
const planWithSwimLanes = await createPlanFromJSON(page, {
|
||||
json: testPlanWithOrderedLanes
|
||||
});
|
||||
await assertPlanOrderedSwimLanes(page, testPlanWithOrderedLanes, planWithSwimLanes.url);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -284,16 +284,29 @@ test.describe('Flexible Layout Toolbar Actions @localStorage', () => {
|
||||
type: 'issue',
|
||||
description: 'https://github.com/nasa/openmct/issues/7234'
|
||||
});
|
||||
await page.locator('div:nth-child(5) > .c-fl-container__frames-holder').click();
|
||||
expect(await page.locator('.c-fl-container').count()).toEqual(2);
|
||||
expect(await page.getByRole('group', { name: 'Container' }).count()).toEqual(2);
|
||||
await page.getByRole('group', { name: 'Container' }).nth(1).click();
|
||||
await page.getByTitle('Add Container').click();
|
||||
expect(await page.locator('.c-fl-container').count()).toEqual(3);
|
||||
expect(await page.getByRole('group', { name: 'Container' }).count()).toEqual(3);
|
||||
await page.getByTitle('Remove Container').click();
|
||||
await expect(page.getByRole('dialog')).toHaveText(
|
||||
'This action will permanently delete this container from this Flexible Layout. Do you want to continue?'
|
||||
);
|
||||
await page.getByRole('button', { name: 'OK' }).click();
|
||||
expect(await page.locator('.c-fl-container').count()).toEqual(2);
|
||||
expect(await page.getByRole('group', { name: 'Container' }).count()).toEqual(2);
|
||||
});
|
||||
test('Remove Frame', async ({ page }) => {
|
||||
expect(await page.getByRole('group', { name: 'Frame' }).count()).toEqual(2);
|
||||
await page.getByRole('group', { name: 'Child Layout 1' }).click();
|
||||
await page.getByTitle('Remove Frame').click();
|
||||
await expect(page.getByRole('dialog')).toHaveText(
|
||||
'This action will remove this frame from this Flexible Layout. Do you want to continue?'
|
||||
);
|
||||
await page.getByRole('button', { name: 'OK' }).click();
|
||||
expect(await page.getByRole('group', { name: 'Frame' }).count()).toEqual(1);
|
||||
});
|
||||
test('Columns/Rows Layout Toggle', async ({ page }) => {
|
||||
await page.locator('div:nth-child(5) > .c-fl-container__frames-holder').click();
|
||||
await page.getByRole('group', { name: 'Container' }).nth(1).click();
|
||||
expect(await page.locator('.c-fl--rows').count()).toEqual(0);
|
||||
await page.getByTitle('Columns layout').click();
|
||||
expect(await page.locator('.c-fl--rows').count()).toEqual(1);
|
||||
|
||||
@@ -247,6 +247,14 @@ test.describe('Example Imagery Object', () => {
|
||||
await page.mouse.click(canvasCenterX - 50, canvasCenterY - 50);
|
||||
await expect(page.getByText('Driving')).toBeVisible();
|
||||
await expect(page.getByText('Science')).toBeVisible();
|
||||
|
||||
// add another tag and expect it to appear without changing selection
|
||||
await page.getByRole('button', { name: /Add Tag/ }).click();
|
||||
await page.getByPlaceholder('Type to select tag').click();
|
||||
await page.getByText('Drilling').click();
|
||||
await expect(page.getByText('Driving')).toBeVisible();
|
||||
await expect(page.getByText('Science')).toBeVisible();
|
||||
await expect(page.getByText('Drilling')).toBeVisible();
|
||||
});
|
||||
|
||||
test('Can use + - buttons to zoom on the image @unstable', async ({ page }) => {
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2023, 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.
|
||||
*****************************************************************************/
|
||||
/* global __dirname */
|
||||
|
||||
const { test, expect } = require('../../../../pluginFixtures');
|
||||
const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||
const path = require('path');
|
||||
|
||||
test.describe('Testing numeric data with inspector data visualization (i.e., data pivoting)', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
// eslint-disable-next-line no-undef
|
||||
await page.addInitScript({
|
||||
path: path.join(__dirname, '../../../../helper/', 'addInitDataVisualization.js')
|
||||
});
|
||||
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||
});
|
||||
|
||||
test('Can click on telemetry and see data in inspector', async ({ page }) => {
|
||||
const exampleDataVisualizationSource = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Example Data Visualization Source'
|
||||
});
|
||||
await createDomainObjectWithDefaults(page, {
|
||||
type: 'Sine Wave Generator',
|
||||
name: 'First Sine Wave Generator',
|
||||
parent: exampleDataVisualizationSource.uuid
|
||||
});
|
||||
await createDomainObjectWithDefaults(page, {
|
||||
type: 'Sine Wave Generator',
|
||||
name: 'Second Sine Wave Generator',
|
||||
parent: exampleDataVisualizationSource.uuid
|
||||
});
|
||||
|
||||
await page.goto(exampleDataVisualizationSource.url);
|
||||
|
||||
await page.getByRole('tab', { name: 'Data Visualization' }).click();
|
||||
await page.getByRole('cell', { name: /First Sine Wave Generator/ }).click();
|
||||
await expect(page.getByText('Numeric Data')).toBeVisible();
|
||||
await expect(
|
||||
page.locator('span.plot-series-name', { hasText: 'First Sine Wave Generator Hz' })
|
||||
).toBeVisible();
|
||||
await expect(page.locator('.js-series-data-loaded')).toBeVisible();
|
||||
|
||||
await page.getByRole('cell', { name: /Second Sine Wave Generator/ }).click();
|
||||
await expect(page.getByText('Numeric Data')).toBeVisible();
|
||||
await expect(
|
||||
page.locator('span.plot-series-name', { hasText: 'Second Sine Wave Generator Hz' })
|
||||
).toBeVisible();
|
||||
await expect(page.locator('.js-series-data-loaded')).toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -32,12 +32,25 @@ const path = require('path');
|
||||
const NOTEBOOK_NAME = 'Notebook';
|
||||
|
||||
test.describe('Notebook CRUD Operations', () => {
|
||||
test.fixme('Can create a Notebook Object', async ({ page }) => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
//Navigate to baseURL
|
||||
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||
});
|
||||
test('Can create a Notebook Object', async ({ page }) => {
|
||||
//Create domain object
|
||||
await createDomainObjectWithDefaults(page, {
|
||||
type: NOTEBOOK_NAME
|
||||
});
|
||||
//Newly created notebook should have one Section and one page, 'Unnamed Section'/'Unnamed Page'
|
||||
const notebookSectionNames = page.locator('.c-notebook__sections .c-list__item__name');
|
||||
const notebookPageNames = page.locator('.c-notebook__pages .c-list__item__name');
|
||||
await expect(notebookSectionNames).toBeHidden();
|
||||
await expect(notebookPageNames).toBeHidden();
|
||||
await expect(notebookSectionNames).toHaveText('Unnamed Section');
|
||||
await expect(notebookPageNames).toHaveText('Unnamed Page');
|
||||
});
|
||||
test.fixme('Can update a Notebook Object', async ({ page }) => {});
|
||||
test.fixme('Can view a perviously created Notebook Object', async ({ page }) => {});
|
||||
test.fixme('Can view a previously created Notebook Object', async ({ page }) => {});
|
||||
test.fixme('Can Delete a Notebook Object', async ({ page }) => {
|
||||
// Other than non-persistable objects
|
||||
});
|
||||
|
||||
@@ -19,12 +19,13 @@
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
/* global __dirname */
|
||||
/*
|
||||
This test suite is dedicated to tests which verify the basic operations surrounding Notebooks.
|
||||
*/
|
||||
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
const { test, expect } = require('../../../../pluginFixtures');
|
||||
const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||
|
||||
@@ -176,7 +177,9 @@ test.describe('Snapshot image tests', () => {
|
||||
});
|
||||
|
||||
test('Can drop an image onto a notebook and create a new entry', async ({ page }) => {
|
||||
const imageData = await fs.readFile('src/images/favicons/favicon-96x96.png');
|
||||
const imageData = await fs.readFile(
|
||||
path.resolve(__dirname, '../../../../../src/images/favicons/favicon-96x96.png')
|
||||
);
|
||||
const imageArray = new Uint8Array(imageData);
|
||||
const fileData = Array.from(imageArray);
|
||||
|
||||
@@ -201,14 +204,17 @@ test.describe('Snapshot image tests', () => {
|
||||
// drop another image onto the entry
|
||||
await page.dispatchEvent('.c-snapshots', 'drop', { dataTransfer: dropTransfer });
|
||||
|
||||
const secondThumbnail = page.getByRole('img', { name: 'favicon-96x96.png thumbnail' }).nth(1);
|
||||
await secondThumbnail.waitFor({ state: 'attached' });
|
||||
// expect two embedded images now
|
||||
expect(await page.getByRole('img', { name: 'favicon-96x96.png thumbnail' }).count()).toBe(2);
|
||||
|
||||
await page.locator('.c-snapshot.c-ne__embed').first().getByTitle('More options').click();
|
||||
|
||||
await page.getByRole('menuitem', { name: /Remove This Embed/ }).click();
|
||||
|
||||
await page.getByRole('button', { name: 'Ok', exact: true }).click();
|
||||
// Ensure that the thumbnail is removed before we assert
|
||||
await secondThumbnail.waitFor({ state: 'detached' });
|
||||
|
||||
// expect one embedded image now as we deleted the other
|
||||
expect(await page.getByRole('img', { name: 'favicon-96x96.png thumbnail' }).count()).toBe(1);
|
||||
|
||||
@@ -224,4 +224,22 @@ test.describe('Tagging in Notebooks @addInit', () => {
|
||||
// Verify the AutoComplete field is hidden
|
||||
await expect(page.locator('[placeholder="Type to select tag"]')).toBeHidden();
|
||||
});
|
||||
test('Can start to add a tag, click away, and add a tag', async ({ page }) => {
|
||||
await createNotebookEntryAndTags(page);
|
||||
|
||||
await page.getByRole('tab', { name: 'Annotations' }).click();
|
||||
|
||||
// Click on the body simulating a click outside the autocomplete)
|
||||
await page.locator('body').click();
|
||||
await page.locator(`[aria-label="Notebook Entry"]`).click();
|
||||
|
||||
await page.hover(`button:has-text("Add Tag")`);
|
||||
await page.locator(`button:has-text("Add Tag")`).click();
|
||||
|
||||
// Click inside the tag search input
|
||||
await page.locator('[placeholder="Type to select tag"]').click();
|
||||
// Select the "Driving" tag
|
||||
await page.locator('[aria-label="Autocomplete Options"] >> text=Drilling').click();
|
||||
await expect(page.getByLabel('Notebook Entries').getByText('Drilling')).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,6 +25,11 @@ Tests to verify plot tagging functionality.
|
||||
*/
|
||||
|
||||
const { test, expect } = require('../../../../pluginFixtures');
|
||||
const {
|
||||
basicTagsTests,
|
||||
createTags,
|
||||
testTelemetryItem
|
||||
} = require('../../../../helper/plotTagsUtils');
|
||||
const {
|
||||
createDomainObjectWithDefaults,
|
||||
setRealTimeMode,
|
||||
@@ -33,140 +38,6 @@ const {
|
||||
} = require('../../../../appActions');
|
||||
|
||||
test.describe('Plot Tagging', () => {
|
||||
/**
|
||||
* Given a canvas and a set of points, tags the points on the canvas.
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {HTMLCanvasElement} canvas a telemetry item with a plot
|
||||
* @param {Number} xEnd a telemetry item with a plot
|
||||
* @param {Number} yEnd a telemetry item with a plot
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async function createTags({ page, canvas, xEnd = 700, yEnd = 520 }) {
|
||||
await canvas.hover({ trial: true });
|
||||
|
||||
//Alt+Shift Drag Start to select some points to tag
|
||||
await page.keyboard.down('Alt');
|
||||
await page.keyboard.down('Shift');
|
||||
|
||||
await canvas.dragTo(canvas, {
|
||||
sourcePosition: {
|
||||
x: 1,
|
||||
y: 1
|
||||
},
|
||||
targetPosition: {
|
||||
x: xEnd,
|
||||
y: yEnd
|
||||
}
|
||||
});
|
||||
|
||||
//Alt Drag End
|
||||
await page.keyboard.up('Alt');
|
||||
await page.keyboard.up('Shift');
|
||||
|
||||
//Wait for canvas to stabilize.
|
||||
await canvas.hover({ trial: true });
|
||||
|
||||
// add some tags
|
||||
await page.getByText('Annotations').click();
|
||||
await page.getByRole('button', { name: /Add Tag/ }).click();
|
||||
await page.getByPlaceholder('Type to select tag').click();
|
||||
await page.getByText('Driving').click();
|
||||
|
||||
await page.getByRole('button', { name: /Add Tag/ }).click();
|
||||
await page.getByPlaceholder('Type to select tag').click();
|
||||
await page.getByText('Science').click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a telemetry item (e.g., a Sine Wave Generator) with a plot, tests that the plot can be tagged.
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {import('../../../../appActions').CreatedObjectInfo} telemetryItem a telemetry item with a plot
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async function testTelemetryItem(page, telemetryItem) {
|
||||
// Check that telemetry item also received the tag
|
||||
await page.goto(telemetryItem.url);
|
||||
|
||||
await expect(page.getByText('No tags to display for this item')).toBeVisible();
|
||||
|
||||
const canvas = page.locator('canvas').nth(1);
|
||||
//Wait for canvas to stabilize.
|
||||
await waitForPlotsToRender(page);
|
||||
|
||||
await expect(canvas).toBeInViewport();
|
||||
await canvas.hover({ trial: true });
|
||||
|
||||
// click on the tagged plot point
|
||||
await canvas.click({
|
||||
position: {
|
||||
x: 100,
|
||||
y: 100
|
||||
}
|
||||
});
|
||||
|
||||
await expect(page.getByText('Science')).toBeVisible();
|
||||
await expect(page.getByText('Driving')).toBeHidden();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a page, tests that tags are searchable, deletable, and persist across reloads.
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async function basicTagsTests(page) {
|
||||
// Search for Driving
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||
|
||||
// Clicking elsewhere should cause annotation selection to be cleared
|
||||
await expect(page.getByText('No tags to display for this item')).toBeVisible();
|
||||
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('driv');
|
||||
// click on the search result
|
||||
await page
|
||||
.getByRole('searchbox', { name: 'OpenMCT Search' })
|
||||
.getByText(/Sine Wave/)
|
||||
.first()
|
||||
.click();
|
||||
|
||||
// Delete Driving
|
||||
await page.hover('[aria-label="Tag"]:has-text("Driving")');
|
||||
await page.locator('[aria-label="Remove tag Driving"]').click();
|
||||
|
||||
// Search for Science
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
|
||||
await expect(page.locator('[aria-label="Search Result"]').nth(0)).toContainText('Science');
|
||||
await expect(page.locator('[aria-label="Search Result"]').nth(0)).not.toContainText('Drilling');
|
||||
|
||||
// Search for Driving
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('driv');
|
||||
await expect(page.getByText('No results found')).toBeVisible();
|
||||
|
||||
//Reload Page
|
||||
await page.reload({ waitUntil: 'domcontentloaded' });
|
||||
// wait for plots to load
|
||||
await waitForPlotsToRender(page);
|
||||
|
||||
await expect(page.getByRole('tab', { name: 'Annotations' })).not.toHaveClass(/is-current/);
|
||||
await page.getByRole('tab', { name: 'Annotations' }).click();
|
||||
await expect(page.getByRole('tab', { name: 'Annotations' })).toHaveClass(/is-current/);
|
||||
|
||||
await expect(page.getByText('No tags to display for this item')).toBeVisible();
|
||||
|
||||
const canvas = page.locator('canvas').nth(1);
|
||||
// click on the tagged plot point
|
||||
await canvas.click({
|
||||
position: {
|
||||
x: 100,
|
||||
y: 100
|
||||
}
|
||||
});
|
||||
|
||||
await expect(page.getByText('Science')).toBeVisible();
|
||||
await expect(page.getByText('Driving')).toBeHidden();
|
||||
}
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||
});
|
||||
@@ -221,19 +92,17 @@ test.describe('Plot Tagging', () => {
|
||||
// set to real time mode
|
||||
await setRealTimeMode(page);
|
||||
|
||||
// Search for Science
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
|
||||
// click on the search result
|
||||
await page
|
||||
.getByRole('searchbox', { name: 'OpenMCT Search' })
|
||||
.getByText('Alpha Sine Wave')
|
||||
.first()
|
||||
.click();
|
||||
// wait for plots to load
|
||||
await expect(page.locator('.js-series-data-loaded')).toBeVisible();
|
||||
// Search for Science Tag
|
||||
await page.getByRole('searchbox', { name: 'Search Input' });
|
||||
await page.getByRole('searchbox', { name: 'Search Input' }).fill('sc');
|
||||
|
||||
// Click on the search object result
|
||||
await page.getByLabel('OpenMCT Search').getByText('Alpha Sine Wave').first().click();
|
||||
|
||||
await waitForPlotsToRender(page);
|
||||
|
||||
// expect plot to be paused
|
||||
await expect(page.locator('[title="Resume displaying real-time data"]')).toBeVisible();
|
||||
await expect(page.getByTitle('Resume displaying real-time data')).toBeVisible();
|
||||
|
||||
await setFixedTimeMode(page);
|
||||
});
|
||||
|
||||
@@ -54,21 +54,35 @@ test.describe('Tabs View', () => {
|
||||
// ensure table header visible
|
||||
await expect(page.getByRole('searchbox', { name: 'message filter input' })).toBeVisible();
|
||||
|
||||
// no canvas (i.e., sine wave generator) in the document should be visible
|
||||
await expect(page.locator('canvas')).toBeHidden();
|
||||
|
||||
// select second tab
|
||||
await page.getByLabel(`${notebook.name} tab`).click();
|
||||
|
||||
// ensure notebook visible
|
||||
await expect(page.locator('.c-notebook__drag-area')).toBeVisible();
|
||||
|
||||
// no canvas (i.e., sine wave generator) in the document should be visible
|
||||
await expect(page.locator('canvas')).toBeHidden();
|
||||
|
||||
// select third tab
|
||||
await page.getByLabel(`${sineWaveGenerator.name} tab`).click();
|
||||
|
||||
// expect sine wave generator visible
|
||||
expect(await page.locator('.c-plot').isVisible()).toBe(true);
|
||||
await expect(page.locator('.c-plot')).toBeVisible();
|
||||
|
||||
// expect two canvases (i.e., overlay & main canvas for sine wave generator) to be visible
|
||||
await expect(page.locator('canvas')).toHaveCount(2);
|
||||
await expect(page.locator('canvas').nth(0)).toBeVisible();
|
||||
await expect(page.locator('canvas').nth(1)).toBeVisible();
|
||||
|
||||
// now try to select the first tab again
|
||||
await page.getByLabel(`${table.name} tab`).click();
|
||||
// ensure table header visible
|
||||
await expect(page.getByRole('searchbox', { name: 'message filter input' })).toBeVisible();
|
||||
|
||||
// no canvas (i.e., sine wave generator) in the document should be visible
|
||||
await expect(page.locator('canvas')).toBeHidden();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -198,6 +198,32 @@ test.describe('Grand Search', () => {
|
||||
await expect(searchResultDropDown).toContainText('Clock A');
|
||||
});
|
||||
|
||||
test('Slowly typing after search debounce will abort requests @couchdb', async ({ page }) => {
|
||||
let requestWasAborted = false;
|
||||
await createObjectsForSearch(page);
|
||||
page.on('requestfailed', (request) => {
|
||||
// check if the request was aborted
|
||||
if (request.failure().errorText === 'net::ERR_ABORTED') {
|
||||
requestWasAborted = true;
|
||||
}
|
||||
});
|
||||
|
||||
// Intercept and delay request
|
||||
const delayInMs = 100;
|
||||
|
||||
await page.route('**', async (route, request) => {
|
||||
await new Promise((resolve) => setTimeout(resolve, delayInMs));
|
||||
route.continue();
|
||||
});
|
||||
|
||||
// Slowly type after search delay
|
||||
const searchInput = page.getByRole('searchbox', { name: 'Search Input' });
|
||||
await searchInput.pressSequentially('Clock', { delay: 200 });
|
||||
await expect(page.getByText('Clock B').first()).toBeVisible();
|
||||
|
||||
expect(requestWasAborted).toBe(true);
|
||||
});
|
||||
|
||||
test('Validate multiple objects in search results return partial matches', async ({ page }) => {
|
||||
test.info().annotations.push({
|
||||
type: 'issue',
|
||||
|
||||
@@ -19,10 +19,15 @@
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/* global __dirname */
|
||||
|
||||
const { test, expect } = require('@playwright/test');
|
||||
const path = require('path');
|
||||
|
||||
const memoryLeakFilePath = 'e2e/test-data/memory-leak-detection.json';
|
||||
const memoryLeakFilePath = path.resolve(
|
||||
__dirname,
|
||||
'../../../../e2e/test-data/memory-leak-detection.json'
|
||||
);
|
||||
/**
|
||||
* Executes tests to verify that views are not leaking memory on navigation away. This sort of
|
||||
* memory leak is generally caused by a failure to clean up registered listeners.
|
||||
@@ -40,54 +45,127 @@ const memoryLeakFilePath = 'e2e/test-data/memory-leak-detection.json';
|
||||
*
|
||||
*/
|
||||
|
||||
const NAV_LEAK_TIMEOUT = 10 * 1000; // 10s
|
||||
test.describe('Navigation memory leak is not detected in', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
// Go to baseURL
|
||||
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||
|
||||
await page.locator('a:has-text("My Items")').click({
|
||||
button: 'right'
|
||||
});
|
||||
await page
|
||||
.getByRole('treeitem', {
|
||||
name: /My Items/
|
||||
})
|
||||
.click({
|
||||
button: 'right'
|
||||
});
|
||||
|
||||
await page.locator('text=Import from JSON').click();
|
||||
await page
|
||||
.getByRole('menuitem', {
|
||||
name: /Import from JSON/
|
||||
})
|
||||
.click();
|
||||
|
||||
// Upload memory-leak-detection.json
|
||||
await page.setInputFiles('#fileElem', memoryLeakFilePath);
|
||||
|
||||
await page.locator('text=OK').click();
|
||||
await page
|
||||
.getByRole('button', {
|
||||
name: 'Save'
|
||||
})
|
||||
.click();
|
||||
|
||||
await expect(page.locator('a:has-text("Memory Leak Detection")')).toBeVisible();
|
||||
});
|
||||
|
||||
test('gauge', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'gauge-single-1hz-swg');
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test('plan', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'plan-generated');
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test('time list', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'time-list');
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test('scatter', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'scatter-plot-single-1hz-swg');
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test('graph', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'graph-single-1hz-swg');
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test('gantt chart', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'gantt-chart');
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test('clock', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'clock');
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test('timer', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'timer-far-future');
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test('web page (nasa.gov)', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'web-page');
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test('Complex Display Layout', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'complex-display-layout');
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test('plot view', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'overlay-plot-single-1hz-swg', {
|
||||
timeout: NAV_LEAK_TIMEOUT
|
||||
});
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'overlay-plot-single-1hz-swg');
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test('stacked plot view', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'stacked-plot-single-1hz-swg', {
|
||||
timeout: NAV_LEAK_TIMEOUT
|
||||
});
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'stacked-plot-single-1hz-swg');
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test('LAD table view', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'lad-table-single-1hz-swg', {
|
||||
timeout: NAV_LEAK_TIMEOUT
|
||||
});
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'lad-table-single-1hz-swg');
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test('LAD table set', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'lad-table-set-single-1hz-swg', {
|
||||
timeout: NAV_LEAK_TIMEOUT
|
||||
});
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'lad-table-set-single-1hz-swg');
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
@@ -96,10 +174,7 @@ test.describe('Navigation memory leak is not detected in', () => {
|
||||
test('telemetry table view', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(
|
||||
page,
|
||||
'telemetry-table-single-1hz-swg',
|
||||
{
|
||||
timeout: NAV_LEAK_TIMEOUT
|
||||
}
|
||||
'telemetry-table-single-1hz-swg'
|
||||
);
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
@@ -110,10 +185,7 @@ test.describe('Navigation memory leak is not detected in', () => {
|
||||
test('notebook view', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(
|
||||
page,
|
||||
'notebook-memory-leak-detection-test',
|
||||
{
|
||||
timeout: NAV_LEAK_TIMEOUT
|
||||
}
|
||||
'notebook-memory-leak-detection-test'
|
||||
);
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
@@ -121,13 +193,7 @@ test.describe('Navigation memory leak is not detected in', () => {
|
||||
});
|
||||
|
||||
test('display layout of a single SWG alphanumeric', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(
|
||||
page,
|
||||
'display-layout-single-1hz-swg',
|
||||
{
|
||||
timeout: NAV_LEAK_TIMEOUT
|
||||
}
|
||||
);
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(page, 'display-layout-single-1hz-swg');
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
expect(result).toBe(true);
|
||||
@@ -136,10 +202,7 @@ test.describe('Navigation memory leak is not detected in', () => {
|
||||
test('display layout of a single SWG plot', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(
|
||||
page,
|
||||
'display-layout-single-overlay-plot',
|
||||
{
|
||||
timeout: NAV_LEAK_TIMEOUT
|
||||
}
|
||||
'display-layout-single-overlay-plot'
|
||||
);
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
@@ -150,10 +213,7 @@ test.describe('Navigation memory leak is not detected in', () => {
|
||||
test('example imagery view', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(
|
||||
page,
|
||||
'example-imagery-memory-leak-test',
|
||||
{
|
||||
timeout: NAV_LEAK_TIMEOUT * 6 // 1 min
|
||||
}
|
||||
'example-imagery-memory-leak-test'
|
||||
);
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
@@ -163,10 +223,7 @@ test.describe('Navigation memory leak is not detected in', () => {
|
||||
test('display layout of example imagery views', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(
|
||||
page,
|
||||
'display-layout-images-memory-leak-test',
|
||||
{
|
||||
timeout: NAV_LEAK_TIMEOUT * 6 // 1 min
|
||||
}
|
||||
'display-layout-images-memory-leak-test'
|
||||
);
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
@@ -178,10 +235,7 @@ test.describe('Navigation memory leak is not detected in', () => {
|
||||
}) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(
|
||||
page,
|
||||
'display-layout-simple-telemetry',
|
||||
{
|
||||
timeout: NAV_LEAK_TIMEOUT * 6 // 1 min
|
||||
}
|
||||
'display-layout-simple-telemetry'
|
||||
);
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
@@ -191,10 +245,7 @@ test.describe('Navigation memory leak is not detected in', () => {
|
||||
test('flexible layout with plots of swgs', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(
|
||||
page,
|
||||
'flexible-layout-plots-memory-leak-test',
|
||||
{
|
||||
timeout: NAV_LEAK_TIMEOUT
|
||||
}
|
||||
'flexible-layout-plots-memory-leak-test'
|
||||
);
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
@@ -204,10 +255,7 @@ test.describe('Navigation memory leak is not detected in', () => {
|
||||
test('flexible layout of example imagery views', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(
|
||||
page,
|
||||
'flexible-layout-images-memory-leak-test',
|
||||
{
|
||||
timeout: NAV_LEAK_TIMEOUT * 6 // 1 min
|
||||
}
|
||||
'flexible-layout-images-memory-leak-test'
|
||||
);
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
@@ -217,10 +265,7 @@ test.describe('Navigation memory leak is not detected in', () => {
|
||||
test('tabbed view of display layouts and time strips', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(
|
||||
page,
|
||||
'tab-view-simple-memory-leak-test',
|
||||
{
|
||||
timeout: NAV_LEAK_TIMEOUT * 6 * 2 // 2 min
|
||||
}
|
||||
'tab-view-simple-memory-leak-test'
|
||||
);
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
@@ -230,10 +275,7 @@ test.describe('Navigation memory leak is not detected in', () => {
|
||||
test('time strip view of telemetry', async ({ page }) => {
|
||||
const result = await navigateToObjectAndDetectMemoryLeak(
|
||||
page,
|
||||
'time-strip-telemetry-memory-leak-test',
|
||||
{
|
||||
timeout: NAV_LEAK_TIMEOUT * 6 // 1 min
|
||||
}
|
||||
'time-strip-telemetry-memory-leak-test'
|
||||
);
|
||||
|
||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||
@@ -247,15 +289,12 @@ test.describe('Navigation memory leak is not detected in', () => {
|
||||
* @returns
|
||||
*/
|
||||
async function navigateToObjectAndDetectMemoryLeak(page, objectName) {
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||
await page.getByRole('searchbox', { name: 'Search Input' }).click();
|
||||
// Fill Search input
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill(objectName);
|
||||
await page.getByRole('searchbox', { name: 'Search Input' }).fill(objectName);
|
||||
|
||||
//Search Result Appears and is clicked
|
||||
await Promise.all([
|
||||
page.locator(`div.c-gsearch-result__title:has-text("${objectName}")`).first().click(),
|
||||
page.waitForNavigation()
|
||||
]);
|
||||
await page.getByText(objectName, { exact: true }).click();
|
||||
|
||||
// Register a finalization listener on the root node for the view. This tends to be the last thing to be
|
||||
// garbage collected since it has either direct or indirect references to all resources used by the view. Therefore it's a pretty good proxy
|
||||
@@ -273,8 +312,7 @@ test.describe('Navigation memory leak is not detected in', () => {
|
||||
});
|
||||
|
||||
// Nav back to folder
|
||||
await page.goto('./#/browse/mine', { waitUntil: 'networkidle' });
|
||||
await page.waitForNavigation();
|
||||
await page.goto('./#/browse/mine');
|
||||
|
||||
// This next code block blocks until the finalization listener is called and the gcPromise resolved. This means that the root node for the view has been garbage collected.
|
||||
// In the event that the root node is not garbage collected, the gcPromise will never resolve and the test will time out.
|
||||
|
||||
@@ -25,6 +25,7 @@ Tests to verify plot tagging performance.
|
||||
*/
|
||||
|
||||
const { test, expect } = require('../../pluginFixtures');
|
||||
const { basicTagsTests, createTags, testTelemetryItem } = require('../../helper/plotTagsUtils');
|
||||
const {
|
||||
createDomainObjectWithDefaults,
|
||||
setRealTimeMode,
|
||||
@@ -33,135 +34,6 @@ const {
|
||||
} = require('../../appActions');
|
||||
|
||||
test.describe('Plot Tagging Performance', () => {
|
||||
/**
|
||||
* Given a canvas and a set of points, tags the points on the canvas.
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {HTMLCanvasElement} canvas a telemetry item with a plot
|
||||
* @param {Number} xEnd a telemetry item with a plot
|
||||
* @param {Number} yEnd a telemetry item with a plot
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async function createTags({ page, canvas, xEnd = 700, yEnd = 520 }) {
|
||||
await canvas.hover({ trial: true });
|
||||
|
||||
//Alt+Shift Drag Start to select some points to tag
|
||||
await page.keyboard.down('Alt');
|
||||
await page.keyboard.down('Shift');
|
||||
|
||||
await canvas.dragTo(canvas, {
|
||||
sourcePosition: {
|
||||
x: 1,
|
||||
y: 1
|
||||
},
|
||||
targetPosition: {
|
||||
x: xEnd,
|
||||
y: yEnd
|
||||
}
|
||||
});
|
||||
|
||||
//Alt Drag End
|
||||
await page.keyboard.up('Alt');
|
||||
await page.keyboard.up('Shift');
|
||||
|
||||
//Wait for canvas to stabilize.
|
||||
await canvas.hover({ trial: true });
|
||||
|
||||
// add some tags
|
||||
await page.getByText('Annotations').click();
|
||||
await page.getByRole('button', { name: /Add Tag/ }).click();
|
||||
await page.getByPlaceholder('Type to select tag').click();
|
||||
await page.getByText('Driving').click();
|
||||
|
||||
await page.getByRole('button', { name: /Add Tag/ }).click();
|
||||
await page.getByPlaceholder('Type to select tag').click();
|
||||
await page.getByText('Science').click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a telemetry item (e.g., a Sine Wave Generator) with a plot, tests that the plot can be tagged.
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {import('../../../../appActions').CreatedObjectInfo} telemetryItem a telemetry item with a plot
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async function testTelemetryItem(page, telemetryItem) {
|
||||
// Check that telemetry item also received the tag
|
||||
await page.goto(telemetryItem.url);
|
||||
|
||||
await expect(page.getByText('No tags to display for this item')).toBeVisible();
|
||||
|
||||
const canvas = page.locator('canvas').nth(1);
|
||||
|
||||
//Wait for canvas to stabilize.
|
||||
await canvas.hover({ trial: true });
|
||||
|
||||
// click on the tagged plot point
|
||||
await canvas.click({
|
||||
position: {
|
||||
x: 100,
|
||||
y: 100
|
||||
}
|
||||
});
|
||||
|
||||
await expect(page.getByText('Science')).toBeVisible();
|
||||
await expect(page.getByText('Driving')).toBeHidden();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a page, tests that tags are searchable, deletable, and persist across reloads.
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async function basicTagsTests(page) {
|
||||
// Search for Driving
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||
|
||||
// Clicking elsewhere should cause annotation selection to be cleared
|
||||
await expect(page.getByText('No tags to display for this item')).toBeVisible();
|
||||
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('driv');
|
||||
// click on the search result
|
||||
await page
|
||||
.getByRole('searchbox', { name: 'OpenMCT Search' })
|
||||
.getByText(/Sine Wave/)
|
||||
.first()
|
||||
.click();
|
||||
|
||||
// Delete Driving
|
||||
await page.hover('[aria-label="Tag"]:has-text("Driving")');
|
||||
await page.locator('[aria-label="Remove tag Driving"]').click();
|
||||
|
||||
// Search for Science
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
|
||||
await expect(page.locator('[aria-label="Search Result"]').nth(0)).toContainText('Science');
|
||||
await expect(page.locator('[aria-label="Search Result"]').nth(0)).not.toContainText('Drilling');
|
||||
|
||||
// Search for Driving
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('driv');
|
||||
await expect(page.getByText('No results found')).toBeVisible();
|
||||
|
||||
//Reload Page
|
||||
await page.reload({ waitUntil: 'domcontentloaded' });
|
||||
// wait for plots to load
|
||||
await waitForPlotsToRender(page);
|
||||
|
||||
await page.getByText('Annotations').click();
|
||||
await expect(page.getByText('No tags to display for this item')).toBeVisible();
|
||||
|
||||
const canvas = page.locator('canvas').nth(1);
|
||||
// click on the tagged plot point
|
||||
await canvas.click({
|
||||
position: {
|
||||
x: 100,
|
||||
y: 100
|
||||
}
|
||||
});
|
||||
|
||||
await expect(page.getByText('Science')).toBeVisible();
|
||||
await expect(page.getByText('Driving')).toBeHidden();
|
||||
}
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||
});
|
||||
@@ -212,18 +84,15 @@ test.describe('Plot Tagging Performance', () => {
|
||||
await setRealTimeMode(page);
|
||||
|
||||
// Search for Science
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
|
||||
await page.getByRole('searchbox', { name: 'Search Input' });
|
||||
await page.getByRole('searchbox', { name: 'Search Input' }).fill('sc');
|
||||
|
||||
// click on the search result
|
||||
await page
|
||||
.getByRole('searchbox', { name: 'OpenMCT Search' })
|
||||
.getByText('Alpha Sine Wave')
|
||||
.first()
|
||||
.click();
|
||||
// wait for plots to load
|
||||
await expect(page.locator('.js-series-data-loaded')).toBeVisible();
|
||||
await page.getByLabel('Search Result').getByText('Alpha Sine Wave').first().click();
|
||||
|
||||
await waitForPlotsToRender(page);
|
||||
// expect plot to be paused
|
||||
await expect(page.locator('[title="Resume displaying real-time data"]')).toBeVisible();
|
||||
await expect(page.getByTitle('Resume displaying real-time data')).toBeVisible();
|
||||
|
||||
await setFixedTimeMode(page);
|
||||
});
|
||||
|
||||
33
e2e/tests/visual-a11y/a11y.visual.spec.js
Normal file
33
e2e/tests/visual-a11y/a11y.visual.spec.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2023, 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.
|
||||
*****************************************************************************/
|
||||
|
||||
const { test, scanForA11yViolations } = require('../../avpFixtures');
|
||||
const VISUAL_URL = require('../../constants').VISUAL_URL;
|
||||
|
||||
test.describe('a11y - Default @a11y', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto(VISUAL_URL, { waitUntil: 'domcontentloaded' });
|
||||
});
|
||||
test('main view @a11y', async ({ page }, testInfo) => {
|
||||
await scanForA11yViolations(page, testInfo.title);
|
||||
});
|
||||
});
|
||||
@@ -26,12 +26,12 @@ are only meant to run against openmct's app.js started by `npm run start` within
|
||||
`./e2e/playwright-visual.config.js` file.
|
||||
*/
|
||||
|
||||
const { test, expect } = require('../../pluginFixtures');
|
||||
const { test, expect, scanForA11yViolations } = require('../../avpFixtures');
|
||||
const percySnapshot = require('@percy/playwright');
|
||||
const { createDomainObjectWithDefaults } = require('../../appActions');
|
||||
const { VISUAL_URL } = require('../../constants');
|
||||
|
||||
test.describe('Visual - Default', () => {
|
||||
test.describe('Visual - Default @a11y', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto(VISUAL_URL, { waitUntil: 'domcontentloaded' });
|
||||
});
|
||||
@@ -98,4 +98,8 @@ test.describe('Visual - Default', () => {
|
||||
// Take a snapshot of the newly created Gauge object
|
||||
await percySnapshot(page, `Default Gauge (theme: '${theme}')`);
|
||||
});
|
||||
|
||||
test.afterEach(async ({ page }, testInfo) => {
|
||||
await scanForA11yViolations(page, testInfo.title);
|
||||
});
|
||||
});
|
||||
@@ -20,7 +20,7 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
const { test } = require('../../pluginFixtures');
|
||||
const { test, scanForA11yViolations } = require('../../avpFixtures');
|
||||
const percySnapshot = require('@percy/playwright');
|
||||
const { expandTreePaneItemByName, createDomainObjectWithDefaults } = require('../../appActions');
|
||||
const {
|
||||
@@ -31,7 +31,8 @@ const { VISUAL_URL } = require('../../constants');
|
||||
|
||||
test.describe('Visual - Restricted Notebook', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await startAndAddRestrictedNotebookObject(page);
|
||||
const restrictedNotebook = await startAndAddRestrictedNotebookObject(page);
|
||||
await page.goto(restrictedNotebook.url + '?hideTree=true&hideInspector=true');
|
||||
});
|
||||
|
||||
test('Restricted Notebook is visually correct @addInit', async ({ page, theme }) => {
|
||||
@@ -58,7 +59,7 @@ test.describe('Visual - Notebook', () => {
|
||||
name: 'Dropped Overlay Plot'
|
||||
});
|
||||
|
||||
//Open Tree
|
||||
//Open Tree to perform drag
|
||||
await page.getByRole('button', { name: 'Browse' }).click();
|
||||
|
||||
await expandTreePaneItemByName(page, myItemsFolderName);
|
||||
@@ -97,4 +98,36 @@ test.describe('Visual - Notebook', () => {
|
||||
// Take snapshot of the notebook with the AutoComplete field hidden and with the "Add Tag" button visible
|
||||
await percySnapshot(page, `Notebook Annotation de-select blur (theme: '${theme}')`);
|
||||
});
|
||||
test('Visual check of entry hover and selection', async ({ page, theme }) => {
|
||||
// Make two entries so we can test an unselected entry
|
||||
await enterTextEntry(page, 'Entry 0');
|
||||
await enterTextEntry(page, 'Entry 1');
|
||||
|
||||
// Hover the first entry
|
||||
await page.getByText('Entry 0').hover();
|
||||
|
||||
// Take a snapshot
|
||||
await percySnapshot(page, `Notebook Non-selected Entry Hover (theme: '${theme}')`);
|
||||
|
||||
// Click the first entry
|
||||
await page.getByText('Entry 0').click();
|
||||
|
||||
// Take a snapshot
|
||||
await percySnapshot(page, `Notebook Selected Entry Hover (theme: '${theme}')`);
|
||||
|
||||
// Hover the text entry area
|
||||
await page.getByText('Entry 0').hover();
|
||||
|
||||
// Take a snapshot
|
||||
await percySnapshot(page, `Notebook Selected Entry Text Area Hover (theme: '${theme}')`);
|
||||
|
||||
// Click the text entry area
|
||||
await page.getByText('Entry 0').click();
|
||||
|
||||
// Take a snapshot
|
||||
await percySnapshot(page, `Notebook Selected Entry Text Area Active (theme: '${theme}')`);
|
||||
});
|
||||
test.afterEach(async ({ page }, testInfo) => {
|
||||
await scanForA11yViolations(page, testInfo.title);
|
||||
});
|
||||
});
|
||||
@@ -24,12 +24,12 @@
|
||||
* This test is dedicated to test notification banner functionality and its accessibility attributes.
|
||||
*/
|
||||
|
||||
const { test, expect } = require('../../pluginFixtures');
|
||||
const { test, expect, scanForA11yViolations } = require('../../avpFixtures');
|
||||
const percySnapshot = require('@percy/playwright');
|
||||
const { createDomainObjectWithDefaults } = require('../../appActions');
|
||||
const VISUAL_URL = require('../../constants').VISUAL_URL;
|
||||
|
||||
test.describe("Visual - Check Notification Info Banner of 'Save successful'", () => {
|
||||
test.describe("Visual - Check Notification Info Banner of 'Save successful' @a11y", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto(VISUAL_URL, { waitUntil: 'domcontentloaded' });
|
||||
});
|
||||
@@ -59,4 +59,7 @@ test.describe("Visual - Check Notification Info Banner of 'Save successful'", ()
|
||||
expect(await page.locator('div[role="dialog"]').isVisible()).toBe(false);
|
||||
await percySnapshot(page, `Notification banner dismissed (theme: '${theme}')`);
|
||||
});
|
||||
test.afterEach(async ({ page }, testInfo) => {
|
||||
await scanForA11yViolations(page, testInfo.title);
|
||||
});
|
||||
});
|
||||
@@ -20,7 +20,7 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
const { test } = require('../../pluginFixtures');
|
||||
const { test, scanForA11yViolations } = require('../../avpFixtures');
|
||||
const {
|
||||
setBoundsToSpanAllActivities,
|
||||
setDraftStatusForPlan
|
||||
@@ -32,7 +32,7 @@ const examplePlanSmall = require('../../test-data/examplePlans/ExamplePlan_Small
|
||||
|
||||
const snapshotScope = '.l-shell__pane-main .l-pane__contents';
|
||||
|
||||
test.describe('Visual - Planning', () => {
|
||||
test.describe('Visual - Planning @a11y', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto(VISUAL_URL, { waitUntil: 'domcontentloaded' });
|
||||
});
|
||||
@@ -97,4 +97,7 @@ test.describe('Visual - Planning', () => {
|
||||
scope: snapshotScope
|
||||
});
|
||||
});
|
||||
test.afterEach(async ({ page }, testInfo) => {
|
||||
await scanForA11yViolations(page, testInfo.title);
|
||||
});
|
||||
});
|
||||
@@ -24,14 +24,14 @@
|
||||
This test suite is dedicated to tests which verify search functionality.
|
||||
*/
|
||||
|
||||
const { test, expect } = require('../../pluginFixtures');
|
||||
const { test, expect, scanForA11yViolations } = require('../../avpFixtures');
|
||||
const { createDomainObjectWithDefaults } = require('../../appActions');
|
||||
const { VISUAL_URL } = require('../../constants');
|
||||
|
||||
const percySnapshot = require('@percy/playwright');
|
||||
|
||||
test.describe('Grand Search', () => {
|
||||
let clock;
|
||||
test.describe('Grand Search @a11y', () => {
|
||||
let conditionWidget;
|
||||
let displayLayout;
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto(VISUAL_URL, { waitUntil: 'domcontentloaded' });
|
||||
@@ -41,9 +41,9 @@ test.describe('Grand Search', () => {
|
||||
name: 'Visual Test Display Layout'
|
||||
});
|
||||
|
||||
clock = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Clock',
|
||||
name: 'Visual Test Clock',
|
||||
conditionWidget = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Condition Widget',
|
||||
name: 'Visual Condition Widget',
|
||||
parent: displayLayout.uuid
|
||||
});
|
||||
});
|
||||
@@ -52,29 +52,27 @@ test.describe('Grand Search', () => {
|
||||
page,
|
||||
theme
|
||||
}) => {
|
||||
const searchInput = page.getByRole('searchbox', { name: 'Search Input' });
|
||||
const searchResults = page.getByRole('searchbox', { name: 'OpenMCT Search' });
|
||||
// Navigate to display layout
|
||||
await page.goto(displayLayout.url);
|
||||
|
||||
// Search for the clock object
|
||||
await searchInput.click();
|
||||
await searchInput.fill(clock.name);
|
||||
await expect(searchResults.getByText('Visual Test Clock')).toBeVisible();
|
||||
// Search for the object
|
||||
await page.getByRole('searchbox', { name: 'Search Input' }).click();
|
||||
await page.getByRole('searchbox', { name: 'Search Input' }).fill(conditionWidget.name);
|
||||
await expect(page.getByLabel('Search Result').getByText(conditionWidget.name)).toBeVisible();
|
||||
|
||||
//Searching for an object returns that object in the grandsearch
|
||||
await percySnapshot(page, `Searching for Clock Object (theme: '${theme}')`);
|
||||
await percySnapshot(page, `Searching for Object (theme: '${theme}')`);
|
||||
|
||||
// Enter Edit mode on the Display Layout
|
||||
await page.getByRole('button', { name: 'Edit' }).click();
|
||||
|
||||
// Navigate to the clock object while in edit mode on the display layout
|
||||
await searchInput.click();
|
||||
await searchResults.getByText('Visual Test Clock').click();
|
||||
// Navigate to the object while in edit mode on the display layout
|
||||
await page.getByRole('searchbox', { name: 'Search Input' }).click();
|
||||
await page.getByLabel('Search Result').getByText(conditionWidget.name).click();
|
||||
|
||||
await percySnapshot(
|
||||
page,
|
||||
`Preview for clock should display when editing enabled and search item clicked (theme: '${theme}')`
|
||||
`Preview should display when editing enabled and search item clicked (theme: '${theme}')`
|
||||
);
|
||||
|
||||
// Close the preview
|
||||
@@ -88,17 +86,20 @@ test.describe('Grand Search', () => {
|
||||
await page.getByRole('button', { name: 'Save' }).click();
|
||||
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
||||
|
||||
// Search for the clock object
|
||||
await searchInput.click();
|
||||
await searchInput.fill(clock.name);
|
||||
await expect(searchResults.getByText('Visual Test Clock')).toBeVisible();
|
||||
// Search for the object
|
||||
await page.getByRole('searchbox', { name: 'Search Input' }).click();
|
||||
await page.getByRole('searchbox', { name: 'Search Input' }).fill(conditionWidget.name);
|
||||
await expect(page.getByLabel('Search Result').getByText(conditionWidget.name)).toBeVisible();
|
||||
|
||||
// Navigate to the clock object while not in edit mode on the display layout
|
||||
await searchResults.getByText('Visual Test Clock').click();
|
||||
// Navigate to the object while not in edit mode on the display layout
|
||||
await page.getByLabel('Search Result').getByText(conditionWidget.name).click();
|
||||
|
||||
await percySnapshot(
|
||||
page,
|
||||
`Clicking on search results should navigate to them if not editing (theme: '${theme}')`
|
||||
);
|
||||
});
|
||||
test.afterEach(async ({ page }, testInfo) => {
|
||||
await scanForA11yViolations(page, testInfo.title);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,75 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2023, 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.
|
||||
*****************************************************************************/
|
||||
|
||||
import mount from 'utils/mount';
|
||||
|
||||
import ExampleDataVisualizationSource from './components/ExampleDataVisualizationSource.vue';
|
||||
|
||||
export default function ExampleDataVisualizationSourceViewProvider(openmct) {
|
||||
return {
|
||||
key: 'exampleDataVisualizationSource',
|
||||
name: 'Example Data Visualization Source',
|
||||
cssClass: 'icon-telemetry',
|
||||
canView: function (domainObject) {
|
||||
return domainObject.type === 'exampleDataVisualizationSource';
|
||||
},
|
||||
canEdit: function (domainObject) {
|
||||
if (domainObject.type === 'exampleDataVisualizationSource') {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
view: function (domainObject) {
|
||||
let _destroy = null;
|
||||
|
||||
return {
|
||||
show: function (element, isEditing) {
|
||||
const { destroy } = mount(
|
||||
{
|
||||
el: element,
|
||||
components: {
|
||||
ExampleDataVisualizationSource
|
||||
},
|
||||
provide: {
|
||||
openmct,
|
||||
domainObject
|
||||
},
|
||||
template: '<example-data-visualization-source></example-data-visualization-source>'
|
||||
},
|
||||
{
|
||||
app: openmct.app,
|
||||
element
|
||||
}
|
||||
);
|
||||
_destroy = destroy;
|
||||
},
|
||||
destroy: function () {
|
||||
if (_destroy) {
|
||||
_destroy();
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
priority: function () {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<!--
|
||||
Open MCT, Copyright (c) 2014-2023, 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.
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div class="c-table c-list-view c-list-view--selectable">
|
||||
<table class="c-table__body">
|
||||
<thead class="c-table__header">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="item in items"
|
||||
:key="item.keyString"
|
||||
class="c-list-item js-folder-child"
|
||||
@click="selectItem(item, $event)"
|
||||
>
|
||||
<td class="c-list-item__name">
|
||||
<a ref="objectLink" class="c-object-label">
|
||||
<div
|
||||
class="c-object-label__type-icon c-list-item__name__type-icon"
|
||||
:class="item.type.cssClass"
|
||||
></div>
|
||||
<div class="c-object-label__name c-list-item__name__name">{{ item.model.name }}</div>
|
||||
</a>
|
||||
</td>
|
||||
<td class="c-list-item__type">
|
||||
{{ item.type.name }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
inject: ['openmct', 'domainObject'],
|
||||
data() {
|
||||
return {
|
||||
items: []
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.composition = this.openmct.composition.get(this.domainObject);
|
||||
this.keystring = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
||||
this.composition.on('add', this.addedTelemetry);
|
||||
this.composition.on('remove', this.removedTelemetry);
|
||||
this.composition.load();
|
||||
},
|
||||
unmounted() {
|
||||
this.composition.off('add', this.addedTelemetry);
|
||||
this.composition.off('remove', this.removedTelemetry);
|
||||
},
|
||||
methods: {
|
||||
selectItem(item, event) {
|
||||
event.stopPropagation();
|
||||
const bounds = this.openmct.time.getBounds();
|
||||
const selection = [
|
||||
{
|
||||
element: this.$el,
|
||||
context: {
|
||||
dataVisualization: {
|
||||
telemetryKeys: [item.objectKeyString],
|
||||
description: {
|
||||
text: item.model.name,
|
||||
icon: item.type.cssClass
|
||||
},
|
||||
dataRanges: [
|
||||
{
|
||||
bounds
|
||||
}
|
||||
],
|
||||
loading: false
|
||||
},
|
||||
item: this.domainObject
|
||||
}
|
||||
}
|
||||
];
|
||||
this.openmct.selection.select(selection, false);
|
||||
},
|
||||
addedTelemetry(child) {
|
||||
const type = this.openmct.types.get(child.type) || {
|
||||
definition: {
|
||||
cssClass: 'icon-object-unknown',
|
||||
name: 'Unknown Type'
|
||||
}
|
||||
};
|
||||
this.items.push({
|
||||
model: child,
|
||||
type: type.definition,
|
||||
isAlias: this.keystring !== child.location,
|
||||
objectPath: [child].concat(this.openmct.router.path),
|
||||
objectKeyString: this.openmct.objects.makeKeyString(child.identifier)
|
||||
});
|
||||
},
|
||||
removedTelemetry(identifier) {
|
||||
this.items = this.items.filter((i) => {
|
||||
return (
|
||||
i.model.identifier.key !== identifier.key ||
|
||||
i.model.identifier.namespace !== identifier.namespace
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
46
example/dataVisualization/plugin.js
Normal file
46
example/dataVisualization/plugin.js
Normal file
@@ -0,0 +1,46 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2023, 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.
|
||||
*****************************************************************************/
|
||||
import ExampleDataVisualizationSourceViewProvider from './ExampleDataVisualizationSourceViewProvider';
|
||||
|
||||
export default function () {
|
||||
return function install(openmct) {
|
||||
openmct.objectViews.addProvider(new ExampleDataVisualizationSourceViewProvider(openmct));
|
||||
|
||||
openmct.types.addType('exampleDataVisualizationSource', {
|
||||
name: 'Example Data Visualization Source',
|
||||
creatable: true,
|
||||
description: 'An example data visualization source to be used with an inspector.',
|
||||
cssClass: 'icon-telemetry',
|
||||
initialize(domainObject) {
|
||||
domainObject.composition = [];
|
||||
}
|
||||
});
|
||||
|
||||
openmct.composition.addPolicy((parent, child) => {
|
||||
if (parent.type === 'exampleDataVisualizationSource') {
|
||||
return Object.prototype.hasOwnProperty.call(child, 'telemetry');
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -23,10 +23,8 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no"
|
||||
/>
|
||||
<!-- Modified viewport meta tag to improve accessibility -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<title>Open MCT</title>
|
||||
<script src="dist/openmct.js"></script>
|
||||
|
||||
29
package.json
29
package.json
@@ -1,18 +1,23 @@
|
||||
{
|
||||
"name": "openmct",
|
||||
"version": "3.2.0",
|
||||
"version": "3.3.0-next",
|
||||
"description": "The Open MCT core platform",
|
||||
"main": "dist/openmct.js",
|
||||
"devDependencies": {
|
||||
"@axe-core/playwright": "4.8.2",
|
||||
"@babel/eslint-parser": "7.22.5",
|
||||
"@braintree/sanitize-url": "6.0.4",
|
||||
"@deploysentinel/playwright": "0.3.4",
|
||||
"@percy/cli": "1.27.4",
|
||||
"@percy/playwright": "1.0.4",
|
||||
"@playwright/test": "1.39.0",
|
||||
"@types/d3-axis": "3.0.6",
|
||||
"@types/d3-scale": "4.0.8",
|
||||
"@types/d3-selection": "3.0.10",
|
||||
"@types/eventemitter3": "1.2.0",
|
||||
"@types/jasmine": "5.1.2",
|
||||
"@types/lodash": "4.14.192",
|
||||
"@vue/compiler-sfc": "3.3.8",
|
||||
"@vue/compiler-sfc": "3.3.10",
|
||||
"babel-loader": "9.1.0",
|
||||
"babel-plugin-istanbul": "6.1.1",
|
||||
"codecov": "3.8.3",
|
||||
@@ -21,9 +26,9 @@
|
||||
"cspell": "7.3.8",
|
||||
"css-loader": "6.8.1",
|
||||
"d3-axis": "3.0.0",
|
||||
"d3-scale": "3.3.0",
|
||||
"d3-scale": "4.0.2",
|
||||
"d3-selection": "3.0.0",
|
||||
"eslint": "8.53.0",
|
||||
"eslint": "8.54.0",
|
||||
"eslint-config-prettier": "9.0.0",
|
||||
"eslint-plugin-compat": "4.2.0",
|
||||
"eslint-plugin-no-unsanitized": "4.0.2",
|
||||
@@ -52,7 +57,7 @@
|
||||
"karma-webpack": "5.0.0",
|
||||
"location-bar": "3.0.1",
|
||||
"lodash": "4.17.21",
|
||||
"marked": "9.1.5",
|
||||
"marked": "11.1.0",
|
||||
"mini-css-extract-plugin": "2.7.6",
|
||||
"moment": "2.29.4",
|
||||
"moment-duration-format": "2.3.2",
|
||||
@@ -60,8 +65,8 @@
|
||||
"npm-run-all2": "6.1.1",
|
||||
"nyc": "15.1.0",
|
||||
"painterro": "1.2.87",
|
||||
"plotly.js-basic-dist": "2.20.0",
|
||||
"plotly.js-gl2d-dist": "2.20.0",
|
||||
"plotly.js-basic-dist-min": "2.20.0",
|
||||
"plotly.js-gl2d-dist-min": "2.20.0",
|
||||
"prettier": "2.8.7",
|
||||
"printj": "1.3.1",
|
||||
"resolve-url-loader": "5.0.0",
|
||||
@@ -70,6 +75,7 @@
|
||||
"sass-loader": "13.3.2",
|
||||
"sinon": "17.0.0",
|
||||
"style-loader": "3.3.3",
|
||||
"terser-webpack-plugin": "5.3.9",
|
||||
"tiny-emitter": "2.1.0",
|
||||
"typescript": "5.2.2",
|
||||
"uuid": "9.0.1",
|
||||
@@ -99,14 +105,15 @@
|
||||
"test": "karma start",
|
||||
"test:debug": "KARMA_DEBUG=true karma start",
|
||||
"test:e2e": "npx playwright test",
|
||||
"test:e2e:a11y": "npx playwright test --config=e2e/playwright-visual-a11y.config.js --project=chrome --grep @a11y",
|
||||
"test:e2e:couchdb": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @couchdb --workers=1",
|
||||
"test:e2e:stable": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep-invert \"@unstable|@couchdb|@generatedata\"",
|
||||
"test:e2e:unstable": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @unstable",
|
||||
"test:e2e:local": "npx playwright test --config=e2e/playwright-local.config.js --project=chrome",
|
||||
"test:e2e:generatedata": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @generatedata",
|
||||
"test:e2e:updatesnapshots": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @snapshot --update-snapshots",
|
||||
"test:e2e:visual:ci": "percy exec --config ./e2e/.percy.ci.yml --partial -- npx playwright test --config=e2e/playwright-visual.config.js --project=chrome --grep-invert @unstable",
|
||||
"test:e2e:visual:full": "percy exec --config ./e2e/.percy.nightly.yml -- npx playwright test --config=e2e/playwright-visual.config.js --grep-invert @unstable",
|
||||
"test:e2e:visual:ci": "percy exec --config ./e2e/.percy.ci.yml --partial -- npx playwright test --config=e2e/playwright-visual-a11y.config.js --project=chrome --grep-invert @unstable",
|
||||
"test:e2e:visual:full": "percy exec --config ./e2e/.percy.nightly.yml -- npx playwright test --config=e2e/playwright-visual-a11y.config.js --grep-invert @unstable",
|
||||
"test:e2e:full": "npx playwright test --config=e2e/playwright-ci.config.js --grep-invert @couchdb",
|
||||
"test:e2e:watch": "npx playwright test --ui --config=e2e/playwright-ci.config.js",
|
||||
"test:perf:contract": "npx playwright test --config=e2e/playwright-performance-dev.config.js",
|
||||
@@ -123,10 +130,10 @@
|
||||
"homepage": "https://nasa.github.io/openmct",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nasa/openmct.git"
|
||||
"url": "git+https://github.com/nasa/openmct.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.19.1 <20"
|
||||
"node": ">=18.14.2 <22"
|
||||
},
|
||||
"browserslist": [
|
||||
"Firefox ESR",
|
||||
|
||||
@@ -366,15 +366,19 @@ export default class AnnotationAPI extends EventEmitter {
|
||||
return tagsAddedToResults;
|
||||
}
|
||||
|
||||
async #addTargetModelsToResults(results) {
|
||||
async #addTargetModelsToResults(results, abortSignal) {
|
||||
const modelAddedToResults = await Promise.all(
|
||||
results.map(async (result) => {
|
||||
const targetModels = await Promise.all(
|
||||
result.targets.map(async (target) => {
|
||||
const targetID = target.keyString;
|
||||
const targetModel = await this.openmct.objects.get(targetID);
|
||||
const targetModel = await this.openmct.objects.get(targetID, abortSignal);
|
||||
const targetKeyString = this.openmct.objects.makeKeyString(targetModel.identifier);
|
||||
const originalPathObjects = await this.openmct.objects.getOriginalPath(targetKeyString);
|
||||
const originalPathObjects = await this.openmct.objects.getOriginalPath(
|
||||
targetKeyString,
|
||||
[],
|
||||
abortSignal
|
||||
);
|
||||
|
||||
return {
|
||||
originalPath: originalPathObjects,
|
||||
@@ -442,7 +446,7 @@ export default class AnnotationAPI extends EventEmitter {
|
||||
* @param {Object} [abortController] An optional abort method to stop the query
|
||||
* @returns {Promise} returns a model of matching tags with their target domain objects attached
|
||||
*/
|
||||
async searchForTags(query, abortController) {
|
||||
async searchForTags(query, abortSignal) {
|
||||
const matchingTagKeys = this.#getMatchingTags(query);
|
||||
if (!matchingTagKeys.length) {
|
||||
return [];
|
||||
@@ -452,7 +456,7 @@ export default class AnnotationAPI extends EventEmitter {
|
||||
await Promise.all(
|
||||
this.openmct.objects.search(
|
||||
matchingTagKeys,
|
||||
abortController,
|
||||
abortSignal,
|
||||
this.openmct.objects.SEARCH_TYPES.TAGS
|
||||
)
|
||||
)
|
||||
@@ -465,7 +469,10 @@ export default class AnnotationAPI extends EventEmitter {
|
||||
combinedSameTargets,
|
||||
matchingTagKeys
|
||||
);
|
||||
const appliedTargetsModels = await this.#addTargetModelsToResults(appliedTagSearchResults);
|
||||
const appliedTargetsModels = await this.#addTargetModelsToResults(
|
||||
appliedTagSearchResults,
|
||||
abortSignal
|
||||
);
|
||||
const resultsWithValidPath = appliedTargetsModels.filter((result) => {
|
||||
return this.openmct.objects.isReachable(result.targetModels?.[0]?.originalPath);
|
||||
});
|
||||
|
||||
@@ -232,6 +232,10 @@ export default class ObjectAPI {
|
||||
.get(identifier, abortSignal)
|
||||
.then((domainObject) => {
|
||||
delete this.cache[keystring];
|
||||
if (!domainObject && abortSignal.aborted) {
|
||||
// we've aborted the request
|
||||
return;
|
||||
}
|
||||
domainObject = this.applyGetInterceptors(identifier, domainObject);
|
||||
|
||||
if (this.supportsMutation(identifier)) {
|
||||
@@ -786,16 +790,20 @@ export default class ObjectAPI {
|
||||
* Given an identifier, constructs the original path by walking up its parents
|
||||
* @param {module:openmct.ObjectAPI~Identifier} identifier
|
||||
* @param {Array<module:openmct.DomainObject>} path an array of path objects
|
||||
* @param {AbortSignal} abortSignal (optional) signal to abort fetch requests
|
||||
* @returns {Promise<Array<module:openmct.DomainObject>>} a promise containing an array of domain objects
|
||||
*/
|
||||
async getOriginalPath(identifier, path = []) {
|
||||
const domainObject = await this.get(identifier);
|
||||
async getOriginalPath(identifier, path = [], abortSignal = null) {
|
||||
const domainObject = await this.get(identifier, abortSignal);
|
||||
if (!domainObject) {
|
||||
return [];
|
||||
}
|
||||
path.push(domainObject);
|
||||
const { location } = domainObject;
|
||||
if (location && !this.#pathContainsDomainObject(location, path)) {
|
||||
// if we have a location, and we don't already have this in our constructed path,
|
||||
// then keep walking up the path
|
||||
return this.getOriginalPath(utils.parseKeyString(location), path);
|
||||
return this.getOriginalPath(utils.parseKeyString(location), path, abortSignal);
|
||||
} else {
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -20,39 +20,25 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
define(['lodash', 'printj'], function (_, printj) {
|
||||
// TODO: needs reference to formatService;
|
||||
function TelemetryValueFormatter(valueMetadata, formatMap) {
|
||||
import _ from 'lodash';
|
||||
import { sprintf } from 'printj';
|
||||
|
||||
// TODO: needs reference to formatService;
|
||||
export default class TelemetryValueFormatter {
|
||||
constructor(valueMetadata, formatMap) {
|
||||
this.valueMetadata = valueMetadata;
|
||||
this.formatMap = formatMap;
|
||||
this.valueMetadataFormat = this.getNonArrayValue(valueMetadata.format);
|
||||
|
||||
const numberFormatter = {
|
||||
parse: function (x) {
|
||||
return Number(x);
|
||||
},
|
||||
format: function (x) {
|
||||
return x;
|
||||
},
|
||||
validate: function (x) {
|
||||
return true;
|
||||
}
|
||||
parse: (x) => Number(x),
|
||||
format: (x) => x,
|
||||
validate: (x) => true
|
||||
};
|
||||
|
||||
this.valueMetadata = valueMetadata;
|
||||
|
||||
function getNonArrayValue(value) {
|
||||
//metadata format could have array formats ex. string[]/number[]
|
||||
const arrayRegex = /\[\]$/g;
|
||||
if (value && value.match(arrayRegex)) {
|
||||
return value.replace(arrayRegex, '');
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
let valueMetadataFormat = getNonArrayValue(valueMetadata.format);
|
||||
|
||||
//Is there an existing formatter for the format specified? If not, default to number format
|
||||
this.formatter = formatMap.get(valueMetadataFormat) || numberFormatter;
|
||||
|
||||
if (valueMetadataFormat === 'enum') {
|
||||
// Is there an existing formatter for the format specified? If not, default to number format
|
||||
this.formatter = formatMap.get(this.valueMetadataFormat) || numberFormatter;
|
||||
if (this.valueMetadataFormat === 'enum') {
|
||||
this.formatter = {};
|
||||
this.enumerations = valueMetadata.enumerations.reduce(
|
||||
function (vm, e) {
|
||||
@@ -66,14 +52,14 @@ define(['lodash', 'printj'], function (_, printj) {
|
||||
byString: {}
|
||||
}
|
||||
);
|
||||
this.formatter.format = function (value) {
|
||||
this.formatter.format = (value) => {
|
||||
if (Object.prototype.hasOwnProperty.call(this.enumerations.byValue, value)) {
|
||||
return this.enumerations.byValue[value];
|
||||
}
|
||||
|
||||
return value;
|
||||
}.bind(this);
|
||||
this.formatter.parse = function (string) {
|
||||
};
|
||||
this.formatter.parse = (string) => {
|
||||
if (typeof string === 'string') {
|
||||
if (Object.prototype.hasOwnProperty.call(this.enumerations.byString, string)) {
|
||||
return this.enumerations.byString[string];
|
||||
@@ -81,19 +67,19 @@ define(['lodash', 'printj'], function (_, printj) {
|
||||
}
|
||||
|
||||
return Number(string);
|
||||
}.bind(this);
|
||||
};
|
||||
}
|
||||
|
||||
// Check for formatString support once instead of per format call.
|
||||
if (valueMetadata.formatString) {
|
||||
const baseFormat = this.formatter.format;
|
||||
const formatString = getNonArrayValue(valueMetadata.formatString);
|
||||
const formatString = this.getNonArrayValue(valueMetadata.formatString);
|
||||
this.formatter.format = function (value) {
|
||||
return printj.sprintf(formatString, baseFormat.call(this, value));
|
||||
return sprintf(formatString, baseFormat.call(this, value));
|
||||
};
|
||||
}
|
||||
|
||||
if (valueMetadataFormat === 'string') {
|
||||
if (this.valueMetadataFormat === 'string') {
|
||||
this.formatter.parse = function (value) {
|
||||
if (value === undefined) {
|
||||
return '';
|
||||
@@ -116,7 +102,17 @@ define(['lodash', 'printj'], function (_, printj) {
|
||||
}
|
||||
}
|
||||
|
||||
TelemetryValueFormatter.prototype.parse = function (datum) {
|
||||
getNonArrayValue(value) {
|
||||
//metadata format could have array formats ex. string[]/number[]
|
||||
const arrayRegex = /\[\]$/g;
|
||||
if (value && value.match(arrayRegex)) {
|
||||
return value.replace(arrayRegex, '');
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
parse(datum) {
|
||||
const isDatumArray = Array.isArray(datum);
|
||||
if (_.isObject(datum)) {
|
||||
const objectDatum = isDatumArray ? datum : datum[this.valueMetadata.source];
|
||||
@@ -130,9 +126,9 @@ define(['lodash', 'printj'], function (_, printj) {
|
||||
}
|
||||
|
||||
return this.formatter.parse(datum);
|
||||
};
|
||||
}
|
||||
|
||||
TelemetryValueFormatter.prototype.format = function (datum) {
|
||||
format(datum) {
|
||||
const isDatumArray = Array.isArray(datum);
|
||||
if (_.isObject(datum)) {
|
||||
const objectDatum = isDatumArray ? datum : datum[this.valueMetadata.source];
|
||||
@@ -146,7 +142,5 @@ define(['lodash', 'printj'], function (_, printj) {
|
||||
}
|
||||
|
||||
return this.formatter.format(datum);
|
||||
};
|
||||
|
||||
return TelemetryValueFormatter;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ export default {
|
||||
},
|
||||
beforeUnmount() {
|
||||
if (this.plotResizeObserver) {
|
||||
this.plotResizeObserver.unobserve(this.$refs.plotWrapper);
|
||||
this.plotResizeObserver.disconnect();
|
||||
clearTimeout(this.resizeTimer);
|
||||
}
|
||||
@@ -106,6 +107,8 @@ export default {
|
||||
if (this.removeBarColorListener) {
|
||||
this.removeBarColorListener();
|
||||
}
|
||||
|
||||
Plotly.purge(this.$refs.plot);
|
||||
},
|
||||
methods: {
|
||||
getAxisMinMax(axis) {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<li>
|
||||
<series-options
|
||||
v-for="series in plotSeries"
|
||||
:key="series.key"
|
||||
:key="series.keyString"
|
||||
:item="series"
|
||||
:color-palette="colorPalette"
|
||||
/>
|
||||
|
||||
@@ -217,7 +217,6 @@ describe('the plugin', function () {
|
||||
'someNamespace:~OpenMCT~outer.test-object.foo.bar'
|
||||
].name
|
||||
).toEqual('A Dotful Object');
|
||||
barGraphView.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -310,7 +309,6 @@ describe('the plugin', function () {
|
||||
|
||||
const plotElement = element.querySelector('.cartesianlayer .scatterlayer .trace .lines');
|
||||
expect(plotElement).not.toBeNull();
|
||||
barGraphView.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -131,6 +131,8 @@ export default {
|
||||
if (this.unobserveColorChanges) {
|
||||
this.unobserveColorChanges();
|
||||
}
|
||||
|
||||
Plotly.purge(this.$refs.plot);
|
||||
},
|
||||
methods: {
|
||||
getUnderlayPlotData() {
|
||||
|
||||
@@ -21,7 +21,10 @@
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div class="c-indicator t-indicator-clock icon-clock no-minify c-indicator--not-clickable">
|
||||
<div
|
||||
class="c-indicator t-indicator-clock icon-clock no-minify c-indicator--not-clickable"
|
||||
role="complementary"
|
||||
>
|
||||
<span class="label c-indicator__label">
|
||||
{{ timeTextValue }}
|
||||
</span>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import printj from 'printj';
|
||||
import { sprintf } from 'printj';
|
||||
|
||||
export default class CustomStringFormatter {
|
||||
constructor(openmct, valueMetadata, itemFormat) {
|
||||
@@ -14,7 +14,7 @@ export default class CustomStringFormatter {
|
||||
}
|
||||
|
||||
if (!this.itemFormat.startsWith('&')) {
|
||||
return printj.sprintf(this.itemFormat, datum[this.valueMetadata.key]);
|
||||
return sprintf(this.itemFormat, datum[this.valueMetadata.key]);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
class="c-fl-container"
|
||||
:style="[{ 'flex-basis': sizeString }]"
|
||||
:class="{ 'is-empty': !frames.length }"
|
||||
role="group"
|
||||
:aria-label="`Container ${container.id}`"
|
||||
>
|
||||
<div
|
||||
v-show="isEditing"
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
ref="frame"
|
||||
class="c-frame c-fl-frame__drag-wrapper is-selectable u-inspectable is-moveable"
|
||||
:draggable="draggable"
|
||||
:aria-label="frameLabel"
|
||||
role="group"
|
||||
@dragstart="initDrag"
|
||||
>
|
||||
<object-frame
|
||||
@@ -95,6 +97,9 @@ export default {
|
||||
},
|
||||
draggable() {
|
||||
return this.isEditing;
|
||||
},
|
||||
frameLabel() {
|
||||
return `${this.domainObject?.name} Frame` || 'Frame';
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
v-show="isEditing && !isDragging"
|
||||
class="c-fl-frame__resize-handle"
|
||||
:class="[dragOrientation]"
|
||||
:aria-grabbed="isGrabbed"
|
||||
@mousedown="mousedown"
|
||||
></div>
|
||||
</template>
|
||||
@@ -49,7 +50,8 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
initialPos: 0,
|
||||
isDragging: false
|
||||
isDragging: false,
|
||||
isGrabbed: false
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
@@ -66,6 +68,7 @@ export default {
|
||||
mousedown(event) {
|
||||
event.preventDefault();
|
||||
|
||||
this.isGrabbed = true;
|
||||
this.$emit('init-move', this.index);
|
||||
|
||||
document.body.addEventListener('mousemove', this.mousemove);
|
||||
@@ -91,6 +94,7 @@ export default {
|
||||
this.$emit('move', this.index, delta, event);
|
||||
},
|
||||
mouseup(event) {
|
||||
this.isGrabbed = false;
|
||||
this.$emit('end-move', event);
|
||||
|
||||
document.body.removeEventListener('mousemove', this.mousemove);
|
||||
|
||||
@@ -103,7 +103,7 @@ function ToolbarProvider(openmct) {
|
||||
emphasis: 'true',
|
||||
callback: function () {
|
||||
openmct.objectViews.emit(
|
||||
`contextAction:${primaryKeyString}`,
|
||||
`contextAction:${tertiaryKeyString}`,
|
||||
'deleteFrame',
|
||||
primary.context.frameId
|
||||
);
|
||||
|
||||
@@ -33,8 +33,11 @@
|
||||
|
||||
<script>
|
||||
import Flatbush from 'flatbush';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import { toRaw } from 'vue';
|
||||
|
||||
import TagEditorClassNames from '../../inspectorViews/annotations/tags/TagEditorClassNames';
|
||||
|
||||
const EXISTING_ANNOTATION_STROKE_STYLE = '#D79078';
|
||||
const EXISTING_ANNOTATION_FILL_STYLE = 'rgba(202, 202, 142, 0.2)';
|
||||
const SELECTED_ANNOTATION_STROKE_COLOR = '#BD8ECC';
|
||||
@@ -118,9 +121,22 @@ export default {
|
||||
document.body.removeEventListener('click', this.cancelSelection);
|
||||
},
|
||||
methods: {
|
||||
onAnnotationChange(annotations) {
|
||||
this.selectedAnnotations = annotations;
|
||||
this.$emit('annotations-changed', annotations);
|
||||
onAnnotationChange(updatedAnnotations) {
|
||||
updatedAnnotations.forEach((updatedAnnotation) => {
|
||||
// Try to find the annotation in the existing selected annotations
|
||||
const existingIndex = this.selectedAnnotations.findIndex((annotation) =>
|
||||
this.openmct.objects.areIdsEqual(annotation.identifier, updatedAnnotation.identifier)
|
||||
);
|
||||
|
||||
// If found, update it
|
||||
if (existingIndex > -1) {
|
||||
this.selectedAnnotations[existingIndex] = updatedAnnotation;
|
||||
} else {
|
||||
// If not found, add it
|
||||
this.selectedAnnotations.push(updatedAnnotation);
|
||||
}
|
||||
});
|
||||
this.$emit('annotations-changed', this.selectedAnnotations);
|
||||
},
|
||||
transformAnnotationRectangleToFlatbushRectangle(annotationRectangle) {
|
||||
let { x, y, width, height } = annotationRectangle;
|
||||
@@ -164,7 +180,13 @@ export default {
|
||||
const targetDetails = [];
|
||||
annotations.forEach((annotation) => {
|
||||
annotation.targets.forEach((target) => {
|
||||
targetDetails.push(toRaw(target));
|
||||
// only add targetDetails if we haven't added it before
|
||||
const targetAlreadyAdded = targetDetails.some((targetDetail) => {
|
||||
return isEqual(targetDetail, toRaw(target));
|
||||
});
|
||||
if (!targetAlreadyAdded) {
|
||||
targetDetails.push(toRaw(target));
|
||||
}
|
||||
});
|
||||
});
|
||||
this.selectedAnnotations = annotations;
|
||||
@@ -296,9 +318,13 @@ export default {
|
||||
cancelSelection(event) {
|
||||
if (this.$refs.canvas) {
|
||||
const clickedInsideCanvas = this.$refs.canvas.contains(event.target);
|
||||
// unfortunate side effect from possibly being detached from the DOM when
|
||||
// adding/deleting tags, so closest() won't work
|
||||
const clickedTagEditor = Object.values(TagEditorClassNames).some((className) => {
|
||||
return event.target.classList.contains(className);
|
||||
});
|
||||
const clickedInsideInspector = event.target.closest('.js-inspector') !== null;
|
||||
const clickedOption = event.target.closest('.js-autocomplete-options') !== null;
|
||||
if (!clickedInsideCanvas && !clickedInsideInspector && !clickedOption) {
|
||||
if (!clickedInsideCanvas && !clickedTagEditor && !clickedInsideInspector) {
|
||||
this.newAnnotationRectangle = {};
|
||||
this.selectedAnnotations = [];
|
||||
this.drawAnnotations();
|
||||
@@ -345,12 +371,13 @@ export default {
|
||||
const resultIndicies = this.annotationsIndex.search(x, y, x, y);
|
||||
resultIndicies.forEach((resultIndex) => {
|
||||
const foundAnnotation = this.indexToAnnotationMap[resultIndex];
|
||||
if (foundAnnotation._deleted) {
|
||||
return;
|
||||
}
|
||||
nearbyAnnotations.push(foundAnnotation);
|
||||
});
|
||||
//show annotations if some were found
|
||||
//if everything has been deleted, don't bother with the selection
|
||||
const allAnnotationsDeleted = nearbyAnnotations.every((annotation) => annotation._deleted);
|
||||
if (allAnnotationsDeleted) {
|
||||
nearbyAnnotations = [];
|
||||
}
|
||||
const { targetDomainObjects, targetDetails } =
|
||||
this.prepareExistingAnnotationSelection(nearbyAnnotations);
|
||||
this.selectImageAnnotations({
|
||||
@@ -419,6 +446,7 @@ export default {
|
||||
},
|
||||
drawAnnotations() {
|
||||
this.clearCanvas();
|
||||
let drawnRectangles = [];
|
||||
this.imageryAnnotations.forEach((annotation) => {
|
||||
if (annotation._deleted) {
|
||||
return;
|
||||
@@ -426,19 +454,31 @@ export default {
|
||||
const annotationRectangle = annotation.targets.find(
|
||||
(target) => target.keyString === this.keyString
|
||||
)?.rectangle;
|
||||
const rectangleForPixelDensity = this.transformRectangleToPixelDense(annotationRectangle);
|
||||
if (this.isSelectedAnnotation(annotation)) {
|
||||
this.drawRectInCanvas(
|
||||
rectangleForPixelDensity,
|
||||
SELECTED_ANNOTATION_FILL_STYLE,
|
||||
SELECTED_ANNOTATION_STROKE_COLOR
|
||||
);
|
||||
} else {
|
||||
this.drawRectInCanvas(
|
||||
rectangleForPixelDensity,
|
||||
EXISTING_ANNOTATION_FILL_STYLE,
|
||||
EXISTING_ANNOTATION_STROKE_STYLE
|
||||
);
|
||||
|
||||
// Check if the rectangle has already been drawn
|
||||
const hasBeenDrawn = drawnRectangles.some(
|
||||
(drawnRect) =>
|
||||
drawnRect.x === annotationRectangle.x &&
|
||||
drawnRect.y === annotationRectangle.y &&
|
||||
drawnRect.width === annotationRectangle.width &&
|
||||
drawnRect.height === annotationRectangle.height
|
||||
);
|
||||
if (!hasBeenDrawn) {
|
||||
const rectangleForPixelDensity = this.transformRectangleToPixelDense(annotationRectangle);
|
||||
if (this.isSelectedAnnotation(annotation)) {
|
||||
this.drawRectInCanvas(
|
||||
rectangleForPixelDensity,
|
||||
SELECTED_ANNOTATION_FILL_STYLE,
|
||||
SELECTED_ANNOTATION_STROKE_COLOR
|
||||
);
|
||||
} else {
|
||||
this.drawRectInCanvas(
|
||||
rectangleForPixelDensity,
|
||||
EXISTING_ANNOTATION_FILL_STYLE,
|
||||
EXISTING_ANNOTATION_STROKE_STYLE
|
||||
);
|
||||
}
|
||||
drawnRectangles.push(annotationRectangle);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as d3Scale from 'd3-scale';
|
||||
import { scaleLinear, scaleUtc } from 'd3-scale';
|
||||
import _ from 'lodash';
|
||||
import mount from 'utils/mount';
|
||||
|
||||
@@ -220,10 +220,10 @@ export default {
|
||||
}
|
||||
|
||||
if (timeSystem.isUTCBased) {
|
||||
this.xScale = d3Scale.scaleUtc();
|
||||
this.xScale = scaleUtc();
|
||||
this.xScale.domain([new Date(this.viewBounds.start), new Date(this.viewBounds.end)]);
|
||||
} else {
|
||||
this.xScale = d3Scale.scaleLinear();
|
||||
this.xScale = scaleLinear();
|
||||
this.xScale.domain([this.viewBounds.start, this.viewBounds.end]);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,8 @@ export default function InspectorDataVisualizationViewProvider(openmct, configur
|
||||
const context = selection[0][0].context;
|
||||
const domainObject = context.item;
|
||||
const dataVisualizationContext = context?.dataVisualization ?? {};
|
||||
const timeFormatter = openmct.telemetry.getFormatter('iso');
|
||||
const timeFormatter =
|
||||
openmct.telemetry.getFormatter('iso') || openmct.telemetry.getFormatter('utc');
|
||||
|
||||
return {
|
||||
show(element) {
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
<script>
|
||||
import mount from 'utils/mount';
|
||||
|
||||
import VisibilityObserver from '../../utils/visibility/VisibilityObserver';
|
||||
import Plot from '../plot/PlotView.vue';
|
||||
import TelemetryFrame from './TelemetryFrame.vue';
|
||||
|
||||
@@ -89,8 +90,9 @@ export default {
|
||||
this.clearPlots();
|
||||
|
||||
this.unregisterTimeContextList = [];
|
||||
this.elementsList = [];
|
||||
this.componentsList = [];
|
||||
this.elementsList = [];
|
||||
this.visibilityObservers = [];
|
||||
|
||||
this.telemetryKeys.forEach(async (telemetryKey) => {
|
||||
const plotObject = await this.openmct.objects.get(telemetryKey);
|
||||
@@ -109,7 +111,10 @@ export default {
|
||||
return this.openmct.time.addIndependentContext(keyString, this.bounds);
|
||||
},
|
||||
renderPlot(plotObject) {
|
||||
const { vNode, destroy } = mount(
|
||||
const wrapper = document.createElement('div');
|
||||
const visibilityObserver = new VisibilityObserver(wrapper);
|
||||
|
||||
const { destroy } = mount(
|
||||
{
|
||||
components: {
|
||||
TelemetryFrame,
|
||||
@@ -117,7 +122,8 @@ export default {
|
||||
},
|
||||
provide: {
|
||||
openmct: this.openmct,
|
||||
path: [plotObject]
|
||||
path: [plotObject],
|
||||
renderWhenVisible: visibilityObserver.renderWhenVisible
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -133,13 +139,15 @@ export default {
|
||||
</TelemetryFrame>`
|
||||
},
|
||||
{
|
||||
app: this.openmct.app
|
||||
app: this.openmct.app,
|
||||
element: wrapper
|
||||
}
|
||||
);
|
||||
|
||||
this.componentsList.push(destroy);
|
||||
this.elementsList.push(vNode.el);
|
||||
this.$refs.numericDataView.append(vNode.el);
|
||||
this.elementsList.push(wrapper);
|
||||
this.visibilityObservers.push(visibilityObserver);
|
||||
this.$refs.numericDataView.append(wrapper);
|
||||
},
|
||||
clearPlots() {
|
||||
if (this.componentsList?.length) {
|
||||
@@ -152,6 +160,11 @@ export default {
|
||||
delete this.elementsList;
|
||||
}
|
||||
|
||||
if (this.visibilityObservers?.length) {
|
||||
this.visibilityObservers.forEach((visibilityObserver) => visibilityObserver.destroy());
|
||||
delete this.visibilityObservers;
|
||||
}
|
||||
|
||||
if (this.plotObjects?.length) {
|
||||
this.plotObjects = [];
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ export default {
|
||||
}
|
||||
|
||||
return this.loadedAnnotations.filter((annotation) => {
|
||||
return !annotation.tags && !annotation._deleted;
|
||||
return !annotation.tags;
|
||||
});
|
||||
},
|
||||
tagAnnotations() {
|
||||
@@ -74,7 +74,7 @@ export default {
|
||||
}
|
||||
|
||||
return this.loadedAnnotations.filter((annotation) => {
|
||||
return !annotation.tags && !annotation._deleted;
|
||||
return !annotation.tags;
|
||||
});
|
||||
},
|
||||
multiSelection() {
|
||||
|
||||
@@ -35,10 +35,13 @@
|
||||
<button
|
||||
v-show="!userAddingTag && !maxTagsAdded"
|
||||
class="c-tag-applier__add-btn c-icon-button c-icon-button--major icon-plus"
|
||||
:class="TagEditorClassNames.ADD_TAG_BUTTON"
|
||||
title="Add new tag"
|
||||
@click="addTag"
|
||||
>
|
||||
<div class="c-icon-button__label c-tag-btn__label">Add Tag</div>
|
||||
<div class="c-icon-button__label c-tag-btn__label" :class="TagEditorClassNames.ADD_TAG_LABEL">
|
||||
Add Tag
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -46,6 +49,7 @@
|
||||
<script>
|
||||
import { toRaw } from 'vue';
|
||||
|
||||
import TagEditorClassNames from './TagEditorClassNames';
|
||||
import TagSelection from './TagSelection.vue';
|
||||
|
||||
export default {
|
||||
@@ -88,7 +92,8 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
addedTags: [],
|
||||
userAddingTag: false
|
||||
userAddingTag: false,
|
||||
TagEditorClassNames: TagEditorClassNames
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
const TagEditorClassNames = Object.freeze({
|
||||
REMOVE_TAG: 'js-remove-tag',
|
||||
AUTOCOMPLETE_INPUT: 'js-autocomplete__input',
|
||||
ADD_TAG_BUTTON: 'js-add-tag-button',
|
||||
ADD_TAG_LABEL: 'js-add-tag-label',
|
||||
TAG_OPTION: 'js-tag-option'
|
||||
});
|
||||
|
||||
export default TagEditorClassNames;
|
||||
@@ -29,7 +29,7 @@
|
||||
:model="availableTagModel"
|
||||
:place-holder-text="'Type to select tag'"
|
||||
class="c-tag-selection"
|
||||
:item-css-class="'icon-circle'"
|
||||
:item-css-class="`icon-circle ${TagEditorClassNames.TAG_OPTION}`"
|
||||
@on-change="tagSelected"
|
||||
/>
|
||||
</template>
|
||||
@@ -42,6 +42,7 @@
|
||||
<button
|
||||
v-show="!readOnly"
|
||||
class="c-completed-tag-deletion c-tag__remove-btn icon-x-in-circle"
|
||||
:class="TagEditorClassNames.REMOVE_TAG"
|
||||
:style="{ textShadow: selectedBackgroundColor + ' 0 0 4px' }"
|
||||
:aria-label="`Remove tag ${selectedTagLabel}`"
|
||||
@click="removeTag"
|
||||
@@ -54,6 +55,7 @@
|
||||
|
||||
<script>
|
||||
import AutoCompleteField from '../../../../api/forms/components/controls/AutoCompleteField.vue';
|
||||
import TagEditorClassNames from './TagEditorClassNames';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -88,7 +90,7 @@ export default {
|
||||
},
|
||||
emits: ['tag-removed', 'tag-added'],
|
||||
data() {
|
||||
return {};
|
||||
return { TagEditorClassNames: TagEditorClassNames };
|
||||
},
|
||||
computed: {
|
||||
availableTagModel() {
|
||||
@@ -137,7 +139,6 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
getAvailableTagByID(tagID) {
|
||||
return this.openmct.annotation.getAvailableTags().find((tag) => {
|
||||
|
||||
@@ -139,6 +139,7 @@
|
||||
@editing-entry="startTransaction"
|
||||
@delete-entry="deleteEntry"
|
||||
@update-entry="updateEntry"
|
||||
@update-annotations="loadAnnotations"
|
||||
@entry-selection="entrySelection(entry)"
|
||||
/>
|
||||
</div>
|
||||
@@ -298,6 +299,12 @@ export default {
|
||||
},
|
||||
showTime() {
|
||||
mutateObject(this.openmct, this.domainObject, 'configuration.showTime', this.showTime);
|
||||
},
|
||||
notebookAnnotations: {
|
||||
handler() {
|
||||
this.filterAndSortEntries();
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
beforeMount() {
|
||||
|
||||
@@ -274,7 +274,8 @@ export default {
|
||||
'change-section-page',
|
||||
'update-entry',
|
||||
'editing-entry',
|
||||
'entry-selection'
|
||||
'entry-selection',
|
||||
'update-annotations'
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
@@ -638,13 +639,16 @@ export default {
|
||||
this.entry.text = restoredQuoteBrackets;
|
||||
this.timestampAndUpdate();
|
||||
},
|
||||
updateAnnotations(newAnnotations) {
|
||||
this.$emit('update-annotations', newAnnotations);
|
||||
},
|
||||
selectAndEmitEntry(event, entry) {
|
||||
selectEntry({
|
||||
element: this.$refs.entry,
|
||||
entryId: entry.id,
|
||||
domainObject: this.domainObject,
|
||||
openmct: this.openmct,
|
||||
onAnnotationChange: this.timestampAndUpdate,
|
||||
onAnnotationChange: this.updateAnnotations,
|
||||
notebookAnnotations: this.notebookAnnotations
|
||||
});
|
||||
event.stopPropagation();
|
||||
|
||||
@@ -20,23 +20,28 @@
|
||||
at runtime from the About dialog for additional information.
|
||||
-->
|
||||
<template>
|
||||
<div
|
||||
class="c-indicator c-indicator--clickable icon-camera"
|
||||
:class="[
|
||||
{ 's-status-off': snapshotCount === 0 },
|
||||
{ 's-status-on': snapshotCount > 0 },
|
||||
{ 's-status-caution': snapshotCount === snapshotMaxCount },
|
||||
{ 'has-new-snapshot': flashIndicator }
|
||||
]"
|
||||
>
|
||||
<span class="label c-indicator__label">
|
||||
{{ indicatorTitle }}
|
||||
<button @click="toggleSnapshot">
|
||||
{{ expanded ? 'Hide' : 'Show' }}
|
||||
</button>
|
||||
</span>
|
||||
<span class="c-indicator__count">{{ snapshotCount }}</span>
|
||||
</div>
|
||||
<aside aria-label="Snapshot Indicator">
|
||||
<div
|
||||
class="c-indicator c-indicator--clickable icon-camera"
|
||||
:class="[
|
||||
{ 's-status-off': snapshotCount === 0 },
|
||||
{ 's-status-on': snapshotCount > 0 },
|
||||
{ 's-status-caution': snapshotCount === snapshotMaxCount },
|
||||
{ 'has-new-snapshot': flashIndicator }
|
||||
]"
|
||||
>
|
||||
<span class="label c-indicator__label">
|
||||
{{ indicatorTitle }}
|
||||
<button
|
||||
:aria-label="expanded ? 'Hide Snapshots' : 'Show Snapshots'"
|
||||
@click="toggleSnapshot"
|
||||
>
|
||||
{{ expanded ? 'Hide' : 'Show' }}
|
||||
</button>
|
||||
</span>
|
||||
<span class="c-indicator__count">{{ snapshotCount }}</span>
|
||||
</div>
|
||||
</aside>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
@@ -180,7 +180,7 @@ define(['uuid'], function ({ v4: uuid }) {
|
||||
{
|
||||
check(domainObject) {
|
||||
return (
|
||||
domainObject.type === 'layout' &&
|
||||
domainObject?.type === 'layout' &&
|
||||
domainObject.configuration &&
|
||||
domainObject.configuration.layout
|
||||
);
|
||||
@@ -201,7 +201,7 @@ define(['uuid'], function ({ v4: uuid }) {
|
||||
{
|
||||
check(domainObject) {
|
||||
return (
|
||||
domainObject.type === 'telemetry.fixed' &&
|
||||
domainObject?.type === 'telemetry.fixed' &&
|
||||
domainObject.configuration &&
|
||||
domainObject.configuration['fixed-display']
|
||||
);
|
||||
@@ -246,7 +246,7 @@ define(['uuid'], function ({ v4: uuid }) {
|
||||
{
|
||||
check(domainObject) {
|
||||
return (
|
||||
domainObject.type === 'table' &&
|
||||
domainObject?.type === 'table' &&
|
||||
domainObject.configuration &&
|
||||
domainObject.configuration.table
|
||||
);
|
||||
|
||||
@@ -53,13 +53,13 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as d3Scale from 'd3-scale';
|
||||
import { scaleLinear, scaleUtc } from 'd3-scale';
|
||||
|
||||
import SwimLane from '@/ui/components/swim-lane/SwimLane.vue';
|
||||
|
||||
import TimelineAxis from '../../../ui/components/TimeSystemAxis.vue';
|
||||
import PlanViewConfiguration from '../PlanViewConfiguration';
|
||||
import { getContrastingColor, getValidatedData } from '../util';
|
||||
import { getContrastingColor, getValidatedData, getValidatedGroups } from '../util';
|
||||
import ActivityTimeline from './ActivityTimeline.vue';
|
||||
|
||||
const PADDING = 1;
|
||||
@@ -342,10 +342,10 @@ export default {
|
||||
}
|
||||
|
||||
if (timeSystem.isUTCBased) {
|
||||
this.xScale = d3Scale.scaleUtc();
|
||||
this.xScale = scaleUtc();
|
||||
this.xScale.domain([new Date(this.viewBounds.start), new Date(this.viewBounds.end)]);
|
||||
} else {
|
||||
this.xScale = d3Scale.scaleLinear();
|
||||
this.xScale = scaleLinear();
|
||||
this.xScale.domain([this.viewBounds.start, this.viewBounds.end]);
|
||||
}
|
||||
|
||||
@@ -416,7 +416,7 @@ export default {
|
||||
return currentRow || SWIMLANE_PADDING;
|
||||
},
|
||||
generateActivities() {
|
||||
const groupNames = Object.keys(this.planData);
|
||||
const groupNames = getValidatedGroups(this.domainObject, this.planData);
|
||||
|
||||
if (!groupNames.length) {
|
||||
return;
|
||||
@@ -430,6 +430,10 @@ export default {
|
||||
let currentRow = 0;
|
||||
|
||||
const rawActivities = this.planData[groupName];
|
||||
if (rawActivities === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
rawActivities.forEach((rawActivity) => {
|
||||
if (!this.isActivityInBounds(rawActivity)) {
|
||||
return;
|
||||
|
||||
@@ -22,17 +22,7 @@
|
||||
|
||||
export function getValidatedData(domainObject) {
|
||||
const sourceMap = domainObject.sourceMap;
|
||||
const body = domainObject.selectFile?.body;
|
||||
let json = {};
|
||||
if (typeof body === 'string') {
|
||||
try {
|
||||
json = JSON.parse(body);
|
||||
} catch (e) {
|
||||
return json;
|
||||
}
|
||||
} else if (body !== undefined) {
|
||||
json = body;
|
||||
}
|
||||
const json = getObjectJson(domainObject);
|
||||
|
||||
if (
|
||||
sourceMap !== undefined &&
|
||||
@@ -69,6 +59,47 @@ export function getValidatedData(domainObject) {
|
||||
}
|
||||
}
|
||||
|
||||
function getObjectJson(domainObject) {
|
||||
const body = domainObject.selectFile?.body;
|
||||
let json = {};
|
||||
if (typeof body === 'string') {
|
||||
try {
|
||||
json = JSON.parse(body);
|
||||
} catch (e) {
|
||||
return json;
|
||||
}
|
||||
} else if (body !== undefined) {
|
||||
json = body;
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
export function getValidatedGroups(domainObject, planData) {
|
||||
let orderedGroupNames;
|
||||
const sourceMap = domainObject.sourceMap;
|
||||
const json = getObjectJson(domainObject);
|
||||
if (sourceMap?.orderedGroups) {
|
||||
const groups = json[sourceMap.orderedGroups];
|
||||
if (groups.length && typeof groups[0] === 'object') {
|
||||
//if groups is a list of objects, then get the name property from each group object.
|
||||
const groupsWithNames = groups.filter(
|
||||
(groupObj) => groupObj.name !== undefined && groupObj.name !== ''
|
||||
);
|
||||
orderedGroupNames = groupsWithNames.map((groupObj) => groupObj.name);
|
||||
} else {
|
||||
// Otherwise, groups is likely a list of names, so use that.
|
||||
orderedGroupNames = groups;
|
||||
}
|
||||
}
|
||||
|
||||
if (orderedGroupNames === undefined) {
|
||||
orderedGroupNames = Object.keys(planData);
|
||||
}
|
||||
|
||||
return orderedGroupNames;
|
||||
}
|
||||
|
||||
export function getContrastingColor(hexColor) {
|
||||
function cutHex(h, start, end) {
|
||||
const hStr = h.charAt(0) === '#' ? h.substring(1, 7) : h;
|
||||
|
||||
@@ -178,7 +178,9 @@
|
||||
import Flatbush from 'flatbush';
|
||||
import _ from 'lodash';
|
||||
import { useEventBus } from 'utils/useEventBus';
|
||||
import { toRaw } from 'vue';
|
||||
|
||||
import TagEditorClassNames from '../inspectorViews/annotations/tags/TagEditorClassNames';
|
||||
import XAxis from './axis/XAxis.vue';
|
||||
import YAxis from './axis/YAxis.vue';
|
||||
import MctChart from './chart/MctChart.vue';
|
||||
@@ -465,9 +467,14 @@ export default {
|
||||
cancelSelection(event) {
|
||||
if (this.$refs?.plot) {
|
||||
const clickedInsidePlot = this.$refs.plot.contains(event.target);
|
||||
// unfortunate side effect from possibly being detached from the DOM when
|
||||
// adding/deleting tags, so closest() won't work
|
||||
const clickedTagEditor = Object.values(TagEditorClassNames).some((className) => {
|
||||
return event.target.classList.contains(className);
|
||||
});
|
||||
const clickedInsideInspector = event.target.closest('.js-inspector') !== null;
|
||||
const clickedOption = event.target.closest('.js-autocomplete-options') !== null;
|
||||
if (!clickedInsidePlot && !clickedInsideInspector && !clickedOption) {
|
||||
if (!clickedInsidePlot && !clickedInsideInspector && !clickedOption && !clickedTagEditor) {
|
||||
this.rectangles = [];
|
||||
this.annotationSelectionsBySeries = {};
|
||||
this.selectPlot();
|
||||
@@ -937,7 +944,10 @@ export default {
|
||||
const targetDetails = [];
|
||||
const uniqueBoundsAnnotations = [];
|
||||
annotations.forEach((annotation) => {
|
||||
targetDetails.push(annotation.targets);
|
||||
// for each target, push toRaw
|
||||
annotation.targets.forEach((target) => {
|
||||
targetDetails.push(toRaw(target));
|
||||
});
|
||||
|
||||
const boundingBoxAlreadyAdded = uniqueBoundsAnnotations.some((existingAnnotation) => {
|
||||
const existingBoundingBox = Object.values(existingAnnotation.targets)[0];
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
<template>
|
||||
<div ref="chart" class="gl-plot-chart-area">
|
||||
<canvas :style="canvasStyle"></canvas>
|
||||
<canvas :style="canvasStyle"></canvas>
|
||||
<canvas :style="canvasStyle" class="js-overlay-canvas"></canvas>
|
||||
<canvas :style="canvasStyle" class="js-main-canvas"></canvas>
|
||||
<div ref="limitArea" class="js-limit-area">
|
||||
<limit-label
|
||||
v-for="(limitLabel, index) in visibleLimitLabels"
|
||||
@@ -197,6 +197,10 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.chartVisible = true;
|
||||
this.chartContainer = this.$refs.chart;
|
||||
this.drawnOnce = false;
|
||||
this.visibilityObserver = new IntersectionObserver(this.visibilityChanged);
|
||||
eventHelpers.extend(this);
|
||||
this.seriesModels = [];
|
||||
this.config = this.getConfig();
|
||||
@@ -239,10 +243,8 @@ export default {
|
||||
this.seriesElements = new WeakMap();
|
||||
this.seriesLimits = new WeakMap();
|
||||
|
||||
let canvasEls = this.$parent.$refs.chartContainer.querySelectorAll('canvas');
|
||||
const mainCanvas = canvasEls[1];
|
||||
const overlayCanvas = canvasEls[0];
|
||||
if (this.initializeCanvas(mainCanvas, overlayCanvas)) {
|
||||
const canvasReadyForDrawing = this.readyCanvasForDrawing();
|
||||
if (canvasReadyForDrawing) {
|
||||
this.draw();
|
||||
}
|
||||
|
||||
@@ -256,6 +258,7 @@ export default {
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.destroy();
|
||||
this.visibilityObserver.unobserve(this.chartContainer);
|
||||
},
|
||||
methods: {
|
||||
getConfig() {
|
||||
@@ -272,6 +275,26 @@ export default {
|
||||
|
||||
return config;
|
||||
},
|
||||
visibilityChanged([entry]) {
|
||||
if (entry.target === this.chartContainer) {
|
||||
const wasVisible = this.chartVisible;
|
||||
this.chartVisible = entry.isIntersecting;
|
||||
if (!this.chartVisible) {
|
||||
// destroy the chart
|
||||
this.destroyCanvas();
|
||||
} else if (!wasVisible && this.chartVisible) {
|
||||
// rebuild the chart
|
||||
this.buildCanvasElements();
|
||||
const canvasInitialized = this.readyCanvasForDrawing();
|
||||
if (canvasInitialized) {
|
||||
this.draw();
|
||||
}
|
||||
this.$emit('plot-reinitialize-canvas');
|
||||
} else if (wasVisible && this.chartVisible) {
|
||||
// ignore, moving on
|
||||
}
|
||||
}
|
||||
},
|
||||
reDraw(newXKey, oldXKey, series) {
|
||||
this.changeInterpolate(newXKey, oldXKey, series);
|
||||
this.changeMarkers(newXKey, oldXKey, series);
|
||||
@@ -417,13 +440,12 @@ export default {
|
||||
this.scheduleDraw();
|
||||
},
|
||||
destroy() {
|
||||
this.destroyCanvas();
|
||||
this.isDestroyed = true;
|
||||
this.stopListening();
|
||||
this.lines.forEach((line) => line.destroy());
|
||||
this.limitLines.forEach((line) => line.destroy());
|
||||
this.pointSets.forEach((pointSet) => pointSet.destroy());
|
||||
this.alarmSets.forEach((alarmSet) => alarmSet.destroy());
|
||||
DrawLoader.releaseDrawAPI(this.drawAPI);
|
||||
},
|
||||
resetYOffsetAndSeriesDataForYAxis(yAxisId) {
|
||||
delete this.offset[yAxisId].y;
|
||||
@@ -477,36 +499,51 @@ export default {
|
||||
return this.offset[yAxisId].y(pSeries.getYVal(point));
|
||||
}.bind(this);
|
||||
},
|
||||
|
||||
initializeCanvas(canvas, overlay) {
|
||||
this.canvas = canvas;
|
||||
this.overlay = overlay;
|
||||
this.drawAPI = DrawLoader.getDrawAPI(canvas, overlay);
|
||||
destroyCanvas() {
|
||||
if (this.isDestroyed) {
|
||||
return;
|
||||
}
|
||||
this.stopListening(this.drawAPI);
|
||||
DrawLoader.releaseDrawAPI(this.drawAPI);
|
||||
if (this.chartContainer) {
|
||||
const canvasElements = this.chartContainer.querySelectorAll('canvas');
|
||||
canvasElements.forEach((canvas) => {
|
||||
canvas.parentNode.removeChild(canvas);
|
||||
});
|
||||
}
|
||||
},
|
||||
readyCanvasForDrawing() {
|
||||
const canvasEls = this.chartContainer.querySelectorAll('canvas');
|
||||
const mainCanvas = canvasEls[1];
|
||||
const overlayCanvas = canvasEls[0];
|
||||
this.canvas = mainCanvas;
|
||||
this.overlay = overlayCanvas;
|
||||
this.drawAPI = DrawLoader.getDrawAPI(mainCanvas, overlayCanvas);
|
||||
if (this.drawAPI) {
|
||||
this.listenTo(this.drawAPI, 'error', this.fallbackToCanvas, this);
|
||||
}
|
||||
|
||||
return Boolean(this.drawAPI);
|
||||
},
|
||||
fallbackToCanvas() {
|
||||
this.stopListening(this.drawAPI);
|
||||
DrawLoader.releaseDrawAPI(this.drawAPI);
|
||||
// Have to throw away the old canvas elements and replace with new
|
||||
// canvas elements in order to get new drawing contexts.
|
||||
buildCanvasElements() {
|
||||
const div = document.createElement('div');
|
||||
div.innerHTML = `
|
||||
<canvas style="position: absolute; background: none; width: 100%; height: 100%;"></canvas>
|
||||
<canvas style="position: absolute; background: none; width: 100%; height: 100%;"></canvas>
|
||||
<canvas style="position: absolute; background: none; width: 100%; height: 100%;" class="js-overlay-canvas"></canvas>
|
||||
<canvas style="position: absolute; background: none; width: 100%; height: 100%;" class="js-main-canvas"></canvas>
|
||||
`;
|
||||
const mainCanvas = div.querySelectorAll('canvas')[1];
|
||||
const overlayCanvas = div.querySelectorAll('canvas')[0];
|
||||
this.canvas.parentNode.replaceChild(mainCanvas, this.canvas);
|
||||
this.chartContainer.appendChild(mainCanvas, this.canvas);
|
||||
this.canvas = mainCanvas;
|
||||
this.overlay.parentNode.replaceChild(overlayCanvas, this.overlay);
|
||||
this.chartContainer.appendChild(overlayCanvas, this.overlay);
|
||||
this.overlay = overlayCanvas;
|
||||
},
|
||||
fallbackToCanvas() {
|
||||
console.warn(`📈 fallback to 2D canvas`);
|
||||
this.destroyCanvas();
|
||||
this.buildCanvasElements();
|
||||
this.drawAPI = DrawLoader.getFallbackDrawAPI(this.canvas, this.overlay);
|
||||
this.$emit('plot-reinitialize-canvas');
|
||||
console.warn(`📈 fallback to 2D canvas`);
|
||||
},
|
||||
removeChartElement(series) {
|
||||
const elements = this.seriesElements.get(toRaw(series));
|
||||
@@ -650,11 +687,15 @@ export default {
|
||||
if (!this.drawScheduled) {
|
||||
const called = this.renderWhenVisible(this.draw);
|
||||
this.drawScheduled = called;
|
||||
if (!this.drawnOnce && called) {
|
||||
this.drawnOnce = true;
|
||||
this.visibilityObserver.observe(this.chartContainer);
|
||||
}
|
||||
}
|
||||
},
|
||||
draw() {
|
||||
this.drawScheduled = false;
|
||||
if (this.isDestroyed) {
|
||||
if (this.isDestroyed || !this.chartVisible) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -682,6 +723,9 @@ export default {
|
||||
});
|
||||
},
|
||||
updateViewport(yAxisId) {
|
||||
if (!this.chartVisible) {
|
||||
return;
|
||||
}
|
||||
const mainYAxisId = this.config.yAxis.get('id');
|
||||
const xRange = this.config.xAxis.get('displayRange');
|
||||
let yRange;
|
||||
|
||||
@@ -29,6 +29,7 @@ define([
|
||||
'./myItems/plugin',
|
||||
'../../example/generator/plugin',
|
||||
'../../example/eventGenerator/plugin',
|
||||
'../../example/dataVisualization/plugin',
|
||||
'./autoflow/AutoflowTabularPlugin',
|
||||
'./timeConductor/plugin',
|
||||
'../../example/imagery/plugin',
|
||||
@@ -94,6 +95,7 @@ define([
|
||||
MyItems,
|
||||
GeneratorPlugin,
|
||||
EventGeneratorPlugin,
|
||||
ExampleDataVisualizationSourcePlugin,
|
||||
AutoflowPlugin,
|
||||
TimeConductorPlugin,
|
||||
ExampleImagery,
|
||||
@@ -158,6 +160,8 @@ define([
|
||||
plugins.example.ExampleImagery = ExampleImagery.default;
|
||||
plugins.example.ExampleFaultSource = ExampleFaultSource.default;
|
||||
plugins.example.EventGeneratorPlugin = EventGeneratorPlugin.default;
|
||||
plugins.example.ExampleDataVisualizationSourcePlugin =
|
||||
ExampleDataVisualizationSourcePlugin.default;
|
||||
plugins.example.ExampleTags = ExampleTags.default;
|
||||
plugins.example.Generator = () => GeneratorPlugin.default;
|
||||
|
||||
|
||||
@@ -477,7 +477,7 @@ export default {
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.filterChanged = _.debounce(this.filterChanged, 500);
|
||||
this.filterTelemetry = _.debounce(this.filterTelemetry, 500);
|
||||
},
|
||||
mounted() {
|
||||
this.csvExporter = new CSVExporter();
|
||||
@@ -667,8 +667,7 @@ export default {
|
||||
this.headersHolderEl.scrollLeft = this.scrollable.scrollLeft;
|
||||
}
|
||||
},
|
||||
filterChanged(columnKey, newFilterValue) {
|
||||
this.filters[columnKey] = newFilterValue;
|
||||
filterTelemetry(columnKey) {
|
||||
if (this.enableRegexSearch[columnKey]) {
|
||||
if (this.isCompleteRegex(this.filters[columnKey])) {
|
||||
this.table.tableRows.setColumnRegexFilter(
|
||||
@@ -684,6 +683,10 @@ export default {
|
||||
|
||||
this.setHeight();
|
||||
},
|
||||
filterChanged(columnKey, newFilterValue) {
|
||||
this.filters[columnKey] = newFilterValue;
|
||||
this.filterTelemetry(columnKey);
|
||||
},
|
||||
clearFilter(columnKey) {
|
||||
this.filters[columnKey] = '';
|
||||
this.table.tableRows.setColumnFilter(columnKey, '');
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as d3Axis from 'd3-axis';
|
||||
import * as d3Scale from 'd3-scale';
|
||||
import * as d3Selection from 'd3-selection';
|
||||
import { axisTop } from 'd3-axis';
|
||||
import { scaleLinear, scaleUtc } from 'd3-scale';
|
||||
import { select } from 'd3-selection';
|
||||
|
||||
import { TIME_CONTEXT_EVENTS } from '../../api/time/constants';
|
||||
import utcMultiTimeFormat from './utcMultiTimeFormat.js';
|
||||
@@ -78,9 +78,9 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
let vis = d3Selection.select(this.$refs.axisHolder).append('svg:svg');
|
||||
let vis = select(this.$refs.axisHolder).append('svg:svg');
|
||||
|
||||
this.xAxis = d3Axis.axisTop();
|
||||
this.xAxis = axisTop();
|
||||
this.dragging = false;
|
||||
|
||||
// draw x axis with labels. CSS is used to position them.
|
||||
@@ -135,9 +135,9 @@ export default {
|
||||
//The D3 scale used depends on the type of time system as d3
|
||||
// supports UTC out of the box.
|
||||
if (timeSystem.isUTCBased) {
|
||||
this.xScale = d3Scale.scaleUtc();
|
||||
this.xScale = scaleUtc();
|
||||
} else {
|
||||
this.xScale = d3Scale.scaleLinear();
|
||||
this.xScale = scaleLinear();
|
||||
}
|
||||
|
||||
this.xAxis.scale(this.xScale);
|
||||
|
||||
@@ -53,7 +53,7 @@ import _ from 'lodash';
|
||||
import SwimLane from '@/ui/components/swim-lane/SwimLane.vue';
|
||||
|
||||
import TimelineAxis from '../../ui/components/TimeSystemAxis.vue';
|
||||
import { getValidatedData } from '../plan/util';
|
||||
import { getValidatedData, getValidatedGroups } from '../plan/util';
|
||||
import TimelineObjectView from './TimelineObjectView.vue';
|
||||
|
||||
const unknownObjectType = {
|
||||
@@ -108,7 +108,8 @@ export default {
|
||||
let objectPath = [domainObject].concat(this.objectPath.slice());
|
||||
let rowCount = 0;
|
||||
if (domainObject.type === 'plan') {
|
||||
rowCount = Object.keys(getValidatedData(domainObject)).length;
|
||||
const planData = getValidatedData(domainObject);
|
||||
rowCount = getValidatedGroups(domainObject, planData).length;
|
||||
} else if (domainObject.type === 'gantt-chart') {
|
||||
rowCount = Object.keys(domainObject.configuration.swimlaneVisibility).length;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ import { v4 as uuid } from 'uuid';
|
||||
import { TIME_CONTEXT_EVENTS } from '../../api/time/constants';
|
||||
import ListView from '../../ui/components/List/ListView.vue';
|
||||
import { getPreciseDuration } from '../../utils/duration';
|
||||
import { getValidatedData } from '../plan/util';
|
||||
import { getValidatedData, getValidatedGroups } from '../plan/util';
|
||||
import { SORT_ORDER_OPTIONS } from './constants';
|
||||
|
||||
const SCROLL_TIMEOUT = 10000;
|
||||
@@ -283,10 +283,13 @@ export default {
|
||||
this.planData = getValidatedData(domainObject);
|
||||
},
|
||||
listActivities() {
|
||||
let groups = Object.keys(this.planData);
|
||||
let groups = getValidatedGroups(this.domainObject, this.planData);
|
||||
let activities = [];
|
||||
|
||||
groups.forEach((key) => {
|
||||
if (this.planData[key] === undefined) {
|
||||
return;
|
||||
}
|
||||
// Create new objects so Vue 3 can detect any changes
|
||||
activities = activities.concat(JSON.parse(JSON.stringify(this.planData[key])));
|
||||
});
|
||||
|
||||
@@ -300,6 +300,7 @@ $colorFormLines: rgba(#000, 0.2);
|
||||
$colorFormSectionHeaderBg: rgba(#000, 0.1);
|
||||
$colorFormSectionHeaderFg: rgba($colorBodyFg, 0.8);
|
||||
$colorInputBg: rgba(black, 0.2);
|
||||
$colorInputBgHov: rgba(black, 0.1);
|
||||
$colorInputFg: $colorBodyFg;
|
||||
$colorFormText: pushBack($colorBodyFg, 10%);
|
||||
$colorInputIcon: pushBack($colorBodyFg, 25%);
|
||||
|
||||
@@ -303,6 +303,7 @@ $colorFormLines: rgba(#000, 0.1);
|
||||
$colorFormSectionHeaderBg: rgba(#000, 0.1);
|
||||
$colorFormSectionHeaderFg: rgba($colorBodyFg, 0.8);
|
||||
$colorInputBg: rgba(black, 0.2);
|
||||
$colorInputBgHov: rgba(black, 0.1);
|
||||
$colorInputFg: $colorBodyFg;
|
||||
$colorFormText: pushBack($colorBodyFg, 10%);
|
||||
$colorInputIcon: pushBack($colorBodyFg, 25%);
|
||||
|
||||
@@ -300,6 +300,7 @@ $colorFormLines: rgba(#000, 0.2);
|
||||
$colorFormSectionHeaderBg: rgba(#000, 0.05);
|
||||
$colorFormSectionHeaderFg: rgba($colorBodyFg, 0.5);
|
||||
$colorInputBg: $colorGenBg;
|
||||
$colorInputBgHov: rgba($colorGenBg, 0.7);
|
||||
$colorInputFg: $colorBodyFg;
|
||||
$colorFormText: pushBack($colorBodyFg, 10%);
|
||||
$colorInputIcon: pushBack($colorBodyFg, 25%);
|
||||
|
||||
@@ -295,8 +295,8 @@
|
||||
cursor: text;
|
||||
|
||||
@include hover() {
|
||||
&:not(:focus, .locked) {
|
||||
background: $colorInputBg;
|
||||
&:not(.locked) {
|
||||
background: $colorInputBgHov;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ export default {
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
this.abortController = new AbortController();
|
||||
this.nameChangeListeners = {};
|
||||
const keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
||||
|
||||
@@ -87,7 +88,18 @@ export default {
|
||||
|
||||
let rawPath = null;
|
||||
if (this.objectPath === null) {
|
||||
rawPath = await this.openmct.objects.getOriginalPath(keyString);
|
||||
try {
|
||||
rawPath = await this.openmct.objects.getOriginalPath(
|
||||
keyString,
|
||||
[],
|
||||
this.abortController.signal
|
||||
);
|
||||
} catch (error) {
|
||||
// aborting the search is ok, everything else should be thrown
|
||||
if (error.name !== 'AbortError') {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rawPath = this.objectPath;
|
||||
}
|
||||
@@ -115,6 +127,9 @@ export default {
|
||||
}
|
||||
},
|
||||
unmounted() {
|
||||
if (this.abortController) {
|
||||
this.abortController.abort();
|
||||
}
|
||||
Object.values(this.nameChangeListeners).forEach((unlisten) => {
|
||||
unlisten();
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<input
|
||||
class="c-search__input"
|
||||
aria-label="Search Input"
|
||||
tabindex="10000"
|
||||
tabindex="0"
|
||||
type="search"
|
||||
:value="value"
|
||||
v-bind="$attrs"
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as d3Axis from 'd3-axis';
|
||||
import * as d3Scale from 'd3-scale';
|
||||
import * as d3Selection from 'd3-selection';
|
||||
import { axisTop } from 'd3-axis';
|
||||
import { scaleLinear, scaleUtc } from 'd3-scale';
|
||||
import { select } from 'd3-selection';
|
||||
|
||||
import utcMultiTimeFormat from '@/plugins/timeConductor/utcMultiTimeFormat';
|
||||
|
||||
@@ -89,7 +89,7 @@ export default {
|
||||
this.useSVG = true;
|
||||
}
|
||||
|
||||
this.container = d3Selection.select(this.$refs.axisHolder);
|
||||
this.container = select(this.$refs.axisHolder);
|
||||
this.svgElement = this.container.append('svg:svg');
|
||||
// draw x axis with labels. CSS is used to position them.
|
||||
this.axisElement = this.svgElement
|
||||
@@ -155,17 +155,17 @@ export default {
|
||||
}
|
||||
|
||||
if (timeSystem.isUTCBased) {
|
||||
this.xScale = d3Scale.scaleUtc();
|
||||
this.xScale = scaleUtc();
|
||||
this.xScale.domain([new Date(bounds.start), new Date(bounds.end)]);
|
||||
} else {
|
||||
this.xScale = d3Scale.scaleLinear();
|
||||
this.xScale = scaleLinear();
|
||||
this.xScale.domain([bounds.start, bounds.end]);
|
||||
}
|
||||
|
||||
this.xScale.range([PADDING, this.offsetWidth - PADDING * 2]);
|
||||
},
|
||||
setAxis() {
|
||||
this.xAxis = d3Axis.axisTop(this.xScale);
|
||||
this.xAxis = axisTop(this.xScale);
|
||||
this.xAxis.tickFormat(utcMultiTimeFormat);
|
||||
|
||||
if (this.width > 1800) {
|
||||
|
||||
19
src/ui/composables/editor.js
Normal file
19
src/ui/composables/editor.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useEventListener } from './event';
|
||||
|
||||
/**
|
||||
* @param {import('../../../openmct').OpenMCT} openmct
|
||||
* @returns {{isEditing: import('vue').Ref<boolean>}} isEditing
|
||||
*/
|
||||
export function useIsEditing(openmct) {
|
||||
const isEditing = ref(false);
|
||||
|
||||
// eslint-disable-next-line func-style
|
||||
const handler = (value) => (isEditing.value = value);
|
||||
|
||||
// Use the base event listener composable
|
||||
useEventListener(openmct.editor, 'isEditing', handler);
|
||||
|
||||
return { isEditing };
|
||||
}
|
||||
18
src/ui/composables/event.js
Normal file
18
src/ui/composables/event.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { onBeforeMount, onBeforeUnmount } from 'vue';
|
||||
|
||||
/**
|
||||
* @param {*} api the specific openmct API to use i.e. openmct.editor
|
||||
* @param {string} eventName
|
||||
* @param {() => void} handler
|
||||
*/
|
||||
export function useEventListener(api, eventName, handler) {
|
||||
onBeforeMount(() => {
|
||||
// Add the event listener before the component is mounted
|
||||
api.on(eventName, handler);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
// Remove the event listener before the component is unmounted
|
||||
api.off(eventName, handler);
|
||||
});
|
||||
}
|
||||
@@ -120,7 +120,7 @@
|
||||
</pane>
|
||||
</multipane>
|
||||
</pane>
|
||||
<pane class="l-shell__pane-main">
|
||||
<pane class="l-shell__pane-main" role="main">
|
||||
<browse-bar
|
||||
ref="browseBar"
|
||||
class="l-shell__main-view-browse-bar"
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<div ref="createButton" class="c-create-button--w">
|
||||
<button
|
||||
class="c-create-button c-button--menu c-button--major icon-plus"
|
||||
:disabled="isEditing"
|
||||
@click.prevent.stop="showCreateMenu"
|
||||
>
|
||||
<span class="c-button__label">Create</span>
|
||||
@@ -31,10 +32,19 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { inject } from 'vue';
|
||||
|
||||
import CreateAction from '@/plugins/formActions/CreateAction';
|
||||
|
||||
import { useIsEditing } from '../composables/editor';
|
||||
|
||||
export default {
|
||||
inject: ['openmct'],
|
||||
setup() {
|
||||
const openmct = inject('openmct');
|
||||
const { isEditing } = useIsEditing(openmct);
|
||||
return { isEditing };
|
||||
},
|
||||
data: function () {
|
||||
return {
|
||||
menuItems: {},
|
||||
|
||||
@@ -21,11 +21,10 @@
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div ref="GrandSearch" aria-label="OpenMCT Search" class="c-gsearch" role="searchbox">
|
||||
<div ref="GrandSearch" aria-label="OpenMCT Search" class="c-gsearch" role="search">
|
||||
<search
|
||||
ref="shell-search"
|
||||
class="c-gsearch__input"
|
||||
tabindex="0"
|
||||
:value="searchValue"
|
||||
@input="searchEverything"
|
||||
@clear="searchEverything"
|
||||
@@ -104,7 +103,7 @@ export default {
|
||||
});
|
||||
};
|
||||
},
|
||||
getPathsForObjects(objectsNeedingPaths) {
|
||||
getPathsForObjects(objectsNeedingPaths, abortSignal) {
|
||||
return Promise.all(
|
||||
objectsNeedingPaths.map(async (domainObject) => {
|
||||
if (!domainObject) {
|
||||
@@ -114,7 +113,9 @@ export default {
|
||||
|
||||
const keyStringForObject = this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||
const originalPathObjects = await this.openmct.objects.getOriginalPath(
|
||||
keyStringForObject
|
||||
keyStringForObject,
|
||||
[],
|
||||
abortSignal
|
||||
);
|
||||
|
||||
return {
|
||||
@@ -130,45 +131,56 @@ export default {
|
||||
this.searchLoading = true;
|
||||
this.$refs.searchResultsDropDown.showSearchStarted();
|
||||
this.abortSearchController = new AbortController();
|
||||
const abortSignal = this.abortSearchController.signal;
|
||||
try {
|
||||
this.annotationSearchResults = await this.openmct.annotation.searchForTags(
|
||||
this.searchValue,
|
||||
abortSignal
|
||||
);
|
||||
const fullObjectSearchResults = await Promise.all(
|
||||
this.openmct.objects.search(this.searchValue, abortSignal)
|
||||
);
|
||||
const aggregatedObjectSearchResults = fullObjectSearchResults.flat();
|
||||
const aggregatedObjectSearchResultsWithPaths = await this.getPathsForObjects(
|
||||
aggregatedObjectSearchResults
|
||||
);
|
||||
const filterAnnotationsAndValidPaths = aggregatedObjectSearchResultsWithPaths.filter(
|
||||
(result) => {
|
||||
if (this.openmct.annotation.isAnnotation(result)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.openmct.objects.isReachable(result?.objectPath);
|
||||
}
|
||||
);
|
||||
this.objectSearchResults = filterAnnotationsAndValidPaths;
|
||||
try {
|
||||
const searchObjectsPromise = this.searchObjects(this.abortSearchController.signal);
|
||||
const searchAnnotationsPromise = this.searchAnnotations(this.abortSearchController.signal);
|
||||
|
||||
// Wait for all promises, but they process their results as they complete
|
||||
await Promise.allSettled([searchObjectsPromise, searchAnnotationsPromise]);
|
||||
|
||||
this.searchLoading = false;
|
||||
this.showSearchResults();
|
||||
} catch (error) {
|
||||
this.searchLoading = false;
|
||||
|
||||
if (this.abortSearchController) {
|
||||
delete this.abortSearchController;
|
||||
}
|
||||
|
||||
// Is this coming from the AbortController?
|
||||
// If so, we can swallow the error. If not, 🤮 it to console
|
||||
if (error.name !== 'AbortError') {
|
||||
console.error(`😞 Error searching`, error);
|
||||
}
|
||||
} finally {
|
||||
if (this.abortSearchController) {
|
||||
delete this.abortSearchController;
|
||||
}
|
||||
}
|
||||
},
|
||||
async searchObjects(abortSignal) {
|
||||
const objectSearchPromises = this.openmct.objects.search(this.searchValue, abortSignal);
|
||||
for await (const objectSearchResult of objectSearchPromises) {
|
||||
const objectsWithPaths = await this.getPathsForObjects(objectSearchResult, abortSignal);
|
||||
this.objectSearchResults.push(
|
||||
...objectsWithPaths.filter((result) => {
|
||||
// Check if the result is NOT an annotation and has a reachable path
|
||||
return (
|
||||
!this.openmct.annotation.isAnnotation(result) &&
|
||||
this.openmct.objects.isReachable(result?.objectPath)
|
||||
);
|
||||
})
|
||||
);
|
||||
// Display the available results so far for objects
|
||||
this.showSearchResults();
|
||||
}
|
||||
},
|
||||
async searchAnnotations(abortSignal) {
|
||||
const annotationSearchResults = await this.openmct.annotation.searchForTags(
|
||||
this.searchValue,
|
||||
abortSignal
|
||||
);
|
||||
this.annotationSearchResults = annotationSearchResults;
|
||||
// Display the available results so far for annotations
|
||||
this.showSearchResults();
|
||||
},
|
||||
showSearchResults() {
|
||||
const dropdownOptions = {
|
||||
searchLoading: this.searchLoading,
|
||||
|
||||
@@ -247,7 +247,7 @@ describe('GrandSearch', () => {
|
||||
// eslint-disable-next-line require-await
|
||||
mockObjectProvider.search = async (query, abortSignal, searchType) => {
|
||||
if (searchType === openmct.objects.SEARCH_TYPES.OBJECTS) {
|
||||
return mockNewObject;
|
||||
return [mockNewObject];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -38,13 +38,11 @@ export default class VisibilityObserver {
|
||||
if (!element) {
|
||||
throw new Error(`VisibilityObserver must be created with an element`);
|
||||
}
|
||||
// set the id to some random 4 letters
|
||||
this.id = Math.random().toString(36).substring(2, 6);
|
||||
this.#element = element;
|
||||
this.isIntersecting = true;
|
||||
this.calledOnce = false;
|
||||
|
||||
this.#observer = new IntersectionObserver(this.#observerCallback);
|
||||
this.#observer.observe(this.#element);
|
||||
this.lastUnfiredFunc = null;
|
||||
this.renderWhenVisible = this.renderWhenVisible.bind(this);
|
||||
}
|
||||
@@ -68,7 +66,12 @@ export default class VisibilityObserver {
|
||||
* @returns {boolean} True if the function was executed immediately, false otherwise.
|
||||
*/
|
||||
renderWhenVisible(func) {
|
||||
if (this.isIntersecting) {
|
||||
if (!this.calledOnce) {
|
||||
this.calledOnce = true;
|
||||
this.#observer.observe(this.#element);
|
||||
window.requestAnimationFrame(func);
|
||||
return true;
|
||||
} else if (this.isIntersecting) {
|
||||
window.requestAnimationFrame(func);
|
||||
return true;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user