Compare commits
118 Commits
fix-gauge
...
release/2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4958594336 | ||
|
|
532cec1531 | ||
|
|
a11a4a23e1 | ||
|
|
1e4d585e9d | ||
|
|
cbecd79f71 | ||
|
|
3deb2e3dc2 | ||
|
|
d6e80447ab | ||
|
|
1a4bd0fb55 | ||
|
|
80f89c7609 | ||
|
|
b82649772f | ||
|
|
7f2ed27106 | ||
|
|
57e02db6b5 | ||
|
|
d54335d21c | ||
|
|
e0ed0bb6e2 | ||
|
|
ed3fd8f965 | ||
|
|
e6d59c61d1 | ||
|
|
b74b27c464 | ||
|
|
d35e161701 | ||
|
|
653cb62f9c | ||
|
|
19b3232fa0 | ||
|
|
19892aab53 | ||
|
|
a168ce25cf | ||
|
|
189c58f952 | ||
|
|
0dfc028e1b | ||
|
|
77e93f1aee | ||
|
|
394fbbe61b | ||
|
|
40afb04f0c | ||
|
|
be73b0158a | ||
|
|
625205f24b | ||
|
|
a706a8b73e | ||
|
|
1ddf5e5137 | ||
|
|
a79646a915 | ||
|
|
d5266e7ac7 | ||
|
|
05de7ee2e0 | ||
|
|
dad88112c4 | ||
|
|
202d6d8c5d | ||
|
|
e70bcc414c | ||
|
|
7bb4a136d7 | ||
|
|
8af3b4309f | ||
|
|
bed3d83fd7 | ||
|
|
efda42cf6d | ||
|
|
e8ee5b3fc9 | ||
|
|
393cb9767f | ||
|
|
8b5daad65c | ||
|
|
fabfecdb3e | ||
|
|
a2d8b13204 | ||
|
|
4b14d2d6d2 | ||
|
|
d545124942 | ||
|
|
6abdbfdff0 | ||
|
|
500e655476 | ||
|
|
5e1f026db2 | ||
|
|
d9efae98c8 | ||
|
|
091f6406a8 | ||
|
|
42a0e503cc | ||
|
|
4697352f60 | ||
|
|
015c764ab3 | ||
|
|
8fe465d9fc | ||
|
|
9c1368885a | ||
|
|
391c0b2e7c | ||
|
|
2ae061dbcd | ||
|
|
41fc502564 | ||
|
|
b4554d2fc1 | ||
|
|
feba5f6d3b | ||
|
|
4357d35f4a | ||
|
|
5041f80e5b | ||
|
|
9e23f79bc8 | ||
|
|
bd1e869f6a | ||
|
|
e4a36532e7 | ||
|
|
2bc2316613 | ||
|
|
2fa36b2176 | ||
|
|
efa38d779e | ||
|
|
951cc6ec0d | ||
|
|
ef4b8a9934 | ||
|
|
c14b48917e | ||
|
|
26165d0a99 | ||
|
|
f7cf3f72c2 | ||
|
|
cb8e09c9f9 | ||
|
|
026eb86f5f | ||
|
|
866859a937 | ||
|
|
afc54f41f6 | ||
|
|
72c980f991 | ||
|
|
9bf39a9cd4 | ||
|
|
33fd95cb2b | ||
|
|
8c92178895 | ||
|
|
35bbebbbc7 | ||
|
|
ce463babff | ||
|
|
27c30132d2 | ||
|
|
2bdac56505 | ||
|
|
35c42ba43d | ||
|
|
6bdb8c9e1c | ||
|
|
4a5467aba7 | ||
|
|
b85238d7d0 | ||
|
|
410b3d6036 | ||
|
|
9a727cac2e | ||
|
|
be5472ebdb | ||
|
|
f39419bc84 | ||
|
|
07bf85a623 | ||
|
|
425e662d6e | ||
|
|
2a689b896f | ||
|
|
ffe6fd1941 | ||
|
|
cae579f5b3 | ||
|
|
a073649e64 | ||
|
|
f40e14cb2c | ||
|
|
4629fbf115 | ||
|
|
500e3bc583 | ||
|
|
a65757d197 | ||
|
|
f20bb4de10 | ||
|
|
1c762f506f | ||
|
|
7d900a80b5 | ||
|
|
8a06dedf9d | ||
|
|
15ab0dae50 | ||
|
|
a7ea5afa59 | ||
|
|
c231c2d7cb | ||
|
|
47fb81ff1c | ||
|
|
0efc6987a5 | ||
|
|
79d1df39b7 | ||
|
|
0c9ea26888 | ||
|
|
153538b6bf |
@@ -2,10 +2,11 @@ version: 2.1
|
|||||||
executors:
|
executors:
|
||||||
pw-focal-development:
|
pw-focal-development:
|
||||||
docker:
|
docker:
|
||||||
- image: mcr.microsoft.com/playwright:v1.23.0-focal
|
- image: mcr.microsoft.com/playwright:v1.25.2-focal
|
||||||
environment:
|
environment:
|
||||||
NODE_ENV: development # Needed to ensure 'dist' folder created and devDependencies installed
|
NODE_ENV: development # Needed to ensure 'dist' folder created and devDependencies installed
|
||||||
PERCY_POSTINSTALL_BROWSER: 'true' # Needed to store the percy browser in cache deps
|
PERCY_POSTINSTALL_BROWSER: 'true' # Needed to store the percy browser in cache deps
|
||||||
|
PERCY_LOGLEVEL: 'debug' # Enable DEBUG level logging for Percy (Issue: https://github.com/nasa/openmct/issues/5742)
|
||||||
parameters:
|
parameters:
|
||||||
BUST_CACHE:
|
BUST_CACHE:
|
||||||
description: "Set this with the CircleCI UI Trigger Workflow button (boolean = true) to bust the cache!"
|
description: "Set this with the CircleCI UI Trigger Workflow button (boolean = true) to bust the cache!"
|
||||||
|
|||||||
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -21,9 +21,9 @@ Closes <!--- Insert Issue Number(s) this PR addresses. Start by typing # will op
|
|||||||
### Reviewer Checklist
|
### Reviewer Checklist
|
||||||
|
|
||||||
* [ ] Changes appear to address issue?
|
* [ ] Changes appear to address issue?
|
||||||
|
* [ ] Reviewer has tested changes by following the provided instructions?
|
||||||
* [ ] Changes appear not to be breaking changes?
|
* [ ] Changes appear not to be breaking changes?
|
||||||
* [ ] Appropriate unit tests included?
|
* [ ] Appropriate automated tests included?
|
||||||
* [ ] Code style and in-line documentation are appropriate?
|
* [ ] Code style and in-line documentation are appropriate?
|
||||||
* [ ] Commit messages meet standards?
|
|
||||||
* [ ] Has associated issue been labelled unverified? (only applicable if this PR closes the issue)
|
* [ ] 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)
|
* [ ] Has associated issue been labelled bug? (only applicable if this PR is for a bug fix)
|
||||||
|
|||||||
1
.github/codeql/codeql-config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
name: 'Custom CodeQL config'
|
||||||
14
.github/dependabot.yml
vendored
@@ -13,8 +13,18 @@ updates:
|
|||||||
- "pr:daveit"
|
- "pr:daveit"
|
||||||
- "pr:platform"
|
- "pr:platform"
|
||||||
ignore:
|
ignore:
|
||||||
- dependency-name: "@playwright/test" #we source the container instead of the dependency in CI
|
#We have to source the playwright container which is not detected by Dependabot
|
||||||
|
- dependency-name: "@playwright/test"
|
||||||
|
- dependency-name: "playwright-core"
|
||||||
|
#Lots of noise in these type patch releases.
|
||||||
|
- dependency-name: "@babel/eslint-parser"
|
||||||
|
update-types: ["version-update:semver-patch"]
|
||||||
|
- dependency-name: "eslint-plugin-vue"
|
||||||
|
update-types: ["version-update:semver-patch"]
|
||||||
|
- dependency-name: "babel-loader"
|
||||||
|
update-types: ["version-update:semver-patch"]
|
||||||
|
- dependency-name: "sinon"
|
||||||
|
update-types: ["version-update:semver-patch"]
|
||||||
- package-ecosystem: "github-actions"
|
- package-ecosystem: "github-actions"
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
|
|||||||
31
.github/workflows/codeql-analysis.yml
vendored
@@ -1,11 +1,10 @@
|
|||||||
|
name: 'CodeQL'
|
||||||
name: "CodeQL"
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [master, 'release/*']
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [master, 'release/*']
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**/*Spec.js'
|
- '**/*Spec.js'
|
||||||
- '**/*.md'
|
- '**/*.md'
|
||||||
@@ -27,17 +26,19 @@ jobs:
|
|||||||
security-events: write
|
security-events: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v2
|
uses: github/codeql-action/init@v2
|
||||||
with:
|
with:
|
||||||
languages: javascript
|
config-file: ./.github/codeql/codeql-config.yml
|
||||||
|
languages: javascript
|
||||||
|
queries: security-and-quality
|
||||||
|
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v2
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v2
|
uses: github/codeql-action/analyze@v2
|
||||||
|
|||||||
7
.github/workflows/e2e-couchdb.yml
vendored
@@ -17,12 +17,13 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- run : docker-compose up -d -f src/plugins/persistence/couch/couchdb-compose.yaml
|
- run : docker-compose -f src/plugins/persistence/couch/couchdb-compose.yaml up --detach
|
||||||
- run : sh src/plugins/persistence/couch/setup-couchdb.sh
|
- run : sleep 3 # wait until CouchDB has started (TODO: there must be a better way)
|
||||||
|
- run : bash src/plugins/persistence/couch/setup-couchdb.sh
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '16'
|
node-version: '16'
|
||||||
- run: npx playwright@1.23.0 install
|
- run: npx playwright@1.25.2 install
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: sh src/plugins/persistence/couch/replace-localstorage-with-couchdb-indexhtml.sh
|
- run: sh src/plugins/persistence/couch/replace-localstorage-with-couchdb-indexhtml.sh
|
||||||
- run: npm run test:e2e:couchdb
|
- run: npm run test:e2e:couchdb
|
||||||
|
|||||||
2
.github/workflows/e2e-pr.yml
vendored
@@ -30,7 +30,7 @@ jobs:
|
|||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '16'
|
node-version: '16'
|
||||||
- run: npx playwright@1.23.0 install
|
- run: npx playwright@1.25.2 install
|
||||||
- run: npx playwright install chrome-beta
|
- run: npx playwright install chrome-beta
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm run test:e2e:full
|
- run: npm run test:e2e:full
|
||||||
|
|||||||
98
.github/workflows/lighthouse.yml
vendored
@@ -1,98 +0,0 @@
|
|||||||
name: lighthouse
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
version:
|
|
||||||
description: 'Which branch do you want to test?' # Limited to branch for now
|
|
||||||
required: false
|
|
||||||
default: 'master'
|
|
||||||
pull_request:
|
|
||||||
types:
|
|
||||||
- labeled
|
|
||||||
jobs:
|
|
||||||
lighthouse-pr:
|
|
||||||
if: ${{ github.event.label.name == 'pr:lighthouse' }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout Master for Baseline
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
ref: master #explicitly checkout master for baseline
|
|
||||||
- name: Install Node 16
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: '16'
|
|
||||||
- name: Cache node modules
|
|
||||||
uses: actions/cache@v2
|
|
||||||
env:
|
|
||||||
cache-name: cache-node-modules
|
|
||||||
with:
|
|
||||||
path: ~/.npm
|
|
||||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
|
|
||||||
- name: npm install with lighthouse cli
|
|
||||||
run: npm install && npm install -g @lhci/cli
|
|
||||||
- name: Run lhci against master to generate baseline and ignore exit codes
|
|
||||||
run: lhci autorun || true
|
|
||||||
- name: Perform clean checkout of PR
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
clean: true
|
|
||||||
- name: Install Node version which is compatible with PR
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
- name: npm install with lighthouse cli
|
|
||||||
run: npm install && npm install -g @lhci/cli
|
|
||||||
- name: Run lhci with PR
|
|
||||||
run: lhci autorun
|
|
||||||
env:
|
|
||||||
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
|
|
||||||
lighthouse-nightly:
|
|
||||||
if: ${{ github.event.schedule }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Install Node 16
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: '16'
|
|
||||||
- name: Cache node modules
|
|
||||||
uses: actions/cache@v2
|
|
||||||
env:
|
|
||||||
cache-name: cache-node-modules
|
|
||||||
with:
|
|
||||||
path: ~/.npm
|
|
||||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
|
|
||||||
- name: npm install with lighthouse cli
|
|
||||||
run: npm install && npm install -g @lhci/cli
|
|
||||||
- name: Run lhci against master to generate baseline
|
|
||||||
run: lhci autorun
|
|
||||||
env:
|
|
||||||
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
|
|
||||||
lighthouse-dispatch:
|
|
||||||
if: ${{ github.event.workflow_dispatch }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
ref: ${{ github.event.inputs.version }}
|
|
||||||
- name: Install Node 14
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: '16'
|
|
||||||
- name: Cache node modules
|
|
||||||
uses: actions/cache@v3
|
|
||||||
env:
|
|
||||||
cache-name: cache-node-modules
|
|
||||||
with:
|
|
||||||
path: ~/.npm
|
|
||||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
|
|
||||||
- name: npm install with lighthouse cli
|
|
||||||
run: npm install && npm install -g @lhci/cli
|
|
||||||
- name: Run lhci against master to generate baseline
|
|
||||||
run: lhci autorun
|
|
||||||
|
|
||||||
8
.github/workflows/npm-prerelease.yml
vendored
@@ -16,7 +16,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: 16
|
node-version: 16
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm test
|
- run: |
|
||||||
|
echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
|
||||||
|
npm whoami
|
||||||
|
npm publish --access=public --tag unstable openmct
|
||||||
|
# - run: npm test
|
||||||
|
|
||||||
publish-npm-prerelease:
|
publish-npm-prerelease:
|
||||||
needs: build
|
needs: build
|
||||||
@@ -28,6 +32,6 @@ jobs:
|
|||||||
node-version: 16
|
node-version: 16
|
||||||
registry-url: https://registry.npmjs.org/
|
registry-url: https://registry.npmjs.org/
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm publish --access public --tag unstable
|
- run: npm publish --access=public --tag unstable
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|||||||
4
.gitignore
vendored
@@ -36,6 +36,10 @@ report.*.json
|
|||||||
test-results
|
test-results
|
||||||
html-test-results
|
html-test-results
|
||||||
|
|
||||||
|
# couchdb scripting artifacts
|
||||||
|
src/plugins/persistence/couch/.env.local
|
||||||
|
index.html.bak
|
||||||
|
|
||||||
# codecov artifacts
|
# codecov artifacts
|
||||||
.nyc_output
|
.nyc_output
|
||||||
coverage
|
coverage
|
||||||
|
|||||||
11
.npmignore
@@ -10,9 +10,6 @@
|
|||||||
# https://github.com/nasa/openmct/issues/4992
|
# https://github.com/nasa/openmct/issues/4992
|
||||||
!/example/**/*
|
!/example/**/*
|
||||||
|
|
||||||
# We will remove this in https://github.com/nasa/openmct/issues/4922
|
|
||||||
!/app.js
|
|
||||||
|
|
||||||
# ...except for these files in the above folders.
|
# ...except for these files in the above folders.
|
||||||
/src/**/*Spec.js
|
/src/**/*Spec.js
|
||||||
/src/**/test/
|
/src/**/test/
|
||||||
@@ -24,4 +21,10 @@
|
|||||||
!copyright-notice.html
|
!copyright-notice.html
|
||||||
!index.html
|
!index.html
|
||||||
!openmct.js
|
!openmct.js
|
||||||
!SECURITY.md
|
!SECURITY.md
|
||||||
|
|
||||||
|
# Add e2e tests to npm package
|
||||||
|
!/e2e/**/*
|
||||||
|
|
||||||
|
# ... except our test-data folder files.
|
||||||
|
/e2e/test-data/*.json
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ accept changes from external contributors.
|
|||||||
|
|
||||||
The short version:
|
The short version:
|
||||||
|
|
||||||
1. Write your contribution or describe your idea in the form of an [GitHub issue](https://github.com/nasa/openmct/issues/new/choose) or [Starting a GitHub Discussion](https://github.com/nasa/openmct/discussions)
|
1. Write your contribution or describe your idea in the form of a [GitHub issue](https://github.com/nasa/openmct/issues/new/choose) or [start a GitHub discussion](https://github.com/nasa/openmct/discussions).
|
||||||
2. Make sure your contribution meets code, test, and commit message
|
2. Make sure your contribution meets code, test, and commit message
|
||||||
standards as described below.
|
standards as described below.
|
||||||
3. Submit a pull request from a topic branch back to `master`. Include a check
|
3. Submit a pull request from a topic branch back to `master`. Include a check
|
||||||
@@ -173,7 +173,7 @@ The following guidelines are provided for anyone contributing source code to the
|
|||||||
1. Avoid deep nesting (especially of functions), except where necessary
|
1. Avoid deep nesting (especially of functions), except where necessary
|
||||||
(e.g. due to closure scope).
|
(e.g. due to closure scope).
|
||||||
1. End with a single new-line character.
|
1. End with a single new-line character.
|
||||||
1. Always use ES6 `Class`es and inheritence rather than the pre-ES6 prototypal
|
1. Always use ES6 `Class`es and inheritance rather than the pre-ES6 prototypal
|
||||||
pattern.
|
pattern.
|
||||||
1. Within a given function's scope, do not mix declarations and imperative
|
1. Within a given function's scope, do not mix declarations and imperative
|
||||||
code, and present these in the following order:
|
code, and present these in the following order:
|
||||||
@@ -328,4 +328,4 @@ checklist).
|
|||||||
Write out a small list of tests performed with just enough detail for another developer on the team
|
Write out a small list of tests performed with just enough detail for another developer on the team
|
||||||
to execute.
|
to execute.
|
||||||
|
|
||||||
i.e. ```When Clicking on Add button, new `object` appears in dropdown.```
|
i.e. ```When Clicking on Add button, new `object` appears in dropdown.```
|
||||||
|
|||||||
16
README.md
@@ -6,10 +6,8 @@ Please visit our [Official Site](https://nasa.github.io/openmct/) and [Getting S
|
|||||||
|
|
||||||
Once you've created something amazing with Open MCT, showcase your work in our GitHub Discussions [Show and Tell](https://github.com/nasa/openmct/discussions/categories/show-and-tell) section. We love seeing unique and wonderful implementations of Open MCT!
|
Once you've created something amazing with Open MCT, showcase your work in our GitHub Discussions [Show and Tell](https://github.com/nasa/openmct/discussions/categories/show-and-tell) section. We love seeing unique and wonderful implementations of Open MCT!
|
||||||
|
|
||||||
## See Open MCT in Action
|

|
||||||
|
|
||||||
Try Open MCT now with our [live demo](https://openmct-demo.herokuapp.com/).
|
|
||||||

|
|
||||||
|
|
||||||
## Building and Running Open MCT Locally
|
## Building and Running Open MCT Locally
|
||||||
|
|
||||||
@@ -30,6 +28,8 @@ Building and running Open MCT in your local dev environment is very easy. Be sur
|
|||||||
|
|
||||||
Open MCT is now running, and can be accessed by pointing a web browser at [http://localhost:8080/](http://localhost:8080/)
|
Open MCT is now running, and can be accessed by pointing a web browser at [http://localhost:8080/](http://localhost:8080/)
|
||||||
|
|
||||||
|
Open MCT is built using [`npm`](http://npmjs.com/) and [`webpack`](https://webpack.js.org/).
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Documentation is available on the [Open MCT website](https://nasa.github.io/openmct/documentation/).
|
Documentation is available on the [Open MCT website](https://nasa.github.io/openmct/documentation/).
|
||||||
@@ -43,11 +43,9 @@ our documentation.
|
|||||||
We want Open MCT to be as easy to use, install, run, and develop for as
|
We want Open MCT to be as easy to use, install, run, and develop for as
|
||||||
possible, and your feedback will help us get there! Feedback can be provided via [GitHub issues](https://github.com/nasa/openmct/issues/new/choose), [Starting a GitHub Discussion](https://github.com/nasa/openmct/discussions), or by emailing us at [arc-dl-openmct@mail.nasa.gov](mailto:arc-dl-openmct@mail.nasa.gov).
|
possible, and your feedback will help us get there! Feedback can be provided via [GitHub issues](https://github.com/nasa/openmct/issues/new/choose), [Starting a GitHub Discussion](https://github.com/nasa/openmct/discussions), or by emailing us at [arc-dl-openmct@mail.nasa.gov](mailto:arc-dl-openmct@mail.nasa.gov).
|
||||||
|
|
||||||
## Building Applications With Open MCT
|
## Developing Applications With Open MCT
|
||||||
|
|
||||||
Open MCT is built using [`npm`](http://npmjs.com/) and [`webpack`](https://webpack.js.org/).
|
For more on developing with Open MCT, see our documentation for a guide on [Developing Applications with Open MCT](./API.md#starting-an-open-mct-application).
|
||||||
|
|
||||||
See our documentation for a guide on [building Applications with Open MCT](https://github.com/nasa/openmct/blob/master/API.md#starting-an-open-mct-application).
|
|
||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
@@ -64,7 +62,7 @@ that is intended to be added or removed as a single unit.
|
|||||||
As well as providing an extension mechanism, most of the core Open MCT codebase is also
|
As well as providing an extension mechanism, most of the core Open MCT codebase is also
|
||||||
written as plugins.
|
written as plugins.
|
||||||
|
|
||||||
For information on writing plugins, please see [our API documentation](https://github.com/nasa/openmct/blob/master/API.md#plugins).
|
For information on writing plugins, please see [our API documentation](./API.md#plugins).
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
@@ -100,7 +98,7 @@ To run the performance tests:
|
|||||||
The test suite is configured to all tests localed in `e2e/tests/` ending in `*.e2e.spec.js`. For more about the e2e test suite, please see the [README](./e2e/README.md)
|
The test suite is configured to all tests localed in `e2e/tests/` ending in `*.e2e.spec.js`. For more about the e2e test suite, please see the [README](./e2e/README.md)
|
||||||
|
|
||||||
### Security Tests
|
### Security Tests
|
||||||
Each commit is analyzed for known security vulnerabilities using [CodeQL](https://codeql.github.com/docs/codeql-language-guides/codeql-library-for-javascript/) and our overall security report is available on [LGTM](https://lgtm.com/projects/g/nasa/openmct/)
|
Each commit is analyzed for known security vulnerabilities using [CodeQL](https://codeql.github.com/docs/codeql-language-guides/codeql-library-for-javascript/) and our overall security report is available on [LGTM](https://lgtm.com/projects/g/nasa/openmct/). The list of CWE coverage items is avaiable in the [CodeQL docs](https://codeql.github.com/codeql-query-help/javascript-cwe/). The CodeQL workflow is specified in the [CodeQL analysis file](./.github/workflows/codeql-analysis.yml) and the custom [CodeQL config](./.github/codeql/codeql-config.yml).
|
||||||
|
|
||||||
### Test Reporting and Code Coverage
|
### Test Reporting and Code Coverage
|
||||||
|
|
||||||
|
|||||||
92
app.js
@@ -1,92 +0,0 @@
|
|||||||
/*global process*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Usage:
|
|
||||||
*
|
|
||||||
* npm install minimist express
|
|
||||||
* node app.js [options]
|
|
||||||
*/
|
|
||||||
|
|
||||||
const options = require('minimist')(process.argv.slice(2));
|
|
||||||
const express = require('express');
|
|
||||||
const app = express();
|
|
||||||
const fs = require('fs');
|
|
||||||
const request = require('request');
|
|
||||||
const __DEV__ = !process.env.NODE_ENV || process.env.NODE_ENV === 'development';
|
|
||||||
|
|
||||||
// Defaults
|
|
||||||
options.port = options.port || options.p || 8080;
|
|
||||||
options.host = options.host || 'localhost';
|
|
||||||
options.directory = options.directory || options.D || '.';
|
|
||||||
|
|
||||||
// Show command line options
|
|
||||||
if (options.help || options.h) {
|
|
||||||
console.log("\nUsage: node app.js [options]\n");
|
|
||||||
console.log("Options:");
|
|
||||||
console.log(" --help, -h Show this message.");
|
|
||||||
console.log(" --port, -p <number> Specify port.");
|
|
||||||
console.log(" --directory, -D <bundle> Serve files from specified directory.");
|
|
||||||
console.log("");
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
app.disable('x-powered-by');
|
|
||||||
|
|
||||||
app.use('/proxyUrl', function proxyRequest(req, res, next) {
|
|
||||||
console.log('Proxying request to: ', req.query.url);
|
|
||||||
req.pipe(request({
|
|
||||||
url: req.query.url,
|
|
||||||
strictSSL: false
|
|
||||||
}).on('error', next)).pipe(res);
|
|
||||||
});
|
|
||||||
|
|
||||||
class WatchRunPlugin {
|
|
||||||
apply(compiler) {
|
|
||||||
compiler.hooks.emit.tapAsync('WatchRunPlugin', (compilation, callback) => {
|
|
||||||
console.log('Begin compile at ' + new Date());
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const webpack = require('webpack');
|
|
||||||
let webpackConfig;
|
|
||||||
if (__DEV__) {
|
|
||||||
webpackConfig = require('./webpack.dev');
|
|
||||||
webpackConfig.plugins.push(new webpack.HotModuleReplacementPlugin());
|
|
||||||
webpackConfig.entry.openmct = [
|
|
||||||
'webpack-hot-middleware/client?reload=true',
|
|
||||||
webpackConfig.entry.openmct
|
|
||||||
];
|
|
||||||
webpackConfig.plugins.push(new WatchRunPlugin());
|
|
||||||
} else {
|
|
||||||
webpackConfig = require('./webpack.coverage');
|
|
||||||
}
|
|
||||||
|
|
||||||
const compiler = webpack(webpackConfig);
|
|
||||||
|
|
||||||
app.use(require('webpack-dev-middleware')(
|
|
||||||
compiler,
|
|
||||||
{
|
|
||||||
publicPath: '/dist',
|
|
||||||
stats: 'errors-warnings'
|
|
||||||
}
|
|
||||||
));
|
|
||||||
|
|
||||||
if (__DEV__) {
|
|
||||||
app.use(require('webpack-hot-middleware')(
|
|
||||||
compiler,
|
|
||||||
{}
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Expose index.html for development users.
|
|
||||||
app.get('/', function (req, res) {
|
|
||||||
fs.createReadStream('index.html').pipe(res);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Finally, open the HTTP server and log the instance to the console
|
|
||||||
app.listen(options.port, options.host, function () {
|
|
||||||
console.log('Open MCT application running at %s:%s', options.host, options.port);
|
|
||||||
});
|
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<hr>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
209
docs/gendocs.js
@@ -1,209 +0,0 @@
|
|||||||
/*****************************************************************************
|
|
||||||
* Open MCT, Copyright (c) 2014-2022, 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 require,process,__dirname,GLOBAL*/
|
|
||||||
/*jslint nomen: false */
|
|
||||||
|
|
||||||
|
|
||||||
// Usage:
|
|
||||||
// node gendocs.js --in <source directory> --out <dest directory>
|
|
||||||
|
|
||||||
var CONSTANTS = {
|
|
||||||
DIAGRAM_WIDTH: 800,
|
|
||||||
DIAGRAM_HEIGHT: 500
|
|
||||||
},
|
|
||||||
TOC_HEAD = "# Table of Contents";
|
|
||||||
|
|
||||||
GLOBAL.window = GLOBAL.window || GLOBAL; // nomnoml expects window to be defined
|
|
||||||
(function () {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var fs = require("fs"),
|
|
||||||
mkdirp = require("mkdirp"),
|
|
||||||
path = require("path"),
|
|
||||||
glob = require("glob"),
|
|
||||||
marked = require("marked"),
|
|
||||||
split = require("split"),
|
|
||||||
stream = require("stream"),
|
|
||||||
nomnoml = require('nomnoml'),
|
|
||||||
toc = require("markdown-toc"),
|
|
||||||
Canvas = require('canvas'),
|
|
||||||
header = fs.readFileSync(path.resolve(__dirname, 'header.html')),
|
|
||||||
footer = fs.readFileSync(path.resolve(__dirname, 'footer.html')),
|
|
||||||
options = require("minimist")(process.argv.slice(2));
|
|
||||||
|
|
||||||
// Convert from nomnoml source to a target PNG file.
|
|
||||||
function renderNomnoml(source, target) {
|
|
||||||
var canvas =
|
|
||||||
new Canvas(CONSTANTS.DIAGRAM_WIDTH, CONSTANTS.DIAGRAM_HEIGHT);
|
|
||||||
nomnoml.draw(canvas, source, 1.0);
|
|
||||||
canvas.pngStream().pipe(fs.createWriteStream(target));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stream transform.
|
|
||||||
// Pulls out nomnoml diagrams from fenced code blocks and renders them
|
|
||||||
// as PNG files in the output directory, prefixed with a provided name.
|
|
||||||
// The fenced code blocks will be replaced with Markdown in the
|
|
||||||
// output of this stream.
|
|
||||||
function nomnomlifier(outputDirectory, prefix) {
|
|
||||||
var transform = new stream.Transform({ objectMode: true }),
|
|
||||||
isBuilding = false,
|
|
||||||
counter = 1,
|
|
||||||
outputPath,
|
|
||||||
source = "";
|
|
||||||
|
|
||||||
transform._transform = function (chunk, encoding, done) {
|
|
||||||
if (!isBuilding) {
|
|
||||||
if (chunk.trim().indexOf("```nomnoml") === 0) {
|
|
||||||
var outputFilename = prefix + '-' + counter + '.png';
|
|
||||||
outputPath = path.join(outputDirectory, outputFilename);
|
|
||||||
this.push([
|
|
||||||
"\n\n\n"
|
|
||||||
].join(""));
|
|
||||||
isBuilding = true;
|
|
||||||
source = "";
|
|
||||||
counter += 1;
|
|
||||||
} else {
|
|
||||||
// Otherwise, pass through
|
|
||||||
this.push(chunk + '\n');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (chunk.trim() === "```") {
|
|
||||||
// End nomnoml
|
|
||||||
renderNomnoml(source, outputPath);
|
|
||||||
isBuilding = false;
|
|
||||||
} else {
|
|
||||||
source += chunk + '\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
done();
|
|
||||||
};
|
|
||||||
|
|
||||||
return transform;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert from Github-flavored Markdown to HTML
|
|
||||||
function gfmifier(renderTOC) {
|
|
||||||
var transform = new stream.Transform({ objectMode: true }),
|
|
||||||
markdown = "";
|
|
||||||
transform._transform = function (chunk, encoding, done) {
|
|
||||||
markdown += chunk;
|
|
||||||
done();
|
|
||||||
};
|
|
||||||
transform._flush = function (done) {
|
|
||||||
if (renderTOC){
|
|
||||||
// Prepend table of contents
|
|
||||||
markdown =
|
|
||||||
[ TOC_HEAD, toc(markdown).content, "", markdown ].join("\n");
|
|
||||||
}
|
|
||||||
this.push(header);
|
|
||||||
this.push(marked(markdown));
|
|
||||||
this.push(footer);
|
|
||||||
done();
|
|
||||||
};
|
|
||||||
return transform;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Custom renderer for marked; converts relative links from md to html,
|
|
||||||
// and makes headings linkable.
|
|
||||||
function CustomRenderer() {
|
|
||||||
var renderer = new marked.Renderer(),
|
|
||||||
customRenderer = Object.create(renderer);
|
|
||||||
customRenderer.heading = function (text, level) {
|
|
||||||
var escapedText = (text || "").trim().toLowerCase().replace(/\W/g, "-"),
|
|
||||||
aOpen = "<a name=\"" + escapedText + "\" href=\"#" + escapedText + "\">",
|
|
||||||
aClose = "</a>";
|
|
||||||
return aOpen + renderer.heading.apply(renderer, arguments) + aClose;
|
|
||||||
};
|
|
||||||
// Change links to .md files to .html
|
|
||||||
customRenderer.link = function (href, title, text) {
|
|
||||||
// ...but only if they look like relative paths
|
|
||||||
return (href || "").indexOf(":") === -1 && href[0] !== "/" ?
|
|
||||||
renderer.link(href.replace(/\.md/, ".html"), title, text) :
|
|
||||||
renderer.link.apply(renderer, arguments);
|
|
||||||
};
|
|
||||||
return customRenderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
options['in'] = options['in'] || options.i;
|
|
||||||
options.out = options.out || options.o;
|
|
||||||
|
|
||||||
marked.setOptions({
|
|
||||||
renderer: new CustomRenderer(),
|
|
||||||
gfm: true,
|
|
||||||
tables: true,
|
|
||||||
breaks: false,
|
|
||||||
pedantic: false,
|
|
||||||
sanitize: true,
|
|
||||||
smartLists: true,
|
|
||||||
smartypants: false
|
|
||||||
});
|
|
||||||
|
|
||||||
// Convert all markdown files.
|
|
||||||
// First, pull out nomnoml diagrams.
|
|
||||||
// Then, convert remaining Markdown to HTML.
|
|
||||||
glob(options['in'] + "/**/*.md", {}, function (err, files) {
|
|
||||||
files.forEach(function (file) {
|
|
||||||
var destination = file.replace(options['in'], options.out)
|
|
||||||
.replace(/md$/, "html"),
|
|
||||||
destPath = path.dirname(destination),
|
|
||||||
prefix = path.basename(destination).replace(/\.html$/, ""),
|
|
||||||
//Determine whether TOC should be rendered for this file based
|
|
||||||
//on regex provided as command line option
|
|
||||||
renderTOC = file.match(options['suppress-toc'] || "") === null;
|
|
||||||
|
|
||||||
mkdirp(destPath, function (err) {
|
|
||||||
fs.createReadStream(file, { encoding: 'utf8' })
|
|
||||||
.pipe(split())
|
|
||||||
.pipe(nomnomlifier(destPath, prefix))
|
|
||||||
.pipe(gfmifier(renderTOC))
|
|
||||||
.pipe(fs.createWriteStream(destination, {
|
|
||||||
encoding: 'utf8'
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Also copy over all HTML, CSS, or PNG files
|
|
||||||
glob(options['in'] + "/**/*.@(html|css|png)", {}, function (err, files) {
|
|
||||||
files.forEach(function (file) {
|
|
||||||
var destination = file.replace(options['in'], options.out),
|
|
||||||
destPath = path.dirname(destination),
|
|
||||||
streamOptions = {};
|
|
||||||
if (file.match(/png$/)) {
|
|
||||||
streamOptions.encoding = null;
|
|
||||||
} else {
|
|
||||||
streamOptions.encoding = 'utf8';
|
|
||||||
}
|
|
||||||
|
|
||||||
mkdirp(destPath, function (err) {
|
|
||||||
fs.createReadStream(file, streamOptions)
|
|
||||||
.pipe(fs.createWriteStream(destination, streamOptions));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
}());
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<link rel="stylesheet"
|
|
||||||
href="//nasa.github.io/openmct/static/res/css/styles.css">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
href="//nasa.github.io/openmct/static/res/css/documentation.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
@@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
## Sections
|
## Sections
|
||||||
|
|
||||||
* The [API](api/) document is generated from inline documentation
|
* The [API](api/) uses inline documentation
|
||||||
using [JSDoc](http://usejsdoc.org/), and describes the JavaScript objects and
|
using [TypeScript](https://www.typescriptlang.org) and some legacy [JSDoc](https://jsdoc.app/). It describes the JavaScript objects and
|
||||||
functions that make up the software platform.
|
functions that make up the software platform.
|
||||||
|
|
||||||
* The [Development Process](process/) document describes the
|
* The [Development Process](process/) document describes the
|
||||||
|
|||||||
@@ -2,4 +2,5 @@ version: 2
|
|||||||
snapshot:
|
snapshot:
|
||||||
widths: [1024, 2000]
|
widths: [1024, 2000]
|
||||||
min-height: 1440 # px
|
min-height: 1440 # px
|
||||||
|
discovery:
|
||||||
|
concurrency: 2 # https://github.com/percy/cli/discussions/1067
|
||||||
|
|||||||
155
e2e/README.md
@@ -70,83 +70,88 @@ The bulk of our e2e coverage lies in "functional" test coverage which verifies t
|
|||||||
Visual Testing is an essential part of our e2e strategy as it ensures that the application _appears_ correctly to a user while it compliments the functional e2e suite. It would be impractical to make thousands of assertions functional assertions on the look and feel of the application. Visual testing is interested in getting the DOM into a specified state and then comparing that it has not changed against a baseline.
|
Visual Testing is an essential part of our e2e strategy as it ensures that the application _appears_ correctly to a user while it compliments the functional e2e suite. It would be impractical to make thousands of assertions functional assertions on the look and feel of the application. Visual testing is interested in getting the DOM into a specified state and then comparing that it has not changed against a baseline.
|
||||||
|
|
||||||
For a better understanding of the visual issues which affect Open MCT, please see our bug tracker with the `label:visual` filter applied [here](https://github.com/nasa/openmct/issues?q=label%3Abug%3Avisual+)
|
For a better understanding of the visual issues which affect Open MCT, please see our bug tracker with the `label:visual` filter applied [here](https://github.com/nasa/openmct/issues?q=label%3Abug%3Avisual+)
|
||||||
To read about how to write a good visual test, please see [How to write a great Visual Test](#how-to-write-a-great-visual-test).
|
To read about how to write a good visual test, please see [How to write a great Visual Test](#how-to-write-a-great-visual-test).
|
||||||
|
|
||||||
`npm run test:e2e:visual` will run all of the visual tests against a local instance of Open MCT. If no `PERCY_TOKEN` API key is found in the terminal or command line environment variables, no visual comparisons will be made.
|
`npm run test:e2e:visual` will run all of the visual tests against a local instance of Open MCT. If no `PERCY_TOKEN` API key is found in the terminal or command line environment variables, no visual comparisons will be made.
|
||||||
|
|
||||||
#### Percy.io
|
#### Percy.io
|
||||||
|
|
||||||
To make this possible, we're leveraging a 3rd party service, [Percy](https://percy.io/). This service maintains a copy of all changes, users, scm-metadata, and baselines to verify that the application looks and feels the same _unless approved by a Open MCT developer_. To request a Percy API token, please reach out to the Open MCT Dev team on GitHub. For more information, please see the official [Percy documentation](https://docs.percy.io/docs/visual-testing-basics)
|
To make this possible, we're leveraging a 3rd party service, [Percy](https://percy.io/). This service maintains a copy of all changes, users, scm-metadata, and baselines to verify that the application looks and feels the same _unless approved by a Open MCT developer_. To request a Percy API token, please reach out to the Open MCT Dev team on GitHub. For more information, please see the official [Percy documentation](https://docs.percy.io/docs/visual-testing-basics)
|
||||||
|
|
||||||
### (Advanced) Snapshot Testing
|
### (Advanced) Snapshot Testing
|
||||||
|
|
||||||
Snapshot testing is very similar to visual testing but allows us to be more precise in detecting change without relying on a 3rd party service. Unfortuantely, this precision requires advanced test setup and teardown and so we're using this pattern as a last resort.
|
Snapshot testing is very similar to visual testing but allows us to be more precise in detecting change without relying on a 3rd party service. Unfortuantely, this precision requires advanced test setup and teardown and so we're using this pattern as a last resort.
|
||||||
|
|
||||||
To give an example, if a *single* visual test assertion for an Overlay plot is run through multiple DOM rendering engines at various viewports to see how the Plot looks. If that same test were run as a snapshot test, it could only be executed against a single browser, on a single platform (ubuntu docker container).
|
To give an example, if a _single_ visual test assertion for an Overlay plot is run through multiple DOM rendering engines at various viewports to see how the Plot looks. If that same test were run as a snapshot test, it could only be executed against a single browser, on a single platform (ubuntu docker container).
|
||||||
|
|
||||||
Read more about [Playwright Snapshots](https://playwright.dev/docs/test-snapshots)
|
Read more about [Playwright Snapshots](https://playwright.dev/docs/test-snapshots)
|
||||||
|
|
||||||
Open MCT's implementation
|
#### Open MCT's implementation
|
||||||
-Our Snapshot tests receive a @snapshot tag.
|
|
||||||
-Snapshots need to be executed within the official playwright container to ensure we're using the exact rendering platform in CI and locally
|
|
||||||
|
|
||||||
```
|
- Our Snapshot tests receive a `@snapshot` tag.
|
||||||
|
- Snapshots need to be executed within the official Playwright container to ensure we're using the exact rendering platform in CI and locally.
|
||||||
|
|
||||||
|
```sh
|
||||||
docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:[GET THIS VERSION FROM OUR CIRCLECI CONFIG FILE]-focal /bin/bash
|
docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:[GET THIS VERSION FROM OUR CIRCLECI CONFIG FILE]-focal /bin/bash
|
||||||
npm install
|
npm install
|
||||||
npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @snapshot
|
npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @snapshot
|
||||||
```
|
```
|
||||||
|
|
||||||
(WIP) Updating Snapshots
|
### (WIP) Updating Snapshots
|
||||||
When the @snapshot tests fail, they will need to be evaluated to see if the failure is an acceptable change or
|
|
||||||
|
When the `@snapshot` tests fail, they will need to be evaluated to see if the failure is an acceptable change or
|
||||||
|
|
||||||
## Performance Testing
|
## Performance Testing
|
||||||
|
|
||||||
The open source performance tests function mostly as a contract for the locator logic, functionality, and assumptions will work in our downstream, closed source test suites.
|
The open source performance tests function mostly as a contract for the locator logic, functionality, and assumptions will work in our downstream, closed source test suites.
|
||||||
|
|
||||||
They're found in the `/e2e/tests/performance` repo and are to be executed with the following npm script:
|
They're found under `./e2e/tests/performance` and are to be executed with the following npm script:
|
||||||
|
|
||||||
```npm run test:perf```
|
`npm run test:perf`
|
||||||
|
|
||||||
These tests are expected to become blocking and gating with assertions as we extend the capabilities of playwright.
|
These tests are expected to become blocking and gating with assertions as we extend the capabilities of Playwright.
|
||||||
|
|
||||||
## Test Architecture and CI
|
## Test Architecture and CI
|
||||||
|
|
||||||
### Architecture (TODO)
|
### Architecture (TODO)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### File Structure
|
### File Structure
|
||||||
|
|
||||||
Our file structure follows the type of type of testing being excercised at the e2e layer and files containing test suites which matcher application behavior or our `src` and `example` layout. This area is not well refined as we figure out what works best for closed source and downstream projects. This may change altogether if we move `e2e` to it's own npm package.
|
Our file structure follows the type of type of testing being excercised at the e2e layer and files containing test suites which matcher application behavior or our `src` and `example` layout. This area is not well refined as we figure out what works best for closed source and downstream projects. This may change altogether if we move `e2e` to it's own npm package.
|
||||||
|
|
||||||
- `./helper` - contains helper functions or scripts which are leveraged directly within the testsuites. i.e. non-default plugin scripts injected into DOM
|
- `./helper` - contains helper functions or scripts which are leveraged directly within the testsuites. i.e. non-default plugin scripts injected into DOM
|
||||||
- `./test-data` - contains test data which is leveraged or generated in the functional, performance, or visual test suites. i.e. localStorage data
|
- `./test-data` - contains test data which is leveraged or generated in the functional, performance, or visual test suites. i.e. localStorage data
|
||||||
- `./tests/functional` - the bulk of the tests are contained within this folder to verify the functionality of open mct
|
- `./tests/functional` - the bulk of the tests are contained within this folder to verify the functionality of open mct
|
||||||
- `./tests/functional/example/` - tests which specifically verify the example plugins
|
- `./tests/functional/example/` - tests which specifically verify the example plugins
|
||||||
- `./tests/functional/plugins/` - tests which loosely test each plugin. This folder is the most likely to change. Note: some @snapshot tests are still contained within this structure
|
- `./tests/functional/plugins/` - tests which loosely test each plugin. This folder is the most likely to change. Note: some @snapshot tests are still contained within this structure
|
||||||
- `./tests/framework/` - tests which verify that our testframework functionality and assumptions will continue to work based on further refactoring or playwright version changes
|
- `./tests/framework/` - tests which verify that our testframework functionality and assumptions will continue to work based on further refactoring or playwright version changes
|
||||||
- `./tests/performance/` - performance tests
|
- `./tests/performance/` - performance tests
|
||||||
- `./tests/visual/` - Visual tests
|
- `./tests/visual/` - Visual tests
|
||||||
- `./appActions.js` - Contains common fixtures which can be leveraged by testcase authors to quickly move through the application when writing new tests.
|
- `./appActions.js` - Contains common fixtures which can be leveraged by testcase authors to quickly move through the application when writing new tests.
|
||||||
- `./baseFixture.js` - Contains base fixtures which only extend default `@playwright/test` functionality. The goal is to remove these fixtures as native Playwright APIs improve.
|
- `./baseFixture.js` - Contains base fixtures which only extend default `@playwright/test` functionality. The goal is to remove these fixtures as native Playwright APIs improve.
|
||||||
|
|
||||||
Our functional tests end in `*.e2e.spec.js`, visual tests in `*.visual.spec.js` and performance tests in `*.perf.spec.js`.
|
Our functional tests end in `*.e2e.spec.js`, visual tests in `*.visual.spec.js` and performance tests in `*.perf.spec.js`.
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
Where possible, we try to run Open MCT without modification or configuration change so that the Open MCT doesn't fail exclusively in "test mode" or in "production mode".
|
Where possible, we try to run Open MCT without modification or configuration change so that the Open MCT doesn't fail exclusively in "test mode" or in "production mode".
|
||||||
|
|
||||||
Open MCT is leveraging the [config file](https://playwright.dev/docs/test-configuration) pattern to describe the capabilities of Open MCT e2e _where_ it's run
|
Open MCT is leveraging the [config file](https://playwright.dev/docs/test-configuration) pattern to describe the capabilities of Open MCT e2e _where_ it's run
|
||||||
|
|
||||||
- `./playwright-ci.config.js` - Used when running in CI or to debug CI issues locally
|
- `./playwright-ci.config.js` - Used when running in CI or to debug CI issues locally
|
||||||
- `./playwright-local.config.js` - Used when running locally
|
- `./playwright-local.config.js` - Used when running locally
|
||||||
- `./playwright-performance.config.js` - Used when running performance tests in CI or locally
|
- `./playwright-performance.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.config.js` - Used to run the visual tests in CI or locally
|
||||||
|
|
||||||
#### Test Tags
|
#### Test Tags
|
||||||
|
|
||||||
Test tags are a great way of organizing tests outside of a file structure. To learn more see the official documentation [here](https://playwright.dev/docs/test-annotations#tag-tests)
|
Test tags are a great way of organizing tests outside of a file structure. To learn more see the official documentation [here](https://playwright.dev/docs/test-annotations#tag-tests).
|
||||||
|
|
||||||
Current list of test tags:
|
Current list of test tags:
|
||||||
|
|
||||||
- `@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).
|
- `@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).
|
||||||
- `@gds` - Denotes a GDS Test Case used in the VIPER Mission.
|
- `@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 app.js.
|
- `@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).
|
- `@localStorage` - Captures or generates session storage to manipulate browser state. Useful for excluding in tests which require a persistent backend (i.e. CouchDB).
|
||||||
- `@snapshot` - Uses Playwright's snapshot functionality to record a copy of the DOM for direct comparison. Must be run inside of the playwright container.
|
- `@snapshot` - Uses Playwright's snapshot functionality to record a copy of the DOM for direct comparison. Must be run inside of the playwright container.
|
||||||
- `@unstable` - A new test or test which is known to be flaky.
|
- `@unstable` - A new test or test which is known to be flaky.
|
||||||
@@ -154,34 +159,42 @@ Current list of test tags:
|
|||||||
|
|
||||||
### Continuous Integration
|
### Continuous Integration
|
||||||
|
|
||||||
The cheapest time to catch a bug is Pre-merge. Unfortuantely, this is the most expensive time to run all of the tests since each Merge event can consistent of hundreds of commits. For this reason, we're selective in _what_ we run as much as _when_ we run it.
|
The cheapest time to catch a bug is pre-merge. Unfortuantely, this is the most expensive time to run all of the tests since each merge event can consist of hundreds of commits. For this reason, we're selective in _what we run_ as much as _when we run it_.
|
||||||
|
|
||||||
We leverage CircleCI to run tests against each commit and inject the Test Reports which are generated by playwright so that they team can keep track of flaky and [historical Test Trends](https://app.circleci.com/insights/github/nasa/openmct/workflows/overall-circleci-commit-status/tests?branch=master&reporting-window=last-30-days)
|
We leverage CircleCI to run tests against each commit and inject the Test Reports which are generated by Playwright so that they team can keep track of flaky and [historical test trends](https://app.circleci.com/insights/github/nasa/openmct/workflows/overall-circleci-commit-status/tests?branch=master&reporting-window=last-30-days)
|
||||||
|
|
||||||
We leverage Github Actions / Workflows to execute tests as it gives us the ability to run against multiple operating systems with greater control over git event triggers (i.e. Run on a PR Comment event).
|
We leverage Github Actions / Workflows to execute tests as it gives us the ability to run against multiple operating systems with greater control over git event triggers (i.e. Run on a PR Comment event).
|
||||||
|
|
||||||
Our CI environment consists of 3 main modes of operation:
|
Our CI environment consists of 3 main modes of operation:
|
||||||
|
|
||||||
#### 1. Per-Commit Testing
|
#### 1. Per-Commit Testing
|
||||||
|
|
||||||
CircleCI
|
CircleCI
|
||||||
|
|
||||||
- Stable e2e tests against ubuntu and chrome
|
- Stable e2e tests against ubuntu and chrome
|
||||||
- Performance tests against ubuntu and chrome
|
- Performance tests against ubuntu and chrome
|
||||||
- e2e tests are linted
|
- e2e tests are linted
|
||||||
|
|
||||||
#### 2. Per-Merge Testing
|
#### 2. Per-Merge Testing
|
||||||
|
|
||||||
Github Actions / Workflow
|
Github Actions / Workflow
|
||||||
|
|
||||||
- Full suite against all browsers/projects. Triggered with Github Label Event 'pr:e2e'
|
- Full suite against all browsers/projects. Triggered with Github Label Event 'pr:e2e'
|
||||||
- Visual Tests. Triggered with Github Label Event 'pr:visual'
|
- Visual Tests. Triggered with Github Label Event 'pr:visual'
|
||||||
|
|
||||||
#### 3. Scheduled / Batch Testing
|
#### 3. Scheduled / Batch Testing
|
||||||
|
|
||||||
Nightly Testing in Circle CI
|
Nightly Testing in Circle CI
|
||||||
|
|
||||||
- Full e2e suite against ubuntu and chrome
|
- Full e2e suite against ubuntu and chrome
|
||||||
- Performance tests against ubuntu and chrome
|
- Performance tests against ubuntu and chrome
|
||||||
|
|
||||||
Github Actions / Workflow
|
Github Actions / Workflow
|
||||||
|
|
||||||
- Visual Test baseline generation.
|
- Visual Test baseline generation.
|
||||||
|
|
||||||
#### Parallelism and Fast Feedback
|
#### Parallelism and Fast Feedback
|
||||||
|
|
||||||
In order to provide fast feedback in the Per-Commit context, we try to keep total test feedback at 5 minutes or less. That is to say, A developer should have a pass/fail result in under 5 minutes.
|
In order to provide fast feedback in the Per-Commit context, we try to keep total test feedback at 5 minutes or less. That is to say, A developer should have a pass/fail result in under 5 minutes.
|
||||||
|
|
||||||
Playwright has native support for semi-intelligent sharding. Read about it [here](https://playwright.dev/docs/test-parallel#shard-tests-between-multiple-machines).
|
Playwright has native support for semi-intelligent sharding. Read about it [here](https://playwright.dev/docs/test-parallel#shard-tests-between-multiple-machines).
|
||||||
@@ -193,6 +206,7 @@ In addition to the Parallelization of Test Runners (Sharding), we're also runnin
|
|||||||
So for every commit, Playwright is effectively running 4 x 2 concurrent browsercontexts to keep the overall runtime to a miminum.
|
So for every commit, Playwright is effectively running 4 x 2 concurrent browsercontexts to keep the overall runtime to a miminum.
|
||||||
|
|
||||||
At the same time, we don't want to waste CI resources on parallel runs, so we've configured each shard to fail after 5 test failures. Test failure logs are recorded and stored to allow fast triage.
|
At the same time, we don't want to waste CI resources on parallel runs, so we've configured each shard to fail after 5 test failures. Test failure logs are recorded and stored to allow fast triage.
|
||||||
|
|
||||||
#### Test Promotion
|
#### Test Promotion
|
||||||
|
|
||||||
In order to maintain fast and reliable feedback, tests go through a promotion process. All new test cases or test suites must be labeled with the `@unstable` annotation. The Open MCT dev team runs these unstable tests in our private repos to ensure they work downstream and are reliable.
|
In order to maintain fast and reliable feedback, tests go through a promotion process. All new test cases or test suites must be labeled with the `@unstable` annotation. The Open MCT dev team runs these unstable tests in our private repos to ensure they work downstream and are reliable.
|
||||||
@@ -200,34 +214,98 @@ In order to maintain fast and reliable feedback, tests go through a promotion pr
|
|||||||
To run the stable tests, use the ```npm run test:e2e:stable``` command. To run the new and flaky tests, use the ```npm run test:e2e:unstable``` command.
|
To run the stable tests, use the ```npm run test:e2e:stable``` command. To run the new and flaky tests, use the ```npm run test:e2e:unstable``` command.
|
||||||
|
|
||||||
A testcase and testsuite are to be unmarked as @unstable when:
|
A testcase and testsuite are to be unmarked as @unstable when:
|
||||||
|
|
||||||
1. They run as part of "full" run 5 times without failure.
|
1. They run as part of "full" run 5 times without failure.
|
||||||
2. They've been by a Open MCT Developer 5 times in the closed source repo without failure.
|
2. They've been by a Open MCT Developer 5 times in the closed source repo without failure.
|
||||||
|
|
||||||
### Cross-browser and Cross-operating system
|
### Cross-browser and Cross-operating system
|
||||||
|
|
||||||
- Where is it tested
|
#### **What's supported:**
|
||||||
- What's supported
|
|
||||||
- Mobile
|
We are leveraging the `browserslist` project to declare our supported list of browsers.
|
||||||
|
|
||||||
|
#### **Where it's tested:**
|
||||||
|
|
||||||
|
We lint on `browserslist` to ensure that we're not implementing deprecated browser APIs and are aware of browser API improvements over time.
|
||||||
|
|
||||||
|
We also have the need to execute our e2e tests across this published list of browsers. Our browsers and browser version matrix is found inside of our `./playwright-*.config.js`, but mostly follows in order of bleeding edge to stable:
|
||||||
|
|
||||||
|
- `playwright-chromium channel:beta`
|
||||||
|
- A beta version of Chromium from official chromium channels. As close to the bleeding edge as we can get.
|
||||||
|
- `playwright-chromium`
|
||||||
|
- A stable version of Chromium from the official chromium channels. This is always at least 1 version ahead of desktop chrome.
|
||||||
|
- `playwright-chrome`
|
||||||
|
- The stable channel of Chrome from the official chrome channels. This is always 2 versions behind chromium.
|
||||||
|
|
||||||
|
#### **Mobile**
|
||||||
|
|
||||||
|
We have the Mission-need to support iPad. To run our iPad suite, please see our `playwright-*.config.js` with the 'iPad' project.
|
||||||
|
|
||||||
|
#### **Skipping or executing tests based on browser, os, and/os browser version:**
|
||||||
|
|
||||||
|
Conditionally skipping tests based on browser (**RECOMMENDED**):
|
||||||
|
|
||||||
|
```js
|
||||||
|
test('Can adjust image brightness/contrast by dragging the sliders', async ({ page, browserName }) => {
|
||||||
|
// eslint-disable-next-line playwright/no-skipped-test
|
||||||
|
test.skip(browserName === 'firefox', 'This test needs to be updated to work with firefox');
|
||||||
|
|
||||||
|
// ...
|
||||||
|
```
|
||||||
|
|
||||||
|
Conditionally skipping tests based on OS:
|
||||||
|
|
||||||
|
```js
|
||||||
|
test('Can adjust image brightness/contrast by dragging the sliders', async ({ page }) => {
|
||||||
|
// eslint-disable-next-line playwright/no-skipped-test
|
||||||
|
test.skip(process.platform === 'darwin', 'This test needs to be updated to work with MacOS');
|
||||||
|
|
||||||
|
// ...
|
||||||
|
```
|
||||||
|
|
||||||
|
Skipping based on browser version (Rarely used): <https://github.com/microsoft/playwright/discussions/17318>
|
||||||
|
|
||||||
## Test Design, Best Practices, and Tips & Tricks
|
## Test Design, Best Practices, and Tips & Tricks
|
||||||
|
|
||||||
### Test Design (TODO)
|
### Test Design (TODO)
|
||||||
|
|
||||||
- How to make tests robust to function in other contexts (VISTA, VIPER, etc.)
|
- How to make tests robust to function in other contexts (VISTA, VIPER, etc.)
|
||||||
- Leverage the use of appActions.js like getOrCreateDomainObject
|
- Leverage the use of `appActions.js` methods such as `createDomainObjectWithDefaults()`
|
||||||
- How to make tests faster and more resilient
|
- How to make tests faster and more resilient
|
||||||
- When possible, navigate directly by URL
|
- When possible, navigate directly by URL
|
||||||
- Leverage ```await page.goto('/', { waitUntil: 'networkidle' });```
|
- Leverage `await page.goto('./', { waitUntil: 'networkidle' });`
|
||||||
- Avoid repeated setup to test to test a single assertion. Write longer tests with multiple soft assertions.
|
- Avoid repeated setup to test to test a single assertion. Write longer tests with multiple soft assertions.
|
||||||
|
|
||||||
### How to write a great test (TODO)
|
### How to write a great test (WIP)
|
||||||
|
|
||||||
|
- Use our [App Actions](./appActions.js) for performing common actions whenever applicable.
|
||||||
|
- If you create an object outside of using the `createDomainObjectWithDefaults` App Action, make sure to fill in the 'Notes' section of your object with `page.testNotes`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Fill the "Notes" section with information about the
|
||||||
|
// currently running test and its project.
|
||||||
|
const { testNotes } = page;
|
||||||
|
const notesInput = page.locator('form[name="mctForm"] #notes-textarea');
|
||||||
|
await notesInput.fill(testNotes);
|
||||||
|
```
|
||||||
|
|
||||||
#### How to write a great visual test (TODO)
|
#### How to write a great visual test (TODO)
|
||||||
|
|
||||||
|
#### How to write a great network test
|
||||||
|
|
||||||
|
- Where possible, it is best to mock out third-party network activity to ensure we are testing application behavior of Open MCT.
|
||||||
|
- It is best to be as specific as possible about the expected network request/response structures in creating your mocks.
|
||||||
|
- Make sure to only mock requests which are relevant to the specific behavior being tested.
|
||||||
|
- Where possible, network requests and responses should be treated in an order-agnostic manner, as the order in which certain requests/responses happen is dynamic and subject to change.
|
||||||
|
|
||||||
|
Some examples of mocking network responses in regards to CouchDB can be found in our [couchdb.e2e.spec.js](./tests/functional/couchdb.e2e.spec.js) test file.
|
||||||
|
|
||||||
### Best Practices
|
### Best Practices
|
||||||
|
|
||||||
For now, our best practices exist as self-tested, living documentation in our [exampleTemplate.e2e.spec.js](./tests/framework/exampleTemplate.e2e.spec.js) file.
|
For now, our best practices exist as self-tested, living documentation in our [exampleTemplate.e2e.spec.js](./tests/framework/exampleTemplate.e2e.spec.js) file.
|
||||||
|
|
||||||
|
For best practices with regards to mocking network responses, see our [couchdb.e2e.spec.js](./tests/functional/couchdb.e2e.spec.js) file.
|
||||||
|
|
||||||
### Tips & Tricks (TODO)
|
### Tips & Tricks (TODO)
|
||||||
|
|
||||||
The following contains a list of tips and tricks which don't exactly fit into a FAQ or Best Practices doc.
|
The following contains a list of tips and tricks which don't exactly fit into a FAQ or Best Practices doc.
|
||||||
@@ -240,6 +318,7 @@ There are instances where multiple browser pages will need to be opened to verif
|
|||||||
Test Reporting is done through official Playwright reporters and the CI Systems which execute them.
|
Test Reporting is done through official Playwright reporters and the CI Systems which execute them.
|
||||||
|
|
||||||
We leverage the following official Playwright reporters:
|
We leverage the following official Playwright reporters:
|
||||||
|
|
||||||
- HTML
|
- HTML
|
||||||
- junit
|
- junit
|
||||||
- github annotations
|
- github annotations
|
||||||
@@ -249,6 +328,7 @@ We leverage the following official Playwright reporters:
|
|||||||
When running the tests locally with the `npm run test:local` command, the html report will open automatically on failure. Inside this HTML report will be a complete summary of the finished tests. If the tests failed, you'll see embedded links to screenshot failure, execution logs, and the Tracefile.
|
When running the tests locally with the `npm run test:local` command, the html report will open automatically on failure. Inside this HTML report will be a complete summary of the finished tests. If the tests failed, you'll see embedded links to screenshot failure, execution logs, and the Tracefile.
|
||||||
|
|
||||||
When looking at the reports run in CI, you'll leverage this same HTML Report which is hosted either in CircleCI or Github Actions as a build artifact.
|
When looking at the reports run in CI, you'll leverage this same HTML Report which is hosted either in CircleCI or Github Actions as a build artifact.
|
||||||
|
|
||||||
### e2e Code Coverage
|
### e2e Code Coverage
|
||||||
|
|
||||||
Code coverage is collected during test execution using our custom [baseFixture](./baseFixtures.js). The raw coverage files are stored in a `.nyc_report` directory to be converted into a lcov file with the following [nyc](https://github.com/istanbuljs/nyc) command:
|
Code coverage is collected during test execution using our custom [baseFixture](./baseFixtures.js). The raw coverage files are stored in a `.nyc_report` directory to be converted into a lcov file with the following [nyc](https://github.com/istanbuljs/nyc) command:
|
||||||
@@ -257,13 +337,14 @@ Code coverage is collected during test execution using our custom [baseFixture](
|
|||||||
|
|
||||||
At this point, the nyc linecov report can be published to [codecov.io](https://about.codecov.io/) with the following command:
|
At this point, the nyc linecov report can be published to [codecov.io](https://about.codecov.io/) with the following command:
|
||||||
|
|
||||||
```npm run cov:e2e:stable:publish``` for the stable suite running in ubuntu.
|
```npm run cov:e2e:stable:publish``` for the stable suite running in ubuntu.
|
||||||
or
|
or
|
||||||
```npm run cov:e2e:full:publish``` for the full suite running against all available platforms.
|
```npm run cov:e2e:full:publish``` for the full suite running against all available platforms.
|
||||||
|
|
||||||
Codecov.io will combine each of the above commands with [Codecov.io Flags](https://docs.codecov.com/docs/flags). Effectively, this allows us to combine multiple reports which are run at various stages of our CI Pipeline or run as part of a parallel process.
|
Codecov.io will combine each of the above commands with [Codecov.io Flags](https://docs.codecov.com/docs/flags). Effectively, this allows us to combine multiple reports which are run at various stages of our CI Pipeline or run as part of a parallel process.
|
||||||
|
|
||||||
This e2e coverage is combined with our unit test report to give a comprehensive (if flawed) view of line coverage.
|
This e2e coverage is combined with our unit test report to give a comprehensive (if flawed) view of line coverage.
|
||||||
|
|
||||||
## Other
|
## Other
|
||||||
|
|
||||||
### About e2e testing
|
### About e2e testing
|
||||||
@@ -316,6 +397,6 @@ A single e2e test in Open MCT is extended to run:
|
|||||||
|
|
||||||
- Why is my test failing on CI and not locally?
|
- Why is my test failing on CI and not locally?
|
||||||
- How can I view the failing tests on CI?
|
- How can I view the failing tests on CI?
|
||||||
- Tests won't start because 'Error: http://localhost:8080/# is already used...'
|
- Tests won't start because 'Error: <http://localhost:8080/># is already used...'
|
||||||
This error will appear when running the tests locally. Sometimes, the webserver is left in an orphaned state and needs to be cleaned up. To clear up the orphaned webserver, execute the following from your Terminal:
|
This error will appear when running the tests locally. Sometimes, the webserver is left in an orphaned state and needs to be cleaned up. To clear up the orphaned webserver, execute the following from your Terminal:
|
||||||
```lsof -n -i4TCP:8080 | awk '{print$2}' | tail -1 | xargs kill -9```
|
```lsof -n -i4TCP:8080 | awk '{print$2}' | tail -1 | xargs kill -9```
|
||||||
|
|||||||
@@ -45,6 +45,9 @@
|
|||||||
* @property {string} url the relative url to the object (for use with `page.goto()`)
|
* @property {string} url the relative url to the object (for use with `page.goto()`)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const Buffer = require('buffer').Buffer;
|
||||||
|
const genUuid = require('uuid').v4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This common function creates a domain object with the default options. It is the preferred way of creating objects
|
* This common function creates a domain object with the default options. It is the preferred way of creating objects
|
||||||
* in the e2e suite when uninterested in properties of the objects themselves.
|
* in the e2e suite when uninterested in properties of the objects themselves.
|
||||||
@@ -54,6 +57,10 @@
|
|||||||
* @returns {Promise<CreatedObjectInfo>} An object containing information about the newly created domain object.
|
* @returns {Promise<CreatedObjectInfo>} An object containing information about the newly created domain object.
|
||||||
*/
|
*/
|
||||||
async function createDomainObjectWithDefaults(page, { type, name, parent = 'mine' }) {
|
async function createDomainObjectWithDefaults(page, { type, name, parent = 'mine' }) {
|
||||||
|
if (!name) {
|
||||||
|
name = `${type}:${genUuid()}`;
|
||||||
|
}
|
||||||
|
|
||||||
const parentUrl = await getHashUrlToDomainObject(page, parent);
|
const parentUrl = await getHashUrlToDomainObject(page, parent);
|
||||||
|
|
||||||
// Navigate to the parent object. This is necessary to create the object
|
// Navigate to the parent object. This is necessary to create the object
|
||||||
@@ -65,13 +72,18 @@ async function createDomainObjectWithDefaults(page, { type, name, parent = 'mine
|
|||||||
await page.click('button:has-text("Create")');
|
await page.click('button:has-text("Create")');
|
||||||
|
|
||||||
// Click the object specified by 'type'
|
// Click the object specified by 'type'
|
||||||
await page.click(`li:text("${type}")`);
|
await page.click(`li[role='menuitem']:text("${type}")`);
|
||||||
|
|
||||||
// Modify the name input field of the domain object to accept 'name'
|
// Modify the name input field of the domain object to accept 'name'
|
||||||
if (name) {
|
const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]');
|
||||||
const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]');
|
await nameInput.fill("");
|
||||||
await nameInput.fill("");
|
await nameInput.fill(name);
|
||||||
await nameInput.fill(name);
|
|
||||||
|
if (page.testNotes) {
|
||||||
|
// Fill the "Notes" section with information about the
|
||||||
|
// currently running test and its project.
|
||||||
|
const notesInput = page.locator('form[name="mctForm"] #notes-textarea');
|
||||||
|
await notesInput.fill(page.testNotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Click OK button and wait for Navigate event
|
// Click OK button and wait for Navigate event
|
||||||
@@ -94,8 +106,72 @@ async function createDomainObjectWithDefaults(page, { type, name, parent = 'mine
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: name || `Unnamed ${type}`,
|
name,
|
||||||
uuid: uuid,
|
uuid,
|
||||||
|
url: objectUrl
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {string} name
|
||||||
|
*/
|
||||||
|
async function expandTreePaneItemByName(page, name) {
|
||||||
|
const treePane = page.locator('#tree-pane');
|
||||||
|
const treeItem = treePane.locator(`role=treeitem[expanded=false][name=/${name}/]`);
|
||||||
|
const expandTriangle = treeItem.locator('.c-disclosure-triangle');
|
||||||
|
await expandTriangle.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Plan object from JSON with the provided options.
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {*} options
|
||||||
|
* @returns {Promise<CreatedObjectInfo>} An object containing information about the newly created domain object.
|
||||||
|
*/
|
||||||
|
async function createPlanFromJSON(page, { name, json, parent = 'mine' }) {
|
||||||
|
const parentUrl = await getHashUrlToDomainObject(page, parent);
|
||||||
|
|
||||||
|
// Navigate to the parent object. This is necessary to create the object
|
||||||
|
// in the correct location, such as a folder, layout, or plot.
|
||||||
|
await page.goto(`${parentUrl}?hideTree=true`);
|
||||||
|
|
||||||
|
//Click the Create button
|
||||||
|
await page.click('button:has-text("Create")');
|
||||||
|
|
||||||
|
// Click 'Plan' menu option
|
||||||
|
await page.click(`li:text("Plan")`);
|
||||||
|
|
||||||
|
// Modify the name input field of the domain object to accept 'name'
|
||||||
|
if (name) {
|
||||||
|
const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]');
|
||||||
|
await nameInput.fill("");
|
||||||
|
await nameInput.fill(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Upload buffer from memory
|
||||||
|
await page.locator('input#fileElem').setInputFiles({
|
||||||
|
name: 'plan.txt',
|
||||||
|
mimeType: 'text/plain',
|
||||||
|
buffer: Buffer.from(JSON.stringify(json))
|
||||||
|
});
|
||||||
|
|
||||||
|
// Click OK button and wait for Navigate event
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForLoadState(),
|
||||||
|
page.click('[aria-label="Save"]'),
|
||||||
|
// Wait for Save Banner to appear
|
||||||
|
page.waitForSelector('.c-message-banner__message')
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Wait until the URL is updated
|
||||||
|
await page.waitForURL(`**/mine/*`);
|
||||||
|
const uuid = await getFocusedObjectUuid(page);
|
||||||
|
const objectUrl = await getHashUrlToDomainObject(page, uuid);
|
||||||
|
|
||||||
|
return {
|
||||||
|
uuid,
|
||||||
|
name,
|
||||||
url: objectUrl
|
url: objectUrl
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -159,15 +235,14 @@ async function getHashUrlToDomainObject(page, uuid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilizes the OpenMCT API to detect if the given object has an active transaction (is in Edit mode).
|
* Utilizes the OpenMCT API to detect if the UI is in Edit mode.
|
||||||
* @private
|
* @private
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
* @param {string | import('../src/api/objects/ObjectAPI').Identifier} identifier
|
* @return {Promise<boolean>} true if the Open MCT is in Edit Mode
|
||||||
* @return {Promise<boolean>} true if the object has an active transaction, false otherwise
|
|
||||||
*/
|
*/
|
||||||
async function _isInEditMode(page, identifier) {
|
async function _isInEditMode(page, identifier) {
|
||||||
// eslint-disable-next-line no-return-await
|
// eslint-disable-next-line no-return-await
|
||||||
return await page.evaluate((objectIdentifier) => window.openmct.objects.isTransactionActive(objectIdentifier), identifier);
|
return await page.evaluate(() => window.openmct.editor.isEditing());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -258,6 +333,8 @@ async function setEndOffset(page, offset) {
|
|||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
module.exports = {
|
module.exports = {
|
||||||
createDomainObjectWithDefaults,
|
createDomainObjectWithDefaults,
|
||||||
|
expandTreePaneItemByName,
|
||||||
|
createPlanFromJSON,
|
||||||
openObjectTreeContextMenu,
|
openObjectTreeContextMenu,
|
||||||
getHashUrlToDomainObject,
|
getHashUrlToDomainObject,
|
||||||
getFocusedObjectUuid,
|
getFocusedObjectUuid,
|
||||||
|
|||||||
60
e2e/helper/notebookUtils.js
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, 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 { createDomainObjectWithDefaults } = require('../appActions');
|
||||||
|
|
||||||
|
const NOTEBOOK_DROP_AREA = '.c-notebook__drag-area';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
*/
|
||||||
|
async function enterTextEntry(page, text) {
|
||||||
|
// Click .c-notebook__drag-area
|
||||||
|
await page.locator(NOTEBOOK_DROP_AREA).click();
|
||||||
|
|
||||||
|
// enter text
|
||||||
|
await page.locator('div.c-ne__text').click();
|
||||||
|
await page.locator('div.c-ne__text').fill(text);
|
||||||
|
await page.locator('div.c-ne__text').press('Enter');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
*/
|
||||||
|
async function dragAndDropEmbed(page, notebookObject) {
|
||||||
|
// Create example telemetry object
|
||||||
|
const swg = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: "Sine Wave Generator"
|
||||||
|
});
|
||||||
|
// Navigate to notebook
|
||||||
|
await page.goto(notebookObject.url);
|
||||||
|
// Expand the tree to reveal the notebook
|
||||||
|
await page.click('button[title="Show selected item in tree"]');
|
||||||
|
// Drag and drop the SWG into the notebook
|
||||||
|
await page.dragAndDrop(`text=${swg.name}`, NOTEBOOK_DROP_AREA);
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
module.exports = {
|
||||||
|
enterTextEntry,
|
||||||
|
dragAndDropEmbed
|
||||||
|
};
|
||||||
@@ -14,7 +14,7 @@ const config = {
|
|||||||
testIgnore: '**/*.perf.spec.js', //Ignore performance tests and define in playwright-perfromance.config.js
|
testIgnore: '**/*.perf.spec.js', //Ignore performance tests and define in playwright-perfromance.config.js
|
||||||
timeout: 60 * 1000,
|
timeout: 60 * 1000,
|
||||||
webServer: {
|
webServer: {
|
||||||
command: 'cross-env NODE_ENV=test npm run start',
|
command: 'npm run start:coverage',
|
||||||
url: 'http://localhost:8080/#',
|
url: 'http://localhost:8080/#',
|
||||||
timeout: 200 * 1000,
|
timeout: 200 * 1000,
|
||||||
reuseExistingServer: false
|
reuseExistingServer: false
|
||||||
|
|||||||
@@ -12,10 +12,7 @@ const config = {
|
|||||||
testIgnore: '**/*.perf.spec.js',
|
testIgnore: '**/*.perf.spec.js',
|
||||||
timeout: 30 * 1000,
|
timeout: 30 * 1000,
|
||||||
webServer: {
|
webServer: {
|
||||||
env: {
|
command: 'npm run start:coverage',
|
||||||
NODE_ENV: 'test'
|
|
||||||
},
|
|
||||||
command: 'npm run start',
|
|
||||||
url: 'http://localhost:8080/#',
|
url: 'http://localhost:8080/#',
|
||||||
timeout: 120 * 1000,
|
timeout: 120 * 1000,
|
||||||
reuseExistingServer: true
|
reuseExistingServer: true
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ const CI = process.env.CI === 'true';
|
|||||||
|
|
||||||
/** @type {import('@playwright/test').PlaywrightTestConfig} */
|
/** @type {import('@playwright/test').PlaywrightTestConfig} */
|
||||||
const config = {
|
const config = {
|
||||||
retries: 1, //Only for debugging purposes because trace is enabled only on first retry
|
retries: 1, //Only for debugging purposes for trace: 'on-first-retry'
|
||||||
testDir: 'tests/performance/',
|
testDir: 'tests/performance/',
|
||||||
timeout: 60 * 1000,
|
timeout: 60 * 1000,
|
||||||
workers: 1, //Only run in serial with 1 worker
|
workers: 1, //Only run in serial with 1 worker
|
||||||
webServer: {
|
webServer: {
|
||||||
command: 'cross-env NODE_ENV=test npm run start',
|
command: 'npm run start', //coverage not generated
|
||||||
url: 'http://localhost:8080/#',
|
url: 'http://localhost:8080/#',
|
||||||
timeout: 200 * 1000,
|
timeout: 200 * 1000,
|
||||||
reuseExistingServer: !CI
|
reuseExistingServer: !CI
|
||||||
|
|||||||
@@ -4,13 +4,13 @@
|
|||||||
|
|
||||||
/** @type {import('@playwright/test').PlaywrightTestConfig<{ theme: string }>} */
|
/** @type {import('@playwright/test').PlaywrightTestConfig<{ theme: string }>} */
|
||||||
const config = {
|
const config = {
|
||||||
retries: 0, // visual tests should never retry due to snapshot comparison errors
|
retries: 0, // Visual tests should never retry due to snapshot comparison errors. Leaving as a shim
|
||||||
testDir: 'tests/visual',
|
testDir: 'tests/visual',
|
||||||
testMatch: '**/*.visual.spec.js', // only run visual tests
|
testMatch: '**/*.visual.spec.js', // only run visual tests
|
||||||
timeout: 60 * 1000,
|
timeout: 60 * 1000,
|
||||||
workers: 2, //Limit to 2 for CircleCI Agent
|
workers: 1, //Lower stress on Circle CI Agent for Visual tests https://github.com/percy/cli/discussions/1067
|
||||||
webServer: {
|
webServer: {
|
||||||
command: 'cross-env NODE_ENV=test npm run start',
|
command: 'npm run start:coverage',
|
||||||
url: 'http://localhost:8080/#',
|
url: 'http://localhost:8080/#',
|
||||||
timeout: 200 * 1000,
|
timeout: 200 * 1000,
|
||||||
reuseExistingServer: !process.env.CI
|
reuseExistingServer: !process.env.CI
|
||||||
@@ -19,8 +19,8 @@ const config = {
|
|||||||
baseURL: 'http://localhost:8080/',
|
baseURL: 'http://localhost:8080/',
|
||||||
headless: true, // this needs to remain headless to avoid visual changes due to GPU rendering in headed browsers
|
headless: true, // this needs to remain headless to avoid visual changes due to GPU rendering in headed browsers
|
||||||
ignoreHTTPSErrors: true,
|
ignoreHTTPSErrors: true,
|
||||||
screenshot: 'on',
|
screenshot: 'only-on-failure',
|
||||||
trace: 'on',
|
trace: 'on-first-retry',
|
||||||
video: 'off'
|
video: 'off'
|
||||||
},
|
},
|
||||||
projects: [
|
projects: [
|
||||||
@@ -31,7 +31,7 @@ const config = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'chrome-snow-theme',
|
name: 'chrome-snow-theme', //Runs the same visual tests but with snow-theme enabled
|
||||||
use: {
|
use: {
|
||||||
browserName: 'chromium',
|
browserName: 'chromium',
|
||||||
theme: 'snow'
|
theme: 'snow'
|
||||||
|
|||||||
@@ -126,13 +126,21 @@ exports.test = test.extend({
|
|||||||
// This should follow in the Project's configuration. Can be set to 'snow' in playwright config.js
|
// This should follow in the Project's configuration. Can be set to 'snow' in playwright config.js
|
||||||
theme: [theme, { option: true }],
|
theme: [theme, { option: true }],
|
||||||
// eslint-disable-next-line no-shadow
|
// eslint-disable-next-line no-shadow
|
||||||
page: async ({ page, theme }, use) => {
|
page: async ({ page, theme }, use, testInfo) => {
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
// eslint-disable-next-line playwright/no-conditional-in-test
|
||||||
if (theme === 'snow') {
|
if (theme === 'snow') {
|
||||||
//inject snow theme
|
//inject snow theme
|
||||||
await page.addInitScript({ path: path.join(__dirname, './helper', './useSnowTheme.js') });
|
await page.addInitScript({ path: path.join(__dirname, './helper', './useSnowTheme.js') });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attach info about the currently running test and its project.
|
||||||
|
// This will be used by appActions to fill in the created
|
||||||
|
// domain object's notes.
|
||||||
|
page.testNotes = [
|
||||||
|
`${testInfo.titlePath.join('\n')}`,
|
||||||
|
`${testInfo.project.name}`
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
await use(page);
|
await use(page);
|
||||||
},
|
},
|
||||||
myItemsFolderName: [myItemsFolderName, { option: true }],
|
myItemsFolderName: [myItemsFolderName, { option: true }],
|
||||||
@@ -140,22 +148,5 @@ exports.test = test.extend({
|
|||||||
openmctConfig: async ({ myItemsFolderName }, use) => {
|
openmctConfig: async ({ myItemsFolderName }, use) => {
|
||||||
await use({ myItemsFolderName });
|
await use({ myItemsFolderName });
|
||||||
}
|
}
|
||||||
// objectCreateOptions: [objectCreateOptions, {option: true}],
|
|
||||||
// eslint-disable-next-line no-shadow
|
|
||||||
// domainObject: [async ({ page, objectCreateOptions }, use) => {
|
|
||||||
// // FIXME: This is a false-positive caused by a bug in the eslint-plugin-playwright rule.
|
|
||||||
// // eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
// if (objectCreateOptions === null) {
|
|
||||||
// await use(page);
|
|
||||||
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //Go to baseURL
|
|
||||||
// await page.goto('./', { waitUntil: 'networkidle' });
|
|
||||||
|
|
||||||
// const uuid = await getOrCreateDomainObject(page, objectCreateOptions);
|
|
||||||
// await use({ uuid });
|
|
||||||
// }, { auto: true }]
|
|
||||||
});
|
});
|
||||||
exports.expect = expect;
|
exports.expect = expect;
|
||||||
|
|||||||
2207
e2e/test-data/ExampleLayouts.json
Normal file
@@ -20,7 +20,7 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
const { test, expect } = require('../../baseFixtures.js');
|
const { test, expect } = require('../../pluginFixtures.js');
|
||||||
const { createDomainObjectWithDefaults } = require('../../appActions.js');
|
const { createDomainObjectWithDefaults } = require('../../appActions.js');
|
||||||
|
|
||||||
test.describe('AppActions', () => {
|
test.describe('AppActions', () => {
|
||||||
@@ -50,11 +50,11 @@ test.describe('AppActions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await page.goto(timer1.url, { waitUntil: 'networkidle' });
|
await page.goto(timer1.url, { waitUntil: 'networkidle' });
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Timer Foo');
|
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer1.name);
|
||||||
await page.goto(timer2.url, { waitUntil: 'networkidle' });
|
await page.goto(timer2.url, { waitUntil: 'networkidle' });
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Timer Bar');
|
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer2.name);
|
||||||
await page.goto(timer3.url, { waitUntil: 'networkidle' });
|
await page.goto(timer3.url, { waitUntil: 'networkidle' });
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Timer Baz');
|
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer3.name);
|
||||||
});
|
});
|
||||||
|
|
||||||
await test.step('Create multiple nested objects in a row', async () => {
|
await test.step('Create multiple nested objects in a row', async () => {
|
||||||
@@ -74,11 +74,11 @@ test.describe('AppActions', () => {
|
|||||||
parent: folder2.uuid
|
parent: folder2.uuid
|
||||||
});
|
});
|
||||||
await page.goto(folder1.url, { waitUntil: 'networkidle' });
|
await page.goto(folder1.url, { waitUntil: 'networkidle' });
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Folder Foo');
|
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(folder1.name);
|
||||||
await page.goto(folder2.url, { waitUntil: 'networkidle' });
|
await page.goto(folder2.url, { waitUntil: 'networkidle' });
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Folder Bar');
|
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(folder2.name);
|
||||||
await page.goto(folder3.url, { waitUntil: 'networkidle' });
|
await page.goto(folder3.url, { waitUntil: 'networkidle' });
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText('Folder Baz');
|
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(folder3.name);
|
||||||
|
|
||||||
expect(folder1.url).toBe(`${e2eFolder.url}/${folder1.uuid}`);
|
expect(folder1.url).toBe(`${e2eFolder.url}/${folder1.uuid}`);
|
||||||
expect(folder2.url).toBe(`${e2eFolder.url}/${folder1.uuid}/${folder2.uuid}`);
|
expect(folder2.url).toBe(`${e2eFolder.url}/${folder1.uuid}/${folder2.uuid}`);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
/*
|
/*
|
||||||
This test suite is dedicated to testing our use of the playwright framework as it
|
This test suite is dedicated to testing our use of the playwright framework as it
|
||||||
relates to how we've extended it (i.e. ./e2e/baseFixtures.js) and assumptions made in our dev environment
|
relates to how we've extended it (i.e. ./e2e/baseFixtures.js) and assumptions made in our dev environment
|
||||||
(app.js and ./e2e/webpack-dev-middleware.js)
|
(`npm start` and ./e2e/webpack-dev-middleware.js)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { test } = require('../../baseFixtures.js');
|
const { test } = require('../../baseFixtures.js');
|
||||||
|
|||||||
@@ -21,12 +21,11 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This test suite template is to be used when creating new testsuites. It will be kept up to date with the latest improvements
|
* This test suite template is to be used when creating new test suites. It will be kept up to date with the latest improvements
|
||||||
* made by the Open MCT team. It will also follow our best pratices as those evolve. Please use this structure as a _reference_ and clear
|
* made by the Open MCT team. It will also follow our best pratices as those evolve. Please use this structure as a _reference_ and clear
|
||||||
* or update any references when creating a new test suite!
|
* or update any references when creating a new test suite!
|
||||||
*
|
*
|
||||||
* To illustrate current best practices, we've included a mocked up test suite for Renaming a Timer domain object. In this example
|
* To illustrate current best practices, we've included a mocked up test suite for Renaming a Timer domain object.
|
||||||
* this test suite should be cloned and renamed as /e2e/tests/plugins/timer/renameTimer.e2e.spec.js
|
|
||||||
*
|
*
|
||||||
* Demonstrated:
|
* Demonstrated:
|
||||||
* - Using appActions to leverage existing functions
|
* - Using appActions to leverage existing functions
|
||||||
@@ -43,55 +42,73 @@
|
|||||||
* -> test2
|
* -> test2
|
||||||
* -> test3(stub)
|
* -> test3(stub)
|
||||||
* 4. Any custom functions
|
* 4. Any custom functions
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Structure: Some standard Imports. Please update the required pathing
|
// Structure: Some standard Imports. Please update the required pathing.
|
||||||
const { test, expect } = require('../../baseFixtures');
|
const { test, expect } = require('../../pluginFixtures');
|
||||||
const { createDomainObjectWithDefaults } = require('../../appActions');
|
const { createDomainObjectWithDefaults } = require('../../appActions');
|
||||||
|
|
||||||
// Structure: Try to keep a single describe block per logical groups of tests. If your test runtime exceeds 5 minutes or 500 lines, it's likely that it will need to be split.
|
/**
|
||||||
// Annotations: Please use the @unstable tag so that our automation can pick it up as a part of our test promotion pipeline.
|
* Structure:
|
||||||
|
* Try to keep a single describe block per logical groups of tests.
|
||||||
|
* If your test runtime exceeds 5 minutes or 500 lines, it's likely that it will need to be split.
|
||||||
|
*
|
||||||
|
* Annotations:
|
||||||
|
* Please use the @unstable tag at the end of the test title so that our automation can pick it up
|
||||||
|
* as a part of our test promotion pipeline.
|
||||||
|
*/
|
||||||
test.describe('Renaming Timer Object', () => {
|
test.describe('Renaming Timer Object', () => {
|
||||||
//Create a testcase name which will be obvious when it fails in CI
|
// Top-level declaration of the Timer object created in beforeEach().
|
||||||
test('Can create a new Timer object and rename it from actions Menu', async ({ page }) => {
|
// We can then use this throughout the entire test suite.
|
||||||
//Open a browser, navigate to the main page, and wait until all networkevents to resolve
|
let timer;
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// Open a browser, navigate to the main page, and wait until all network events to resolve
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
//We provide some helper functions in appActions like createDomainObjectWithDefaults. This example will create a Timer object
|
|
||||||
await createDomainObjectWithDefaults(page, { type: 'Timer' });
|
|
||||||
//Assert the object to be created and check it's name in the title
|
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Timer');
|
|
||||||
|
|
||||||
|
// We provide some helper functions in appActions like `createDomainObjectWithDefaults()`.
|
||||||
|
// This example will create a Timer object with default properties, under the root folder:
|
||||||
|
timer = await createDomainObjectWithDefaults(page, { type: 'Timer' });
|
||||||
|
|
||||||
|
// Assert the object to be created and check its name in the title
|
||||||
|
await expect(page.locator('.l-browse-bar__object-name')).toContainText(timer.name);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make sure to use testcase names which are descriptive and easy to understand.
|
||||||
|
* A good testcase name concisely describes the test's goal(s) and should give
|
||||||
|
* some hint as to what went wrong if the test fails.
|
||||||
|
*/
|
||||||
|
test('An existing Timer object can be renamed via the 3dot actions menu', async ({ page }) => {
|
||||||
const newObjectName = "Renamed Timer";
|
const newObjectName = "Renamed Timer";
|
||||||
//We've created an example of a shared function which pases the page and newObjectName values
|
|
||||||
await renameObjectFrom3DotMenu(page, newObjectName);
|
|
||||||
|
|
||||||
//Assert that the name has changed in the browser bar to the value we assigned above
|
// We've created an example of a shared function which pases the page and newObjectName values
|
||||||
|
await renameTimerFrom3DotMenu(page, timer.url, newObjectName);
|
||||||
|
|
||||||
|
// Assert that the name has changed in the browser bar to the value we assigned above
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText(newObjectName);
|
await expect(page.locator('.l-browse-bar__object-name')).toContainText(newObjectName);
|
||||||
});
|
});
|
||||||
test('An existing Timer object can be renamed twice', async ({ page }) => {
|
|
||||||
//Open a browser, navigate to the main page, and wait until all networkevents to resolve
|
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
|
||||||
//We provide some helper functions in appActions like createDomainObjectWithDefaults. This example will create a Timer object
|
|
||||||
await createDomainObjectWithDefaults(page, { type: 'Timer' });
|
|
||||||
//Expect the object to be created and check it's name in the title
|
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Timer');
|
|
||||||
|
|
||||||
|
test('An existing Timer object can be renamed twice', async ({ page }) => {
|
||||||
const newObjectName = "Renamed Timer";
|
const newObjectName = "Renamed Timer";
|
||||||
const newObjectName2 = "Re-Renamed Timer";
|
const newObjectName2 = "Re-Renamed Timer";
|
||||||
//We've created an example of a shared function which pases the page and newObjectName values
|
|
||||||
await renameObjectFrom3DotMenu(page, newObjectName);
|
|
||||||
|
|
||||||
//Assert that the name has changed in the browser bar to the value we assigned above
|
await renameTimerFrom3DotMenu(page, timer.url, newObjectName);
|
||||||
|
|
||||||
|
// Assert that the name has changed in the browser bar to the value we assigned above
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText(newObjectName);
|
await expect(page.locator('.l-browse-bar__object-name')).toContainText(newObjectName);
|
||||||
|
|
||||||
await renameObjectFrom3DotMenu(page, newObjectName2);
|
// Rename the Timer object again
|
||||||
|
await renameTimerFrom3DotMenu(page, timer.url, newObjectName2);
|
||||||
|
|
||||||
//Assert that the name has changed in the browser bar to the second value
|
// Assert that the name has changed in the browser bar to the second value
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText(newObjectName2);
|
await expect(page.locator('.l-browse-bar__object-name')).toContainText(newObjectName2);
|
||||||
});
|
});
|
||||||
|
|
||||||
//If you run out of time to write new tests, please stub in the missing tests in place with a test.fixme and BDD-style test steps. Someone will carry the baton!
|
/**
|
||||||
|
* If you run out of time to write new tests, please stub in the missing tests
|
||||||
|
* in-place with a test.fixme and BDD-style test steps.
|
||||||
|
* Someone will carry the baton!
|
||||||
|
*/
|
||||||
test.fixme('Can Rename Timer Object from Tree', async ({ page }) => {
|
test.fixme('Can Rename Timer Object from Tree', async ({ page }) => {
|
||||||
//Create a new object
|
//Create a new object
|
||||||
//Copy this object
|
//Copy this object
|
||||||
@@ -100,24 +117,32 @@ test.describe('Renaming Timer Object', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//Structure: custom functions should be declared last. We are leaning on JSDoc pretty heavily to describe functionality. It is not required, but heavily recommended.
|
/**
|
||||||
|
* Structure:
|
||||||
|
* Custom functions should be declared last.
|
||||||
|
* We are leaning on JSDoc pretty heavily to describe functionality. It is not required, but highly recommended.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an example of a function which is shared between testcases in this test suite. When refactoring, we'll be looking
|
* This is an example of a function which is shared between testcases in this test suite. When refactoring, we'll be looking
|
||||||
* for common functionality which makes sense to generalize for the entire test framework.
|
* for common functionality which makes sense to generalize for the entire test framework.
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
* @param {string} newNameForTimer New Name for object
|
* @param {string} timerUrl The URL of the timer object to be renamed
|
||||||
|
* @param {string} newNameForTimer New name for object
|
||||||
*/
|
*/
|
||||||
async function renameObjectFrom3DotMenu(page, newNameForTimer) {
|
async function renameTimerFrom3DotMenu(page, timerUrl, newNameForTimer) {
|
||||||
|
// Navigate to the timer object
|
||||||
|
await page.goto(timerUrl);
|
||||||
|
|
||||||
// Click on 3 Dot Menu
|
// Click on 3 Dot Menu
|
||||||
await page.locator('button[title="More options"]').click();
|
await page.locator('button[title="More options"]').click();
|
||||||
|
|
||||||
// Click text=Edit Properties...
|
// Click text=Edit Properties...
|
||||||
await page.locator('text=Edit Properties...').click();
|
await page.locator('text=Edit Properties...').click();
|
||||||
|
|
||||||
// Rename the object with newNameForTimer variable which is passed into this function
|
// Rename the timer object
|
||||||
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(newNameForTimer);
|
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(newNameForTimer);
|
||||||
|
|
||||||
// Click Ok button to Save
|
// Click Ok button to Save
|
||||||
await page.locator('text=OK').click();
|
await page.locator('button:has-text("OK")').click();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,14 +43,14 @@ test('Generate Visual Test Data @localStorage', async ({ page, context }) => {
|
|||||||
await page.locator('button:has-text("Create")').click();
|
await page.locator('button:has-text("Create")').click();
|
||||||
|
|
||||||
// add sine wave generator with defaults
|
// add sine wave generator with defaults
|
||||||
await page.locator('li:has-text("Sine Wave Generator")').click();
|
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
|
||||||
|
|
||||||
//Add a 5000 ms Delay
|
//Add a 5000 ms Delay
|
||||||
await page.locator('[aria-label="Loading Delay \\(ms\\)"]').fill('5000');
|
await page.locator('[aria-label="Loading Delay \\(ms\\)"]').fill('5000');
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForNavigation(),
|
page.waitForNavigation(),
|
||||||
page.locator('text=OK').click(),
|
page.locator('button:has-text("OK")').click(),
|
||||||
//Wait for Save Banner to appear
|
//Wait for Save Banner to appear
|
||||||
page.waitForSelector('.c-message-banner__message')
|
page.waitForSelector('.c-message-banner__message')
|
||||||
]);
|
]);
|
||||||
@@ -58,7 +58,7 @@ test('Generate Visual Test Data @localStorage', async ({ page, context }) => {
|
|||||||
// focus the overlay plot
|
// focus the overlay plot
|
||||||
await page.goto(overlayPlot.url);
|
await page.goto(overlayPlot.url);
|
||||||
|
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Overlay Plot');
|
await expect(page.locator('.l-browse-bar__object-name')).toContainText(overlayPlot.name);
|
||||||
//Save localStorage for future test execution
|
//Save localStorage for future test execution
|
||||||
await context.storageState({ path: './e2e/test-data/VisualTestData_storage.json' });
|
await context.storageState({ path: './e2e/test-data/VisualTestData_storage.json' });
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,9 +25,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { test, expect } = require('../../baseFixtures');
|
const { test, expect } = require('../../pluginFixtures');
|
||||||
|
|
||||||
test.describe("CouchDB Status Indicator @couchdb", () => {
|
test.describe("CouchDB Status Indicator with mocked responses @couchdb", () => {
|
||||||
test.use({ failOnConsoleError: false });
|
test.use({ failOnConsoleError: false });
|
||||||
//TODO BeforeAll Verify CouchDB Connectivity with APIContext
|
//TODO BeforeAll Verify CouchDB Connectivity with APIContext
|
||||||
test('Shows green if connected', async ({ page }) => {
|
test('Shows green if connected', async ({ page }) => {
|
||||||
@@ -71,38 +71,41 @@ test.describe("CouchDB Status Indicator @couchdb", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe("CouchDB initialization @couchdb", () => {
|
test.describe("CouchDB initialization with mocked responses @couchdb", () => {
|
||||||
test.use({ failOnConsoleError: false });
|
test.use({ failOnConsoleError: false });
|
||||||
test("'My Items' folder is created if it doesn't exist", async ({ page }) => {
|
test("'My Items' folder is created if it doesn't exist", async ({ page }) => {
|
||||||
// Store any relevant PUT requests that happen on the page
|
const mockedMissingObjectResponsefromCouchDB = {
|
||||||
const createMineFolderRequests = [];
|
status: 404,
|
||||||
page.on('request', req => {
|
contentType: 'application/json',
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
body: JSON.stringify({})
|
||||||
if (req.method() === 'PUT' && req.url().endsWith('openmct/mine')) {
|
};
|
||||||
createMineFolderRequests.push(req);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Override the first request to GET openmct/mine to return a 404
|
// Override the first request to GET openmct/mine to return a 404.
|
||||||
await page.route('**/openmct/mine', route => {
|
// This simulates the case of starting Open MCT with a fresh database
|
||||||
route.fulfill({
|
// and no "My Items" folder created yet.
|
||||||
status: 404,
|
await page.route('**/mine', route => {
|
||||||
contentType: 'application/json',
|
route.fulfill(mockedMissingObjectResponsefromCouchDB);
|
||||||
body: JSON.stringify({})
|
|
||||||
});
|
|
||||||
}, { times: 1 });
|
}, { times: 1 });
|
||||||
|
|
||||||
// Go to baseURL
|
// Set up promise to verify that a PUT request to create "My Items"
|
||||||
|
// folder was made.
|
||||||
|
const putMineFolderRequest = page.waitForRequest(req =>
|
||||||
|
req.url().endsWith('/mine')
|
||||||
|
&& req.method() === 'PUT');
|
||||||
|
|
||||||
|
// Set up promise to verify that a GET request to retrieve "My Items"
|
||||||
|
// folder was made.
|
||||||
|
const getMineFolderRequest = page.waitForRequest(req =>
|
||||||
|
req.url().endsWith('/mine')
|
||||||
|
&& req.method() === 'GET');
|
||||||
|
|
||||||
|
// Go to baseURL.
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
// Verify that error banner is displayed
|
// Wait for both requests to resolve.
|
||||||
const bannerMessage = await page.locator('.c-message-banner__message').innerText();
|
await Promise.all([
|
||||||
expect(bannerMessage).toEqual('Failed to retrieve object mine');
|
putMineFolderRequest,
|
||||||
|
getMineFolderRequest
|
||||||
// Verify that a PUT request to create "My Items" folder was made
|
]);
|
||||||
expect.poll(() => createMineFolderRequests.length, {
|
|
||||||
message: 'Verify that PUT request to create "mine" folder was made',
|
|
||||||
timeout: 1000
|
|
||||||
}).toBeGreaterThanOrEqual(1);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
This test suite is dedicated to tests which verify the basic operations surrounding the example event generator.
|
This test suite is dedicated to tests which verify the basic operations surrounding the example event generator.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { test, expect } = require('../../../baseFixtures');
|
const { test, expect } = require('../../../pluginFixtures');
|
||||||
const { createDomainObjectWithDefaults } = require('../../../appActions');
|
const { createDomainObjectWithDefaults } = require('../../../appActions');
|
||||||
|
|
||||||
test.describe('Example Event Generator CRUD Operations', () => {
|
test.describe('Example Event Generator CRUD Operations', () => {
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ test.describe('Sine Wave Generator', () => {
|
|||||||
//Click text=OK
|
//Click text=OK
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForNavigation(),
|
page.waitForNavigation(),
|
||||||
page.click('text=OK')
|
page.click('button:has-text("OK")')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Verify that the Sine Wave Generator is displayed and correct
|
// Verify that the Sine Wave Generator is displayed and correct
|
||||||
|
|||||||
@@ -24,7 +24,9 @@
|
|||||||
This test suite is dedicated to tests which verify form functionality in isolation
|
This test suite is dedicated to tests which verify form functionality in isolation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { test, expect } = require('../../baseFixtures');
|
const { test, expect } = require('../../pluginFixtures');
|
||||||
|
const { createDomainObjectWithDefaults } = require('../../appActions');
|
||||||
|
const genUuid = require('uuid').v4;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const TEST_FOLDER = 'test folder';
|
const TEST_FOLDER = 'test folder';
|
||||||
@@ -43,7 +45,7 @@ test.describe('Form Validation Behavior', () => {
|
|||||||
await page.press('text=Properties Title Notes >> input[type="text"]', 'Tab');
|
await page.press('text=Properties Title Notes >> input[type="text"]', 'Tab');
|
||||||
|
|
||||||
//Required Field Form Validation
|
//Required Field Form Validation
|
||||||
await expect(page.locator('text=OK')).toBeDisabled();
|
await expect(page.locator('button:has-text("OK")')).toBeDisabled();
|
||||||
await expect(page.locator('.c-form-row__state-indicator').first()).toHaveClass(/invalid/);
|
await expect(page.locator('.c-form-row__state-indicator').first()).toHaveClass(/invalid/);
|
||||||
|
|
||||||
//Correct Form Validation for missing title and trigger validation with 'Tab'
|
//Correct Form Validation for missing title and trigger validation with 'Tab'
|
||||||
@@ -52,13 +54,13 @@ test.describe('Form Validation Behavior', () => {
|
|||||||
await page.press('text=Properties Title Notes >> input[type="text"]', 'Tab');
|
await page.press('text=Properties Title Notes >> input[type="text"]', 'Tab');
|
||||||
|
|
||||||
//Required Field Form Validation is corrected
|
//Required Field Form Validation is corrected
|
||||||
await expect(page.locator('text=OK')).toBeEnabled();
|
await expect(page.locator('button:has-text("OK")')).toBeEnabled();
|
||||||
await expect(page.locator('.c-form-row__state-indicator').first()).not.toHaveClass(/invalid/);
|
await expect(page.locator('.c-form-row__state-indicator').first()).not.toHaveClass(/invalid/);
|
||||||
|
|
||||||
//Finish Creating Domain Object
|
//Finish Creating Domain Object
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForNavigation(),
|
page.waitForNavigation(),
|
||||||
page.click('text=OK')
|
page.click('button:has-text("OK")')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//Verify that the Domain Object has been created with the corrected title property
|
//Verify that the Domain Object has been created with the corrected title property
|
||||||
@@ -91,6 +93,146 @@ test.describe('Persistence operations @addInit', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test.describe('Persistence operations @couchdb', () => {
|
||||||
|
test.use({ failOnConsoleError: false });
|
||||||
|
test('Editing object properties should generate a single persistence operation', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5616'
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
// Create a new 'Clock' object with default settings
|
||||||
|
const clock = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Clock'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Count all persistence operations (PUT requests) for this specific object
|
||||||
|
let putRequestCount = 0;
|
||||||
|
page.on('request', req => {
|
||||||
|
if (req.method() === 'PUT' && req.url().endsWith(clock.uuid)) {
|
||||||
|
putRequestCount += 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Open the edit form for the clock object
|
||||||
|
await page.click('button[title="More options"]');
|
||||||
|
await page.click('li[title="Edit properties of this object."]');
|
||||||
|
|
||||||
|
// Modify the display format from default 12hr -> 24hr and click 'Save'
|
||||||
|
await page.locator('select[aria-label="12 or 24 hour clock"]').selectOption({ value: 'clock24' });
|
||||||
|
await page.click('button[aria-label="Save"]');
|
||||||
|
|
||||||
|
await expect.poll(() => putRequestCount, {
|
||||||
|
message: 'Verify a single PUT request was made to persist the object',
|
||||||
|
timeout: 1000
|
||||||
|
}).toEqual(1);
|
||||||
|
});
|
||||||
|
test('Can create an object after a conflict error @couchdb @2p', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5982'
|
||||||
|
});
|
||||||
|
|
||||||
|
const page2 = await page.context().newPage();
|
||||||
|
|
||||||
|
// Both pages: Go to baseURL
|
||||||
|
await Promise.all([
|
||||||
|
page.goto('./', { waitUntil: 'networkidle' }),
|
||||||
|
page2.goto('./', { waitUntil: 'networkidle' })
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Both pages: Click the Create button
|
||||||
|
await Promise.all([
|
||||||
|
page.click('button:has-text("Create")'),
|
||||||
|
page2.click('button:has-text("Create")')
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Both pages: Click "Clock" in the Create menu
|
||||||
|
await Promise.all([
|
||||||
|
page.click(`li[role='menuitem']:text("Clock")`),
|
||||||
|
page2.click(`li[role='menuitem']:text("Clock")`)
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Generate unique names for both objects
|
||||||
|
const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]');
|
||||||
|
const nameInput2 = page2.locator('form[name="mctForm"] .first input[type="text"]');
|
||||||
|
|
||||||
|
// Both pages: Fill in the 'Name' form field.
|
||||||
|
await Promise.all([
|
||||||
|
nameInput.fill(""),
|
||||||
|
nameInput.fill(`Clock:${genUuid()}`),
|
||||||
|
nameInput2.fill(""),
|
||||||
|
nameInput2.fill(`Clock:${genUuid()}`)
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Both pages: Fill the "Notes" section with information about the
|
||||||
|
// currently running test and its project.
|
||||||
|
const testNotes = page.testNotes;
|
||||||
|
const notesInput = page.locator('form[name="mctForm"] #notes-textarea');
|
||||||
|
const notesInput2 = page2.locator('form[name="mctForm"] #notes-textarea');
|
||||||
|
await Promise.all([
|
||||||
|
notesInput.fill(testNotes),
|
||||||
|
notesInput2.fill(testNotes)
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Page 2: Click "OK" to create the domain object and wait for navigation.
|
||||||
|
// This will update the composition of the parent folder, setting the
|
||||||
|
// conditions for a conflict error from the first page.
|
||||||
|
await Promise.all([
|
||||||
|
page2.waitForLoadState(),
|
||||||
|
page2.click('[aria-label="Save"]'),
|
||||||
|
// Wait for Save Banner to appear
|
||||||
|
page2.waitForSelector('.c-message-banner__message')
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Close Page 2, we're done with it.
|
||||||
|
await page2.close();
|
||||||
|
|
||||||
|
// Page 1: Click "OK" to create the domain object and wait for navigation.
|
||||||
|
// This will trigger a conflict error upon attempting to update
|
||||||
|
// the composition of the parent folder.
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForLoadState(),
|
||||||
|
page.click('[aria-label="Save"]'),
|
||||||
|
// Wait for Save Banner to appear
|
||||||
|
page.waitForSelector('.c-message-banner__message')
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Page 1: Verify that the conflict has occurred and an error notification is displayed.
|
||||||
|
await expect(page.locator('.c-message-banner__message', {
|
||||||
|
hasText: "Conflict detected while saving mine"
|
||||||
|
})).toBeVisible();
|
||||||
|
|
||||||
|
// Page 1: Start logging console errors from this point on
|
||||||
|
let errors = [];
|
||||||
|
page.on('console', (msg) => {
|
||||||
|
if (msg.type() === 'error') {
|
||||||
|
errors.push(msg.text());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Page 1: Try to create a clock with the page that received the conflict.
|
||||||
|
const clockAfterConflict = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Clock'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Page 1: Wait for save progress dialog to appear/disappear
|
||||||
|
await page.locator('.c-message-banner__message', {
|
||||||
|
hasText: 'Do not navigate away from this page or close this browser tab while this message is displayed.',
|
||||||
|
state: 'visible'
|
||||||
|
}).waitFor({ state: 'hidden' });
|
||||||
|
|
||||||
|
// Page 1: Navigate to 'My Items' and verify that the second clock was created
|
||||||
|
await page.goto('./#/browse/mine');
|
||||||
|
await expect(page.locator(`.c-grid-item__name[title="${clockAfterConflict.name}"]`)).toBeVisible();
|
||||||
|
|
||||||
|
// Verify no console errors occurred
|
||||||
|
expect(errors).toHaveLength(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test.describe('Form Correctness by Object Type', () => {
|
test.describe('Form Correctness by Object Type', () => {
|
||||||
test.fixme('Verify correct behavior of number object (SWG)', async ({page}) => {});
|
test.fixme('Verify correct behavior of number object (SWG)', async ({page}) => {});
|
||||||
test.fixme('Verify correct behavior of number object Timer', async ({page}) => {});
|
test.fixme('Verify correct behavior of number object Timer', async ({page}) => {});
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ test.describe('Persistence operations @addInit', () => {
|
|||||||
button: 'right'
|
button: 'right'
|
||||||
});
|
});
|
||||||
|
|
||||||
const menuOptions = page.locator('.c-menu ul');
|
const menuOptions = page.locator('.c-menu li');
|
||||||
|
|
||||||
await expect.soft(menuOptions).toContainText(['Open In New Tab', 'View', 'Create Link']);
|
await expect.soft(menuOptions).toContainText(['Open In New Tab', 'View', 'Create Link']);
|
||||||
await expect(menuOptions).not.toContainText(['Move', 'Duplicate', 'Remove', 'Add New Folder', 'Edit Properties...', 'Export as JSON', 'Import from JSON']);
|
await expect(menuOptions).not.toContainText(['Move', 'Duplicate', 'Remove', 'Add New Folder', 'Edit Properties...', 'Export as JSON', 'Import from JSON']);
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ test.describe('Move & link item tests', () => {
|
|||||||
await page.locator('li.icon-move').click();
|
await page.locator('li.icon-move').click();
|
||||||
await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
|
await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
|
||||||
|
|
||||||
await page.locator('text=OK').click();
|
await page.locator('button:has-text("OK")').click();
|
||||||
|
|
||||||
// Expect that Child Folder is in My Items, the root folder
|
// Expect that Child Folder is in My Items, the root folder
|
||||||
expect(page.locator(`text=${myItemsFolderName} >> nth=0:has(text=Child Folder)`)).toBeTruthy();
|
expect(page.locator(`text=${myItemsFolderName} >> nth=0:has(text=Child Folder)`)).toBeTruthy();
|
||||||
@@ -95,11 +95,11 @@ test.describe('Move & link item tests', () => {
|
|||||||
// Create Telemetry Table
|
// Create Telemetry Table
|
||||||
let telemetryTable = 'Test Telemetry Table';
|
let telemetryTable = 'Test Telemetry Table';
|
||||||
await page.locator('button:has-text("Create")').click();
|
await page.locator('button:has-text("Create")').click();
|
||||||
await page.locator('li:has-text("Telemetry Table")').click();
|
await page.locator('li[role="menuitem"]:has-text("Telemetry Table")').click();
|
||||||
await page.locator('text=Properties Title Notes >> input[type="text"]').click();
|
await page.locator('text=Properties Title Notes >> input[type="text"]').click();
|
||||||
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(telemetryTable);
|
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(telemetryTable);
|
||||||
|
|
||||||
await page.locator('text=OK').click();
|
await page.locator('button:has-text("OK")').click();
|
||||||
|
|
||||||
// Finish editing and save Telemetry Table
|
// Finish editing and save Telemetry Table
|
||||||
await page.locator('.c-button--menu.c-button--major.icon-save').click();
|
await page.locator('.c-button--menu.c-button--major.icon-save').click();
|
||||||
@@ -108,7 +108,7 @@ test.describe('Move & link item tests', () => {
|
|||||||
// Create New Folder Basic Domain Object
|
// Create New Folder Basic Domain Object
|
||||||
let folder = 'Test Folder';
|
let folder = 'Test Folder';
|
||||||
await page.locator('button:has-text("Create")').click();
|
await page.locator('button:has-text("Create")').click();
|
||||||
await page.locator('li:has-text("Folder")').click();
|
await page.locator('li[role="menuitem"]:has-text("Folder")').click();
|
||||||
await page.locator('text=Properties Title Notes >> input[type="text"]').click();
|
await page.locator('text=Properties Title Notes >> input[type="text"]').click();
|
||||||
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(folder);
|
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(folder);
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ test.describe('Move & link item tests', () => {
|
|||||||
|
|
||||||
// Continue test regardless of assertion and create it in My Items
|
// Continue test regardless of assertion and create it in My Items
|
||||||
await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
|
await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
|
||||||
await page.locator('text=OK').click();
|
await page.locator('button:has-text("OK")').click();
|
||||||
|
|
||||||
// Open My Items
|
// Open My Items
|
||||||
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
|
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
|
||||||
@@ -196,7 +196,7 @@ test.describe('Move & link item tests', () => {
|
|||||||
await page.locator('li.icon-link').click();
|
await page.locator('li.icon-link').click();
|
||||||
await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
|
await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
|
||||||
|
|
||||||
await page.locator('text=OK').click();
|
await page.locator('button:has-text("OK")').click();
|
||||||
|
|
||||||
// Expect that Child Folder is in My Items, the root folder
|
// Expect that Child Folder is in My Items, the root folder
|
||||||
expect(page.locator(`text=${myItemsFolderName} >> nth=0:has(text=Child Folder)`)).toBeTruthy();
|
expect(page.locator(`text=${myItemsFolderName} >> nth=0:has(text=Child Folder)`)).toBeTruthy();
|
||||||
|
|||||||
87
e2e/tests/functional/planning/plan.e2e.spec.js
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, 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, expect } = require('../../../pluginFixtures');
|
||||||
|
const { createPlanFromJSON } = require('../../../appActions');
|
||||||
|
|
||||||
|
const testPlan = {
|
||||||
|
"TEST_GROUP": [
|
||||||
|
{
|
||||||
|
"name": "Past event 1",
|
||||||
|
"start": 1660320408000,
|
||||||
|
"end": 1660343797000,
|
||||||
|
"type": "TEST-GROUP",
|
||||||
|
"color": "orange",
|
||||||
|
"textColor": "white"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Past event 2",
|
||||||
|
"start": 1660406808000,
|
||||||
|
"end": 1660429160000,
|
||||||
|
"type": "TEST-GROUP",
|
||||||
|
"color": "orange",
|
||||||
|
"textColor": "white"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Past event 3",
|
||||||
|
"start": 1660493208000,
|
||||||
|
"end": 1660503981000,
|
||||||
|
"type": "TEST-GROUP",
|
||||||
|
"color": "orange",
|
||||||
|
"textColor": "white"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Past event 4",
|
||||||
|
"start": 1660579608000,
|
||||||
|
"end": 1660624108000,
|
||||||
|
"type": "TEST-GROUP",
|
||||||
|
"color": "orange",
|
||||||
|
"textColor": "white"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Past event 5",
|
||||||
|
"start": 1660666008000,
|
||||||
|
"end": 1660681529000,
|
||||||
|
"type": "TEST-GROUP",
|
||||||
|
"color": "orange",
|
||||||
|
"textColor": "white"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
test.describe("Plan", () => {
|
||||||
|
test("Create a Plan and display all plan events @unstable", async ({ page }) => {
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
const plan = await createPlanFromJSON(page, {
|
||||||
|
name: 'Test Plan',
|
||||||
|
json: testPlan
|
||||||
|
});
|
||||||
|
const startBound = testPlan.TEST_GROUP[0].start;
|
||||||
|
const endBound = testPlan.TEST_GROUP[testPlan.TEST_GROUP.length - 1].end;
|
||||||
|
|
||||||
|
// Switch to fixed time mode with all plan events within the bounds
|
||||||
|
await page.goto(`${plan.url}?tc.mode=fixed&tc.startBound=${startBound}&tc.endBound=${endBound}&tc.timeSystem=utc&view=plan.view`);
|
||||||
|
const eventCount = await page.locator('.activity-bounds').count();
|
||||||
|
expect(eventCount).toEqual(testPlan.TEST_GROUP.length);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
181
e2e/tests/functional/planning/timestrip.e2e.spec.js
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, 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, expect } = require('../../../pluginFixtures');
|
||||||
|
const { createDomainObjectWithDefaults, createPlanFromJSON } = require('../../../appActions');
|
||||||
|
|
||||||
|
const testPlan = {
|
||||||
|
"TEST_GROUP": [
|
||||||
|
{
|
||||||
|
"name": "Past event 1",
|
||||||
|
"start": 1660320408000,
|
||||||
|
"end": 1660343797000,
|
||||||
|
"type": "TEST-GROUP",
|
||||||
|
"color": "orange",
|
||||||
|
"textColor": "white"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Past event 2",
|
||||||
|
"start": 1660406808000,
|
||||||
|
"end": 1660429160000,
|
||||||
|
"type": "TEST-GROUP",
|
||||||
|
"color": "orange",
|
||||||
|
"textColor": "white"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Past event 3",
|
||||||
|
"start": 1660493208000,
|
||||||
|
"end": 1660503981000,
|
||||||
|
"type": "TEST-GROUP",
|
||||||
|
"color": "orange",
|
||||||
|
"textColor": "white"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Past event 4",
|
||||||
|
"start": 1660579608000,
|
||||||
|
"end": 1660624108000,
|
||||||
|
"type": "TEST-GROUP",
|
||||||
|
"color": "orange",
|
||||||
|
"textColor": "white"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Past event 5",
|
||||||
|
"start": 1660666008000,
|
||||||
|
"end": 1660681529000,
|
||||||
|
"type": "TEST-GROUP",
|
||||||
|
"color": "orange",
|
||||||
|
"textColor": "white"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
test.describe("Time Strip", () => {
|
||||||
|
test("Create two Time Strips, add a single Plan to both, and verify they can have separate Indepdenent Time Contexts @unstable", async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5627'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Constant locators
|
||||||
|
const independentTimeConductorInputs = page.locator('.l-shell__main-independent-time-conductor .c-input--datetime');
|
||||||
|
const activityBounds = page.locator('.activity-bounds');
|
||||||
|
|
||||||
|
// Goto baseURL
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
const timestrip = await test.step("Create a Time Strip", async () => {
|
||||||
|
const createdTimeStrip = await createDomainObjectWithDefaults(page, { type: 'Time Strip' });
|
||||||
|
const objectName = await page.locator('.l-browse-bar__object-name').innerText();
|
||||||
|
expect(objectName).toBe(createdTimeStrip.name);
|
||||||
|
|
||||||
|
return createdTimeStrip;
|
||||||
|
});
|
||||||
|
|
||||||
|
const plan = await test.step("Create a Plan and add it to the timestrip", async () => {
|
||||||
|
const createdPlan = await createPlanFromJSON(page, {
|
||||||
|
name: 'Test Plan',
|
||||||
|
json: testPlan
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.goto(timestrip.url);
|
||||||
|
// Expand the tree to show the plan
|
||||||
|
await page.click("button[title='Show selected item in tree']");
|
||||||
|
await page.dragAndDrop(`role=treeitem[name=/${createdPlan.name}/]`, '.c-object-view');
|
||||||
|
await page.click("button[title='Save']");
|
||||||
|
await page.click("li[title='Save and Finish Editing']");
|
||||||
|
const startBound = testPlan.TEST_GROUP[0].start;
|
||||||
|
const endBound = testPlan.TEST_GROUP[testPlan.TEST_GROUP.length - 1].end;
|
||||||
|
|
||||||
|
// Switch to fixed time mode with all plan events within the bounds
|
||||||
|
await page.goto(`${timestrip.url}?tc.mode=fixed&tc.startBound=${startBound}&tc.endBound=${endBound}&tc.timeSystem=utc&view=time-strip.view`);
|
||||||
|
|
||||||
|
// Verify all events are displayed
|
||||||
|
const eventCount = await page.locator('.activity-bounds').count();
|
||||||
|
expect(eventCount).toEqual(testPlan.TEST_GROUP.length);
|
||||||
|
|
||||||
|
return createdPlan;
|
||||||
|
});
|
||||||
|
|
||||||
|
await test.step("TimeStrip can use the Independent Time Conductor", async () => {
|
||||||
|
// Activate Independent Time Conductor in Fixed Time Mode
|
||||||
|
await page.click('.c-toggle-switch__slider');
|
||||||
|
expect(await activityBounds.count()).toEqual(0);
|
||||||
|
|
||||||
|
// Set the independent time bounds so that only one event is shown
|
||||||
|
const startBound = testPlan.TEST_GROUP[0].start;
|
||||||
|
const endBound = testPlan.TEST_GROUP[0].end;
|
||||||
|
const startBoundString = new Date(startBound).toISOString().replace('T', ' ');
|
||||||
|
const endBoundString = new Date(endBound).toISOString().replace('T', ' ');
|
||||||
|
|
||||||
|
await independentTimeConductorInputs.nth(0).fill('');
|
||||||
|
await independentTimeConductorInputs.nth(0).fill(startBoundString);
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await independentTimeConductorInputs.nth(1).fill('');
|
||||||
|
await independentTimeConductorInputs.nth(1).fill(endBoundString);
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
expect(await activityBounds.count()).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
await test.step("Can have multiple TimeStrips with the same plan linked and different Independent Time Contexts", async () => {
|
||||||
|
// Create another Time Strip and verify that it has been created
|
||||||
|
const createdTimeStrip = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Time Strip',
|
||||||
|
name: "Another Time Strip"
|
||||||
|
});
|
||||||
|
|
||||||
|
const objectName = await page.locator('.l-browse-bar__object-name').innerText();
|
||||||
|
expect(objectName).toBe(createdTimeStrip.name);
|
||||||
|
|
||||||
|
// Drag the existing Plan onto the newly created Time Strip, and save.
|
||||||
|
await page.dragAndDrop(`role=treeitem[name=/${plan.name}/]`, '.c-object-view');
|
||||||
|
await page.click("button[title='Save']");
|
||||||
|
await page.click("li[title='Save and Finish Editing']");
|
||||||
|
|
||||||
|
// Activate Independent Time Conductor in Fixed Time Mode
|
||||||
|
await page.click('.c-toggle-switch__slider');
|
||||||
|
|
||||||
|
// All events should be displayed at this point because the
|
||||||
|
// initial independent context bounds will match the global bounds
|
||||||
|
expect(await activityBounds.count()).toEqual(5);
|
||||||
|
|
||||||
|
// Set the independent time bounds so that two events are shown
|
||||||
|
const startBound = testPlan.TEST_GROUP[0].start;
|
||||||
|
const endBound = testPlan.TEST_GROUP[1].end;
|
||||||
|
const startBoundString = new Date(startBound).toISOString().replace('T', ' ');
|
||||||
|
const endBoundString = new Date(endBound).toISOString().replace('T', ' ');
|
||||||
|
|
||||||
|
await independentTimeConductorInputs.nth(0).fill('');
|
||||||
|
await independentTimeConductorInputs.nth(0).fill(startBoundString);
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await independentTimeConductorInputs.nth(1).fill('');
|
||||||
|
await independentTimeConductorInputs.nth(1).fill(endBoundString);
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
|
||||||
|
// Verify that two events are displayed
|
||||||
|
expect(await activityBounds.count()).toEqual(2);
|
||||||
|
|
||||||
|
// Switch to the previous Time Strip and verify that only one event is displayed
|
||||||
|
await page.goto(timestrip.url);
|
||||||
|
expect(await activityBounds.count()).toEqual(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -40,11 +40,11 @@ test.describe.serial('Condition Set CRUD Operations on @localStorage', () => {
|
|||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
await page.click('button:has-text("Create")');
|
await page.click('button:has-text("Create")');
|
||||||
|
|
||||||
await page.locator('li:has-text("Condition Set")').click();
|
await page.locator('li[role="menuitem"]:has-text("Condition Set")').click();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForNavigation(),
|
page.waitForNavigation(),
|
||||||
page.click('text=OK')
|
page.click('button:has-text("OK")')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//Save localStorage for future test execution
|
//Save localStorage for future test execution
|
||||||
@@ -163,9 +163,9 @@ test.describe.serial('Condition Set CRUD Operations on @localStorage', () => {
|
|||||||
// Click hamburger button
|
// Click hamburger button
|
||||||
await page.locator('[title="More options"]').click();
|
await page.locator('[title="More options"]').click();
|
||||||
|
|
||||||
// Click text=Remove
|
// Click 'Remove' and press OK
|
||||||
await page.locator('text=Remove').click();
|
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||||
await page.locator('text=OK').click();
|
await page.locator('button:has-text("OK")').click();
|
||||||
|
|
||||||
//Expect Unnamed Condition Set to be removed in Main View
|
//Expect Unnamed Condition Set to be removed in Main View
|
||||||
const numberOfConditionSetsAtEnd = await page.locator('a:has-text("Unnamed Condition Set Condition Set")').count();
|
const numberOfConditionSetsAtEnd = await page.locator('a:has-text("Unnamed Condition Set Condition Set")').count();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
const { test, expect } = require('../../../../pluginFixtures');
|
const { test, expect } = require('../../../../pluginFixtures');
|
||||||
const { createDomainObjectWithDefaults, setStartOffset, setFixedTimeMode, setRealTimeMode } = require('../../../../appActions');
|
const { createDomainObjectWithDefaults, setStartOffset, setFixedTimeMode, setRealTimeMode } = require('../../../../appActions');
|
||||||
|
|
||||||
test.describe('Testing Display Layout @unstable', () => {
|
test.describe('Display Layout', () => {
|
||||||
let sineWaveObject;
|
let sineWaveObject;
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
@@ -55,12 +55,12 @@ test.describe('Testing Display Layout @unstable', () => {
|
|||||||
// On getting data, check if the value found in the Display Layout is the most recent value
|
// On getting data, check if the value found in the Display Layout is the most recent value
|
||||||
// from the Sine Wave Generator
|
// from the Sine Wave Generator
|
||||||
const getTelemValuePromise = await subscribeToTelemetry(page, sineWaveObject.uuid);
|
const getTelemValuePromise = await subscribeToTelemetry(page, sineWaveObject.uuid);
|
||||||
const formattedTelemetryValue = await getTelemValuePromise;
|
const formattedTelemetryValue = getTelemValuePromise;
|
||||||
const displayLayoutValuePromise = await page.waitForSelector(`text="${formattedTelemetryValue}"`);
|
const displayLayoutValuePromise = await page.waitForSelector(`text="${formattedTelemetryValue}"`);
|
||||||
const displayLayoutValue = await displayLayoutValuePromise.textContent();
|
const displayLayoutValue = await displayLayoutValuePromise.textContent();
|
||||||
const trimmedDisplayValue = displayLayoutValue.trim();
|
const trimmedDisplayValue = displayLayoutValue.trim();
|
||||||
|
|
||||||
await expect(trimmedDisplayValue).toBe(formattedTelemetryValue);
|
expect(trimmedDisplayValue).toBe(formattedTelemetryValue);
|
||||||
});
|
});
|
||||||
test('alpha-numeric widget telemetry value exactly matches latest telemetry value received in fixed time', async ({ page }) => {
|
test('alpha-numeric widget telemetry value exactly matches latest telemetry value received in fixed time', async ({ page }) => {
|
||||||
// Create a Display Layout
|
// Create a Display Layout
|
||||||
@@ -86,12 +86,12 @@ test.describe('Testing Display Layout @unstable', () => {
|
|||||||
|
|
||||||
// On getting data, check if the value found in the Display Layout is the most recent value
|
// On getting data, check if the value found in the Display Layout is the most recent value
|
||||||
// from the Sine Wave Generator
|
// from the Sine Wave Generator
|
||||||
const formattedTelemetryValue = await getTelemValuePromise;
|
const formattedTelemetryValue = getTelemValuePromise;
|
||||||
const displayLayoutValuePromise = await page.waitForSelector(`text="${formattedTelemetryValue}"`);
|
const displayLayoutValuePromise = await page.waitForSelector(`text="${formattedTelemetryValue}"`);
|
||||||
const displayLayoutValue = await displayLayoutValuePromise.textContent();
|
const displayLayoutValue = await displayLayoutValuePromise.textContent();
|
||||||
const trimmedDisplayValue = displayLayoutValue.trim();
|
const trimmedDisplayValue = displayLayoutValue.trim();
|
||||||
|
|
||||||
await expect(trimmedDisplayValue).toBe(formattedTelemetryValue);
|
expect(trimmedDisplayValue).toBe(formattedTelemetryValue);
|
||||||
});
|
});
|
||||||
test('items in a display layout can be removed with object tree context menu when viewing the display layout', async ({ page }) => {
|
test('items in a display layout can be removed with object tree context menu when viewing the display layout', async ({ page }) => {
|
||||||
// Create a Display Layout
|
// Create a Display Layout
|
||||||
@@ -116,16 +116,20 @@ test.describe('Testing Display Layout @unstable', () => {
|
|||||||
|
|
||||||
// Bring up context menu and remove
|
// Bring up context menu and remove
|
||||||
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').first().click({ button: 'right' });
|
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').first().click({ button: 'right' });
|
||||||
await page.locator('text=Remove').click();
|
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||||
await page.locator('text=OK').click();
|
await page.locator('button:has-text("OK")').click();
|
||||||
|
|
||||||
// delete
|
// delete
|
||||||
|
|
||||||
expect.soft(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0);
|
expect(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0);
|
||||||
});
|
});
|
||||||
test('items in a display layout can be removed with object tree context menu when viewing another item', async ({ page }) => {
|
test('items in a display layout can be removed with object tree context menu when viewing another item', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/3117'
|
||||||
|
});
|
||||||
// Create a Display Layout
|
// Create a Display Layout
|
||||||
await createDomainObjectWithDefaults(page, {
|
const displayLayout = await createDomainObjectWithDefaults(page, {
|
||||||
type: 'Display Layout',
|
type: 'Display Layout',
|
||||||
name: "Test Display Layout"
|
name: "Test Display Layout"
|
||||||
});
|
});
|
||||||
@@ -144,18 +148,18 @@ test.describe('Testing Display Layout @unstable', () => {
|
|||||||
// Expand the Display Layout so we can remove the sine wave generator
|
// Expand the Display Layout so we can remove the sine wave generator
|
||||||
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
|
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
|
||||||
|
|
||||||
// Click the original Sine Wave Generator to navigate away from the Display Layout
|
// Go to the original Sine Wave Generator to navigate away from the Display Layout
|
||||||
await page.locator('.c-tree__item .c-tree__item__name:text("Test Sine Wave Generator")').click();
|
await page.goto(sineWaveObject.url);
|
||||||
|
|
||||||
// Bring up context menu and remove
|
// Bring up context menu and remove
|
||||||
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').click({ button: 'right' });
|
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').click({ button: 'right' });
|
||||||
await page.locator('text=Remove').click();
|
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||||
await page.locator('text=OK').click();
|
await page.locator('button:has-text("OK")').click();
|
||||||
|
|
||||||
// navigate back to the display layout to confirm it has been removed
|
// navigate back to the display layout to confirm it has been removed
|
||||||
await page.locator('.c-tree__item .c-tree__item__name:text("Test Display Layout")').click();
|
await page.goto(displayLayout.url);
|
||||||
|
|
||||||
expect.soft(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0);
|
expect(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -28,14 +28,14 @@ test.describe('The Fault Management Plugin using example faults', () => {
|
|||||||
await utils.navigateToFaultManagementWithExample(page);
|
await utils.navigateToFaultManagementWithExample(page);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Shows a criticality icon for every fault', async ({ page }) => {
|
test('Shows a criticality icon for every fault @unstable', async ({ page }) => {
|
||||||
const faultCount = await page.locator('c-fault-mgmt__list').count();
|
const faultCount = await page.locator('c-fault-mgmt__list').count();
|
||||||
const criticalityIconCount = await page.locator('c-fault-mgmt__list-severity').count();
|
const criticalityIconCount = await page.locator('c-fault-mgmt__list-severity').count();
|
||||||
|
|
||||||
expect.soft(faultCount).toEqual(criticalityIconCount);
|
expect.soft(faultCount).toEqual(criticalityIconCount);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('When selecting a fault, it has an "is-selected" class and it\'s information shows in the inspector', async ({ page }) => {
|
test('When selecting a fault, it has an "is-selected" class and it\'s information shows in the inspector @unstable', async ({ page }) => {
|
||||||
await utils.selectFaultItem(page, 1);
|
await utils.selectFaultItem(page, 1);
|
||||||
|
|
||||||
const selectedFaultName = await page.locator('.c-fault-mgmt__list.is-selected .c-fault-mgmt__list-faultname').textContent();
|
const selectedFaultName = await page.locator('.c-fault-mgmt__list.is-selected .c-fault-mgmt__list-faultname').textContent();
|
||||||
@@ -45,7 +45,7 @@ test.describe('The Fault Management Plugin using example faults', () => {
|
|||||||
expect.soft(inspectorFaultNameCount).toEqual(1);
|
expect.soft(inspectorFaultNameCount).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('When selecting multiple faults, no specific fault information is shown in the inspector', async ({ page }) => {
|
test('When selecting multiple faults, no specific fault information is shown in the inspector @unstable', async ({ page }) => {
|
||||||
await utils.selectFaultItem(page, 1);
|
await utils.selectFaultItem(page, 1);
|
||||||
await utils.selectFaultItem(page, 2);
|
await utils.selectFaultItem(page, 2);
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ test.describe('The Fault Management Plugin using example faults', () => {
|
|||||||
expect.soft(secondNameInInspectorCount).toEqual(0);
|
expect.soft(secondNameInInspectorCount).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Allows you to shelve a fault', async ({ page }) => {
|
test('Allows you to shelve a fault @unstable', async ({ page }) => {
|
||||||
const shelvedFaultName = await utils.getFaultName(page, 2);
|
const shelvedFaultName = await utils.getFaultName(page, 2);
|
||||||
const beforeShelvedFault = utils.getFaultByName(page, shelvedFaultName);
|
const beforeShelvedFault = utils.getFaultByName(page, shelvedFaultName);
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ test.describe('The Fault Management Plugin using example faults', () => {
|
|||||||
expect.soft(await shelvedViewFault.count()).toBe(1);
|
expect.soft(await shelvedViewFault.count()).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Allows you to acknowledge a fault', async ({ page }) => {
|
test('Allows you to acknowledge a fault @unstable', async ({ page }) => {
|
||||||
const acknowledgedFaultName = await utils.getFaultName(page, 3);
|
const acknowledgedFaultName = await utils.getFaultName(page, 3);
|
||||||
|
|
||||||
await utils.acknowledgeFault(page, 3);
|
await utils.acknowledgeFault(page, 3);
|
||||||
@@ -94,7 +94,7 @@ test.describe('The Fault Management Plugin using example faults', () => {
|
|||||||
expect.soft(acknowledgedFaultName).toEqual(acknowledgedViewFaultName);
|
expect.soft(acknowledgedFaultName).toEqual(acknowledgedViewFaultName);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Allows you to shelve multiple faults', async ({ page }) => {
|
test('Allows you to shelve multiple faults @unstable', async ({ page }) => {
|
||||||
const shelvedFaultNameOne = await utils.getFaultName(page, 1);
|
const shelvedFaultNameOne = await utils.getFaultName(page, 1);
|
||||||
const shelvedFaultNameFour = await utils.getFaultName(page, 4);
|
const shelvedFaultNameFour = await utils.getFaultName(page, 4);
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ test.describe('The Fault Management Plugin using example faults', () => {
|
|||||||
expect.soft(await shelvedViewFaultFour.count()).toBe(1);
|
expect.soft(await shelvedViewFaultFour.count()).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Allows you to acknowledge multiple faults', async ({ page }) => {
|
test('Allows you to acknowledge multiple faults @unstable', async ({ page }) => {
|
||||||
const acknowledgedFaultNameTwo = await utils.getFaultName(page, 2);
|
const acknowledgedFaultNameTwo = await utils.getFaultName(page, 2);
|
||||||
const acknowledgedFaultNameFive = await utils.getFaultName(page, 5);
|
const acknowledgedFaultNameFive = await utils.getFaultName(page, 5);
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ test.describe('The Fault Management Plugin using example faults', () => {
|
|||||||
expect.soft(await acknowledgedViewFaultFive.count()).toBe(1);
|
expect.soft(await acknowledgedViewFaultFive.count()).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Allows you to search faults', async ({ page }) => {
|
test('Allows you to search faults @unstable', async ({ page }) => {
|
||||||
const faultThreeNamespace = await utils.getFaultNamespace(page, 3);
|
const faultThreeNamespace = await utils.getFaultNamespace(page, 3);
|
||||||
const faultTwoName = await utils.getFaultName(page, 2);
|
const faultTwoName = await utils.getFaultName(page, 2);
|
||||||
const faultFiveTriggerTime = await utils.getFaultTriggerTime(page, 5);
|
const faultFiveTriggerTime = await utils.getFaultTriggerTime(page, 5);
|
||||||
@@ -184,7 +184,7 @@ test.describe('The Fault Management Plugin using example faults', () => {
|
|||||||
expect.soft(await utils.getFaultTriggerTime(page, 1)).toEqual(faultFiveTriggerTime);
|
expect.soft(await utils.getFaultTriggerTime(page, 1)).toEqual(faultFiveTriggerTime);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Allows you to sort faults', async ({ page }) => {
|
test('Allows you to sort faults @unstable', async ({ page }) => {
|
||||||
const highestSeverity = await utils.getHighestSeverity(page);
|
const highestSeverity = await utils.getHighestSeverity(page);
|
||||||
const lowestSeverity = await utils.getLowestSeverity(page);
|
const lowestSeverity = await utils.getLowestSeverity(page);
|
||||||
const faultOneName = 'Example Fault 1';
|
const faultOneName = 'Example Fault 1';
|
||||||
@@ -213,7 +213,7 @@ test.describe('The Fault Management Plugin without using example faults', () =>
|
|||||||
await utils.navigateToFaultManagementWithoutExample(page);
|
await utils.navigateToFaultManagementWithoutExample(page);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Shows no faults when no faults are provided', async ({ page }) => {
|
test('Shows no faults when no faults are provided @unstable', async ({ page }) => {
|
||||||
const faultCount = await page.locator('c-fault-mgmt__list').count();
|
const faultCount = await page.locator('c-fault-mgmt__list').count();
|
||||||
|
|
||||||
expect.soft(faultCount).toEqual(0);
|
expect.soft(faultCount).toEqual(0);
|
||||||
@@ -227,7 +227,7 @@ test.describe('The Fault Management Plugin without using example faults', () =>
|
|||||||
expect.soft(shelvedCount).toEqual(0);
|
expect.soft(shelvedCount).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Will return no faults when searching', async ({ page }) => {
|
test('Will return no faults when searching @unstable', async ({ page }) => {
|
||||||
await utils.enterSearchTerm(page, 'fault');
|
await utils.enterSearchTerm(page, 'fault');
|
||||||
|
|
||||||
const faultCount = await page.locator('c-fault-mgmt__list').count();
|
const faultCount = await page.locator('c-fault-mgmt__list').count();
|
||||||
|
|||||||
@@ -0,0 +1,135 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, 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, expect } = require('../../../../pluginFixtures');
|
||||||
|
const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||||
|
|
||||||
|
test.describe('Flexible Layout', () => {
|
||||||
|
let sineWaveObject;
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
// Create Sine Wave Generator
|
||||||
|
sineWaveObject = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Sine Wave Generator',
|
||||||
|
name: "Test Sine Wave Generator"
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create Clock Object
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Clock',
|
||||||
|
name: "Test Clock"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('panes have the appropriate draggable attribute while in Edit and Browse modes', async ({ page }) => {
|
||||||
|
// Create a Flexible Layout
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Flexible Layout',
|
||||||
|
name: "Test Flexible Layout"
|
||||||
|
});
|
||||||
|
// Edit Flexible Layout
|
||||||
|
await page.locator('[title="Edit"]').click();
|
||||||
|
|
||||||
|
// Expand the 'My Items' folder in the left tree
|
||||||
|
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').first().click();
|
||||||
|
// Add the Sine Wave Generator and Clock to the Flexible Layout
|
||||||
|
await page.dragAndDrop('text=Test Sine Wave Generator', '.c-fl__container.is-empty');
|
||||||
|
await page.dragAndDrop('text=Test Clock', '.c-fl__container.is-empty');
|
||||||
|
// Check that panes can be dragged while Flexible Layout is in Edit mode
|
||||||
|
let dragWrapper = page.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper').first();
|
||||||
|
await expect(dragWrapper).toHaveAttribute('draggable', 'true');
|
||||||
|
// Save Flexible Layout
|
||||||
|
await page.locator('button[title="Save"]').click();
|
||||||
|
await page.locator('text=Save and Finish Editing').click();
|
||||||
|
// Check that panes are not draggable while Flexible Layout is in Browse mode
|
||||||
|
dragWrapper = page.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper').first();
|
||||||
|
await expect(dragWrapper).toHaveAttribute('draggable', 'false');
|
||||||
|
});
|
||||||
|
test('items in a flexible layout can be removed with object tree context menu when viewing the flexible layout', async ({ page }) => {
|
||||||
|
// Create a Display Layout
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Flexible Layout',
|
||||||
|
name: "Test Flexible Layout"
|
||||||
|
});
|
||||||
|
// Edit Flexible Layout
|
||||||
|
await page.locator('[title="Edit"]').click();
|
||||||
|
|
||||||
|
// Expand the 'My Items' folder in the left tree
|
||||||
|
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').first().click();
|
||||||
|
// Add the Sine Wave Generator to the Flexible Layout and save changes
|
||||||
|
await page.dragAndDrop('text=Test Sine Wave Generator', '.c-fl__container.is-empty');
|
||||||
|
await page.locator('button[title="Save"]').click();
|
||||||
|
await page.locator('text=Save and Finish Editing').click();
|
||||||
|
|
||||||
|
expect.soft(await page.locator('.c-fl-container__frame').count()).toEqual(1);
|
||||||
|
|
||||||
|
// Expand the Flexible Layout so we can remove the sine wave generator
|
||||||
|
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
|
||||||
|
|
||||||
|
// Bring up context menu and remove
|
||||||
|
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').first().click({ button: 'right' });
|
||||||
|
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||||
|
await page.locator('button:has-text("OK")').click();
|
||||||
|
|
||||||
|
// Verify that the item has been removed from the layout
|
||||||
|
expect(await page.locator('.c-fl-container__frame').count()).toEqual(0);
|
||||||
|
});
|
||||||
|
test('items in a flexible layout can be removed with object tree context menu when viewing another item', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/3117'
|
||||||
|
});
|
||||||
|
// Create a Flexible Layout
|
||||||
|
const flexibleLayout = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Flexible Layout',
|
||||||
|
name: "Test Flexible Layout"
|
||||||
|
});
|
||||||
|
// Edit Flexible Layout
|
||||||
|
await page.locator('[title="Edit"]').click();
|
||||||
|
|
||||||
|
// Expand the 'My Items' folder in the left tree
|
||||||
|
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
|
||||||
|
// Add the Sine Wave Generator to the Flexible Layout and save changes
|
||||||
|
await page.dragAndDrop('text=Test Sine Wave Generator', '.c-fl__container.is-empty');
|
||||||
|
await page.locator('button[title="Save"]').click();
|
||||||
|
await page.locator('text=Save and Finish Editing').click();
|
||||||
|
|
||||||
|
expect.soft(await page.locator('.c-fl-container__frame').count()).toEqual(1);
|
||||||
|
|
||||||
|
// Expand the Flexible Layout so we can remove the sine wave generator
|
||||||
|
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
|
||||||
|
|
||||||
|
// Go to the original Sine Wave Generator to navigate away from the Flexible Layout
|
||||||
|
await page.goto(sineWaveObject.url);
|
||||||
|
|
||||||
|
// Bring up context menu and remove
|
||||||
|
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').click({ button: 'right' });
|
||||||
|
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||||
|
await page.locator('button:has-text("OK")').click();
|
||||||
|
|
||||||
|
// navigate back to the display layout to confirm it has been removed
|
||||||
|
await page.goto(flexibleLayout.url);
|
||||||
|
|
||||||
|
// Verify that the item has been removed from the layout
|
||||||
|
expect(await page.locator('.c-fl-container__frame').count()).toEqual(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
124
e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This test suite is dedicated to testing the Gauge component.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const { test, expect } = require('../../../../pluginFixtures');
|
||||||
|
const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||||
|
const uuid = require('uuid').v4;
|
||||||
|
|
||||||
|
test.describe('Gauge', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// Open a browser, navigate to the main page, and wait until all networkevents to resolve
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Can add and remove telemetry sources @unstable', async ({ page }) => {
|
||||||
|
// Create the gauge with defaults
|
||||||
|
const gauge = await createDomainObjectWithDefaults(page, { type: 'Gauge' });
|
||||||
|
const editButtonLocator = page.locator('button[title="Edit"]');
|
||||||
|
const saveButtonLocator = page.locator('button[title="Save"]');
|
||||||
|
|
||||||
|
// Create a sine wave generator within the gauge
|
||||||
|
const swg1 = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Sine Wave Generator',
|
||||||
|
name: `swg-${uuid()}`,
|
||||||
|
parent: gauge.uuid
|
||||||
|
});
|
||||||
|
|
||||||
|
// Navigate to the gauge and verify that
|
||||||
|
// the SWG appears in the elements pool
|
||||||
|
await page.goto(gauge.url);
|
||||||
|
await editButtonLocator.click();
|
||||||
|
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeVisible();
|
||||||
|
await saveButtonLocator.click();
|
||||||
|
await page.locator('li[title="Save and Finish Editing"]').click();
|
||||||
|
|
||||||
|
// Create another sine wave generator within the gauge
|
||||||
|
const swg2 = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Sine Wave Generator',
|
||||||
|
name: `swg-${uuid()}`,
|
||||||
|
parent: gauge.uuid
|
||||||
|
});
|
||||||
|
|
||||||
|
// Verify that the 'Replace telemetry source' modal appears and accept it
|
||||||
|
await expect.soft(page.locator('text=This action will replace the current telemetry source. Do you want to continue?')).toBeVisible();
|
||||||
|
await page.click('text=Ok');
|
||||||
|
|
||||||
|
// Navigate to the gauge and verify that the new SWG
|
||||||
|
// appears in the elements pool and the old one is gone
|
||||||
|
await page.goto(gauge.url);
|
||||||
|
await editButtonLocator.click();
|
||||||
|
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeHidden();
|
||||||
|
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg2.name}`)).toBeVisible();
|
||||||
|
await saveButtonLocator.click();
|
||||||
|
|
||||||
|
// Right click on the new SWG in the elements pool and delete it
|
||||||
|
await page.locator(`#inspector-elements-tree >> text=${swg2.name}`).click({
|
||||||
|
button: 'right'
|
||||||
|
});
|
||||||
|
await page.locator('li[title="Remove this object from its containing object."]').click();
|
||||||
|
|
||||||
|
// Verify that the 'Remove object' confirmation modal appears and accept it
|
||||||
|
await expect.soft(page.locator('text=Warning! This action will remove this object. Are you sure you want to continue?')).toBeVisible();
|
||||||
|
await page.click('text=Ok');
|
||||||
|
|
||||||
|
// Verify that the elements pool shows no elements
|
||||||
|
await expect(page.locator('text="No contained elements"')).toBeVisible();
|
||||||
|
});
|
||||||
|
test('Can create a non-default Gauge', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5356'
|
||||||
|
});
|
||||||
|
//Click the Create button
|
||||||
|
await page.click('button:has-text("Create")');
|
||||||
|
|
||||||
|
// Click the object specified by 'type'
|
||||||
|
await page.click(`li[role='menuitem']:text("Gauge")`);
|
||||||
|
// FIXME: We need better selectors for these custom form controls
|
||||||
|
const displayCurrentValueSwitch = page.locator('.c-toggle-switch__slider >> nth=0');
|
||||||
|
await displayCurrentValueSwitch.setChecked(false);
|
||||||
|
await page.click('button[aria-label="Save"]');
|
||||||
|
|
||||||
|
// TODO: Verify changes in the UI
|
||||||
|
});
|
||||||
|
test('Can edit a single Gauge-specific property', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5985'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the gauge with defaults
|
||||||
|
await createDomainObjectWithDefaults(page, { type: 'Gauge' });
|
||||||
|
await page.click('button[title="More options"]');
|
||||||
|
await page.click('li[role="menuitem"]:has-text("Edit Properties")');
|
||||||
|
// FIXME: We need better selectors for these custom form controls
|
||||||
|
const displayCurrentValueSwitch = page.locator('.c-toggle-switch__slider >> nth=0');
|
||||||
|
await displayCurrentValueSwitch.setChecked(false);
|
||||||
|
await page.click('button[aria-label="Save"]');
|
||||||
|
|
||||||
|
// TODO: Verify changes in the UI
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -35,45 +35,24 @@ const expectedAltText = process.platform === 'linux' ? 'Ctrl+Alt drag to pan' :
|
|||||||
|
|
||||||
//The following block of tests verifies the basic functionality of example imagery and serves as a template for Imagery objects embedded in other objects.
|
//The following block of tests verifies the basic functionality of example imagery and serves as a template for Imagery objects embedded in other objects.
|
||||||
test.describe('Example Imagery Object', () => {
|
test.describe('Example Imagery Object', () => {
|
||||||
|
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
//Go to baseURL
|
//Go to baseURL
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
// Create a default 'Example Imagery' object
|
// Create a default 'Example Imagery' object
|
||||||
createDomainObjectWithDefaults(page, { type: 'Example Imagery' });
|
const exampleImagery = await createDomainObjectWithDefaults(page, { type: 'Example Imagery' });
|
||||||
|
|
||||||
await Promise.all([
|
|
||||||
page.waitForNavigation(),
|
|
||||||
page.locator(backgroundImageSelector).hover({trial: true}),
|
|
||||||
// eslint-disable-next-line playwright/missing-playwright-await
|
|
||||||
expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Example Imagery')
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Verify that the created object is focused
|
// Verify that the created object is focused
|
||||||
|
await expect(page.locator('.l-browse-bar__object-name')).toContainText(exampleImagery.name);
|
||||||
|
await page.locator(backgroundImageSelector).hover({trial: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Can use Mouse Wheel to zoom in and out of latest image', async ({ page }) => {
|
test('Can use Mouse Wheel to zoom in and out of latest image', async ({ page }) => {
|
||||||
const deltaYStep = 100; //equivalent to 1x zoom
|
// Zoom in x2 and assert
|
||||||
await page.locator(backgroundImageSelector).hover({trial: true});
|
await mouseZoomOnImageAndAssert(page, 2);
|
||||||
const originalImageDimensions = await page.locator(backgroundImageSelector).boundingBox();
|
|
||||||
// zoom in
|
|
||||||
await page.locator(backgroundImageSelector).hover({trial: true});
|
|
||||||
await page.mouse.wheel(0, deltaYStep * 2);
|
|
||||||
// wait for zoom animation to finish
|
|
||||||
await page.locator(backgroundImageSelector).hover({trial: true});
|
|
||||||
const imageMouseZoomedIn = await page.locator(backgroundImageSelector).boundingBox();
|
|
||||||
// zoom out
|
|
||||||
await page.locator(backgroundImageSelector).hover({trial: true});
|
|
||||||
await page.mouse.wheel(0, -deltaYStep);
|
|
||||||
// wait for zoom animation to finish
|
|
||||||
await page.locator(backgroundImageSelector).hover({trial: true});
|
|
||||||
const imageMouseZoomedOut = await page.locator(backgroundImageSelector).boundingBox();
|
|
||||||
|
|
||||||
expect(imageMouseZoomedIn.height).toBeGreaterThan(originalImageDimensions.height);
|
// Zoom out x2 and assert
|
||||||
expect(imageMouseZoomedIn.width).toBeGreaterThan(originalImageDimensions.width);
|
await mouseZoomOnImageAndAssert(page, -2);
|
||||||
expect(imageMouseZoomedOut.height).toBeLessThan(imageMouseZoomedIn.height);
|
|
||||||
expect(imageMouseZoomedOut.width).toBeLessThan(imageMouseZoomedIn.width);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Can adjust image brightness/contrast by dragging the sliders', async ({ page, browserName }) => {
|
test('Can adjust image brightness/contrast by dragging the sliders', async ({ page, browserName }) => {
|
||||||
@@ -151,30 +130,7 @@ test.describe('Example Imagery Object', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Can use + - buttons to zoom on the image @unstable', async ({ page }) => {
|
test('Can use + - buttons to zoom on the image @unstable', async ({ page }) => {
|
||||||
// Get initial image dimensions
|
await buttonZoomOnImageAndAssert(page);
|
||||||
const initialBoundingBox = await page.locator(backgroundImageSelector).boundingBox();
|
|
||||||
|
|
||||||
// Zoom in twice via button
|
|
||||||
await zoomIntoImageryByButton(page);
|
|
||||||
await zoomIntoImageryByButton(page);
|
|
||||||
|
|
||||||
// Get and assert zoomed in image dimensions
|
|
||||||
const zoomedInBoundingBox = await page.locator(backgroundImageSelector).boundingBox();
|
|
||||||
expect(zoomedInBoundingBox.height).toBeGreaterThan(initialBoundingBox.height);
|
|
||||||
expect(zoomedInBoundingBox.width).toBeGreaterThan(initialBoundingBox.width);
|
|
||||||
|
|
||||||
// Zoom out once via button
|
|
||||||
await zoomOutOfImageryByButton(page);
|
|
||||||
|
|
||||||
// Get and assert zoomed out image dimensions
|
|
||||||
const zoomedOutBoundingBox = await page.locator(backgroundImageSelector).boundingBox();
|
|
||||||
expect(zoomedOutBoundingBox.height).toBeLessThan(zoomedInBoundingBox.height);
|
|
||||||
expect(zoomedOutBoundingBox.width).toBeLessThan(zoomedInBoundingBox.width);
|
|
||||||
|
|
||||||
// Zoom out again via button, assert against the initial image dimensions
|
|
||||||
await zoomOutOfImageryByButton(page);
|
|
||||||
const finalBoundingBox = await page.locator(backgroundImageSelector).boundingBox();
|
|
||||||
expect(finalBoundingBox).toEqual(initialBoundingBox);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Can use the reset button to reset the image @unstable', async ({ page }, testInfo) => {
|
test('Can use the reset button to reset the image @unstable', async ({ page }, testInfo) => {
|
||||||
@@ -212,46 +168,227 @@ test.describe('Example Imagery Object', () => {
|
|||||||
await expect(pausePlayButton).not.toHaveClass(/is-paused/);
|
await expect(pausePlayButton).not.toHaveClass(/is-paused/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Uses low fetch priority', async ({ page }) => {
|
||||||
|
const priority = await page.locator('.js-imageryView-image').getAttribute('fetchpriority');
|
||||||
|
await expect(priority).toBe('low');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// The following test case will cover these scenarios
|
test.describe('Example Imagery in Display Layout', () => {
|
||||||
// ('Can use Mouse Wheel to zoom in and out of previous image');
|
let displayLayout;
|
||||||
// ('Can use alt+drag to move around image once zoomed in');
|
test.beforeEach(async ({ page }) => {
|
||||||
// ('Clicking on the left arrow should pause the imagery and go to previous image');
|
// Go to baseURL
|
||||||
// ('If the imagery view is in pause mode, it should not be updated when new images come in');
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
// ('If the imagery view is not in pause mode, it should be updated when new images come in');
|
|
||||||
test('Example Imagery in Display layout @unstable', async ({ page }) => {
|
displayLayout = await createDomainObjectWithDefaults(page, { type: 'Display Layout' });
|
||||||
test.info().annotations.push({
|
await page.goto(displayLayout.url);
|
||||||
type: 'issue',
|
|
||||||
description: 'https://github.com/nasa/openmct/issues/5265'
|
/* Create Sine Wave Generator with minimum Image Load Delay */
|
||||||
|
// Click the Create button
|
||||||
|
await page.click('button:has-text("Create")');
|
||||||
|
|
||||||
|
// Click text=Example Imagery
|
||||||
|
await page.click('li[role="menuitem"]:has-text("Example Imagery")');
|
||||||
|
|
||||||
|
// Clear and set Image load delay to minimum value
|
||||||
|
await page.locator('input[type="number"]').fill('');
|
||||||
|
await page.locator('input[type="number"]').fill('5000');
|
||||||
|
|
||||||
|
// Click text=OK
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForNavigation({waitUntil: 'networkidle'}),
|
||||||
|
page.click('button:has-text("OK")'),
|
||||||
|
//Wait for Save Banner to appear
|
||||||
|
page.waitForSelector('.c-message-banner__message')
|
||||||
|
]);
|
||||||
|
|
||||||
|
await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Example Imagery');
|
||||||
|
|
||||||
|
await page.goto(displayLayout.url);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Go to baseURL
|
test('Imagery View operations @unstable', async ({ page }) => {
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5265'
|
||||||
|
});
|
||||||
|
|
||||||
// Click the Create button
|
// Edit mode
|
||||||
await page.click('button:has-text("Create")');
|
await page.click('button[title="Edit"]');
|
||||||
|
|
||||||
// Click text=Example Imagery
|
// Click on example imagery to expose toolbar
|
||||||
await page.click('text=Example Imagery');
|
await page.locator('.c-so-view__header').click();
|
||||||
|
|
||||||
// Clear and set Image load delay to minimum value
|
// Adjust object height
|
||||||
await page.locator('input[type="number"]').fill('');
|
await page.locator('div[title="Resize object height"] > input').click();
|
||||||
await page.locator('input[type="number"]').fill('5000');
|
await page.locator('div[title="Resize object height"] > input').fill('50');
|
||||||
|
|
||||||
// Click text=OK
|
// Adjust object width
|
||||||
await Promise.all([
|
await page.locator('div[title="Resize object width"] > input').click();
|
||||||
page.waitForNavigation({waitUntil: 'networkidle'}),
|
await page.locator('div[title="Resize object width"] > input').fill('50');
|
||||||
page.click('text=OK'),
|
|
||||||
//Wait for Save Banner to appear
|
|
||||||
page.waitForSelector('.c-message-banner__message')
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Wait until Save Banner is gone
|
await performImageryViewOperationsAndAssert(page);
|
||||||
await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
|
});
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Example Imagery');
|
|
||||||
await page.locator(backgroundImageSelector).hover({trial: true});
|
|
||||||
|
|
||||||
|
test('Resizing the layout changes thumbnail visibility and size', async ({ page }) => {
|
||||||
|
const thumbsWrapperLocator = page.locator('.c-imagery__thumbs-wrapper');
|
||||||
|
// Edit mode
|
||||||
|
await page.click('button[title="Edit"]');
|
||||||
|
|
||||||
|
// Click on example imagery to expose toolbar
|
||||||
|
await page.locator('.c-so-view__header').click();
|
||||||
|
|
||||||
|
// expect thumbnails not be visible when first added
|
||||||
|
expect.soft(thumbsWrapperLocator.isHidden()).toBeTruthy();
|
||||||
|
|
||||||
|
// Resize the example imagery vertically to change the thumbnail visibility
|
||||||
|
/*
|
||||||
|
The following arbitrary values are added to observe the separate visual
|
||||||
|
conditions of the thumbnails (hidden, small thumbnails, regular thumbnails).
|
||||||
|
Specifically, height is set to 50px for small thumbs and 100px for regular
|
||||||
|
*/
|
||||||
|
await page.locator('div[title="Resize object height"] > input').click();
|
||||||
|
await page.locator('div[title="Resize object height"] > input').fill('50');
|
||||||
|
|
||||||
|
expect(thumbsWrapperLocator.isVisible()).toBeTruthy();
|
||||||
|
await expect(thumbsWrapperLocator).toHaveClass(/is-small-thumbs/);
|
||||||
|
|
||||||
|
// Resize the example imagery vertically to change the thumbnail visibility
|
||||||
|
await page.locator('div[title="Resize object height"] > input').click();
|
||||||
|
await page.locator('div[title="Resize object height"] > input').fill('100');
|
||||||
|
|
||||||
|
expect(thumbsWrapperLocator.isVisible()).toBeTruthy();
|
||||||
|
await expect(thumbsWrapperLocator).not.toHaveClass(/is-small-thumbs/);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe('Example Imagery in Flexible layout', () => {
|
||||||
|
let flexibleLayout;
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
flexibleLayout = await createDomainObjectWithDefaults(page, { type: 'Flexible Layout' });
|
||||||
|
await page.goto(flexibleLayout.url);
|
||||||
|
|
||||||
|
/* Create Sine Wave Generator with minimum Image Load Delay */
|
||||||
|
// Click the Create button
|
||||||
|
await page.click('button:has-text("Create")');
|
||||||
|
|
||||||
|
// Click text=Example Imagery
|
||||||
|
await page.click('li[role="menuitem"]:has-text("Example Imagery")');
|
||||||
|
|
||||||
|
// Clear and set Image load delay to minimum value
|
||||||
|
await page.locator('input[type="number"]').fill('');
|
||||||
|
await page.locator('input[type="number"]').fill('5000');
|
||||||
|
|
||||||
|
// Click text=OK
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForNavigation({waitUntil: 'networkidle'}),
|
||||||
|
page.click('button:has-text("OK")'),
|
||||||
|
//Wait for Save Banner to appear
|
||||||
|
page.waitForSelector('.c-message-banner__message')
|
||||||
|
]);
|
||||||
|
|
||||||
|
await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Example Imagery');
|
||||||
|
|
||||||
|
await page.goto(flexibleLayout.url);
|
||||||
|
});
|
||||||
|
test('Imagery View operations @unstable', async ({ page, browserName }) => {
|
||||||
|
test.fixme(browserName === 'firefox', 'This test needs to be updated to work with firefox');
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5326'
|
||||||
|
});
|
||||||
|
|
||||||
|
await performImageryViewOperationsAndAssert(page);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe('Example Imagery in Tabs View', () => {
|
||||||
|
let tabsView;
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
tabsView = await createDomainObjectWithDefaults(page, { type: 'Tabs View' });
|
||||||
|
await page.goto(tabsView.url);
|
||||||
|
|
||||||
|
/* Create Sine Wave Generator with minimum Image Load Delay */
|
||||||
|
// Click the Create button
|
||||||
|
await page.click('button:has-text("Create")');
|
||||||
|
|
||||||
|
// Click text=Example Imagery
|
||||||
|
await page.click('li[role="menuitem"]:has-text("Example Imagery")');
|
||||||
|
|
||||||
|
// Clear and set Image load delay to minimum value
|
||||||
|
await page.locator('input[type="number"]').fill('');
|
||||||
|
await page.locator('input[type="number"]').fill('5000');
|
||||||
|
|
||||||
|
// Click text=OK
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForNavigation({waitUntil: 'networkidle'}),
|
||||||
|
page.click('button:has-text("OK")'),
|
||||||
|
//Wait for Save Banner to appear
|
||||||
|
page.waitForSelector('.c-message-banner__message')
|
||||||
|
]);
|
||||||
|
|
||||||
|
await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Example Imagery');
|
||||||
|
|
||||||
|
await page.goto(tabsView.url);
|
||||||
|
});
|
||||||
|
test('Imagery View operations @unstable', async ({ page }) => {
|
||||||
|
await performImageryViewOperationsAndAssert(page);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe('Example Imagery in Time Strip', () => {
|
||||||
|
let timeStripObject;
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
timeStripObject = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Time Strip',
|
||||||
|
name: 'Time Strip'.concat(' ', uuid())
|
||||||
|
});
|
||||||
|
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Example Imagery',
|
||||||
|
name: 'Example Imagery'.concat(' ', uuid()),
|
||||||
|
parent: timeStripObject.uuid
|
||||||
|
});
|
||||||
|
// Navigate to timestrip
|
||||||
|
await page.goto(timeStripObject.url);
|
||||||
|
});
|
||||||
|
test('Clicking a thumbnail loads the image in large view', async ({ page, browserName }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5632'
|
||||||
|
});
|
||||||
|
await page.locator('.c-imagery-tsv-container').hover();
|
||||||
|
// get url of the hovered image
|
||||||
|
const hoveredImg = page.locator('.c-imagery-tsv div.c-imagery-tsv__image-wrapper:hover img');
|
||||||
|
const hoveredImgSrc = await hoveredImg.getAttribute('src');
|
||||||
|
expect(hoveredImgSrc).toBeTruthy();
|
||||||
|
await page.locator('.c-imagery-tsv-container').click();
|
||||||
|
// get image of view large container
|
||||||
|
const viewLargeImg = page.locator('img.c-imagery__main-image__image');
|
||||||
|
const viewLargeImgSrc = await viewLargeImg.getAttribute('src');
|
||||||
|
expect(viewLargeImgSrc).toBeTruthy();
|
||||||
|
expect(viewLargeImgSrc).toEqual(hoveredImgSrc);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform the common actions and assertions for the Imagery View.
|
||||||
|
* This function verifies the following in order:
|
||||||
|
* 1. Can zoom in/out using the zoom buttons
|
||||||
|
* 2. Can zoom in/out using the mouse wheel
|
||||||
|
* 3. Can pan the image using the pan hotkey + mouse drag
|
||||||
|
* 4. Clicking on the left arrow button pauses imagery and moves to the previous image
|
||||||
|
* 5. Imagery is updated as new images stream in, regardless of pause status
|
||||||
|
* 6. Old images are discarded when new images stream in
|
||||||
|
* 7. Image brightness/contrast can be adjusted by dragging the sliders
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
*/
|
||||||
|
async function performImageryViewOperationsAndAssert(page) {
|
||||||
// Click previous image button
|
// Click previous image button
|
||||||
const previousImageButton = page.locator('.c-nav--prev');
|
const previousImageButton = page.locator('.c-nav--prev');
|
||||||
await previousImageButton.click();
|
await previousImageButton.click();
|
||||||
@@ -260,27 +397,17 @@ test('Example Imagery in Display layout @unstable', async ({ page }) => {
|
|||||||
const selectedImage = page.locator('.selected');
|
const selectedImage = page.locator('.selected');
|
||||||
await expect(selectedImage).toBeVisible();
|
await expect(selectedImage).toBeVisible();
|
||||||
|
|
||||||
// Zoom in
|
// Use the zoom buttons to zoom in and out
|
||||||
const originalImageDimensions = await page.locator(backgroundImageSelector).boundingBox();
|
await buttonZoomOnImageAndAssert(page);
|
||||||
await page.locator(backgroundImageSelector).hover({trial: true});
|
|
||||||
const deltaYStep = 100; // equivalent to 1x zoom
|
|
||||||
await page.mouse.wheel(0, deltaYStep * 2);
|
|
||||||
const zoomedBoundingBox = await page.locator(backgroundImageSelector).boundingBox();
|
|
||||||
const imageCenterX = zoomedBoundingBox.x + zoomedBoundingBox.width / 2;
|
|
||||||
const imageCenterY = zoomedBoundingBox.y + zoomedBoundingBox.height / 2;
|
|
||||||
|
|
||||||
// Wait for zoom animation to finish
|
// Use Mouse Wheel to zoom in to previous image
|
||||||
await page.locator(backgroundImageSelector).hover({trial: true});
|
await mouseZoomOnImageAndAssert(page, 2);
|
||||||
const imageMouseZoomedIn = await page.locator(backgroundImageSelector).boundingBox();
|
|
||||||
expect(imageMouseZoomedIn.height).toBeGreaterThan(originalImageDimensions.height);
|
|
||||||
expect(imageMouseZoomedIn.width).toBeGreaterThan(originalImageDimensions.width);
|
|
||||||
|
|
||||||
// Center the mouse pointer
|
// Use alt+drag to move around image once zoomed in
|
||||||
await page.mouse.move(imageCenterX, imageCenterY);
|
await panZoomAndAssertImageProperties(page);
|
||||||
|
|
||||||
// Pan Imagery Hints
|
// Use Mouse Wheel to zoom out of previous image
|
||||||
const imageryHintsText = await page.locator('.c-imagery__hints').innerText();
|
await mouseZoomOnImageAndAssert(page, -2);
|
||||||
expect(expectedAltText).toEqual(imageryHintsText);
|
|
||||||
|
|
||||||
// Click next image button
|
// Click next image button
|
||||||
const nextImageButton = page.locator('.c-nav--next');
|
const nextImageButton = page.locator('.c-nav--next');
|
||||||
@@ -293,21 +420,14 @@ test('Example Imagery in Display layout @unstable', async ({ page }) => {
|
|||||||
await page.locator('[data-testid=conductor-modeOption-realtime]').click();
|
await page.locator('[data-testid=conductor-modeOption-realtime]').click();
|
||||||
|
|
||||||
// Zoom in on next image
|
// Zoom in on next image
|
||||||
await page.locator(backgroundImageSelector).hover({trial: true});
|
await mouseZoomOnImageAndAssert(page, 2);
|
||||||
await page.mouse.wheel(0, deltaYStep * 2);
|
|
||||||
|
|
||||||
// Wait for zoom animation to finish
|
// Clicking on the left arrow should pause the imagery and go to previous image
|
||||||
await page.locator(backgroundImageSelector).hover({trial: true});
|
|
||||||
const imageNextMouseZoomedIn = await page.locator(backgroundImageSelector).boundingBox();
|
|
||||||
expect(imageNextMouseZoomedIn.height).toBeGreaterThan(originalImageDimensions.height);
|
|
||||||
expect(imageNextMouseZoomedIn.width).toBeGreaterThan(originalImageDimensions.width);
|
|
||||||
|
|
||||||
// Click previous image button
|
|
||||||
await previousImageButton.click();
|
await previousImageButton.click();
|
||||||
|
await expect(page.locator('.c-button.pause-play')).toHaveClass(/is-paused/);
|
||||||
// Verify previous image
|
|
||||||
await expect(selectedImage).toBeVisible();
|
await expect(selectedImage).toBeVisible();
|
||||||
|
|
||||||
|
// The imagery view should be updated when new images come in
|
||||||
const imageCount = await page.locator('.c-imagery__thumb').count();
|
const imageCount = await page.locator('.c-imagery__thumb').count();
|
||||||
await expect.poll(async () => {
|
await expect.poll(async () => {
|
||||||
const newImageCount = await page.locator('.c-imagery__thumb').count();
|
const newImageCount = await page.locator('.c-imagery__thumb').count();
|
||||||
@@ -315,7 +435,7 @@ test('Example Imagery in Display layout @unstable', async ({ page }) => {
|
|||||||
return newImageCount;
|
return newImageCount;
|
||||||
}, {
|
}, {
|
||||||
message: "verify that old images are discarded",
|
message: "verify that old images are discarded",
|
||||||
timeout: 6 * 1000
|
timeout: 7 * 1000
|
||||||
}).toBe(imageCount);
|
}).toBe(imageCount);
|
||||||
|
|
||||||
// Verify selected image is still displayed
|
// Verify selected image is still displayed
|
||||||
@@ -333,283 +453,6 @@ test('Example Imagery in Display layout @unstable', async ({ page }) => {
|
|||||||
// Drag the brightness and contrast sliders around and assert filter values
|
// Drag the brightness and contrast sliders around and assert filter values
|
||||||
await dragBrightnessSliderAndAssertFilterValues(page);
|
await dragBrightnessSliderAndAssertFilterValues(page);
|
||||||
await dragContrastSliderAndAssertFilterValues(page);
|
await dragContrastSliderAndAssertFilterValues(page);
|
||||||
});
|
|
||||||
|
|
||||||
test.describe('Example imagery thumbnails resize in display layouts', () => {
|
|
||||||
test('Resizing the layout changes thumbnail visibility and size', async ({ page }) => {
|
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
|
||||||
|
|
||||||
const thumbsWrapperLocator = page.locator('.c-imagery__thumbs-wrapper');
|
|
||||||
// Click button:has-text("Create")
|
|
||||||
await page.locator('button:has-text("Create")').click();
|
|
||||||
|
|
||||||
// Click li:has-text("Display Layout")
|
|
||||||
await page.locator('li:has-text("Display Layout")').click();
|
|
||||||
const displayLayoutTitleField = page.locator('text=Properties Title Notes Horizontal grid (px) Vertical grid (px) Horizontal size ( >> input[type="text"]');
|
|
||||||
await displayLayoutTitleField.click();
|
|
||||||
|
|
||||||
await displayLayoutTitleField.fill('Thumbnail Display Layout');
|
|
||||||
|
|
||||||
// Click text=OK
|
|
||||||
await Promise.all([
|
|
||||||
page.waitForNavigation(),
|
|
||||||
page.locator('text=OK').click()
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Click text=Snapshot Save and Finish Editing Save and Continue Editing >> button >> nth=1
|
|
||||||
await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1).click();
|
|
||||||
|
|
||||||
// Click text=Save and Finish Editing
|
|
||||||
await page.locator('text=Save and Finish Editing').click();
|
|
||||||
|
|
||||||
// Click button:has-text("Create")
|
|
||||||
await page.locator('button:has-text("Create")').click();
|
|
||||||
|
|
||||||
// Click li:has-text("Example Imagery")
|
|
||||||
await page.locator('li:has-text("Example Imagery")').click();
|
|
||||||
|
|
||||||
const imageryTitleField = page.locator('text=Properties Title Notes Images url list (comma separated) Image load delay (milli >> input[type="text"]');
|
|
||||||
// Click text=Properties Title Notes Images url list (comma separated) Image load delay (milli >> input[type="text"]
|
|
||||||
await imageryTitleField.click();
|
|
||||||
|
|
||||||
// Fill text=Properties Title Notes Images url list (comma separated) Image load delay (milli >> input[type="text"]
|
|
||||||
await imageryTitleField.fill('Thumbnail Example Imagery');
|
|
||||||
|
|
||||||
// Click text=OK
|
|
||||||
await Promise.all([
|
|
||||||
page.waitForNavigation(),
|
|
||||||
page.locator('text=OK').click()
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Click text=Thumbnail Example Imagery Imagery Layout Snapshot >> button >> nth=0
|
|
||||||
await Promise.all([
|
|
||||||
page.waitForNavigation(),
|
|
||||||
page.locator('text=Thumbnail Example Imagery Imagery Layout Snapshot >> button').first().click()
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Edit mode
|
|
||||||
await page.locator('text=Thumbnail Display Layout Snapshot >> button').nth(3).click();
|
|
||||||
|
|
||||||
// Click on example imagery to expose toolbar
|
|
||||||
await page.locator('text=Thumbnail Example Imagery Snapshot Large View').click();
|
|
||||||
|
|
||||||
// expect thumbnails not be visible when first added
|
|
||||||
expect.soft(thumbsWrapperLocator.isHidden()).toBeTruthy();
|
|
||||||
|
|
||||||
// Resize the example imagery vertically to change the thumbnail visibility
|
|
||||||
/*
|
|
||||||
The following arbitrary values are added to observe the separate visual
|
|
||||||
conditions of the thumbnails (hidden, small thumbnails, regular thumbnails).
|
|
||||||
Specifically, height is set to 50px for small thumbs and 100px for regular
|
|
||||||
*/
|
|
||||||
// Click #mct-input-id-103
|
|
||||||
await page.locator('#mct-input-id-103').click();
|
|
||||||
|
|
||||||
// Fill #mct-input-id-103
|
|
||||||
await page.locator('#mct-input-id-103').fill('50');
|
|
||||||
|
|
||||||
expect(thumbsWrapperLocator.isVisible()).toBeTruthy();
|
|
||||||
await expect(thumbsWrapperLocator).toHaveClass(/is-small-thumbs/);
|
|
||||||
|
|
||||||
// Resize the example imagery vertically to change the thumbnail visibility
|
|
||||||
// Click #mct-input-id-103
|
|
||||||
await page.locator('#mct-input-id-103').click();
|
|
||||||
|
|
||||||
// Fill #mct-input-id-103
|
|
||||||
await page.locator('#mct-input-id-103').fill('100');
|
|
||||||
|
|
||||||
expect(thumbsWrapperLocator.isVisible()).toBeTruthy();
|
|
||||||
await expect(thumbsWrapperLocator).not.toHaveClass(/is-small-thumbs/);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test.describe('Example Imagery in Flexible layout', () => {
|
|
||||||
test('Example Imagery in Flexible layout @unstable', async ({ page, browserName, openmctConfig }) => {
|
|
||||||
const { myItemsFolderName } = openmctConfig;
|
|
||||||
|
|
||||||
// eslint-disable-next-line playwright/no-skipped-test
|
|
||||||
test.skip(browserName === 'firefox', 'This test needs to be updated to work with firefox');
|
|
||||||
test.info().annotations.push({
|
|
||||||
type: 'issue',
|
|
||||||
description: 'https://github.com/nasa/openmct/issues/5326'
|
|
||||||
});
|
|
||||||
|
|
||||||
// Go to baseURL
|
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
|
||||||
|
|
||||||
// Click the Create button
|
|
||||||
await page.click('button:has-text("Create")');
|
|
||||||
|
|
||||||
// Click text=Example Imagery
|
|
||||||
await page.click('text=Example Imagery');
|
|
||||||
|
|
||||||
// Clear and set Image load delay (milliseconds)
|
|
||||||
await page.click('input[type="number"]', {clickCount: 3});
|
|
||||||
await page.type('input[type="number"]', "20");
|
|
||||||
|
|
||||||
// Click text=OK
|
|
||||||
await Promise.all([
|
|
||||||
page.waitForNavigation({waitUntil: 'networkidle'}),
|
|
||||||
page.click('text=OK'),
|
|
||||||
//Wait for Save Banner to appear
|
|
||||||
page.waitForSelector('.c-message-banner__message')
|
|
||||||
]);
|
|
||||||
// Wait until Save Banner is gone
|
|
||||||
await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
|
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Example Imagery');
|
|
||||||
await page.locator(backgroundImageSelector).hover({trial: true});
|
|
||||||
|
|
||||||
// Click the Create button
|
|
||||||
await page.click('button:has-text("Create")');
|
|
||||||
|
|
||||||
// Click text=Flexible Layout
|
|
||||||
await page.click('text=Flexible Layout');
|
|
||||||
|
|
||||||
// Assert Flexible layout
|
|
||||||
await expect(page.locator('.js-form-title')).toHaveText('Create a New Flexible Layout');
|
|
||||||
|
|
||||||
await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
|
|
||||||
|
|
||||||
// Click My Items
|
|
||||||
await Promise.all([
|
|
||||||
page.locator('text=OK').click(),
|
|
||||||
page.waitForNavigation({waitUntil: 'networkidle'})
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Click My Items
|
|
||||||
await page.locator('.c-disclosure-triangle').click();
|
|
||||||
|
|
||||||
// Right click example imagery
|
|
||||||
await page.click(('text=Unnamed Example Imagery'), { button: 'right' });
|
|
||||||
|
|
||||||
// Click move
|
|
||||||
await page.locator('.icon-move').click();
|
|
||||||
|
|
||||||
// Click triangle to open sub menu
|
|
||||||
await page.locator('.c-form__section .c-disclosure-triangle').click();
|
|
||||||
|
|
||||||
// Click Flexable Layout
|
|
||||||
await page.click('.c-overlay__outer >> text=Unnamed Flexible Layout');
|
|
||||||
|
|
||||||
// Click text=OK
|
|
||||||
await page.locator('text=OK').click();
|
|
||||||
|
|
||||||
// Save template
|
|
||||||
await saveTemplate(page);
|
|
||||||
|
|
||||||
// Zoom in
|
|
||||||
await mouseZoomIn(page);
|
|
||||||
|
|
||||||
// Center the mouse pointer
|
|
||||||
const zoomedBoundingBox = await page.locator(backgroundImageSelector).boundingBox();
|
|
||||||
const imageCenterX = zoomedBoundingBox.x + zoomedBoundingBox.width / 2;
|
|
||||||
const imageCenterY = zoomedBoundingBox.y + zoomedBoundingBox.height / 2;
|
|
||||||
await page.mouse.move(imageCenterX, imageCenterY);
|
|
||||||
|
|
||||||
// Pan zoom
|
|
||||||
await panZoomAndAssertImageProperties(page);
|
|
||||||
|
|
||||||
// Click previous image button
|
|
||||||
const previousImageButton = page.locator('.c-nav--prev');
|
|
||||||
await previousImageButton.click();
|
|
||||||
|
|
||||||
// Verify previous image
|
|
||||||
const selectedImage = page.locator('.selected');
|
|
||||||
await expect(selectedImage).toBeVisible();
|
|
||||||
|
|
||||||
// Click time conductor mode button
|
|
||||||
await page.locator('.c-mode-button').click();
|
|
||||||
|
|
||||||
// Select local clock mode
|
|
||||||
await page.locator('[data-testid=conductor-modeOption-realtime]').nth(0).click();
|
|
||||||
|
|
||||||
// Zoom in on next image
|
|
||||||
await mouseZoomIn(page);
|
|
||||||
|
|
||||||
// Click previous image button
|
|
||||||
await previousImageButton.click();
|
|
||||||
|
|
||||||
// Verify previous image
|
|
||||||
await expect(selectedImage).toBeVisible();
|
|
||||||
|
|
||||||
const imageCount = await page.locator('.c-imagery__thumb').count();
|
|
||||||
await expect.poll(async () => {
|
|
||||||
const newImageCount = await page.locator('.c-imagery__thumb').count();
|
|
||||||
|
|
||||||
return newImageCount;
|
|
||||||
}, {
|
|
||||||
message: "verify that old images are discarded",
|
|
||||||
timeout: 6 * 1000
|
|
||||||
}).toBe(imageCount);
|
|
||||||
|
|
||||||
// Verify selected image is still displayed
|
|
||||||
await expect(selectedImage).toBeVisible();
|
|
||||||
|
|
||||||
// Unpause imagery
|
|
||||||
await page.locator('.pause-play').click();
|
|
||||||
|
|
||||||
//Get background-image url from background-image css prop
|
|
||||||
await assertBackgroundImageUrlFromBackgroundCss(page);
|
|
||||||
|
|
||||||
// Open the image filter menu
|
|
||||||
await page.locator('[role=toolbar] button[title="Brightness and contrast"]').click();
|
|
||||||
|
|
||||||
// Drag the brightness and contrast sliders around and assert filter values
|
|
||||||
await dragBrightnessSliderAndAssertFilterValues(page);
|
|
||||||
await dragContrastSliderAndAssertFilterValues(page);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test.describe('Example Imagery in Tabs view', () => {
|
|
||||||
test.fixme('Can use Mouse Wheel to zoom in and out of previous image');
|
|
||||||
test.fixme('Can use alt+drag to move around image once zoomed in');
|
|
||||||
test.fixme('Can zoom into the latest image and the real-time/fixed-time imagery will pause');
|
|
||||||
test.fixme('Can zoom into a previous image from thumbstrip in real-time or fixed-time');
|
|
||||||
test.fixme('Clicking on the left arrow should pause the imagery and go to previous image');
|
|
||||||
test.fixme('If the imagery view is in pause mode, it should not be updated when new images come in');
|
|
||||||
test.fixme('If the imagery view is not in pause mode, it should be updated when new images come in');
|
|
||||||
});
|
|
||||||
|
|
||||||
test.describe('Example Imagery in Time Strip', () => {
|
|
||||||
test('ensure that clicking a thumbnail loads the image in large view', async ({ page, browserName }) => {
|
|
||||||
test.info().annotations.push({
|
|
||||||
type: 'issue',
|
|
||||||
description: 'https://github.com/nasa/openmct/issues/5632'
|
|
||||||
});
|
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
|
||||||
const timeStripObject = await createDomainObjectWithDefaults(page, {
|
|
||||||
type: 'Time Strip',
|
|
||||||
name: 'Time Strip'.concat(' ', uuid())
|
|
||||||
});
|
|
||||||
|
|
||||||
await createDomainObjectWithDefaults(page, {
|
|
||||||
type: 'Example Imagery',
|
|
||||||
name: 'Example Imagery'.concat(' ', uuid()),
|
|
||||||
parent: timeStripObject.uuid
|
|
||||||
});
|
|
||||||
// Navigate to timestrip
|
|
||||||
await page.goto(timeStripObject.url);
|
|
||||||
|
|
||||||
await page.locator('.c-imagery-tsv-container').hover();
|
|
||||||
// get url of the hovered image
|
|
||||||
const hoveredImg = page.locator('.c-imagery-tsv div.c-imagery-tsv__image-wrapper:hover img');
|
|
||||||
const hoveredImgSrc = await hoveredImg.getAttribute('src');
|
|
||||||
expect(hoveredImgSrc).toBeTruthy();
|
|
||||||
await page.locator('.c-imagery-tsv-container').click();
|
|
||||||
// get image of view large container
|
|
||||||
const viewLargeImg = page.locator('img.c-imagery__main-image__image');
|
|
||||||
const viewLargeImgSrc = await viewLargeImg.getAttribute('src');
|
|
||||||
expect(viewLargeImgSrc).toBeTruthy();
|
|
||||||
expect(viewLargeImgSrc).toEqual(hoveredImgSrc);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {import('@playwright/test').Page} page
|
|
||||||
*/
|
|
||||||
async function saveTemplate(page) {
|
|
||||||
await page.locator('.c-button--menu.c-button--major.icon-save').click();
|
|
||||||
await page.locator('text=Save and Finish Editing').click();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -692,7 +535,7 @@ async function assertBackgroundImageUrlFromBackgroundCss(page) {
|
|||||||
return backgroundImageUrl2;
|
return backgroundImageUrl2;
|
||||||
}, {
|
}, {
|
||||||
message: "verify next image has updated",
|
message: "verify next image has updated",
|
||||||
timeout: 6 * 1000
|
timeout: 7 * 1000
|
||||||
}).not.toBe(backgroundImageUrl1);
|
}).not.toBe(backgroundImageUrl1);
|
||||||
console.log('backgroundImageUrl2 ' + backgroundImageUrl2);
|
console.log('backgroundImageUrl2 ' + backgroundImageUrl2);
|
||||||
}
|
}
|
||||||
@@ -746,14 +589,17 @@ async function panZoomAndAssertImageProperties(page) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Use the mouse wheel to zoom in or out of an image and assert that the image
|
||||||
|
* has successfully zoomed in or out.
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {number} [factor = 2] The zoom factor. Positive for zoom in, negative for zoom out.
|
||||||
*/
|
*/
|
||||||
async function mouseZoomIn(page) {
|
async function mouseZoomOnImageAndAssert(page, factor = 2) {
|
||||||
// Zoom in
|
// Zoom in
|
||||||
const originalImageDimensions = await page.locator(backgroundImageSelector).boundingBox();
|
const originalImageDimensions = await page.locator(backgroundImageSelector).boundingBox();
|
||||||
await page.locator(backgroundImageSelector).hover({trial: true});
|
await page.locator(backgroundImageSelector).hover({trial: true});
|
||||||
const deltaYStep = 100; // equivalent to 1x zoom
|
const deltaYStep = 100; // equivalent to 1x zoom
|
||||||
await page.mouse.wheel(0, deltaYStep * 2);
|
await page.mouse.wheel(0, deltaYStep * factor);
|
||||||
const zoomedBoundingBox = await page.locator(backgroundImageSelector).boundingBox();
|
const zoomedBoundingBox = await page.locator(backgroundImageSelector).boundingBox();
|
||||||
const imageCenterX = zoomedBoundingBox.x + zoomedBoundingBox.width / 2;
|
const imageCenterX = zoomedBoundingBox.x + zoomedBoundingBox.width / 2;
|
||||||
const imageCenterY = zoomedBoundingBox.y + zoomedBoundingBox.height / 2;
|
const imageCenterY = zoomedBoundingBox.y + zoomedBoundingBox.height / 2;
|
||||||
@@ -763,9 +609,47 @@ async function mouseZoomIn(page) {
|
|||||||
|
|
||||||
// Wait for zoom animation to finish
|
// Wait for zoom animation to finish
|
||||||
await page.locator(backgroundImageSelector).hover({trial: true});
|
await page.locator(backgroundImageSelector).hover({trial: true});
|
||||||
const imageMouseZoomedIn = await page.locator(backgroundImageSelector).boundingBox();
|
const imageMouseZoomed = await page.locator(backgroundImageSelector).boundingBox();
|
||||||
expect(imageMouseZoomedIn.height).toBeGreaterThan(originalImageDimensions.height);
|
|
||||||
expect(imageMouseZoomedIn.width).toBeGreaterThan(originalImageDimensions.width);
|
if (factor > 0) {
|
||||||
|
expect(imageMouseZoomed.height).toBeGreaterThan(originalImageDimensions.height);
|
||||||
|
expect(imageMouseZoomed.width).toBeGreaterThan(originalImageDimensions.width);
|
||||||
|
} else {
|
||||||
|
expect(imageMouseZoomed.height).toBeLessThan(originalImageDimensions.height);
|
||||||
|
expect(imageMouseZoomed.width).toBeLessThan(originalImageDimensions.width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zoom in and out of the image using the buttons, and assert that the image has
|
||||||
|
* been successfully zoomed in or out.
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
*/
|
||||||
|
async function buttonZoomOnImageAndAssert(page) {
|
||||||
|
// Get initial image dimensions
|
||||||
|
const initialBoundingBox = await page.locator(backgroundImageSelector).boundingBox();
|
||||||
|
|
||||||
|
// Zoom in twice via button
|
||||||
|
await zoomIntoImageryByButton(page);
|
||||||
|
await zoomIntoImageryByButton(page);
|
||||||
|
|
||||||
|
// Get and assert zoomed in image dimensions
|
||||||
|
const zoomedInBoundingBox = await page.locator(backgroundImageSelector).boundingBox();
|
||||||
|
expect(zoomedInBoundingBox.height).toBeGreaterThan(initialBoundingBox.height);
|
||||||
|
expect(zoomedInBoundingBox.width).toBeGreaterThan(initialBoundingBox.width);
|
||||||
|
|
||||||
|
// Zoom out once via button
|
||||||
|
await zoomOutOfImageryByButton(page);
|
||||||
|
|
||||||
|
// Get and assert zoomed out image dimensions
|
||||||
|
const zoomedOutBoundingBox = await page.locator(backgroundImageSelector).boundingBox();
|
||||||
|
expect(zoomedOutBoundingBox.height).toBeLessThan(zoomedInBoundingBox.height);
|
||||||
|
expect(zoomedOutBoundingBox.width).toBeLessThan(zoomedInBoundingBox.width);
|
||||||
|
|
||||||
|
// Zoom out again via button, assert against the initial image dimensions
|
||||||
|
await zoomOutOfImageryByButton(page);
|
||||||
|
const finalBoundingBox = await page.locator(backgroundImageSelector).boundingBox();
|
||||||
|
expect(finalBoundingBox).toEqual(initialBoundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ This test suite is dedicated to tests which verify the basic operations surround
|
|||||||
|
|
||||||
// FIXME: Remove this eslint exception once tests are implemented
|
// FIXME: Remove this eslint exception once tests are implemented
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const { test, expect } = require('../../../../baseFixtures');
|
const { test, expect } = require('../../../../pluginFixtures');
|
||||||
|
const { expandTreePaneItemByName, createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||||
|
const nbUtils = require('../../../../helper/notebookUtils');
|
||||||
|
|
||||||
test.describe('Notebook CRUD Operations', () => {
|
test.describe('Notebook CRUD Operations', () => {
|
||||||
test.fixme('Can create a Notebook Object', async ({ page }) => {
|
test.fixme('Can create a Notebook Object', async ({ page }) => {
|
||||||
@@ -67,10 +69,32 @@ test.describe('Default Notebook', () => {
|
|||||||
|
|
||||||
test.describe('Notebook section tests', () => {
|
test.describe('Notebook section tests', () => {
|
||||||
//The following test cases are associated with Notebook Sections
|
//The following test cases are associated with Notebook Sections
|
||||||
test.fixme('New sections are automatically named Unnamed Section with Unnamed Page', async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
//Create new notebook A
|
//Navigate to baseURL
|
||||||
//Add section
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
//Verify new section and new page details
|
|
||||||
|
// Create Notebook
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Notebook',
|
||||||
|
name: "Test Notebook"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('Default and new sections are automatically named Unnamed Section with Unnamed Page', async ({ page }) => {
|
||||||
|
// Check that the default section and page are created and the name matches the defaults
|
||||||
|
const defaultSectionName = await page.locator('.c-notebook__sections .c-list__item__name').textContent();
|
||||||
|
expect(defaultSectionName).toBe('Unnamed Section');
|
||||||
|
const defaultPageName = await page.locator('.c-notebook__pages .c-list__item__name').textContent();
|
||||||
|
expect(defaultPageName).toBe('Unnamed Page');
|
||||||
|
|
||||||
|
// Expand sidebar and add a section
|
||||||
|
await page.locator('.c-notebook__toggle-nav-button').click();
|
||||||
|
await page.locator('.js-sidebar-sections .c-icon-button.icon-plus').click();
|
||||||
|
|
||||||
|
// Check that new section and page within the new section match the defaults
|
||||||
|
const newSectionName = await page.locator('.c-notebook__sections .c-list__item__name').nth(1).textContent();
|
||||||
|
expect(newSectionName).toBe('Unnamed Section');
|
||||||
|
const newPageName = await page.locator('.c-notebook__pages .c-list__item__name').textContent();
|
||||||
|
expect(newPageName).toBe('Unnamed Page');
|
||||||
});
|
});
|
||||||
test.fixme('Section selection operations and associated behavior', async ({ page }) => {
|
test.fixme('Section selection operations and associated behavior', async ({ page }) => {
|
||||||
//Create new notebook A
|
//Create new notebook A
|
||||||
@@ -107,6 +131,38 @@ test.describe('Notebook section tests', () => {
|
|||||||
|
|
||||||
test.describe('Notebook page tests', () => {
|
test.describe('Notebook page tests', () => {
|
||||||
//The following test cases are associated with Notebook Pages
|
//The following test cases are associated with Notebook Pages
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
//Navigate to baseURL
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
// Create Notebook
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Notebook',
|
||||||
|
name: "Test Notebook"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//Test will need to be implemented after a refactor in #5713
|
||||||
|
// eslint-disable-next-line playwright/no-skipped-test
|
||||||
|
test.skip('Delete page popup is removed properly on clicking dropdown again', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5713'
|
||||||
|
});
|
||||||
|
// Expand sidebar and add a second page
|
||||||
|
await page.locator('.c-notebook__toggle-nav-button').click();
|
||||||
|
await page.locator('text=Page Add >> button').click();
|
||||||
|
|
||||||
|
// Click on the 2nd page dropdown button and expect the Delete Page option to appear
|
||||||
|
await page.locator('button[title="Open context menu"]').nth(2).click();
|
||||||
|
await expect(page.locator('text=Delete Page')).toBeEnabled();
|
||||||
|
// Clicking on the same page a second time causes the same Delete Page option to recreate
|
||||||
|
await page.locator('button[title="Open context menu"]').nth(2).click();
|
||||||
|
await expect(page.locator('text=Delete Page')).toBeEnabled();
|
||||||
|
// Clicking on the first page causes the first delete button to detach and recreate on the first page
|
||||||
|
await page.locator('button[title="Open context menu"]').nth(1).click();
|
||||||
|
const numOfDeletePagePopups = await page.locator('li[title="Delete Page"]').count();
|
||||||
|
expect(numOfDeletePagePopups).toBe(1);
|
||||||
|
});
|
||||||
test.fixme('Page selection operations and associated behavior', async ({ page }) => {
|
test.fixme('Page selection operations and associated behavior', async ({ page }) => {
|
||||||
//Create new notebook A
|
//Create new notebook A
|
||||||
//Delete existing Page
|
//Delete existing Page
|
||||||
@@ -154,13 +210,58 @@ test.describe('Notebook search tests', () => {
|
|||||||
|
|
||||||
test.describe('Notebook entry tests', () => {
|
test.describe('Notebook entry tests', () => {
|
||||||
test.fixme('When a new entry is created, it should be focused', async ({ page }) => {});
|
test.fixme('When a new entry is created, it should be focused', async ({ page }) => {});
|
||||||
test.fixme('When a telemetry object is dropped into a notebook, a new entry is created and it should be focused', async ({ page }) => {
|
test('When an object is dropped into a notebook, a new entry is created and it should be focused @unstable', async ({ page }) => {
|
||||||
// Drag and drop any telmetry object on 'drop object'
|
await page.goto('./#/browse/mine', { waitUntil: 'networkidle' });
|
||||||
// new entry gets created with telemtry object
|
|
||||||
|
// Create Notebook
|
||||||
|
const notebook = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Notebook',
|
||||||
|
name: "Embed Test Notebook"
|
||||||
|
});
|
||||||
|
// Create Overlay Plot
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Overlay Plot',
|
||||||
|
name: "Dropped Overlay Plot"
|
||||||
|
});
|
||||||
|
|
||||||
|
await expandTreePaneItemByName(page, 'My Items');
|
||||||
|
|
||||||
|
await page.goto(notebook.url);
|
||||||
|
await page.dragAndDrop('role=treeitem[name=/Dropped Overlay Plot/]', '.c-notebook__drag-area');
|
||||||
|
|
||||||
|
const embed = page.locator('.c-ne__embed__link');
|
||||||
|
const embedName = await embed.textContent();
|
||||||
|
|
||||||
|
await expect(embed).toHaveClass(/icon-plot-overlay/);
|
||||||
|
expect(embedName).toBe('Dropped Overlay Plot');
|
||||||
});
|
});
|
||||||
test.fixme('When a telemetry object is dropped into a notebooks existing entry, it should be focused', async ({ page }) => {
|
test('When an object is dropped into a notebooks existing entry, it should be focused @unstable', async ({ page }) => {
|
||||||
// Drag and drop any telemetry object onto existing entry
|
await page.goto('./#/browse/mine', { waitUntil: 'networkidle' });
|
||||||
// Entry updated with object and snapshot
|
|
||||||
|
// Create Notebook
|
||||||
|
const notebook = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Notebook',
|
||||||
|
name: "Embed Test Notebook"
|
||||||
|
});
|
||||||
|
// Create Overlay Plot
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Overlay Plot',
|
||||||
|
name: "Dropped Overlay Plot"
|
||||||
|
});
|
||||||
|
|
||||||
|
await expandTreePaneItemByName(page, 'My Items');
|
||||||
|
|
||||||
|
await page.goto(notebook.url);
|
||||||
|
|
||||||
|
await nbUtils.enterTextEntry(page, 'Entry to drop into');
|
||||||
|
await page.dragAndDrop('role=treeitem[name=/Dropped Overlay Plot/]', 'text=Entry to drop into');
|
||||||
|
|
||||||
|
const existingEntry = page.locator('.c-ne__content', { has: page.locator('text="Entry to drop into"') });
|
||||||
|
const embed = existingEntry.locator('.c-ne__embed__link');
|
||||||
|
const embedName = await embed.textContent();
|
||||||
|
|
||||||
|
await expect(embed).toHaveClass(/icon-plot-overlay/);
|
||||||
|
expect(embedName).toBe('Dropped Overlay Plot');
|
||||||
});
|
});
|
||||||
test.fixme('new entries persist through navigation events without save', async ({ page }) => {});
|
test.fixme('new entries persist through navigation events without save', async ({ page }) => {});
|
||||||
test.fixme('previous and new entries can be deleted', async ({ page }) => {});
|
test.fixme('previous and new entries can be deleted', async ({ page }) => {});
|
||||||
|
|||||||
@@ -0,0 +1,271 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
This test suite is dedicated to tests which verify the basic operations surrounding Notebooks with CouchDB.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const { test, expect } = require('../../../../pluginFixtures');
|
||||||
|
const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||||
|
|
||||||
|
test.describe('Notebook Tests with CouchDB @couchdb', () => {
|
||||||
|
let testNotebook;
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
//Navigate to baseURL
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
// Create Notebook
|
||||||
|
testNotebook = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Notebook',
|
||||||
|
name: "TestNotebook"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Inspect Notebook Entry Network Requests', async ({ page }) => {
|
||||||
|
// Expand sidebar
|
||||||
|
await page.locator('.c-notebook__toggle-nav-button').click();
|
||||||
|
|
||||||
|
// Collect all request events to count and assert after notebook action
|
||||||
|
let addingNotebookElementsRequests = [];
|
||||||
|
page.on('request', (request) => addingNotebookElementsRequests.push(request));
|
||||||
|
|
||||||
|
let [notebookUrlRequest, allDocsRequest] = await Promise.all([
|
||||||
|
// Waits for the next request with the specified url
|
||||||
|
page.waitForRequest(`**/openmct/${testNotebook.uuid}`),
|
||||||
|
page.waitForRequest('**/openmct/_all_docs?include_docs=true'),
|
||||||
|
// Triggers the request
|
||||||
|
page.click('[aria-label="Add Page"]'),
|
||||||
|
// Ensures that there are no other network requests
|
||||||
|
page.waitForLoadState('networkidle')
|
||||||
|
]);
|
||||||
|
// Assert that only two requests are made
|
||||||
|
// Network Requests are:
|
||||||
|
// 1) The actual POST to create the page
|
||||||
|
// 2) The shared worker event from 👆 request
|
||||||
|
expect(addingNotebookElementsRequests.length).toBe(2);
|
||||||
|
|
||||||
|
// Assert on request object
|
||||||
|
expect(notebookUrlRequest.postDataJSON().metadata.name).toBe('TestNotebook');
|
||||||
|
expect(notebookUrlRequest.postDataJSON().model.persisted).toBeGreaterThanOrEqual(notebookUrlRequest.postDataJSON().model.modified);
|
||||||
|
expect(allDocsRequest.postDataJSON().keys).toContain(testNotebook.uuid);
|
||||||
|
|
||||||
|
// Add an entry
|
||||||
|
// Network Requests are:
|
||||||
|
// 1) The actual POST to create the entry
|
||||||
|
// 2) The shared worker event from 👆 POST request
|
||||||
|
addingNotebookElementsRequests = [];
|
||||||
|
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"]').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"]').fill(`First Entry`);
|
||||||
|
await page.waitForLoadState('networkidle');
|
||||||
|
expect(addingNotebookElementsRequests.length).toBeLessThanOrEqual(2);
|
||||||
|
|
||||||
|
// Add some tags
|
||||||
|
// Network Requests are for each tag creation are:
|
||||||
|
// 1) Getting the original path of the parent object
|
||||||
|
// 2) Getting the original path of the grandparent object (recursive call)
|
||||||
|
// 3) Creating the annotation/tag object
|
||||||
|
// 4) The shared worker event from 👆 POST request
|
||||||
|
// 5) Mutate notebook domain object's annotationModified property
|
||||||
|
// 6) The shared worker event from 👆 POST request
|
||||||
|
// 7) Notebooks fetching new annotations due to annotationModified changed
|
||||||
|
// 8) The update of the notebook domain's object's modified property
|
||||||
|
// 9) The shared worker event from 👆 POST request
|
||||||
|
// 10) Entry is timestamped
|
||||||
|
// 11) The shared worker event from 👆 POST request
|
||||||
|
|
||||||
|
addingNotebookElementsRequests = [];
|
||||||
|
await page.hover(`button:has-text("Add Tag")`);
|
||||||
|
await page.locator(`button:has-text("Add Tag")`).click();
|
||||||
|
await page.locator('[placeholder="Type to select tag"]').click();
|
||||||
|
await page.locator('[aria-label="Autocomplete Options"] >> text=Driving').click();
|
||||||
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Driving")');
|
||||||
|
page.waitForLoadState('networkidle');
|
||||||
|
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(11);
|
||||||
|
|
||||||
|
addingNotebookElementsRequests = [];
|
||||||
|
await page.hover(`button:has-text("Add Tag")`);
|
||||||
|
await page.locator(`button:has-text("Add Tag")`).click();
|
||||||
|
await page.locator('[placeholder="Type to select tag"]').click();
|
||||||
|
await page.locator('[aria-label="Autocomplete Options"] >> text=Drilling').click();
|
||||||
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Drilling")');
|
||||||
|
page.waitForLoadState('networkidle');
|
||||||
|
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(11);
|
||||||
|
|
||||||
|
addingNotebookElementsRequests = [];
|
||||||
|
await page.hover(`button:has-text("Add Tag")`);
|
||||||
|
await page.locator(`button:has-text("Add Tag")`).click();
|
||||||
|
await page.locator('[placeholder="Type to select tag"]').click();
|
||||||
|
await page.locator('[aria-label="Autocomplete Options"] >> text=Science').click();
|
||||||
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Science")');
|
||||||
|
page.waitForLoadState('networkidle');
|
||||||
|
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(11);
|
||||||
|
|
||||||
|
// Delete all the tags
|
||||||
|
// Network requests are:
|
||||||
|
// 1) Send POST to mutate _delete property to true on annotation with tag
|
||||||
|
// 2) The shared worker event from 👆 POST request
|
||||||
|
// 3) Timestamp update on entry
|
||||||
|
// 4) The shared worker event from 👆 POST request
|
||||||
|
// This happens for 3 tags so 12 requests
|
||||||
|
addingNotebookElementsRequests = [];
|
||||||
|
await page.hover('[aria-label="Tag"]:has-text("Driving")');
|
||||||
|
await page.locator('[aria-label="Tag"]:has-text("Driving") ~ .c-completed-tag-deletion').click();
|
||||||
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Driving")', {state: 'hidden'});
|
||||||
|
await page.hover('[aria-label="Tag"]:has-text("Drilling")');
|
||||||
|
await page.locator('[aria-label="Tag"]:has-text("Drilling") ~ .c-completed-tag-deletion').click();
|
||||||
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Drilling")', {state: 'hidden'});
|
||||||
|
page.hover('[aria-label="Tag"]:has-text("Science")');
|
||||||
|
await page.locator('[aria-label="Tag"]:has-text("Science") ~ .c-completed-tag-deletion').click();
|
||||||
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Science")', {state: 'hidden'});
|
||||||
|
page.waitForLoadState('networkidle');
|
||||||
|
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(12);
|
||||||
|
|
||||||
|
// Add two more pages
|
||||||
|
await page.click('[aria-label="Add Page"]');
|
||||||
|
await page.click('[aria-label="Add Page"]');
|
||||||
|
|
||||||
|
// Add three entries
|
||||||
|
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"]').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"]').fill(`First Entry`);
|
||||||
|
|
||||||
|
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=1').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=1').fill(`Second Entry`);
|
||||||
|
|
||||||
|
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=2').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=2').fill(`Third Entry`);
|
||||||
|
|
||||||
|
// Add three tags
|
||||||
|
await page.hover(`button:has-text("Add Tag") >> nth=2`);
|
||||||
|
await page.locator(`button:has-text("Add Tag") >> nth=2`).click();
|
||||||
|
await page.locator('[placeholder="Type to select tag"]').click();
|
||||||
|
await page.locator('[aria-label="Autocomplete Options"] >> text=Science').click();
|
||||||
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Science")');
|
||||||
|
|
||||||
|
await page.hover(`button:has-text("Add Tag") >> nth=2`);
|
||||||
|
await page.locator(`button:has-text("Add Tag") >> nth=2`).click();
|
||||||
|
await page.locator('[placeholder="Type to select tag"]').click();
|
||||||
|
await page.locator('[aria-label="Autocomplete Options"] >> text=Drilling').click();
|
||||||
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Drilling")');
|
||||||
|
|
||||||
|
await page.hover(`button:has-text("Add Tag") >> nth=2`);
|
||||||
|
await page.locator(`button:has-text("Add Tag") >> nth=2`).click();
|
||||||
|
await page.locator('[placeholder="Type to select tag"]').click();
|
||||||
|
await page.locator('[aria-label="Autocomplete Options"] >> text=Driving').click();
|
||||||
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Driving")');
|
||||||
|
page.waitForLoadState('networkidle');
|
||||||
|
|
||||||
|
// Add a fourth entry
|
||||||
|
// Network requests are:
|
||||||
|
// 1) Send POST to add new entry
|
||||||
|
// 2) The shared worker event from 👆 POST request
|
||||||
|
// 3) Timestamp update on entry
|
||||||
|
// 4) The shared worker event from 👆 POST request
|
||||||
|
addingNotebookElementsRequests = [];
|
||||||
|
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=3').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=3').fill(`Fourth Entry`);
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=3').press('Enter');
|
||||||
|
page.waitForLoadState('networkidle');
|
||||||
|
|
||||||
|
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(4);
|
||||||
|
|
||||||
|
// Add a fifth entry
|
||||||
|
// Network requests are:
|
||||||
|
// 1) Send POST to add new entry
|
||||||
|
// 2) The shared worker event from 👆 POST request
|
||||||
|
// 3) Timestamp update on entry
|
||||||
|
// 4) The shared worker event from 👆 POST request
|
||||||
|
addingNotebookElementsRequests = [];
|
||||||
|
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=4').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=4').fill(`Fifth Entry`);
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=4').press('Enter');
|
||||||
|
page.waitForLoadState('networkidle');
|
||||||
|
|
||||||
|
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(4);
|
||||||
|
|
||||||
|
// Add a sixth entry
|
||||||
|
// 1) Send POST to add new entry
|
||||||
|
// 2) The shared worker event from 👆 POST request
|
||||||
|
// 3) Timestamp update on entry
|
||||||
|
// 4) The shared worker event from 👆 POST request
|
||||||
|
addingNotebookElementsRequests = [];
|
||||||
|
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=5').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=5').fill(`Sixth Entry`);
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=5').press('Enter');
|
||||||
|
page.waitForLoadState('networkidle');
|
||||||
|
|
||||||
|
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(4);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Search tests', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/akhenry/openmct-yamcs/issues/69'
|
||||||
|
});
|
||||||
|
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"]').click();
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"]').fill(`First Entry`);
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"]').press('Enter');
|
||||||
|
|
||||||
|
// Add three tags
|
||||||
|
await page.hover(`button:has-text("Add Tag")`);
|
||||||
|
await page.locator(`button:has-text("Add Tag")`).click();
|
||||||
|
await page.locator('[placeholder="Type to select tag"]').click();
|
||||||
|
await page.locator('[aria-label="Autocomplete Options"] >> text=Science').click();
|
||||||
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Science")');
|
||||||
|
|
||||||
|
await page.hover(`button:has-text("Add Tag")`);
|
||||||
|
await page.locator(`button:has-text("Add Tag")`).click();
|
||||||
|
await page.locator('[placeholder="Type to select tag"]').click();
|
||||||
|
await page.locator('[aria-label="Autocomplete Options"] >> text=Drilling').click();
|
||||||
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Drilling")');
|
||||||
|
|
||||||
|
await page.hover(`button:has-text("Add Tag")`);
|
||||||
|
await page.locator(`button:has-text("Add Tag")`).click();
|
||||||
|
await page.locator('[placeholder="Type to select tag"]').click();
|
||||||
|
await page.locator('[aria-label="Autocomplete Options"] >> text=Driving').click();
|
||||||
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Driving")');
|
||||||
|
|
||||||
|
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"]').first()).toContainText("Science");
|
||||||
|
await expect(page.locator('[aria-label="Search Result"]').first()).not.toContainText("Driving");
|
||||||
|
|
||||||
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||||
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Xq');
|
||||||
|
await expect(page.locator('text=No results found')).toBeVisible();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Try to reduce indeterminism of browser requests by only returning fetch requests.
|
||||||
|
// Filter out preflight CORS, fetching stylesheets, page icons, etc. that can occur during tests
|
||||||
|
function filterNonFetchRequests(requests) {
|
||||||
|
return requests.filter(request => {
|
||||||
|
return (request.resourceType() === 'fetch');
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -23,11 +23,11 @@
|
|||||||
const { test, expect } = require('../../../../pluginFixtures');
|
const { test, expect } = require('../../../../pluginFixtures');
|
||||||
const { openObjectTreeContextMenu, createDomainObjectWithDefaults } = require('../../../../appActions');
|
const { openObjectTreeContextMenu, createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const nbUtils = require('../../../../helper/notebookUtils');
|
||||||
|
|
||||||
const TEST_TEXT = 'Testing text for entries.';
|
const TEST_TEXT = 'Testing text for entries.';
|
||||||
const TEST_TEXT_NAME = 'Test Page';
|
const TEST_TEXT_NAME = 'Test Page';
|
||||||
const CUSTOM_NAME = 'CUSTOM_NAME';
|
const CUSTOM_NAME = 'CUSTOM_NAME';
|
||||||
const NOTEBOOK_DROP_AREA = '.c-notebook__drag-area';
|
|
||||||
|
|
||||||
test.describe('Restricted Notebook', () => {
|
test.describe('Restricted Notebook', () => {
|
||||||
let notebook;
|
let notebook;
|
||||||
@@ -36,27 +36,27 @@ test.describe('Restricted Notebook', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Can be renamed @addInit', async ({ page }) => {
|
test('Can be renamed @addInit', async ({ page }) => {
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText(`Unnamed ${CUSTOM_NAME}`);
|
await expect(page.locator('.l-browse-bar__object-name')).toContainText(`${notebook.name}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Can be deleted if there are no locked pages @addInit', async ({ page, openmctConfig }) => {
|
test('Can be deleted if there are no locked pages @addInit', async ({ page }) => {
|
||||||
await openObjectTreeContextMenu(page, notebook.url);
|
await openObjectTreeContextMenu(page, notebook.url);
|
||||||
|
|
||||||
const menuOptions = page.locator('.c-menu ul');
|
const menuOptions = page.locator('.c-menu ul');
|
||||||
await expect.soft(menuOptions).toContainText('Remove');
|
await expect.soft(menuOptions).toContainText('Remove');
|
||||||
|
|
||||||
const restrictedNotebookTreeObject = page.locator(`a:has-text("Unnamed ${CUSTOM_NAME}")`);
|
const restrictedNotebookTreeObject = page.locator(`a:has-text("${notebook.name}")`);
|
||||||
|
|
||||||
// notebook tree object exists
|
// notebook tree object exists
|
||||||
expect.soft(await restrictedNotebookTreeObject.count()).toEqual(1);
|
expect.soft(await restrictedNotebookTreeObject.count()).toEqual(1);
|
||||||
|
|
||||||
// Click Remove Text
|
// Click Remove Text
|
||||||
await page.locator('text=Remove').click();
|
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||||
|
|
||||||
// Click 'OK' on confirmation window and wait for save banner to appear
|
// Click 'OK' on confirmation window and wait for save banner to appear
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForNavigation(),
|
page.waitForNavigation(),
|
||||||
page.locator('text=OK').click(),
|
page.locator('button:has-text("OK")').click(),
|
||||||
page.waitForSelector('.c-message-banner__message')
|
page.waitForSelector('.c-message-banner__message')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ test.describe('Restricted Notebook', () => {
|
|||||||
|
|
||||||
test('Can be locked if at least one page has one entry @addInit', async ({ page }) => {
|
test('Can be locked if at least one page has one entry @addInit', async ({ page }) => {
|
||||||
|
|
||||||
await enterTextEntry(page);
|
await nbUtils.enterTextEntry(page, TEST_TEXT);
|
||||||
|
|
||||||
const commitButton = page.locator('button:has-text("Commit Entries")');
|
const commitButton = page.locator('button:has-text("Commit Entries")');
|
||||||
expect(await commitButton.count()).toEqual(1);
|
expect(await commitButton.count()).toEqual(1);
|
||||||
@@ -78,7 +78,7 @@ test.describe('Restricted Notebook with at least one entry and with the page loc
|
|||||||
let notebook;
|
let notebook;
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
notebook = await startAndAddRestrictedNotebookObject(page);
|
notebook = await startAndAddRestrictedNotebookObject(page);
|
||||||
await enterTextEntry(page);
|
await nbUtils.enterTextEntry(page, TEST_TEXT);
|
||||||
await lockPage(page);
|
await lockPage(page);
|
||||||
|
|
||||||
// open sidebar
|
// open sidebar
|
||||||
@@ -121,7 +121,7 @@ test.describe('Restricted Notebook with at least one entry and with the page loc
|
|||||||
expect.soft(newPageCount).toEqual(1);
|
expect.soft(newPageCount).toEqual(1);
|
||||||
|
|
||||||
// enter test text
|
// enter test text
|
||||||
await enterTextEntry(page);
|
await nbUtils.enterTextEntry(page, TEST_TEXT);
|
||||||
|
|
||||||
// expect new page to be lockable
|
// expect new page to be lockable
|
||||||
const commitButton = page.locator('BUTTON:HAS-TEXT("COMMIT ENTRIES")');
|
const commitButton = page.locator('BUTTON:HAS-TEXT("COMMIT ENTRIES")');
|
||||||
@@ -134,7 +134,7 @@ test.describe('Restricted Notebook with at least one entry and with the page loc
|
|||||||
// Click text=Ok
|
// Click text=Ok
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForNavigation(),
|
page.waitForNavigation(),
|
||||||
page.locator('text=Ok').click()
|
page.locator('button:has-text("OK")').click()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// deleted page, should no longer exist
|
// deleted page, should no longer exist
|
||||||
@@ -145,10 +145,9 @@ test.describe('Restricted Notebook with at least one entry and with the page loc
|
|||||||
|
|
||||||
test.describe('Restricted Notebook with a page locked and with an embed @addInit', () => {
|
test.describe('Restricted Notebook with a page locked and with an embed @addInit', () => {
|
||||||
|
|
||||||
test.beforeEach(async ({ page, openmctConfig }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
const { myItemsFolderName } = openmctConfig;
|
const notebook = await startAndAddRestrictedNotebookObject(page);
|
||||||
await startAndAddRestrictedNotebookObject(page);
|
await nbUtils.dragAndDropEmbed(page, notebook);
|
||||||
await dragAndDropEmbed(page, myItemsFolderName);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Allows embeds to be deleted if page unlocked @addInit', async ({ page }) => {
|
test('Allows embeds to be deleted if page unlocked @addInit', async ({ page }) => {
|
||||||
@@ -181,42 +180,6 @@ async function startAndAddRestrictedNotebookObject(page) {
|
|||||||
return createDomainObjectWithDefaults(page, { type: CUSTOM_NAME });
|
return createDomainObjectWithDefaults(page, { type: CUSTOM_NAME });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {import('@playwright/test').Page} page
|
|
||||||
*/
|
|
||||||
async function enterTextEntry(page) {
|
|
||||||
// Click .c-notebook__drag-area
|
|
||||||
await page.locator(NOTEBOOK_DROP_AREA).click();
|
|
||||||
|
|
||||||
// enter text
|
|
||||||
await page.locator('div.c-ne__text').click();
|
|
||||||
await page.locator('div.c-ne__text').fill(TEST_TEXT);
|
|
||||||
await page.locator('div.c-ne__text').press('Enter');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {import('@playwright/test').Page} page
|
|
||||||
*/
|
|
||||||
async function dragAndDropEmbed(page, myItemsFolderName) {
|
|
||||||
// Click button:has-text("Create")
|
|
||||||
await page.locator('button:has-text("Create")').click();
|
|
||||||
// Click li:has-text("Sine Wave Generator")
|
|
||||||
await page.locator('li:has-text("Sine Wave Generator")').click();
|
|
||||||
// Click form[name="mctForm"] >> text=My Items
|
|
||||||
await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
|
|
||||||
// Click text=OK
|
|
||||||
await page.locator('text=OK').click();
|
|
||||||
// Click text=Open MCT My Items >> span >> nth=3
|
|
||||||
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
|
|
||||||
// Click text=Unnamed CUSTOM_NAME
|
|
||||||
await Promise.all([
|
|
||||||
page.waitForNavigation(),
|
|
||||||
page.locator('text=Unnamed CUSTOM_NAME').click()
|
|
||||||
]);
|
|
||||||
|
|
||||||
await page.dragAndDrop('text=UNNAMED SINE WAVE GENERATOR', NOTEBOOK_DROP_AREA);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -36,15 +36,18 @@ async function createNotebookAndEntry(page, iterations = 1) {
|
|||||||
//Go to baseURL
|
//Go to baseURL
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
createDomainObjectWithDefaults(page, { type: 'Notebook' });
|
const notebook = createDomainObjectWithDefaults(page, { type: 'Notebook' });
|
||||||
|
|
||||||
for (let iteration = 0; iteration < iterations; iteration++) {
|
for (let iteration = 0; iteration < iterations; iteration++) {
|
||||||
// Click text=To start a new entry, click here or drag and drop any object
|
// Create an entry
|
||||||
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
||||||
const entryLocator = `[aria-label="Notebook Entry Input"] >> nth = ${iteration}`;
|
const entryLocator = `[aria-label="Notebook Entry Input"] >> nth = ${iteration}`;
|
||||||
await page.locator(entryLocator).click();
|
await page.locator(entryLocator).click();
|
||||||
await page.locator(entryLocator).fill(`Entry ${iteration}`);
|
await page.locator(entryLocator).fill(`Entry ${iteration}`);
|
||||||
|
await page.locator(entryLocator).press('Enter');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return notebook;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,7 +56,7 @@ async function createNotebookAndEntry(page, iterations = 1) {
|
|||||||
* @param {number} [iterations = 1] - the number of entries (and tags) to create
|
* @param {number} [iterations = 1] - the number of entries (and tags) to create
|
||||||
*/
|
*/
|
||||||
async function createNotebookEntryAndTags(page, iterations = 1) {
|
async function createNotebookEntryAndTags(page, iterations = 1) {
|
||||||
await createNotebookAndEntry(page, iterations);
|
const notebook = await createNotebookAndEntry(page, iterations);
|
||||||
|
|
||||||
for (let iteration = 0; iteration < iterations; iteration++) {
|
for (let iteration = 0; iteration < iterations; iteration++) {
|
||||||
// Hover and click "Add Tag" button
|
// Hover and click "Add Tag" button
|
||||||
@@ -75,16 +78,16 @@ async function createNotebookEntryAndTags(page, iterations = 1) {
|
|||||||
// Select the "Science" tag
|
// Select the "Science" tag
|
||||||
await page.locator('[aria-label="Autocomplete Options"] >> text=Science').click();
|
await page.locator('[aria-label="Autocomplete Options"] >> text=Science').click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return notebook;
|
||||||
}
|
}
|
||||||
|
|
||||||
test.describe('Tagging in Notebooks @addInit', () => {
|
test.describe('Tagging in Notebooks @addInit', () => {
|
||||||
test('Can load tags', async ({ page }) => {
|
test('Can load tags', async ({ page }) => {
|
||||||
|
|
||||||
await createNotebookAndEntry(page);
|
await createNotebookAndEntry(page);
|
||||||
// Click text=To start a new entry, click here or drag and drop any object
|
|
||||||
await page.locator('button:has-text("Add Tag")').click();
|
await page.locator('button:has-text("Add Tag")').click();
|
||||||
|
|
||||||
// Click [placeholder="Type to select tag"]
|
|
||||||
await page.locator('[placeholder="Type to select tag"]').click();
|
await page.locator('[placeholder="Type to select tag"]').click();
|
||||||
|
|
||||||
await expect(page.locator('[aria-label="Autocomplete Options"]')).toContainText("Science");
|
await expect(page.locator('[aria-label="Autocomplete Options"]')).toContainText("Science");
|
||||||
@@ -97,9 +100,7 @@ test.describe('Tagging in Notebooks @addInit', () => {
|
|||||||
await expect(page.locator('[aria-label="Notebook Entry"]')).toContainText("Science");
|
await expect(page.locator('[aria-label="Notebook Entry"]')).toContainText("Science");
|
||||||
await expect(page.locator('[aria-label="Notebook Entry"]')).toContainText("Driving");
|
await expect(page.locator('[aria-label="Notebook Entry"]')).toContainText("Driving");
|
||||||
|
|
||||||
// Click button:has-text("Add Tag")
|
|
||||||
await page.locator('button:has-text("Add Tag")').click();
|
await page.locator('button:has-text("Add Tag")').click();
|
||||||
// Click [placeholder="Type to select tag"]
|
|
||||||
await page.locator('[placeholder="Type to select tag"]').click();
|
await page.locator('[placeholder="Type to select tag"]').click();
|
||||||
|
|
||||||
await expect(page.locator('[aria-label="Autocomplete Options"]')).not.toContainText("Science");
|
await expect(page.locator('[aria-label="Autocomplete Options"]')).not.toContainText("Science");
|
||||||
@@ -108,43 +109,56 @@ test.describe('Tagging in Notebooks @addInit', () => {
|
|||||||
});
|
});
|
||||||
test('Can search for tags', async ({ page }) => {
|
test('Can search for tags', async ({ page }) => {
|
||||||
await createNotebookEntryAndTags(page);
|
await createNotebookEntryAndTags(page);
|
||||||
// Click [aria-label="OpenMCT Search"] input[type="search"]
|
|
||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||||
// Fill [aria-label="OpenMCT Search"] input[type="search"]
|
|
||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
|
||||||
await expect(page.locator('[aria-label="Search Result"]')).toContainText("Science");
|
await expect(page.locator('[aria-label="Search Result"]')).toContainText("Science");
|
||||||
await expect(page.locator('[aria-label="Search Result"]')).toContainText("Driving");
|
await expect(page.locator('[aria-label="Search Result"]')).not.toContainText("Driving");
|
||||||
|
|
||||||
// Click [aria-label="OpenMCT Search"] input[type="search"]
|
|
||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||||
// Fill [aria-label="OpenMCT Search"] input[type="search"]
|
|
||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Sc');
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Sc');
|
||||||
await expect(page.locator('[aria-label="Search Result"]')).toContainText("Science");
|
await expect(page.locator('[aria-label="Search Result"]')).toContainText("Science");
|
||||||
await expect(page.locator('[aria-label="Search Result"]')).toContainText("Driving");
|
await expect(page.locator('[aria-label="Search Result"]')).not.toContainText("Driving");
|
||||||
|
|
||||||
// Click [aria-label="OpenMCT Search"] input[type="search"]
|
|
||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||||
// Fill [aria-label="OpenMCT Search"] input[type="search"]
|
|
||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Xq');
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Xq');
|
||||||
await expect(page.locator('[aria-label="Search Result"]')).toBeHidden();
|
await expect(page.locator('text=No results found')).toBeVisible();
|
||||||
await expect(page.locator('[aria-label="Search Result"]')).toBeHidden();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Can delete tags', async ({ page }) => {
|
test('Can delete tags', async ({ page }) => {
|
||||||
await createNotebookEntryAndTags(page);
|
await createNotebookEntryAndTags(page);
|
||||||
await page.locator('[aria-label="Notebook Entries"]').click();
|
await page.locator('[aria-label="Notebook Entries"]').click();
|
||||||
// Delete Driving
|
// Delete Driving
|
||||||
await page.hover('.c-tag__label:has-text("Driving")');
|
await page.hover('[aria-label="Tag"]:has-text("Driving")');
|
||||||
await page.locator('.c-tag__label:has-text("Driving") ~ .c-completed-tag-deletion').click();
|
await page.locator('[aria-label="Tag"]:has-text("Driving") ~ .c-completed-tag-deletion').click();
|
||||||
|
|
||||||
await expect(page.locator('[aria-label="Notebook Entry"]')).toContainText("Science");
|
await expect(page.locator('[aria-label="Notebook Entry"]')).toContainText("Science");
|
||||||
await expect(page.locator('[aria-label="Notebook Entry"]')).not.toContainText("Driving");
|
await expect(page.locator('[aria-label="Notebook Entry"]')).not.toContainText("Driving");
|
||||||
|
|
||||||
// Fill [aria-label="OpenMCT Search"] input[type="search"]
|
|
||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
|
||||||
await expect(page.locator('[aria-label="Search Result"]')).not.toContainText("Driving");
|
await expect(page.locator('[aria-label="Search Result"]')).not.toContainText("Driving");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Can delete entries without tags', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5823'
|
||||||
|
});
|
||||||
|
|
||||||
|
await createNotebookEntryAndTags(page);
|
||||||
|
|
||||||
|
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
||||||
|
const entryLocator = `[aria-label="Notebook Entry Input"] >> nth = 1`;
|
||||||
|
await page.locator(entryLocator).click();
|
||||||
|
await page.locator(entryLocator).fill(`An entry without tags`);
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=1').press('Enter');
|
||||||
|
|
||||||
|
await page.hover('[aria-label="Notebook Entry Input"] >> nth=1');
|
||||||
|
await page.locator('button[title="Delete this entry"]').last().click();
|
||||||
|
await expect(page.locator('text=This action will permanently delete this entry. Do you wish to continue?')).toBeVisible();
|
||||||
|
await page.locator('button:has-text("Ok")').click();
|
||||||
|
await expect(page.locator('text=This action will permanently delete this entry. Do you wish to continue?')).toBeHidden();
|
||||||
|
});
|
||||||
|
|
||||||
test('Can delete objects with tags and neither return in search', async ({ page }) => {
|
test('Can delete objects with tags and neither return in search', async ({ page }) => {
|
||||||
await createNotebookEntryAndTags(page);
|
await createNotebookEntryAndTags(page);
|
||||||
// Delete Notebook
|
// Delete Notebook
|
||||||
@@ -153,22 +167,21 @@ test.describe('Tagging in Notebooks @addInit', () => {
|
|||||||
await page.locator('button:has-text("OK")').click();
|
await page.locator('button:has-text("OK")').click();
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
// Fill [aria-label="OpenMCT Search"] input[type="search"]
|
|
||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Unnamed');
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Unnamed');
|
||||||
await expect(page.locator('text=No matching results.')).toBeVisible();
|
await expect(page.locator('text=No results found')).toBeVisible();
|
||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sci');
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sci');
|
||||||
await expect(page.locator('text=No matching results.')).toBeVisible();
|
await expect(page.locator('text=No results found')).toBeVisible();
|
||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('dri');
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('dri');
|
||||||
await expect(page.locator('text=No matching results.')).toBeVisible();
|
await expect(page.locator('text=No results found')).toBeVisible();
|
||||||
});
|
});
|
||||||
test('Tags persist across reload', async ({ page }) => {
|
test('Tags persist across reload', async ({ page }) => {
|
||||||
//Go to baseURL
|
//Go to baseURL
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
await createDomainObjectWithDefaults(page, { type: 'Clock' });
|
const clock = await createDomainObjectWithDefaults(page, { type: 'Clock' });
|
||||||
|
|
||||||
const ITERATIONS = 4;
|
const ITERATIONS = 4;
|
||||||
await createNotebookEntryAndTags(page, ITERATIONS);
|
const notebook = await createNotebookEntryAndTags(page, ITERATIONS);
|
||||||
|
|
||||||
for (let iteration = 0; iteration < ITERATIONS; iteration++) {
|
for (let iteration = 0; iteration < ITERATIONS; iteration++) {
|
||||||
const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`;
|
const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`;
|
||||||
@@ -181,11 +194,11 @@ test.describe('Tagging in Notebooks @addInit', () => {
|
|||||||
page.goto('./#/browse/mine?hideTree=false'),
|
page.goto('./#/browse/mine?hideTree=false'),
|
||||||
page.click('.c-disclosure-triangle')
|
page.click('.c-disclosure-triangle')
|
||||||
]);
|
]);
|
||||||
// Click Unnamed Clock
|
// Click Clock
|
||||||
await page.click('text="Unnamed Clock"');
|
await page.click(`text=${clock.name}`);
|
||||||
|
|
||||||
// Click Unnamed Notebook
|
// Click Notebook
|
||||||
await page.click('text="Unnamed Notebook"');
|
await page.click(`text=${notebook.name}`);
|
||||||
|
|
||||||
for (let iteration = 0; iteration < ITERATIONS; iteration++) {
|
for (let iteration = 0; iteration < ITERATIONS; iteration++) {
|
||||||
const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`;
|
const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`;
|
||||||
@@ -199,14 +212,13 @@ test.describe('Tagging in Notebooks @addInit', () => {
|
|||||||
page.waitForLoadState('networkidle')
|
page.waitForLoadState('networkidle')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Click Unnamed Notebook
|
// Click Notebook
|
||||||
await page.click('text="Unnamed Notebook"');
|
await page.click(`text="${notebook.name}"`);
|
||||||
|
|
||||||
for (let iteration = 0; iteration < ITERATIONS; iteration++) {
|
for (let iteration = 0; iteration < ITERATIONS; iteration++) {
|
||||||
const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`;
|
const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`;
|
||||||
await expect(page.locator(entryLocator)).toContainText("Science");
|
await expect(page.locator(entryLocator)).toContainText("Science");
|
||||||
await expect(page.locator(entryLocator)).toContainText("Driving");
|
await expect(page.locator(entryLocator)).toContainText("Driving");
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ test.describe('ExportAsJSON', () => {
|
|||||||
|
|
||||||
await canvas.hover({trial: true});
|
await canvas.hover({trial: true});
|
||||||
|
|
||||||
expect(await canvas.screenshot()).toMatchSnapshot('autoscale-canvas-prepan');
|
expect(await canvas.screenshot()).toMatchSnapshot('autoscale-canvas-prepan.png', { animations: 'disabled' });
|
||||||
|
|
||||||
//Alt Drag Start
|
//Alt Drag Start
|
||||||
await page.keyboard.down('Alt');
|
await page.keyboard.down('Alt');
|
||||||
@@ -80,7 +80,7 @@ test.describe('ExportAsJSON', () => {
|
|||||||
|
|
||||||
await canvas.hover({trial: true});
|
await canvas.hover({trial: true});
|
||||||
|
|
||||||
expect(await canvas.screenshot()).toMatchSnapshot('autoscale-canvas-panned');
|
expect(await canvas.screenshot()).toMatchSnapshot('autoscale-canvas-panned.png', { animations: 'disabled' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -110,10 +110,10 @@ async function createSinewaveOverlayPlot(page, myItemsFolderName) {
|
|||||||
await page.locator('button:has-text("Create")').click();
|
await page.locator('button:has-text("Create")').click();
|
||||||
|
|
||||||
// add overlay plot with defaults
|
// add overlay plot with defaults
|
||||||
await page.locator('li:has-text("Overlay Plot")').click();
|
await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForNavigation(),
|
page.waitForNavigation(),
|
||||||
page.locator('text=OK').click(),
|
page.locator('button:has-text("OK")').click(),
|
||||||
//Wait for Save Banner to appear1
|
//Wait for Save Banner to appear1
|
||||||
page.waitForSelector('.c-message-banner__message')
|
page.waitForSelector('.c-message-banner__message')
|
||||||
]);
|
]);
|
||||||
@@ -129,10 +129,10 @@ async function createSinewaveOverlayPlot(page, myItemsFolderName) {
|
|||||||
await page.locator('button:has-text("Create")').click();
|
await page.locator('button:has-text("Create")').click();
|
||||||
|
|
||||||
// add sine wave generator with defaults
|
// add sine wave generator with defaults
|
||||||
await page.locator('li:has-text("Sine Wave Generator")').click();
|
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForNavigation(),
|
page.waitForNavigation(),
|
||||||
page.locator('text=OK').click(),
|
page.locator('button:has-text("OK")').click(),
|
||||||
//Wait for Save Banner to appear1
|
//Wait for Save Banner to appear1
|
||||||
page.waitForSelector('.c-message-banner__message')
|
page.waitForSelector('.c-message-banner__message')
|
||||||
]);
|
]);
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 21 KiB |
@@ -88,10 +88,10 @@ async function makeOverlayPlot(page, myItemsFolderName) {
|
|||||||
// create overlay plot
|
// create overlay plot
|
||||||
|
|
||||||
await page.locator('button.c-create-button').click();
|
await page.locator('button.c-create-button').click();
|
||||||
await page.locator('li:has-text("Overlay Plot")').click();
|
await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
||||||
page.locator('text=OK').click(),
|
page.locator('button:has-text("OK")').click(),
|
||||||
//Wait for Save Banner to appear
|
//Wait for Save Banner to appear
|
||||||
page.waitForSelector('.c-message-banner__message')
|
page.waitForSelector('.c-message-banner__message')
|
||||||
]);
|
]);
|
||||||
@@ -106,7 +106,7 @@ async function makeOverlayPlot(page, myItemsFolderName) {
|
|||||||
// create a sinewave generator
|
// create a sinewave generator
|
||||||
|
|
||||||
await page.locator('button.c-create-button').click();
|
await page.locator('button.c-create-button').click();
|
||||||
await page.locator('li:has-text("Sine Wave Generator")').click();
|
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
|
||||||
|
|
||||||
// set amplitude to 6, offset 4, period 2
|
// set amplitude to 6, offset 4, period 2
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ async function makeOverlayPlot(page, myItemsFolderName) {
|
|||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
||||||
page.locator('text=OK').click(),
|
page.locator('button:has-text("OK")').click(),
|
||||||
//Wait for Save Banner to appear
|
//Wait for Save Banner to appear
|
||||||
page.waitForSelector('.c-message-banner__message')
|
page.waitForSelector('.c-message-banner__message')
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -88,11 +88,11 @@ async function makeStackedPlot(page, myItemsFolderName) {
|
|||||||
|
|
||||||
// create stacked plot
|
// create stacked plot
|
||||||
await page.locator('button.c-create-button').click();
|
await page.locator('button.c-create-button').click();
|
||||||
await page.locator('li:has-text("Stacked Plot")').click();
|
await page.locator('li[role="menuitem"]:has-text("Stacked Plot")').click();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
||||||
page.locator('text=OK').click(),
|
page.locator('button:has-text("OK")').click(),
|
||||||
//Wait for Save Banner to appear
|
//Wait for Save Banner to appear
|
||||||
page.waitForSelector('.c-message-banner__message')
|
page.waitForSelector('.c-message-banner__message')
|
||||||
]);
|
]);
|
||||||
@@ -146,11 +146,11 @@ async function saveStackedPlot(page) {
|
|||||||
async function createSineWaveGenerator(page) {
|
async function createSineWaveGenerator(page) {
|
||||||
//Create sine wave generator
|
//Create sine wave generator
|
||||||
await page.locator('button.c-create-button').click();
|
await page.locator('button.c-create-button').click();
|
||||||
await page.locator('li:has-text("Sine Wave Generator")').click();
|
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
||||||
page.locator('text=OK').click(),
|
page.locator('button:has-text("OK")').click(),
|
||||||
//Wait for Save Banner to appear
|
//Wait for Save Banner to appear
|
||||||
page.waitForSelector('.c-message-banner__message')
|
page.waitForSelector('.c-message-banner__message')
|
||||||
]);
|
]);
|
||||||
|
|||||||
110
e2e/tests/functional/plugins/plot/plotLegendSwatch.e2e.spec.js
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Tests to verify log plot functionality. Note this test suite if very much under active development and should not
|
||||||
|
necessarily be used for reference when writing new tests in this area.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const { test, expect } = require('../../../../pluginFixtures');
|
||||||
|
|
||||||
|
test.describe('Legend color in sync with plot color', () => {
|
||||||
|
test('Testing', async ({ page }) => {
|
||||||
|
await makeOverlayPlot(page);
|
||||||
|
|
||||||
|
// navigate to plot series color palette
|
||||||
|
await page.click('.l-browse-bar__actions__edit');
|
||||||
|
await page.locator('li.c-tree__item.menus-to-left .c-disclosure-triangle').click();
|
||||||
|
await page.locator('.c-click-swatch--menu').click();
|
||||||
|
await page.locator('.c-palette__item[style="background: rgb(255, 166, 61);"]').click();
|
||||||
|
|
||||||
|
// gets color for swatch located in legend
|
||||||
|
const element = await page.waitForSelector('.plot-series-color-swatch');
|
||||||
|
const color = await element.evaluate((el) => {
|
||||||
|
return window.getComputedStyle(el).getPropertyValue('background-color');
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(color).toBe('rgb(255, 166, 61)');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
async function saveOverlayPlot(page) {
|
||||||
|
// save overlay plot
|
||||||
|
await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1).click();
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
page.locator('text=Save and Finish Editing').click(),
|
||||||
|
//Wait for Save Banner to appear
|
||||||
|
page.waitForSelector('.c-message-banner__message')
|
||||||
|
]);
|
||||||
|
//Wait until Save Banner is gone
|
||||||
|
await page.locator('.c-message-banner__close-button').click();
|
||||||
|
await page.waitForSelector('.c-message-banner__message', { state: 'detached' });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function makeOverlayPlot(page) {
|
||||||
|
// fresh page with time range from 2022-03-29 22:00:00.000Z to 2022-03-29 22:00:30.000Z
|
||||||
|
await page.goto('/', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
// create overlay plot
|
||||||
|
|
||||||
|
await page.locator('button.c-create-button').click();
|
||||||
|
await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click();
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
||||||
|
page.locator('button:has-text("OK")').click(),
|
||||||
|
//Wait for Save Banner to appear
|
||||||
|
page.waitForSelector('.c-message-banner__message')
|
||||||
|
]);
|
||||||
|
//Wait until Save Banner is gone
|
||||||
|
await page.locator('.c-message-banner__close-button').click();
|
||||||
|
await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
|
||||||
|
|
||||||
|
// save the overlay plot
|
||||||
|
|
||||||
|
await saveOverlayPlot(page);
|
||||||
|
|
||||||
|
// create a sinewave generator
|
||||||
|
|
||||||
|
await page.locator('button.c-create-button').click();
|
||||||
|
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
|
||||||
|
|
||||||
|
// Click OK to make generator
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForNavigation({ waitUntil: 'networkidle'}),
|
||||||
|
page.locator('button:has-text("OK")').click(),
|
||||||
|
//Wait for Save Banner to appear
|
||||||
|
page.waitForSelector('.c-message-banner__message')
|
||||||
|
]);
|
||||||
|
//Wait until Save Banner is gone
|
||||||
|
await page.locator('.c-message-banner__close-button').click();
|
||||||
|
await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
|
||||||
|
|
||||||
|
// click on overlay plot
|
||||||
|
|
||||||
|
await page.locator('text=Open MCT My Items >> span').nth(3).click();
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForNavigation(),
|
||||||
|
page.locator('text=Unnamed Overlay Plot').first().click()
|
||||||
|
]);
|
||||||
|
}
|
||||||
139
e2e/tests/functional/plugins/plot/plotRendering.e2e.spec.js
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This test suite is dedicated to testing the rendering and interaction of plots.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const { test, expect } = require('../../../../pluginFixtures');
|
||||||
|
const { createDomainObjectWithDefaults} = require('../../../../appActions');
|
||||||
|
|
||||||
|
test.describe('Plot Integrity Testing @unstable', () => {
|
||||||
|
let sineWaveGeneratorObject;
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
//Open a browser, navigate to the main page, and wait until all networkevents to resolve
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
sineWaveGeneratorObject = await createDomainObjectWithDefaults(page, { type: 'Sine Wave Generator' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Plots do not re-request data when a plot is clicked', async ({ page }) => {
|
||||||
|
//Navigate to Sine Wave Generator
|
||||||
|
await page.goto(sineWaveGeneratorObject.url);
|
||||||
|
//Click on the plot canvas
|
||||||
|
await page.locator('canvas').nth(1).click();
|
||||||
|
//No request was made to get historical data
|
||||||
|
const createMineFolderRequests = [];
|
||||||
|
page.on('request', req => {
|
||||||
|
// eslint-disable-next-line playwright/no-conditional-in-test
|
||||||
|
createMineFolderRequests.push(req);
|
||||||
|
});
|
||||||
|
expect(createMineFolderRequests.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Plot is rendered when infinity values exist', async ({ page }) => {
|
||||||
|
// Edit Plot
|
||||||
|
await editSineWaveToUseInfinityOption(page, sineWaveGeneratorObject);
|
||||||
|
|
||||||
|
//Get pixel data from Canvas
|
||||||
|
const plotPixelSize = await getCanvasPixelsWithData(page);
|
||||||
|
expect(plotPixelSize).toBeGreaterThan(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function edits a sine wave generator with the default options and enables the infinity values option.
|
||||||
|
*
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {import('../../../../appActions').CreateObjectInfo} sineWaveGeneratorObject
|
||||||
|
* @returns {Promise<CreatedObjectInfo>} An object containing information about the edited domain object.
|
||||||
|
*/
|
||||||
|
async function editSineWaveToUseInfinityOption(page, sineWaveGeneratorObject) {
|
||||||
|
await page.goto(sineWaveGeneratorObject.url);
|
||||||
|
// Edit LAD table
|
||||||
|
await page.locator('[title="More options"]').click();
|
||||||
|
await page.locator('[title="Edit properties of this object."]').click();
|
||||||
|
// Modify the infinity option to true
|
||||||
|
const infinityInput = page.locator('[aria-label="Include Infinity Values"]');
|
||||||
|
await infinityInput.click();
|
||||||
|
|
||||||
|
// Click OK button and wait for Navigate event
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForLoadState(),
|
||||||
|
page.click('[aria-label="Save"]'),
|
||||||
|
// Wait for Save Banner to appear
|
||||||
|
page.waitForSelector('.c-message-banner__message')
|
||||||
|
]);
|
||||||
|
|
||||||
|
// FIXME: Changes to SWG properties should be reflected on save, but they're not?
|
||||||
|
// Thus, navigate away and back to the object.
|
||||||
|
await page.goto('./#/browse/mine');
|
||||||
|
await page.goto(sineWaveGeneratorObject.url);
|
||||||
|
|
||||||
|
await page.locator('c-progress-bar c-telemetry-table__progress-bar').waitFor({
|
||||||
|
state: 'hidden'
|
||||||
|
});
|
||||||
|
|
||||||
|
// FIXME: The progress bar disappears on series data load, not on plot render,
|
||||||
|
// so wait for a half a second before evaluating the canvas.
|
||||||
|
// eslint-disable-next-line playwright/no-wait-for-timeout
|
||||||
|
await page.waitForTimeout(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
*/
|
||||||
|
async function getCanvasPixelsWithData(page) {
|
||||||
|
const getTelemValuePromise = new Promise(resolve => page.exposeFunction('getCanvasValue', resolve));
|
||||||
|
|
||||||
|
await page.evaluate(() => {
|
||||||
|
// The document canvas is where the plot points and lines are drawn.
|
||||||
|
// The only way to access the canvas is using document (using page.evaluate)
|
||||||
|
let data;
|
||||||
|
let canvas;
|
||||||
|
let ctx;
|
||||||
|
canvas = document.querySelector('canvas');
|
||||||
|
ctx = canvas.getContext('2d');
|
||||||
|
data = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
|
||||||
|
const imageDataValues = Object.values(data);
|
||||||
|
let plotPixels = [];
|
||||||
|
// Each pixel consists of four values within the ImageData.data array. The for loop iterates by multiples of four.
|
||||||
|
// The values associated with each pixel are R (red), G (green), B (blue), and A (alpha), in that order.
|
||||||
|
for (let i = 0; i < imageDataValues.length;) {
|
||||||
|
if (imageDataValues[i] > 0) {
|
||||||
|
plotPixels.push({
|
||||||
|
startIndex: i,
|
||||||
|
endIndex: i + 3,
|
||||||
|
value: `rgb(${imageDataValues[i]}, ${imageDataValues[i + 1]}, ${imageDataValues[i + 2]}, ${imageDataValues[i + 3]})`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
i = i + 4;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
window.getCanvasValue(plotPixels.length);
|
||||||
|
});
|
||||||
|
|
||||||
|
return getTelemValuePromise;
|
||||||
|
}
|
||||||
93
e2e/tests/functional/plugins/plot/scatterPlot.e2e.spec.js
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This test suite is dedicated to testing the Scatter Plot component.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const { test, expect } = require('../../../../pluginFixtures');
|
||||||
|
const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||||
|
const uuid = require('uuid').v4;
|
||||||
|
|
||||||
|
test.describe('Scatter Plot', () => {
|
||||||
|
let scatterPlot;
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// Open a browser, navigate to the main page, and wait until all networkevents to resolve
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
// Create the Scatter Plot
|
||||||
|
scatterPlot = await createDomainObjectWithDefaults(page, { type: 'Scatter Plot' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Can add and remove telemetry sources', async ({ page }) => {
|
||||||
|
const editButtonLocator = page.locator('button[title="Edit"]');
|
||||||
|
const saveButtonLocator = page.locator('button[title="Save"]');
|
||||||
|
|
||||||
|
// Create a sine wave generator within the scatter plot
|
||||||
|
const swg1 = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Sine Wave Generator',
|
||||||
|
name: `swg-${uuid()}`,
|
||||||
|
parent: scatterPlot.uuid
|
||||||
|
});
|
||||||
|
|
||||||
|
// Navigate to the scatter plot and verify that
|
||||||
|
// the SWG appears in the elements pool
|
||||||
|
await page.goto(scatterPlot.url);
|
||||||
|
await editButtonLocator.click();
|
||||||
|
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeVisible();
|
||||||
|
await saveButtonLocator.click();
|
||||||
|
await page.locator('li[title="Save and Finish Editing"]').click();
|
||||||
|
|
||||||
|
// Create another sine wave generator within the scatter plot
|
||||||
|
const swg2 = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Sine Wave Generator',
|
||||||
|
name: `swg-${uuid()}`,
|
||||||
|
parent: scatterPlot.uuid
|
||||||
|
});
|
||||||
|
|
||||||
|
// Verify that the 'Replace telemetry source' modal appears and accept it
|
||||||
|
await expect.soft(page.locator('text=This action will replace the current telemetry source. Do you want to continue?')).toBeVisible();
|
||||||
|
await page.click('text=Ok');
|
||||||
|
|
||||||
|
// Navigate to the scatter plot and verify that the new SWG
|
||||||
|
// appears in the elements pool and the old one is gone
|
||||||
|
await page.goto(scatterPlot.url);
|
||||||
|
await editButtonLocator.click();
|
||||||
|
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeHidden();
|
||||||
|
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg2.name}`)).toBeVisible();
|
||||||
|
await saveButtonLocator.click();
|
||||||
|
|
||||||
|
// Right click on the new SWG in the elements pool and delete it
|
||||||
|
await page.locator(`#inspector-elements-tree >> text=${swg2.name}`).click({
|
||||||
|
button: 'right'
|
||||||
|
});
|
||||||
|
await page.locator('li[title="Remove this object from its containing object."]').click();
|
||||||
|
|
||||||
|
// Verify that the 'Remove object' confirmation modal appears and accept it
|
||||||
|
await expect.soft(page.locator('text=Warning! This action will remove this object. Are you sure you want to continue?')).toBeVisible();
|
||||||
|
await page.click('text=Ok');
|
||||||
|
|
||||||
|
// Verify that the elements pool shows no elements
|
||||||
|
await expect(page.locator('text="No contained elements"')).toBeVisible();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
const { test, expect } = require('../../../../baseFixtures');
|
const { test, expect } = require('../../../../pluginFixtures');
|
||||||
const { setFixedTimeMode, setRealTimeMode, setStartOffset, setEndOffset } = require('../../../../appActions');
|
const { setFixedTimeMode, setRealTimeMode, setStartOffset, setEndOffset } = require('../../../../appActions');
|
||||||
|
|
||||||
test.describe('Time conductor operations', () => {
|
test.describe('Time conductor operations', () => {
|
||||||
@@ -168,3 +168,23 @@ test.describe('Time conductor input fields real-time mode', () => {
|
|||||||
// select an option and verify the offsets are updated correctly
|
// select an option and verify the offsets are updated correctly
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test.describe('Time Conductor History', () => {
|
||||||
|
test("shows milliseconds on hover @unstable", async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/4386'
|
||||||
|
});
|
||||||
|
// Navigate to Open MCT in Fixed Time Mode, UTC Time System
|
||||||
|
// with startBound at 2022-01-01 00:00:00.000Z
|
||||||
|
// and endBound at 2022-01-01 00:00:00.200Z
|
||||||
|
await page.goto('./#/browse/mine?view=grid&tc.mode=fixed&tc.startBound=1640995200000&tc.endBound=1640995200200&tc.timeSystem=utc&hideInspector=true', { waitUntil: 'networkidle' });
|
||||||
|
await page.locator("[aria-label='Time Conductor History']").hover({ trial: true});
|
||||||
|
await page.locator("[aria-label='Time Conductor History']").click();
|
||||||
|
|
||||||
|
// Validate history item format
|
||||||
|
const historyItem = page.locator('text="2022-01-01 00:00:00 + 200ms"');
|
||||||
|
await expect(historyItem).toBeEnabled();
|
||||||
|
await expect(historyItem).toHaveAttribute('title', '2022-01-01 00:00:00.000 - 2022-01-01 00:00:00.200');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ test.describe('Timer', () => {
|
|||||||
timer = await createDomainObjectWithDefaults(page, { type: 'timer' });
|
timer = await createDomainObjectWithDefaults(page, { type: 'timer' });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Can perform actions on the Timer', async ({ page, openmctConfig }) => {
|
test('Can perform actions on the Timer', async ({ page }) => {
|
||||||
test.info().annotations.push({
|
test.info().annotations.push({
|
||||||
type: 'issue',
|
type: 'issue',
|
||||||
description: 'https://github.com/nasa/openmct/issues/4313'
|
description: 'https://github.com/nasa/openmct/issues/4313'
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ test.describe('Grand Search', () => {
|
|||||||
test('Can search for objects, and subsequent search dropdown behaves properly', async ({ page, openmctConfig }) => {
|
test('Can search for objects, and subsequent search dropdown behaves properly', async ({ page, openmctConfig }) => {
|
||||||
const { myItemsFolderName } = openmctConfig;
|
const { myItemsFolderName } = openmctConfig;
|
||||||
|
|
||||||
await createObjectsForSearch(page, myItemsFolderName);
|
const createdObjects = await createObjectsForSearch(page);
|
||||||
|
|
||||||
// Click [aria-label="OpenMCT Search"] input[type="search"]
|
// Click [aria-label="OpenMCT Search"] input[type="search"]
|
||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||||
@@ -41,8 +41,8 @@ test.describe('Grand Search', () => {
|
|||||||
await expect(page.locator('[aria-label="Search Result"] >> nth=1')).toContainText(`Clock B ${myItemsFolderName} Red Folder Blue Folder`);
|
await expect(page.locator('[aria-label="Search Result"] >> nth=1')).toContainText(`Clock B ${myItemsFolderName} Red Folder Blue Folder`);
|
||||||
await expect(page.locator('[aria-label="Search Result"] >> nth=2')).toContainText(`Clock C ${myItemsFolderName} Red Folder Blue Folder`);
|
await expect(page.locator('[aria-label="Search Result"] >> nth=2')).toContainText(`Clock C ${myItemsFolderName} Red Folder Blue Folder`);
|
||||||
await expect(page.locator('[aria-label="Search Result"] >> nth=3')).toContainText(`Clock D ${myItemsFolderName} Red Folder Blue Folder`);
|
await expect(page.locator('[aria-label="Search Result"] >> nth=3')).toContainText(`Clock D ${myItemsFolderName} Red Folder Blue Folder`);
|
||||||
// Click text=Elements >> nth=0
|
// Click the Elements pool to dismiss the search menu
|
||||||
await page.locator('text=Elements').first().click();
|
await page.locator('.l-pane__label:has-text("Elements")').click();
|
||||||
await expect(page.locator('[aria-label="Search Result"] >> nth=0')).toBeHidden();
|
await expect(page.locator('[aria-label="Search Result"] >> nth=0')).toBeHidden();
|
||||||
|
|
||||||
await page.locator('[aria-label="OpenMCT Search"] [aria-label="Search Input"]').click();
|
await page.locator('[aria-label="OpenMCT Search"] [aria-label="Search Input"]').click();
|
||||||
@@ -77,7 +77,7 @@ test.describe('Grand Search', () => {
|
|||||||
await expect(page.locator('.is-object-type-clock')).toBeVisible();
|
await expect(page.locator('.is-object-type-clock')).toBeVisible();
|
||||||
|
|
||||||
await page.locator('[aria-label="OpenMCT Search"] [aria-label="Search Input"]').fill('Disp');
|
await page.locator('[aria-label="OpenMCT Search"] [aria-label="Search Input"]').fill('Disp');
|
||||||
await expect(page.locator('[aria-label="Search Result"] >> nth=0')).toContainText('Unnamed Display Layout');
|
await expect(page.locator('[aria-label="Search Result"] >> nth=0')).toContainText(createdObjects.displayLayout.name);
|
||||||
await expect(page.locator('[aria-label="Search Result"] >> nth=0')).not.toContainText('Folder');
|
await expect(page.locator('[aria-label="Search Result"] >> nth=0')).not.toContainText('Folder');
|
||||||
|
|
||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Clock C');
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Clock C');
|
||||||
@@ -111,7 +111,7 @@ test.describe("Search Tests @unstable", () => {
|
|||||||
expect(await searchResults.count()).toBe(0);
|
expect(await searchResults.count()).toBe(0);
|
||||||
|
|
||||||
// Verify proper message appears
|
// Verify proper message appears
|
||||||
await expect(page.locator('text=No matching results.')).toBeVisible();
|
await expect(page.locator('text=No results found')).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Validate single object in search result @couchdb', async ({ page }) => {
|
test('Validate single object in search result @couchdb', async ({ page }) => {
|
||||||
@@ -185,7 +185,7 @@ async function createFolderObject(page, folderName) {
|
|||||||
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(folderName);
|
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(folderName);
|
||||||
|
|
||||||
// Create folder object
|
// Create folder object
|
||||||
await page.locator('text=OK').click();
|
await page.locator('button:has-text("OK")').click();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function waitForSearchCompletion(page) {
|
async function waitForSearchCompletion(page) {
|
||||||
@@ -197,75 +197,56 @@ async function waitForSearchCompletion(page) {
|
|||||||
* Creates some domain objects for searching
|
* Creates some domain objects for searching
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
*/
|
*/
|
||||||
async function createObjectsForSearch(page, myItemsFolderName) {
|
async function createObjectsForSearch(page) {
|
||||||
//Go to baseURL
|
//Go to baseURL
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
await page.locator('button:has-text("Create")').click();
|
const redFolder = await createDomainObjectWithDefaults(page, {
|
||||||
await page.locator('li:has-text("Folder") >> nth=1').click();
|
type: 'Folder',
|
||||||
await Promise.all([
|
name: 'Red Folder'
|
||||||
page.waitForNavigation(),
|
});
|
||||||
await page.locator('text=Properties Title Notes >> input[type="text"]').fill('Red Folder'),
|
|
||||||
await page.locator(`text=Save In Open MCT ${myItemsFolderName} >> span`).nth(3).click(),
|
|
||||||
page.locator('button:has-text("OK")').click()
|
|
||||||
]);
|
|
||||||
|
|
||||||
await page.locator('button:has-text("Create")').click();
|
const blueFolder = await createDomainObjectWithDefaults(page, {
|
||||||
await page.locator('li:has-text("Folder") >> nth=2').click();
|
type: 'Folder',
|
||||||
await Promise.all([
|
name: 'Blue Folder',
|
||||||
page.waitForNavigation(),
|
parent: redFolder.uuid
|
||||||
await page.locator('text=Properties Title Notes >> input[type="text"]').fill('Blue Folder'),
|
});
|
||||||
await page.locator('form[name="mctForm"] >> text=Red Folder').click(),
|
|
||||||
page.locator('button:has-text("OK")').click()
|
|
||||||
]);
|
|
||||||
|
|
||||||
await page.locator('button:has-text("Create")').click();
|
const clockA = await createDomainObjectWithDefaults(page, {
|
||||||
await page.locator('li[title="A UTC-based clock that supports a variety of display formats. Clocks can be added to Display Layouts."]').click();
|
type: 'Clock',
|
||||||
await Promise.all([
|
name: 'Clock A',
|
||||||
page.waitForNavigation(),
|
parent: blueFolder.uuid
|
||||||
await page.locator('text=Properties Title Notes >> input[type="text"] >> nth=0').fill('Clock A'),
|
});
|
||||||
await page.locator('form[name="mctForm"] >> text=Blue Folder').click(),
|
const clockB = await createDomainObjectWithDefaults(page, {
|
||||||
page.locator('button:has-text("OK")').click()
|
type: 'Clock',
|
||||||
]);
|
name: 'Clock B',
|
||||||
|
parent: blueFolder.uuid
|
||||||
|
});
|
||||||
|
const clockC = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Clock',
|
||||||
|
name: 'Clock C',
|
||||||
|
parent: blueFolder.uuid
|
||||||
|
});
|
||||||
|
const clockD = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Clock',
|
||||||
|
name: 'Clock D',
|
||||||
|
parent: blueFolder.uuid
|
||||||
|
});
|
||||||
|
|
||||||
await page.locator('button:has-text("Create")').click();
|
const displayLayout = await createDomainObjectWithDefaults(page, {
|
||||||
await page.locator('li[title="A UTC-based clock that supports a variety of display formats. Clocks can be added to Display Layouts."]').click();
|
type: 'Display Layout'
|
||||||
await Promise.all([
|
});
|
||||||
page.waitForNavigation(),
|
|
||||||
await page.locator('text=Properties Title Notes >> input[type="text"] >> nth=0').fill('Clock B'),
|
|
||||||
await page.locator('form[name="mctForm"] >> text=Blue Folder').click(),
|
|
||||||
page.locator('button:has-text("OK")').click()
|
|
||||||
]);
|
|
||||||
|
|
||||||
await page.locator('button:has-text("Create")').click();
|
// Go back into edit mode for the display layout
|
||||||
await page.locator('li[title="A UTC-based clock that supports a variety of display formats. Clocks can be added to Display Layouts."]').click();
|
await page.locator('button[title="Edit"]').click();
|
||||||
await Promise.all([
|
|
||||||
page.waitForNavigation(),
|
|
||||||
await page.locator('text=Properties Title Notes >> input[type="text"] >> nth=0').fill('Clock C'),
|
|
||||||
await page.locator('form[name="mctForm"] >> text=Blue Folder').click(),
|
|
||||||
page.locator('button:has-text("OK")').click()
|
|
||||||
]);
|
|
||||||
|
|
||||||
await page.locator('button:has-text("Create")').click();
|
return {
|
||||||
await page.locator('li[title="A UTC-based clock that supports a variety of display formats. Clocks can be added to Display Layouts."]').click();
|
redFolder,
|
||||||
await Promise.all([
|
blueFolder,
|
||||||
page.waitForNavigation(),
|
clockA,
|
||||||
await page.locator('text=Properties Title Notes >> input[type="text"] >> nth=0').fill('Clock D'),
|
clockB,
|
||||||
await page.locator('form[name="mctForm"] >> text=Blue Folder').click(),
|
clockC,
|
||||||
page.locator('button:has-text("OK")').click()
|
clockD,
|
||||||
]);
|
displayLayout
|
||||||
|
};
|
||||||
await Promise.all([
|
|
||||||
page.waitForNavigation(),
|
|
||||||
page.locator(`a:has-text("${myItemsFolderName}") >> nth=0`).click()
|
|
||||||
]);
|
|
||||||
// Click button:has-text("Create")
|
|
||||||
await page.locator('button:has-text("Create")').click();
|
|
||||||
// Click li:has-text("Notebook")
|
|
||||||
await page.locator('li:has-text("Display Layout")').click();
|
|
||||||
// Click button:has-text("OK")
|
|
||||||
await Promise.all([
|
|
||||||
page.waitForNavigation(),
|
|
||||||
page.locator('button:has-text("OK")').click()
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ test.describe('Performance tests', () => {
|
|||||||
await page.setInputFiles('#fileElem', filePath);
|
await page.setInputFiles('#fileElem', filePath);
|
||||||
|
|
||||||
// Click text=OK
|
// Click text=OK
|
||||||
await page.locator('text=OK').click();
|
await page.locator('button:has-text("OK")').click();
|
||||||
|
|
||||||
await expect(page.locator('a:has-text("Performance Display Layout Display Layout")')).toBeVisible();
|
await expect(page.locator('a:has-text("Performance Display Layout Display Layout")')).toBeVisible();
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Collection of Visual Tests set to run in a default context. The tests within this suite
|
Collection of Visual Tests set to run in a default context. The tests within this suite
|
||||||
are only meant to run against openmct's app.js started by `npm run start` within the
|
are only meant to run against openmct started by `npm start` within the
|
||||||
`./e2e/playwright-visual.config.js` file.
|
`./e2e/playwright-visual.config.js` file.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Collection of Visual Tests set to run in a default context. The tests within this suite
|
Collection of Visual Tests set to run in a default context. The tests within this suite
|
||||||
are only meant to run against openmct's app.js started by `npm run start` within the
|
are only meant to run against openmct started by `npm start` within the
|
||||||
`./e2e/playwright-visual.config.js` file.
|
`./e2e/playwright-visual.config.js` file.
|
||||||
|
|
||||||
These should only use functional expect statements to verify assumptions about the state
|
These should only use functional expect statements to verify assumptions about the state
|
||||||
|
|||||||
51
e2e/tests/visual/notebook.visual.spec.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, 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 } = require('../../pluginFixtures');
|
||||||
|
const percySnapshot = require('@percy/playwright');
|
||||||
|
const { expandTreePaneItemByName, createDomainObjectWithDefaults } = require('../../appActions');
|
||||||
|
|
||||||
|
test.describe('Visual - Notebook', () => {
|
||||||
|
test('Accepts dropped objects as embeds @unstable', async ({ page, theme, openmctConfig }) => {
|
||||||
|
const { myItemsFolderName } = openmctConfig;
|
||||||
|
await page.goto('./#/browse/mine', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
// Create Notebook
|
||||||
|
const notebook = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Notebook',
|
||||||
|
name: "Embed Test Notebook"
|
||||||
|
});
|
||||||
|
// Create Overlay Plot
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Overlay Plot',
|
||||||
|
name: "Dropped Overlay Plot"
|
||||||
|
});
|
||||||
|
|
||||||
|
await expandTreePaneItemByName(page, myItemsFolderName);
|
||||||
|
|
||||||
|
await page.goto(notebook.url);
|
||||||
|
await page.dragAndDrop('role=treeitem[name=/Dropped Overlay Plot/]', '.c-notebook__drag-area');
|
||||||
|
|
||||||
|
await percySnapshot(page, `Notebook w/ dropped embed (theme: ${theme})`);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -33,7 +33,8 @@ define([
|
|||||||
dataRateInHz: 1,
|
dataRateInHz: 1,
|
||||||
randomness: 0,
|
randomness: 0,
|
||||||
phase: 0,
|
phase: 0,
|
||||||
loadDelay: 0
|
loadDelay: 0,
|
||||||
|
infinityValues: false
|
||||||
};
|
};
|
||||||
|
|
||||||
function GeneratorProvider(openmct) {
|
function GeneratorProvider(openmct) {
|
||||||
@@ -56,7 +57,8 @@ define([
|
|||||||
'dataRateInHz',
|
'dataRateInHz',
|
||||||
'randomness',
|
'randomness',
|
||||||
'phase',
|
'phase',
|
||||||
'loadDelay'
|
'loadDelay',
|
||||||
|
'infinityValues'
|
||||||
];
|
];
|
||||||
|
|
||||||
request = request || {};
|
request = request || {};
|
||||||
|
|||||||
@@ -76,10 +76,10 @@
|
|||||||
name: data.name,
|
name: data.name,
|
||||||
utc: nextStep,
|
utc: nextStep,
|
||||||
yesterday: nextStep - 60 * 60 * 24 * 1000,
|
yesterday: nextStep - 60 * 60 * 24 * 1000,
|
||||||
sin: sin(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness),
|
sin: sin(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness, data.infinityValues),
|
||||||
wavelengths: wavelengths(),
|
wavelengths: wavelengths(),
|
||||||
intensities: intensities(),
|
intensities: intensities(),
|
||||||
cos: cos(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness)
|
cos: cos(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness, data.infinityValues)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
nextStep += step;
|
nextStep += step;
|
||||||
@@ -117,6 +117,7 @@
|
|||||||
var phase = request.phase;
|
var phase = request.phase;
|
||||||
var randomness = request.randomness;
|
var randomness = request.randomness;
|
||||||
var loadDelay = Math.max(request.loadDelay, 0);
|
var loadDelay = Math.max(request.loadDelay, 0);
|
||||||
|
var infinityValues = request.infinityValues;
|
||||||
|
|
||||||
var step = 1000 / dataRateInHz;
|
var step = 1000 / dataRateInHz;
|
||||||
var nextStep = start - (start % step) + step;
|
var nextStep = start - (start % step) + step;
|
||||||
@@ -127,10 +128,10 @@
|
|||||||
data.push({
|
data.push({
|
||||||
utc: nextStep,
|
utc: nextStep,
|
||||||
yesterday: nextStep - 60 * 60 * 24 * 1000,
|
yesterday: nextStep - 60 * 60 * 24 * 1000,
|
||||||
sin: sin(nextStep, period, amplitude, offset, phase, randomness),
|
sin: sin(nextStep, period, amplitude, offset, phase, randomness, infinityValues),
|
||||||
wavelengths: wavelengths(),
|
wavelengths: wavelengths(),
|
||||||
intensities: intensities(),
|
intensities: intensities(),
|
||||||
cos: cos(nextStep, period, amplitude, offset, phase, randomness)
|
cos: cos(nextStep, period, amplitude, offset, phase, randomness, infinityValues)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,12 +156,20 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function cos(timestamp, period, amplitude, offset, phase, randomness) {
|
function cos(timestamp, period, amplitude, offset, phase, randomness, infinityValues) {
|
||||||
|
if (infinityValues && Math.random() > 0.5) {
|
||||||
|
return Number.POSITIVE_INFINITY;
|
||||||
|
}
|
||||||
|
|
||||||
return amplitude
|
return amplitude
|
||||||
* Math.cos(phase + (timestamp / period / 1000 * Math.PI * 2)) + (amplitude * Math.random() * randomness) + offset;
|
* Math.cos(phase + (timestamp / period / 1000 * Math.PI * 2)) + (amplitude * Math.random() * randomness) + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sin(timestamp, period, amplitude, offset, phase, randomness) {
|
function sin(timestamp, period, amplitude, offset, phase, randomness, infinityValues) {
|
||||||
|
if (infinityValues && Math.random() > 0.5) {
|
||||||
|
return Number.POSITIVE_INFINITY;
|
||||||
|
}
|
||||||
|
|
||||||
return amplitude
|
return amplitude
|
||||||
* Math.sin(phase + (timestamp / period / 1000 * Math.PI * 2)) + (amplitude * Math.random() * randomness) + offset;
|
* Math.sin(phase + (timestamp / period / 1000 * Math.PI * 2)) + (amplitude * Math.random() * randomness) + offset;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ define([
|
|||||||
|
|
||||||
openmct.types.addType("example.state-generator", {
|
openmct.types.addType("example.state-generator", {
|
||||||
name: "State Generator",
|
name: "State Generator",
|
||||||
description: "For development use. Generates test enumerated telemetry by cycling through a given set of states",
|
description: "For development use. Generates example enumerated telemetry by cycling through a given set of states.",
|
||||||
cssClass: "icon-generator-telemetry",
|
cssClass: "icon-generator-telemetry",
|
||||||
creatable: true,
|
creatable: true,
|
||||||
form: [
|
form: [
|
||||||
@@ -143,6 +143,16 @@ define([
|
|||||||
"telemetry",
|
"telemetry",
|
||||||
"loadDelay"
|
"loadDelay"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Include Infinity Values",
|
||||||
|
control: "toggleSwitch",
|
||||||
|
cssClass: "l-input",
|
||||||
|
key: "infinityValues",
|
||||||
|
property: [
|
||||||
|
"telemetry",
|
||||||
|
"infinityValues"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
initialize: function (object) {
|
initialize: function (object) {
|
||||||
@@ -153,7 +163,8 @@ define([
|
|||||||
dataRateInHz: 1,
|
dataRateInHz: 1,
|
||||||
phase: 0,
|
phase: 0,
|
||||||
randomness: 0,
|
randomness: 0,
|
||||||
loadDelay: 0
|
loadDelay: 0,
|
||||||
|
infinityValues: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
12
jsdoc.json
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"source": {
|
|
||||||
"include": [
|
|
||||||
"src/"
|
|
||||||
],
|
|
||||||
"includePattern": "src/.+\\.js$",
|
|
||||||
"excludePattern": ".+\\Spec\\.js$|lib/.+"
|
|
||||||
},
|
|
||||||
"plugins": [
|
|
||||||
"plugins/markdown"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -23,14 +23,32 @@
|
|||||||
/*global module,process*/
|
/*global module,process*/
|
||||||
|
|
||||||
module.exports = (config) => {
|
module.exports = (config) => {
|
||||||
const webpackConfig = require('./webpack.coverage.js');
|
let webpackConfig;
|
||||||
|
let browsers;
|
||||||
|
let singleRun;
|
||||||
|
|
||||||
|
if (process.env.KARMA_DEBUG) {
|
||||||
|
webpackConfig = require('./webpack.dev.js');
|
||||||
|
browsers = ['ChromeDebugging'];
|
||||||
|
singleRun = false;
|
||||||
|
} else {
|
||||||
|
webpackConfig = require('./webpack.coverage.js');
|
||||||
|
browsers = ['ChromeHeadless'];
|
||||||
|
singleRun = true;
|
||||||
|
}
|
||||||
|
|
||||||
delete webpackConfig.output;
|
delete webpackConfig.output;
|
||||||
|
// karma doesn't support webpack entry
|
||||||
|
delete webpackConfig.entry;
|
||||||
|
|
||||||
config.set({
|
config.set({
|
||||||
basePath: '',
|
basePath: '',
|
||||||
frameworks: ['jasmine'],
|
frameworks: ['jasmine', 'webpack'],
|
||||||
files: [
|
files: [
|
||||||
'indexTest.js',
|
'indexTest.js',
|
||||||
|
// included means: should the files be included in the browser using <script> tag?
|
||||||
|
// We don't want them as a <script> because the shared worker source
|
||||||
|
// needs loaded remotely by the shared worker process.
|
||||||
{
|
{
|
||||||
pattern: 'dist/couchDBChangesFeed.js*',
|
pattern: 'dist/couchDBChangesFeed.js*',
|
||||||
included: false
|
included: false
|
||||||
@@ -46,7 +64,7 @@ module.exports = (config) => {
|
|||||||
],
|
],
|
||||||
port: 9876,
|
port: 9876,
|
||||||
reporters: ['spec', 'junit', 'coverage-istanbul'],
|
reporters: ['spec', 'junit', 'coverage-istanbul'],
|
||||||
browsers: [process.env.NODE_ENV === 'debug' ? 'ChromeDebugging' : 'ChromeHeadless'],
|
browsers,
|
||||||
client: {
|
client: {
|
||||||
jasmine: {
|
jasmine: {
|
||||||
random: false,
|
random: false,
|
||||||
@@ -70,6 +88,7 @@ module.exports = (config) => {
|
|||||||
},
|
},
|
||||||
coverageIstanbulReporter: {
|
coverageIstanbulReporter: {
|
||||||
fixWebpackSourcePaths: true,
|
fixWebpackSourcePaths: true,
|
||||||
|
skipFilesWithNoCoverage: true,
|
||||||
dir: "coverage/unit", //Sets coverage file to be consumed by codecov.io
|
dir: "coverage/unit", //Sets coverage file to be consumed by codecov.io
|
||||||
reports: ['lcovonly']
|
reports: ['lcovonly']
|
||||||
},
|
},
|
||||||
@@ -90,7 +109,7 @@ module.exports = (config) => {
|
|||||||
stats: 'errors-warnings'
|
stats: 'errors-warnings'
|
||||||
},
|
},
|
||||||
concurrency: 1,
|
concurrency: 1,
|
||||||
singleRun: true,
|
singleRun,
|
||||||
browserNoActivityTimeout: 400000
|
browserNoActivityTimeout: 400000
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,96 +0,0 @@
|
|||||||
---
|
|
||||||
ci:
|
|
||||||
collect:
|
|
||||||
urls:
|
|
||||||
- http://localhost/
|
|
||||||
numberOfRuns: 5
|
|
||||||
settings:
|
|
||||||
onlyCategories:
|
|
||||||
- performance
|
|
||||||
- best-practices
|
|
||||||
upload:
|
|
||||||
target: temporary-public-storage
|
|
||||||
assert:
|
|
||||||
preset: lighthouse:recommended
|
|
||||||
assertions:
|
|
||||||
### Applicable assertions
|
|
||||||
bootup-time:
|
|
||||||
- warn
|
|
||||||
- minScore: 0.88 #Original value was calculated at 0.88
|
|
||||||
dom-size:
|
|
||||||
- error
|
|
||||||
- maxNumericValue: 200 #Original value was calculated at 188
|
|
||||||
first-contentful-paint:
|
|
||||||
- error
|
|
||||||
- minScore: 0.07 #Original value was calculated at 0.08
|
|
||||||
mainthread-work-breakdown:
|
|
||||||
- warn
|
|
||||||
- minScore: 0.8 #Original value was calculated at 0.8
|
|
||||||
unused-javascript:
|
|
||||||
- warn
|
|
||||||
- maxLength: 1
|
|
||||||
- error
|
|
||||||
- maxNumericValue: 2000 #Original value was calculated at 1855
|
|
||||||
unused-css-rules: warn
|
|
||||||
installable-manifest: warn
|
|
||||||
service-worker: warn
|
|
||||||
### Disabled seo, accessibility, and pwa assertions, below
|
|
||||||
categories:seo: 'off'
|
|
||||||
categories:accessibility: 'off'
|
|
||||||
categories:pwa: 'off'
|
|
||||||
accesskeys: 'off'
|
|
||||||
apple-touch-icon: 'off'
|
|
||||||
aria-allowed-attr: 'off'
|
|
||||||
aria-command-name: 'off'
|
|
||||||
aria-hidden-body: 'off'
|
|
||||||
aria-hidden-focus: 'off'
|
|
||||||
aria-input-field-name: 'off'
|
|
||||||
aria-meter-name: 'off'
|
|
||||||
aria-progressbar-name: 'off'
|
|
||||||
aria-required-attr: 'off'
|
|
||||||
aria-required-children: 'off'
|
|
||||||
aria-required-parent: 'off'
|
|
||||||
aria-roles: 'off'
|
|
||||||
aria-toggle-field-name: 'off'
|
|
||||||
aria-tooltip-name: 'off'
|
|
||||||
aria-treeitem-name: 'off'
|
|
||||||
aria-valid-attr: 'off'
|
|
||||||
aria-valid-attr-value: 'off'
|
|
||||||
button-name: 'off'
|
|
||||||
bypass: 'off'
|
|
||||||
canonical: 'off'
|
|
||||||
color-contrast: 'off'
|
|
||||||
content-width: 'off'
|
|
||||||
crawlable-anchors: 'off'
|
|
||||||
csp-xss: 'off'
|
|
||||||
font-display: 'off'
|
|
||||||
font-size: 'off'
|
|
||||||
maskable-icon: 'off'
|
|
||||||
heading-order: 'off'
|
|
||||||
hreflang: 'off'
|
|
||||||
html-has-lang: 'off'
|
|
||||||
html-lang-valid: 'off'
|
|
||||||
http-status-code: 'off'
|
|
||||||
image-alt: 'off'
|
|
||||||
input-image-alt: 'off'
|
|
||||||
is-crawlable: 'off'
|
|
||||||
label: 'off'
|
|
||||||
link-name: 'off'
|
|
||||||
link-text: 'off'
|
|
||||||
list: 'off'
|
|
||||||
listitem: 'off'
|
|
||||||
meta-description: 'off'
|
|
||||||
meta-refresh: 'off'
|
|
||||||
meta-viewport: 'off'
|
|
||||||
object-alt: 'off'
|
|
||||||
plugins: 'off'
|
|
||||||
robots-txt: 'off'
|
|
||||||
splash-screen: 'off'
|
|
||||||
tabindex: 'off'
|
|
||||||
tap-targets: 'off'
|
|
||||||
td-headers-attr: 'off'
|
|
||||||
th-has-data-cells: 'off'
|
|
||||||
themed-omnibox: 'off'
|
|
||||||
valid-lang: 'off'
|
|
||||||
video-caption: 'off'
|
|
||||||
viewport: 'off'
|
|
||||||
45
openmct.js
@@ -30,8 +30,53 @@ if (document.currentScript) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} BuildInfo
|
||||||
|
* @property {string} version
|
||||||
|
* @property {string} buildDate
|
||||||
|
* @property {string} revision
|
||||||
|
* @property {string} branch
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} OpenMCT
|
||||||
|
* @property {BuildInfo} buildInfo
|
||||||
|
* @property {*} selection
|
||||||
|
* @property {import('./src/api/time/TimeAPI').default} time
|
||||||
|
* @property {import('./src/api/composition/CompositionAPI').default} composition
|
||||||
|
* @property {*} objectViews
|
||||||
|
* @property {*} inspectorViews
|
||||||
|
* @property {*} propertyEditors
|
||||||
|
* @property {*} toolbars
|
||||||
|
* @property {*} types
|
||||||
|
* @property {import('./src/api/objects/ObjectAPI').default} objects
|
||||||
|
* @property {import('./src/api/telemetry/TelemetryAPI').default} telemetry
|
||||||
|
* @property {import('./src/api/indicators/IndicatorAPI').default} indicators
|
||||||
|
* @property {import('./src/api/user/UserAPI').default} user
|
||||||
|
* @property {import('./src/api/notifications/NotificationAPI').default} notifications
|
||||||
|
* @property {import('./src/api/Editor').default} editor
|
||||||
|
* @property {import('./src/api/overlays/OverlayAPI')} overlays
|
||||||
|
* @property {import('./src/api/menu/MenuAPI').default} menus
|
||||||
|
* @property {import('./src/api/actions/ActionsAPI').default} actions
|
||||||
|
* @property {import('./src/api/status/StatusAPI').default} status
|
||||||
|
* @property {*} priority
|
||||||
|
* @property {import('./src/ui/router/ApplicationRouter')} router
|
||||||
|
* @property {import('./src/api/faultmanagement/FaultManagementAPI').default} faults
|
||||||
|
* @property {import('./src/api/forms/FormsAPI').default} forms
|
||||||
|
* @property {import('./src/api/Branding').default} branding
|
||||||
|
* @property {import('./src/api/annotation/AnnotationAPI').default} annotation
|
||||||
|
* @property {{(plugin: OpenMCTPlugin) => void}} install
|
||||||
|
* @property {{() => string}} getAssetPath
|
||||||
|
* @property {{(domElement: HTMLElement, isHeadlessMode: boolean) => void}} start
|
||||||
|
* @property {{() => void}} startHeadless
|
||||||
|
* @property {{() => void}} destroy
|
||||||
|
* @property {OpenMCTPlugin[]} plugins
|
||||||
|
* @property {OpenMCTComponent[]} components
|
||||||
|
*/
|
||||||
|
|
||||||
const MCT = require('./src/MCT');
|
const MCT = require('./src/MCT');
|
||||||
|
|
||||||
|
/** @type {OpenMCT} */
|
||||||
const openmct = new MCT();
|
const openmct = new MCT();
|
||||||
|
|
||||||
module.exports = openmct;
|
module.exports = openmct;
|
||||||
|
|||||||
83
package.json
@@ -1,40 +1,35 @@
|
|||||||
{
|
{
|
||||||
"name": "openmct",
|
"name": "openmct",
|
||||||
"version": "2.0.8",
|
"version": "2.1.5",
|
||||||
"description": "The Open MCT core platform",
|
"description": "The Open MCT core platform",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/eslint-parser": "7.18.9",
|
"@babel/eslint-parser": "7.18.9",
|
||||||
"@braintree/sanitize-url": "6.0.0",
|
"@braintree/sanitize-url": "6.0.2",
|
||||||
"@percy/cli": "1.10.0",
|
"@percy/cli": "1.16.0",
|
||||||
"@percy/playwright": "1.0.4",
|
"@percy/playwright": "1.0.4",
|
||||||
"@playwright/test": "1.23.0",
|
"@playwright/test": "1.25.2",
|
||||||
"@types/eventemitter3": "^1.0.0",
|
"@types/jasmine": "4.3.1",
|
||||||
"@types/jasmine": "^4.0.1",
|
"@types/lodash": "4.14.191",
|
||||||
"@types/karma": "^6.3.2",
|
"babel-loader": "9.1.0",
|
||||||
"@types/lodash": "^4.14.178",
|
|
||||||
"@types/mocha": "^9.1.0",
|
|
||||||
"babel-loader": "8.2.5",
|
|
||||||
"babel-plugin-istanbul": "6.1.1",
|
"babel-plugin-istanbul": "6.1.1",
|
||||||
|
"codecov": "3.8.3",
|
||||||
"comma-separated-values": "3.6.4",
|
"comma-separated-values": "3.6.4",
|
||||||
"codecov":"3.8.3",
|
|
||||||
"copy-webpack-plugin": "11.0.0",
|
"copy-webpack-plugin": "11.0.0",
|
||||||
"cross-env": "7.0.3",
|
|
||||||
"css-loader": "6.7.1",
|
"css-loader": "6.7.1",
|
||||||
"d3-axis": "3.0.0",
|
"d3-axis": "3.0.0",
|
||||||
"d3-scale": "3.3.0",
|
"d3-scale": "3.3.0",
|
||||||
"d3-selection": "3.0.0",
|
"d3-selection": "3.0.0",
|
||||||
"eslint": "8.22.0",
|
"eslint": "8.30.0",
|
||||||
"eslint-plugin-compat": "4.0.2",
|
"eslint-plugin-compat": "4.0.2",
|
||||||
"eslint-plugin-playwright": "0.11.1",
|
"eslint-plugin-playwright": "0.11.2",
|
||||||
"eslint-plugin-vue": "9.3.0",
|
"eslint-plugin-vue": "9.8.0",
|
||||||
"eslint-plugin-you-dont-need-lodash-underscore": "6.12.0",
|
"eslint-plugin-you-dont-need-lodash-underscore": "6.12.0",
|
||||||
"eventemitter3": "1.2.0",
|
"eventemitter3": "1.2.0",
|
||||||
"express": "4.13.1",
|
|
||||||
"file-saver": "2.0.5",
|
"file-saver": "2.0.5",
|
||||||
"git-rev-sync": "3.0.2",
|
"git-rev-sync": "3.0.2",
|
||||||
"html2canvas": "1.4.1",
|
"html2canvas": "1.4.1",
|
||||||
"imports-loader": "4.0.1",
|
"imports-loader": "4.0.1",
|
||||||
"jasmine-core": "4.3.0",
|
"jasmine-core": "4.5.0",
|
||||||
"karma": "6.3.20",
|
"karma": "6.3.20",
|
||||||
"karma-chrome-launcher": "3.1.1",
|
"karma-chrome-launcher": "3.1.1",
|
||||||
"karma-cli": "2.0.0",
|
"karma-cli": "2.0.0",
|
||||||
@@ -47,45 +42,46 @@
|
|||||||
"karma-webpack": "5.0.0",
|
"karma-webpack": "5.0.0",
|
||||||
"location-bar": "3.0.1",
|
"location-bar": "3.0.1",
|
||||||
"lodash": "4.17.21",
|
"lodash": "4.17.21",
|
||||||
"mini-css-extract-plugin": "2.6.1",
|
"mini-css-extract-plugin": "2.7.2",
|
||||||
"moment": "2.29.4",
|
"moment": "2.29.4",
|
||||||
"moment-duration-format": "2.3.2",
|
"moment-duration-format": "2.3.2",
|
||||||
"moment-timezone": "0.5.37",
|
"moment-timezone": "0.5.40",
|
||||||
"nyc":"15.1.0",
|
"nyc": "15.1.0",
|
||||||
"painterro": "1.2.78",
|
"painterro": "1.2.78",
|
||||||
|
"playwright-core": "1.25.2",
|
||||||
"plotly.js-basic-dist": "2.14.0",
|
"plotly.js-basic-dist": "2.14.0",
|
||||||
"plotly.js-gl2d-dist": "2.14.0",
|
"plotly.js-gl2d-dist": "2.14.0",
|
||||||
"printj": "1.3.1",
|
"printj": "1.3.1",
|
||||||
"request": "2.88.2",
|
|
||||||
"resolve-url-loader": "5.0.0",
|
"resolve-url-loader": "5.0.0",
|
||||||
"sass": "1.54.4",
|
"sass": "1.56.1",
|
||||||
"sass-loader": "13.0.2",
|
"sass-loader": "13.0.2",
|
||||||
"sinon": "14.0.0",
|
"sinon": "15.0.1",
|
||||||
"style-loader": "^1.0.1",
|
"style-loader": "^3.3.1",
|
||||||
"uuid": "8.3.2",
|
"typescript": "4.9.4",
|
||||||
|
"uuid": "9.0.0",
|
||||||
"vue": "2.6.14",
|
"vue": "2.6.14",
|
||||||
"vue-eslint-parser": "9.0.2",
|
"vue-eslint-parser": "9.1.0",
|
||||||
"vue-loader": "15.9.8",
|
"vue-loader": "15.9.8",
|
||||||
"vue-template-compiler": "2.6.14",
|
"vue-template-compiler": "2.6.14",
|
||||||
"webpack": "5.68.0",
|
"webpack": "5.74.0",
|
||||||
"webpack-cli": "4.10.0",
|
"webpack-cli": "5.0.0",
|
||||||
"webpack-dev-middleware": "5.3.3",
|
"webpack-dev-server": "4.11.1",
|
||||||
"webpack-hot-middleware": "2.25.1",
|
|
||||||
"webpack-merge": "5.8.0"
|
"webpack-merge": "5.8.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rm -rf ./dist ./node_modules ./package-lock.json",
|
"clean": "rm -rf ./dist ./node_modules ./package-lock.json",
|
||||||
"clean-test-lint": "npm run clean; npm install; npm run test; npm run lint",
|
"clean-test-lint": "npm run clean; npm install; npm run test; npm run lint",
|
||||||
"start": "node app.js",
|
"start": "npx webpack serve --config ./webpack.dev.js",
|
||||||
|
"start:coverage": "npx webpack serve --config ./webpack.coverage.js",
|
||||||
"lint": "eslint example src e2e --ext .js,.vue openmct.js --max-warnings=0",
|
"lint": "eslint example src e2e --ext .js,.vue openmct.js --max-warnings=0",
|
||||||
"lint:fix": "eslint example src e2e --ext .js,.vue openmct.js --fix",
|
"lint:fix": "eslint example src e2e --ext .js,.vue openmct.js --fix",
|
||||||
"build:prod": "cross-env webpack --config webpack.prod.js",
|
"build:prod": "webpack --config webpack.prod.js",
|
||||||
"build:dev": "webpack --config webpack.dev.js",
|
"build:dev": "webpack --config webpack.dev.js",
|
||||||
"build:coverage": "webpack --config webpack.coverage.js",
|
"build:coverage": "webpack --config webpack.coverage.js",
|
||||||
"build:watch": "webpack --config webpack.dev.js --watch",
|
"build:watch": "webpack --config webpack.dev.js --watch",
|
||||||
"info": "npx envinfo --system --browsers --npmPackages --binaries --languages --markdown",
|
"info": "npx envinfo --system --browsers --npmPackages --binaries --languages --markdown",
|
||||||
"test": "cross-env NODE_ENV=test NODE_OPTIONS=\"--max_old_space_size=4096\" karma start --single-run",
|
"test": "karma start",
|
||||||
"test:debug": "cross-env NODE_ENV=debug karma start --no-single-run",
|
"test:debug": "KARMA_DEBUG=true karma start",
|
||||||
"test:e2e": "npx playwright test",
|
"test:e2e": "npx playwright test",
|
||||||
"test:e2e:couchdb": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @couchdb",
|
"test:e2e:couchdb": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @couchdb",
|
||||||
"test:e2e:stable": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep-invert \"@unstable|@couchdb\"",
|
"test:e2e:stable": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep-invert \"@unstable|@couchdb\"",
|
||||||
@@ -93,16 +89,15 @@
|
|||||||
"test:e2e:local": "npx playwright test --config=e2e/playwright-local.config.js --project=chrome",
|
"test:e2e:local": "npx playwright test --config=e2e/playwright-local.config.js --project=chrome",
|
||||||
"test:e2e:updatesnapshots": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @snapshot --update-snapshots",
|
"test:e2e:updatesnapshots": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @snapshot --update-snapshots",
|
||||||
"test:e2e:visual": "percy exec --config ./e2e/.percy.yml -- npx playwright test --config=e2e/playwright-visual.config.js --grep-invert @unstable",
|
"test:e2e:visual": "percy exec --config ./e2e/.percy.yml -- npx playwright test --config=e2e/playwright-visual.config.js --grep-invert @unstable",
|
||||||
"test:e2e:full": "npx playwright test --config=e2e/playwright-ci.config.js",
|
"test:e2e:full": "npx playwright test --config=e2e/playwright-ci.config.js --grep-invert @couchdb",
|
||||||
"test:perf": "npx playwright test --config=e2e/playwright-performance.config.js",
|
"test:perf": "npx playwright test --config=e2e/playwright-performance.config.js",
|
||||||
"test:watch": "cross-env NODE_ENV=test NODE_OPTIONS=\"--max_old_space_size=4096\" karma start --no-single-run",
|
|
||||||
"update-about-dialog-copyright": "perl -pi -e 's/20\\d\\d\\-202\\d/2014\\-2022/gm' ./src/ui/layout/AboutDialog.vue",
|
"update-about-dialog-copyright": "perl -pi -e 's/20\\d\\d\\-202\\d/2014\\-2022/gm' ./src/ui/layout/AboutDialog.vue",
|
||||||
"update-copyright-date": "npm run update-about-dialog-copyright && grep -lr --null --include=*.{js,scss,vue,ts,sh,html,md,frag} 'Copyright (c) 20' . | xargs -r0 perl -pi -e 's/Copyright\\s\\(c\\)\\s20\\d\\d\\-20\\d\\d/Copyright \\(c\\)\\ 2014\\-2022/gm'",
|
"update-copyright-date": "npm run update-about-dialog-copyright && grep -lr --null --include=*.{js,scss,vue,ts,sh,html,md,frag} 'Copyright (c) 20' . | xargs -r0 perl -pi -e 's/Copyright\\s\\(c\\)\\s20\\d\\d\\-20\\d\\d/Copyright \\(c\\)\\ 2014\\-2022/gm'",
|
||||||
"cov:e2e:report":"nyc report --reporter=lcovonly --report-dir=./coverage/e2e",
|
"cov:e2e:report": "nyc report --reporter=lcovonly --report-dir=./coverage/e2e",
|
||||||
"cov:e2e:full:publish":"codecov --disable=gcov -f ./coverage/e2e/lcov.info -F e2e-full",
|
"cov:e2e:full:publish": "codecov --disable=gcov -f ./coverage/e2e/lcov.info -F e2e-full",
|
||||||
"cov:e2e:stable:publish":"codecov --disable=gcov -f ./coverage/e2e/lcov.info -F e2e-stable",
|
"cov:e2e:stable:publish": "codecov --disable=gcov -f ./coverage/e2e/lcov.info -F e2e-stable",
|
||||||
"cov:unit:publish":"codecov --disable=gcov -f ./coverage/unit/lcov.info -F unit",
|
"cov:unit:publish": "codecov --disable=gcov -f ./coverage/unit/lcov.info -F unit",
|
||||||
"prepare": "npm run build:prod"
|
"prepare": "npm run build:prod && npx tsc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -111,9 +106,6 @@
|
|||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.19.1"
|
"node": ">=14.19.1"
|
||||||
},
|
},
|
||||||
"overrides": {
|
|
||||||
"core-js": "3.21.1"
|
|
||||||
},
|
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"Firefox ESR",
|
"Firefox ESR",
|
||||||
"not IE 11",
|
"not IE 11",
|
||||||
@@ -122,6 +114,5 @@
|
|||||||
"ios_saf > 15"
|
"ios_saf > 15"
|
||||||
],
|
],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0"
|
||||||
"private": true
|
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/MCT.js
@@ -19,7 +19,7 @@
|
|||||||
* this source code distribution or the Licensing information page available
|
* this source code distribution or the Licensing information page available
|
||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
/* eslint-disable no-undef */
|
||||||
define([
|
define([
|
||||||
'EventEmitter',
|
'EventEmitter',
|
||||||
'./api/api',
|
'./api/api',
|
||||||
@@ -81,13 +81,11 @@ define([
|
|||||||
/**
|
/**
|
||||||
* The Open MCT application. This may be configured by installing plugins
|
* The Open MCT application. This may be configured by installing plugins
|
||||||
* or registering extensions before the application is started.
|
* or registering extensions before the application is started.
|
||||||
* @class MCT
|
* @constructor
|
||||||
* @memberof module:openmct
|
* @memberof module:openmct
|
||||||
* @augments {EventEmitter}
|
|
||||||
*/
|
*/
|
||||||
function MCT() {
|
function MCT() {
|
||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
/* eslint-disable no-undef */
|
|
||||||
this.buildInfo = {
|
this.buildInfo = {
|
||||||
version: __OPENMCT_VERSION__,
|
version: __OPENMCT_VERSION__,
|
||||||
buildDate: __OPENMCT_BUILD_DATE__,
|
buildDate: __OPENMCT_BUILD_DATE__,
|
||||||
@@ -101,7 +99,7 @@ define([
|
|||||||
* Tracks current selection state of the application.
|
* Tracks current selection state of the application.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
['selection', () => new Selection(this)],
|
['selection', () => new Selection.default(this)],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MCT's time conductor, which may be used to synchronize view contents
|
* MCT's time conductor, which may be used to synchronize view contents
|
||||||
@@ -125,7 +123,7 @@ define([
|
|||||||
* @memberof module:openmct.MCT#
|
* @memberof module:openmct.MCT#
|
||||||
* @name composition
|
* @name composition
|
||||||
*/
|
*/
|
||||||
['composition', () => new api.CompositionAPI(this)],
|
['composition', () => new api.CompositionAPI.default(this)],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registry for views of domain objects which should appear in the
|
* Registry for views of domain objects which should appear in the
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
let brandingOptions = {};
|
let brandingOptions = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} BrandingOptions
|
* @typedef {object} BrandingOptions
|
||||||
* @memberOf openmct/branding
|
|
||||||
* @property {string} smallLogoImage URL to the image to use as the applications logo.
|
* @property {string} smallLogoImage URL to the image to use as the applications logo.
|
||||||
* This logo will appear on every screen and when clicked will launch the about dialog.
|
* This logo will appear on every screen and when clicked will launch the about dialog.
|
||||||
* @property {string} aboutHtml Custom content for the about screen. When defined the
|
* @property {string} aboutHtml Custom content for the about screen. When defined the
|
||||||
|
|||||||
@@ -56,18 +56,12 @@ export default class Editor extends EventEmitter {
|
|||||||
* Save any unsaved changes from this editing session. This will
|
* Save any unsaved changes from this editing session. This will
|
||||||
* end the current transaction.
|
* end the current transaction.
|
||||||
*/
|
*/
|
||||||
save() {
|
async save() {
|
||||||
const transaction = this.openmct.objects.getActiveTransaction();
|
const transaction = this.openmct.objects.getActiveTransaction();
|
||||||
|
await transaction.commit();
|
||||||
return transaction.commit()
|
this.editing = false;
|
||||||
.then(() => {
|
this.emit('isEditing', false);
|
||||||
this.editing = false;
|
this.openmct.objects.endTransaction();
|
||||||
this.emit('isEditing', false);
|
|
||||||
}).catch(error => {
|
|
||||||
throw error;
|
|
||||||
}).finally(() => {
|
|
||||||
this.openmct.objects.endTransaction();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,6 +73,10 @@ export default class Editor extends EventEmitter {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const transaction = this.openmct.objects.getActiveTransaction();
|
const transaction = this.openmct.objects.getActiveTransaction();
|
||||||
|
if (!transaction) {
|
||||||
|
return resolve();
|
||||||
|
}
|
||||||
|
|
||||||
transaction.cancel()
|
transaction.cancel()
|
||||||
.then(resolve)
|
.then(resolve)
|
||||||
.catch(reject)
|
.catch(reject)
|
||||||
|
|||||||
80
src/api/EditorSpec.js
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, 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 {
|
||||||
|
createOpenMct, resetApplicationState
|
||||||
|
} from '../utils/testing';
|
||||||
|
|
||||||
|
describe('The Editor API', () => {
|
||||||
|
let openmct;
|
||||||
|
|
||||||
|
beforeEach((done) => {
|
||||||
|
openmct = createOpenMct();
|
||||||
|
openmct.on('start', done);
|
||||||
|
|
||||||
|
spyOn(openmct.objects, 'endTransaction');
|
||||||
|
|
||||||
|
openmct.startHeadless();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
return resetApplicationState(openmct);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('opens a transaction on edit', () => {
|
||||||
|
expect(
|
||||||
|
openmct.objects.isTransactionActive()
|
||||||
|
).toBeFalse();
|
||||||
|
openmct.editor.edit();
|
||||||
|
expect(
|
||||||
|
openmct.objects.isTransactionActive()
|
||||||
|
).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('closes an open transaction on successful save', async () => {
|
||||||
|
spyOn(openmct.objects, 'getActiveTransaction')
|
||||||
|
.and.returnValue({
|
||||||
|
commit: () => Promise.resolve(true)
|
||||||
|
});
|
||||||
|
|
||||||
|
openmct.editor.edit();
|
||||||
|
await openmct.editor.save();
|
||||||
|
|
||||||
|
expect(
|
||||||
|
openmct.objects.endTransaction
|
||||||
|
).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not close an open transaction on failed save', async () => {
|
||||||
|
spyOn(openmct.objects, 'getActiveTransaction')
|
||||||
|
.and.returnValue({
|
||||||
|
commit: () => Promise.reject()
|
||||||
|
});
|
||||||
|
|
||||||
|
openmct.editor.edit();
|
||||||
|
await openmct.editor.save().catch(() => {});
|
||||||
|
|
||||||
|
expect(
|
||||||
|
openmct.objects.endTransaction
|
||||||
|
).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import EventEmitter from 'EventEmitter';
|
import EventEmitter from 'EventEmitter';
|
||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @readonly
|
* @readonly
|
||||||
@@ -42,19 +43,28 @@ const ANNOTATION_TYPES = Object.freeze({
|
|||||||
|
|
||||||
const ANNOTATION_TYPE = 'annotation';
|
const ANNOTATION_TYPE = 'annotation';
|
||||||
|
|
||||||
|
const ANNOTATION_LAST_CREATED = 'annotationLastCreated';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} Tag
|
* @typedef {Object} Tag
|
||||||
* @property {String} key a unique identifier for the tag
|
* @property {String} key a unique identifier for the tag
|
||||||
* @property {String} backgroundColor eg. "#cc0000"
|
* @property {String} backgroundColor eg. "#cc0000"
|
||||||
* @property {String} foregroundColor eg. "#ffffff"
|
* @property {String} foregroundColor eg. "#ffffff"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default class AnnotationAPI extends EventEmitter {
|
export default class AnnotationAPI extends EventEmitter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {OpenMCT} openmct
|
||||||
|
*/
|
||||||
constructor(openmct) {
|
constructor(openmct) {
|
||||||
super();
|
super();
|
||||||
this.openmct = openmct;
|
this.openmct = openmct;
|
||||||
this.availableTags = {};
|
this.availableTags = {};
|
||||||
|
|
||||||
this.ANNOTATION_TYPES = ANNOTATION_TYPES;
|
this.ANNOTATION_TYPES = ANNOTATION_TYPES;
|
||||||
|
this.ANNOTATION_TYPE = ANNOTATION_TYPE;
|
||||||
|
this.ANNOTATION_LAST_CREATED = ANNOTATION_LAST_CREATED;
|
||||||
|
|
||||||
this.openmct.types.addType(ANNOTATION_TYPE, {
|
this.openmct.types.addType(ANNOTATION_TYPE, {
|
||||||
name: 'Annotation',
|
name: 'Annotation',
|
||||||
@@ -63,6 +73,7 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
cssClass: 'icon-notebook',
|
cssClass: 'icon-notebook',
|
||||||
initialize: function (domainObject) {
|
initialize: function (domainObject) {
|
||||||
domainObject.targets = domainObject.targets || {};
|
domainObject.targets = domainObject.targets || {};
|
||||||
|
domainObject._deleted = domainObject._deleted || false;
|
||||||
domainObject.originalContextPath = domainObject.originalContextPath || '';
|
domainObject.originalContextPath = domainObject.originalContextPath || '';
|
||||||
domainObject.tags = domainObject.tags || [];
|
domainObject.tags = domainObject.tags || [];
|
||||||
domainObject.contentText = domainObject.contentText || '';
|
domainObject.contentText = domainObject.contentText || '';
|
||||||
@@ -112,6 +123,7 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
namespace
|
namespace
|
||||||
},
|
},
|
||||||
tags,
|
tags,
|
||||||
|
_deleted: false,
|
||||||
annotationType,
|
annotationType,
|
||||||
contentText,
|
contentText,
|
||||||
originalContextPath
|
originalContextPath
|
||||||
@@ -127,6 +139,7 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
const success = await this.openmct.objects.save(createdObject);
|
const success = await this.openmct.objects.save(createdObject);
|
||||||
if (success) {
|
if (success) {
|
||||||
this.emit('annotationCreated', createdObject);
|
this.emit('annotationCreated', createdObject);
|
||||||
|
this.#updateAnnotationModified(domainObject);
|
||||||
|
|
||||||
return createdObject;
|
return createdObject;
|
||||||
} else {
|
} else {
|
||||||
@@ -134,14 +147,32 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#updateAnnotationModified(domainObject) {
|
||||||
|
this.openmct.objects.mutate(domainObject, this.ANNOTATION_LAST_CREATED, Date.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method defineTag
|
||||||
|
* @param {String} key a unique identifier for the tag
|
||||||
|
* @param {Tag} tagsDefinition the definition of the tag to add
|
||||||
|
*/
|
||||||
defineTag(tagKey, tagsDefinition) {
|
defineTag(tagKey, tagsDefinition) {
|
||||||
this.availableTags[tagKey] = tagsDefinition;
|
this.availableTags[tagKey] = tagsDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method isAnnotation
|
||||||
|
* @param {import('../objects/ObjectAPI').DomainObject} domainObject domainObject the domainObject in question
|
||||||
|
* @returns {Boolean} Returns true if the domain object is an annotation
|
||||||
|
*/
|
||||||
isAnnotation(domainObject) {
|
isAnnotation(domainObject) {
|
||||||
return domainObject && (domainObject.type === ANNOTATION_TYPE);
|
return domainObject && (domainObject.type === ANNOTATION_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method getAvailableTags
|
||||||
|
* @returns {Tag[]} Returns an array of the available tags that have been loaded
|
||||||
|
*/
|
||||||
getAvailableTags() {
|
getAvailableTags() {
|
||||||
if (this.availableTags) {
|
if (this.availableTags) {
|
||||||
const rearrangedToArray = Object.keys(this.availableTags).map(tagKey => {
|
const rearrangedToArray = Object.keys(this.availableTags).map(tagKey => {
|
||||||
@@ -157,18 +188,26 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAnnotation(query, searchType) {
|
/**
|
||||||
let foundAnnotation = null;
|
* @method getAnnotations
|
||||||
|
* @param {String} query - The keystring of the domain object to search for annotations for
|
||||||
|
* @returns {import('../objects/ObjectAPI').DomainObject[]} Returns an array of domain objects that match the search query
|
||||||
|
*/
|
||||||
|
async getAnnotations(query) {
|
||||||
|
const searchResults = (await Promise.all(this.openmct.objects.search(query, null, this.openmct.objects.SEARCH_TYPES.ANNOTATIONS))).flat();
|
||||||
|
|
||||||
const searchResults = (await Promise.all(this.openmct.objects.search(query, null, searchType))).flat();
|
return searchResults;
|
||||||
if (searchResults) {
|
|
||||||
foundAnnotation = searchResults[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return foundAnnotation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async addAnnotationTag(existingAnnotation, targetDomainObject, targetSpecificDetails, annotationType, tag) {
|
/**
|
||||||
|
* @method addSingleAnnotationTag
|
||||||
|
* @param {import('../objects/ObjectAPI').DomainObject=} existingAnnotation - An optional annotation to add the tag to. If not specified, we will create an annotation.
|
||||||
|
* @param {import('../objects/ObjectAPI').DomainObject} targetDomainObject - The domain object the annotation will point to.
|
||||||
|
* @param {Object=} targetSpecificDetails - Optional object to add to the target object. E.g., for notebooks this would be an entryID
|
||||||
|
* @param {AnnotationType} annotationType - The type of annotation this is for.
|
||||||
|
* @returns {import('../objects/ObjectAPI').DomainObject[]} Returns the annotation that was either created or passed as an existingAnnotation
|
||||||
|
*/
|
||||||
|
async addSingleAnnotationTag(existingAnnotation, targetDomainObject, targetSpecificDetails, annotationType, tag) {
|
||||||
if (!existingAnnotation) {
|
if (!existingAnnotation) {
|
||||||
const targets = {};
|
const targets = {};
|
||||||
const targetKeyString = this.openmct.objects.makeKeyString(targetDomainObject.identifier);
|
const targetKeyString = this.openmct.objects.makeKeyString(targetDomainObject.identifier);
|
||||||
@@ -186,27 +225,44 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
|
|
||||||
return newAnnotation;
|
return newAnnotation;
|
||||||
} else {
|
} else {
|
||||||
const tagArray = [tag, ...existingAnnotation.tags];
|
if (!existingAnnotation.tags.includes(tag)) {
|
||||||
this.openmct.objects.mutate(existingAnnotation, 'tags', tagArray);
|
throw new Error(`Existing annotation did not contain tag ${tag}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingAnnotation._deleted) {
|
||||||
|
this.unDeleteAnnotation(existingAnnotation);
|
||||||
|
}
|
||||||
|
|
||||||
return existingAnnotation;
|
return existingAnnotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removeAnnotationTag(existingAnnotation, tagToRemove) {
|
/**
|
||||||
if (existingAnnotation && existingAnnotation.tags.includes(tagToRemove)) {
|
* @method deleteAnnotations
|
||||||
const cleanedArray = existingAnnotation.tags.filter(extantTag => extantTag !== tagToRemove);
|
* @param {import('../objects/ObjectAPI').DomainObject[]} existingAnnotation - An array of annotations to delete (set _deleted to true)
|
||||||
this.openmct.objects.mutate(existingAnnotation, 'tags', cleanedArray);
|
*/
|
||||||
} else {
|
deleteAnnotations(annotations) {
|
||||||
throw new Error(`Asked to remove tag (${tagToRemove}) that doesn't exist`, existingAnnotation);
|
if (!annotations) {
|
||||||
|
throw new Error('Asked to delete null annotations! 🙅♂️');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
annotations.forEach(annotation => {
|
||||||
|
if (!annotation._deleted) {
|
||||||
|
this.openmct.objects.mutate(annotation, '_deleted', true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
removeAnnotationTags(existingAnnotation) {
|
/**
|
||||||
// just removes tags on the annotation as we can't really delete objects
|
* @method deleteAnnotations
|
||||||
if (existingAnnotation && existingAnnotation.tags) {
|
* @param {import('../objects/ObjectAPI').DomainObject} existingAnnotation - An annotations to undelete (set _deleted to false)
|
||||||
this.openmct.objects.mutate(existingAnnotation, 'tags', []);
|
*/
|
||||||
|
unDeleteAnnotation(annotation) {
|
||||||
|
if (!annotation) {
|
||||||
|
throw new Error('Asked to undelete null annotation! 🙅♂️');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.openmct.objects.mutate(annotation, '_deleted', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#getMatchingTags(query) {
|
#getMatchingTags(query) {
|
||||||
@@ -266,16 +322,40 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
return modelAddedToResults;
|
return modelAddedToResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#combineSameTargets(results) {
|
||||||
|
const combinedResults = [];
|
||||||
|
results.forEach(currentAnnotation => {
|
||||||
|
const existingAnnotation = combinedResults.find((annotationToFind) => {
|
||||||
|
return _.isEqual(currentAnnotation.targets, annotationToFind.targets);
|
||||||
|
});
|
||||||
|
if (!existingAnnotation) {
|
||||||
|
combinedResults.push(currentAnnotation);
|
||||||
|
} else {
|
||||||
|
existingAnnotation.tags.push(...currentAnnotation.tags);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return combinedResults;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method searchForTags
|
* @method searchForTags
|
||||||
* @param {String} query A query to match against tags. E.g., "dr" will match the tags "drilling" and "driving"
|
* @param {String} query A query to match against tags. E.g., "dr" will match the tags "drilling" and "driving"
|
||||||
* @param {Object} abortController An optional abort method to stop the query
|
* @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
|
* @returns {Promise} returns a model of matching tags with their target domain objects attached
|
||||||
*/
|
*/
|
||||||
async searchForTags(query, abortController) {
|
async searchForTags(query, abortController) {
|
||||||
const matchingTagKeys = this.#getMatchingTags(query);
|
const matchingTagKeys = this.#getMatchingTags(query);
|
||||||
|
if (!matchingTagKeys.length) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
const searchResults = (await Promise.all(this.openmct.objects.search(matchingTagKeys, abortController, this.openmct.objects.SEARCH_TYPES.TAGS))).flat();
|
const searchResults = (await Promise.all(this.openmct.objects.search(matchingTagKeys, abortController, this.openmct.objects.SEARCH_TYPES.TAGS))).flat();
|
||||||
const appliedTagSearchResults = this.#addTagMetaInformationToResults(searchResults, matchingTagKeys);
|
const filteredDeletedResults = searchResults.filter((result) => {
|
||||||
|
return !(result._deleted);
|
||||||
|
});
|
||||||
|
const combinedSameTargets = this.#combineSameTargets(filteredDeletedResults);
|
||||||
|
const appliedTagSearchResults = this.#addTagMetaInformationToResults(combinedSameTargets, matchingTagKeys);
|
||||||
const appliedTargetsModels = await this.#addTargetModelsToResults(appliedTagSearchResults);
|
const appliedTargetsModels = await this.#addTargetModelsToResults(appliedTagSearchResults);
|
||||||
const resultsWithValidPath = appliedTargetsModels.filter(result => {
|
const resultsWithValidPath = appliedTargetsModels.filter(result => {
|
||||||
return this.openmct.objects.isReachable(result.targetModels?.[0]?.originalPath);
|
return this.openmct.objects.isReachable(result.targetModels?.[0]?.originalPath);
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ describe("The Annotation API", () => {
|
|||||||
openmct.startHeadless();
|
openmct.startHeadless();
|
||||||
});
|
});
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
openmct.objects.providers = {};
|
|
||||||
await resetApplicationState(openmct);
|
await resetApplicationState(openmct);
|
||||||
});
|
});
|
||||||
it("is defined", () => {
|
it("is defined", () => {
|
||||||
@@ -126,34 +125,44 @@ describe("The Annotation API", () => {
|
|||||||
|
|
||||||
describe("Tagging", () => {
|
describe("Tagging", () => {
|
||||||
it("can create a tag", async () => {
|
it("can create a tag", async () => {
|
||||||
const annotationObject = await openmct.annotation.addAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
const annotationObject = await openmct.annotation.addSingleAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
||||||
expect(annotationObject).toBeDefined();
|
expect(annotationObject).toBeDefined();
|
||||||
expect(annotationObject.type).toEqual('annotation');
|
expect(annotationObject.type).toEqual('annotation');
|
||||||
expect(annotationObject.tags).toContain('aWonderfulTag');
|
expect(annotationObject.tags).toContain('aWonderfulTag');
|
||||||
});
|
});
|
||||||
it("can delete a tag", async () => {
|
it("can delete a tag", async () => {
|
||||||
const originalAnnotationObject = await openmct.annotation.addAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
const annotationObject = await openmct.annotation.addSingleAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
||||||
const annotationObject = await openmct.annotation.addAnnotationTag(originalAnnotationObject, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'anotherTagToRemove');
|
|
||||||
expect(annotationObject).toBeDefined();
|
expect(annotationObject).toBeDefined();
|
||||||
openmct.annotation.removeAnnotationTag(annotationObject, 'anotherTagToRemove');
|
openmct.annotation.deleteAnnotations([annotationObject]);
|
||||||
expect(annotationObject.tags).toEqual(['aWonderfulTag']);
|
expect(annotationObject._deleted).toBeTrue();
|
||||||
openmct.annotation.removeAnnotationTag(annotationObject, 'aWonderfulTag');
|
|
||||||
expect(annotationObject.tags).toEqual([]);
|
|
||||||
});
|
});
|
||||||
it("throws an error if deleting non-existent tag", async () => {
|
it("throws an error if deleting non-existent tag", async () => {
|
||||||
const annotationObject = await openmct.annotation.addAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
const annotationObject = await openmct.annotation.addSingleAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
||||||
expect(annotationObject).toBeDefined();
|
expect(annotationObject).toBeDefined();
|
||||||
expect(() => {
|
expect(() => {
|
||||||
openmct.annotation.removeAnnotationTag(annotationObject, 'ThisTagShouldNotExist');
|
openmct.annotation.removeAnnotationTag(annotationObject, 'ThisTagShouldNotExist');
|
||||||
}).toThrow();
|
}).toThrow();
|
||||||
});
|
});
|
||||||
it("can remove all tags", async () => {
|
it("can remove all tags", async () => {
|
||||||
const annotationObject = await openmct.annotation.addAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
const annotationObject = await openmct.annotation.addSingleAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
||||||
expect(annotationObject).toBeDefined();
|
expect(annotationObject).toBeDefined();
|
||||||
expect(() => {
|
expect(() => {
|
||||||
openmct.annotation.removeAnnotationTags(annotationObject);
|
openmct.annotation.deleteAnnotations([annotationObject]);
|
||||||
}).not.toThrow();
|
}).not.toThrow();
|
||||||
expect(annotationObject.tags).toEqual([]);
|
expect(annotationObject._deleted).toBeTrue();
|
||||||
|
});
|
||||||
|
it("can add/delete/add a tag", async () => {
|
||||||
|
let annotationObject = await openmct.annotation.addSingleAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
||||||
|
expect(annotationObject).toBeDefined();
|
||||||
|
expect(annotationObject.type).toEqual('annotation');
|
||||||
|
expect(annotationObject.tags).toContain('aWonderfulTag');
|
||||||
|
openmct.annotation.deleteAnnotations([annotationObject]);
|
||||||
|
expect(annotationObject._deleted).toBeTrue();
|
||||||
|
annotationObject = await openmct.annotation.addSingleAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
||||||
|
expect(annotationObject).toBeDefined();
|
||||||
|
expect(annotationObject.type).toEqual('annotation');
|
||||||
|
expect(annotationObject.tags).toContain('aWonderfulTag');
|
||||||
|
expect(annotationObject._deleted).toBeFalse();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -175,16 +184,10 @@ describe("The Annotation API", () => {
|
|||||||
expect(results).toBeDefined();
|
expect(results).toBeDefined();
|
||||||
expect(results.length).toEqual(1);
|
expect(results.length).toEqual(1);
|
||||||
});
|
});
|
||||||
it("can get notebook annotations", async () => {
|
it("returns no tags for empty search", async () => {
|
||||||
const targetKeyString = openmct.objects.makeKeyString(mockDomainObject.identifier);
|
const results = await openmct.annotation.searchForTags('q');
|
||||||
const query = {
|
|
||||||
targetKeyString,
|
|
||||||
entryId: 'fooBarEntry'
|
|
||||||
};
|
|
||||||
|
|
||||||
const results = await openmct.annotation.getAnnotation(query, openmct.objects.SEARCH_TYPES.NOTEBOOK_ANNOTATIONS);
|
|
||||||
expect(results).toBeDefined();
|
expect(results).toBeDefined();
|
||||||
expect(results.tags.length).toEqual(2);
|
expect(results.length).toEqual(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ define([
|
|||||||
'./types/TypeRegistry',
|
'./types/TypeRegistry',
|
||||||
'./user/UserAPI',
|
'./user/UserAPI',
|
||||||
'./annotation/AnnotationAPI'
|
'./annotation/AnnotationAPI'
|
||||||
], function (
|
],
|
||||||
|
|
||||||
|
function (
|
||||||
ActionsAPI,
|
ActionsAPI,
|
||||||
CompositionAPI,
|
CompositionAPI,
|
||||||
EditorAPI,
|
EditorAPI,
|
||||||
|
|||||||
@@ -20,34 +20,41 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
define([
|
import DefaultCompositionProvider from './DefaultCompositionProvider';
|
||||||
'lodash',
|
import CompositionCollection from './CompositionCollection';
|
||||||
'EventEmitter',
|
|
||||||
'./DefaultCompositionProvider',
|
/**
|
||||||
'./CompositionCollection'
|
* @typedef {import('./CompositionProvider').default} CompositionProvider
|
||||||
], function (
|
*/
|
||||||
_,
|
|
||||||
EventEmitter,
|
/**
|
||||||
DefaultCompositionProvider,
|
* @typedef {import('../objects/ObjectAPI').DomainObject} DomainObject
|
||||||
CompositionCollection
|
*/
|
||||||
) {
|
|
||||||
|
/**
|
||||||
|
* @typedef {import('../../../openmct').OpenMCT} OpenMCT
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An interface for interacting with the composition of domain objects.
|
||||||
|
* The composition of a domain object is the list of other domain objects
|
||||||
|
* it "contains" (for instance, that should be displayed beneath it
|
||||||
|
* in the tree.)
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
export default class CompositionAPI {
|
||||||
/**
|
/**
|
||||||
* An interface for interacting with the composition of domain objects.
|
* @param {OpenMCT} publicAPI
|
||||||
* The composition of a domain object is the list of other domain objects
|
|
||||||
* it "contains" (for instance, that should be displayed beneath it
|
|
||||||
* in the tree.)
|
|
||||||
*
|
|
||||||
* @interface CompositionAPI
|
|
||||||
* @returns {module:openmct.CompositionCollection}
|
|
||||||
* @memberof module:openmct
|
|
||||||
*/
|
*/
|
||||||
function CompositionAPI(publicAPI) {
|
constructor(publicAPI) {
|
||||||
|
/** @type {CompositionProvider[]} */
|
||||||
this.registry = [];
|
this.registry = [];
|
||||||
|
/** @type {CompositionPolicy[]} */
|
||||||
this.policies = [];
|
this.policies = [];
|
||||||
this.addProvider(new DefaultCompositionProvider(publicAPI, this));
|
this.addProvider(new DefaultCompositionProvider(publicAPI, this));
|
||||||
|
/** @type {OpenMCT} */
|
||||||
this.publicAPI = publicAPI;
|
this.publicAPI = publicAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a composition provider.
|
* Add a composition provider.
|
||||||
*
|
*
|
||||||
@@ -55,21 +62,19 @@ define([
|
|||||||
* behavior for certain domain objects.
|
* behavior for certain domain objects.
|
||||||
*
|
*
|
||||||
* @method addProvider
|
* @method addProvider
|
||||||
* @param {module:openmct.CompositionProvider} provider the provider to add
|
* @param {CompositionProvider} provider the provider to add
|
||||||
* @memberof module:openmct.CompositionAPI#
|
|
||||||
*/
|
*/
|
||||||
CompositionAPI.prototype.addProvider = function (provider) {
|
addProvider(provider) {
|
||||||
this.registry.unshift(provider);
|
this.registry.unshift(provider);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the composition (if any) of this domain object.
|
* Retrieve the composition (if any) of this domain object.
|
||||||
*
|
*
|
||||||
* @method get
|
* @method get
|
||||||
* @returns {module:openmct.CompositionCollection}
|
* @param {DomainObject} domainObject
|
||||||
* @memberof module:openmct.CompositionAPI#
|
* @returns {CompositionCollection}
|
||||||
*/
|
*/
|
||||||
CompositionAPI.prototype.get = function (domainObject) {
|
get(domainObject) {
|
||||||
const provider = this.registry.find(p => {
|
const provider = this.registry.find(p => {
|
||||||
return p.appliesTo(domainObject);
|
return p.appliesTo(domainObject);
|
||||||
});
|
});
|
||||||
@@ -79,8 +84,7 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new CompositionCollection(domainObject, provider, this.publicAPI);
|
return new CompositionCollection(domainObject, provider, this.publicAPI);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A composition policy is a function which either allows or disallows
|
* A composition policy is a function which either allows or disallows
|
||||||
* placing one object in another's composition.
|
* placing one object in another's composition.
|
||||||
@@ -90,52 +94,51 @@ define([
|
|||||||
* generally be written to return true in the default case.
|
* generally be written to return true in the default case.
|
||||||
*
|
*
|
||||||
* @callback CompositionPolicy
|
* @callback CompositionPolicy
|
||||||
* @memberof module:openmct.CompositionAPI~
|
* @param {DomainObject} containingObject the object which
|
||||||
* @param {module:openmct.DomainObject} containingObject the object which
|
|
||||||
* would act as a container
|
* would act as a container
|
||||||
* @param {module:openmct.DomainObject} containedObject the object which
|
* @param {DomainObject} containedObject the object which
|
||||||
* would be contained
|
* would be contained
|
||||||
* @returns {boolean} false if this composition should be disallowed
|
* @returns {boolean} false if this composition should be disallowed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a composition policy. Composition policies may disallow domain
|
* Add a composition policy. Composition policies may disallow domain
|
||||||
* objects from containing other domain objects.
|
* objects from containing other domain objects.
|
||||||
*
|
*
|
||||||
* @method addPolicy
|
* @method addPolicy
|
||||||
* @param {module:openmct.CompositionAPI~CompositionPolicy} policy
|
* @param {CompositionPolicy} policy
|
||||||
* the policy to add
|
* the policy to add
|
||||||
* @memberof module:openmct.CompositionAPI#
|
|
||||||
*/
|
*/
|
||||||
CompositionAPI.prototype.addPolicy = function (policy) {
|
addPolicy(policy) {
|
||||||
this.policies.push(policy);
|
this.policies.push(policy);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether or not a domain object is allowed to contain another
|
* Check whether or not a domain object is allowed to contain another
|
||||||
* domain object.
|
* domain object.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @method checkPolicy
|
* @method checkPolicy
|
||||||
* @param {module:openmct.DomainObject} containingObject the object which
|
* @param {DomainObject} container the object which
|
||||||
* would act as a container
|
* would act as a container
|
||||||
* @param {module:openmct.DomainObject} containedObject the object which
|
* @param {DomainObject} containee the object which
|
||||||
* would be contained
|
* would be contained
|
||||||
* @returns {boolean} false if this composition should be disallowed
|
* @returns {boolean} false if this composition should be disallowed
|
||||||
|
* @param {CompositionPolicy} policy
|
||||||
* @param {module:openmct.CompositionAPI~CompositionPolicy} policy
|
|
||||||
* the policy to add
|
* the policy to add
|
||||||
* @memberof module:openmct.CompositionAPI#
|
|
||||||
*/
|
*/
|
||||||
CompositionAPI.prototype.checkPolicy = function (container, containee) {
|
checkPolicy(container, containee) {
|
||||||
return this.policies.every(function (policy) {
|
return this.policies.every(function (policy) {
|
||||||
return policy(container, containee);
|
return policy(container, containee);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
CompositionAPI.prototype.supportsComposition = function (domainObject) {
|
/**
|
||||||
|
* Check whether or not a domainObject supports composition
|
||||||
|
*
|
||||||
|
* @param {DomainObject} domainObject
|
||||||
|
* @returns {boolean} true if the domainObject supports composition
|
||||||
|
*/
|
||||||
|
supportsComposition(domainObject) {
|
||||||
return this.get(domainObject) !== undefined;
|
return this.get(domainObject) !== undefined;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return CompositionAPI;
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -1,325 +1,319 @@
|
|||||||
define([
|
import CompositionAPI from './CompositionAPI';
|
||||||
'./CompositionAPI',
|
import CompositionCollection from './CompositionCollection';
|
||||||
'./CompositionCollection'
|
|
||||||
], function (
|
|
||||||
CompositionAPI,
|
|
||||||
CompositionCollection
|
|
||||||
) {
|
|
||||||
|
|
||||||
describe('The Composition API', function () {
|
describe('The Composition API', function () {
|
||||||
let publicAPI;
|
let publicAPI;
|
||||||
let compositionAPI;
|
let compositionAPI;
|
||||||
let topicService;
|
let topicService;
|
||||||
let mutationTopic;
|
let mutationTopic;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
|
||||||
|
mutationTopic = jasmine.createSpyObj('mutationTopic', [
|
||||||
|
'listen'
|
||||||
|
]);
|
||||||
|
topicService = jasmine.createSpy('topicService');
|
||||||
|
topicService.and.returnValue(mutationTopic);
|
||||||
|
publicAPI = {};
|
||||||
|
publicAPI.objects = jasmine.createSpyObj('ObjectAPI', [
|
||||||
|
'get',
|
||||||
|
'mutate',
|
||||||
|
'observe',
|
||||||
|
'areIdsEqual'
|
||||||
|
]);
|
||||||
|
|
||||||
|
publicAPI.objects.areIdsEqual.and.callFake(function (id1, id2) {
|
||||||
|
return id1.namespace === id2.namespace && id1.key === id2.key;
|
||||||
|
});
|
||||||
|
|
||||||
|
publicAPI.composition = jasmine.createSpyObj('CompositionAPI', [
|
||||||
|
'checkPolicy'
|
||||||
|
]);
|
||||||
|
publicAPI.composition.checkPolicy.and.returnValue(true);
|
||||||
|
|
||||||
|
publicAPI.objects.eventEmitter = jasmine.createSpyObj('eventemitter', [
|
||||||
|
'on'
|
||||||
|
]);
|
||||||
|
publicAPI.objects.get.and.callFake(function (identifier) {
|
||||||
|
return Promise.resolve({identifier: identifier});
|
||||||
|
});
|
||||||
|
publicAPI.$injector = jasmine.createSpyObj('$injector', [
|
||||||
|
'get'
|
||||||
|
]);
|
||||||
|
publicAPI.$injector.get.and.returnValue(topicService);
|
||||||
|
compositionAPI = new CompositionAPI(publicAPI);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns falsy if an object does not support composition', function () {
|
||||||
|
expect(compositionAPI.get({})).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('default composition', function () {
|
||||||
|
let domainObject;
|
||||||
|
let composition;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
domainObject = {
|
||||||
mutationTopic = jasmine.createSpyObj('mutationTopic', [
|
name: 'test folder',
|
||||||
'listen'
|
identifier: {
|
||||||
]);
|
namespace: 'test',
|
||||||
topicService = jasmine.createSpy('topicService');
|
key: '1'
|
||||||
topicService.and.returnValue(mutationTopic);
|
},
|
||||||
publicAPI = {};
|
composition: [
|
||||||
publicAPI.objects = jasmine.createSpyObj('ObjectAPI', [
|
{
|
||||||
'get',
|
namespace: 'test',
|
||||||
'mutate',
|
key: 'a'
|
||||||
'observe',
|
},
|
||||||
'areIdsEqual'
|
{
|
||||||
]);
|
namespace: 'test',
|
||||||
|
key: 'b'
|
||||||
publicAPI.objects.areIdsEqual.and.callFake(function (id1, id2) {
|
},
|
||||||
return id1.namespace === id2.namespace && id1.key === id2.key;
|
{
|
||||||
});
|
namespace: 'test',
|
||||||
|
key: 'c'
|
||||||
publicAPI.composition = jasmine.createSpyObj('CompositionAPI', [
|
}
|
||||||
'checkPolicy'
|
]
|
||||||
]);
|
};
|
||||||
publicAPI.composition.checkPolicy.and.returnValue(true);
|
composition = compositionAPI.get(domainObject);
|
||||||
|
|
||||||
publicAPI.objects.eventEmitter = jasmine.createSpyObj('eventemitter', [
|
|
||||||
'on'
|
|
||||||
]);
|
|
||||||
publicAPI.objects.get.and.callFake(function (identifier) {
|
|
||||||
return Promise.resolve({identifier: identifier});
|
|
||||||
});
|
|
||||||
publicAPI.$injector = jasmine.createSpyObj('$injector', [
|
|
||||||
'get'
|
|
||||||
]);
|
|
||||||
publicAPI.$injector.get.and.returnValue(topicService);
|
|
||||||
compositionAPI = new CompositionAPI(publicAPI);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns falsy if an object does not support composition', function () {
|
it('returns composition collection', function () {
|
||||||
expect(compositionAPI.get({})).toBeFalsy();
|
expect(composition).toBeDefined();
|
||||||
|
expect(composition).toEqual(jasmine.any(CompositionCollection));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('default composition', function () {
|
it('correctly reflects composability', function () {
|
||||||
let domainObject;
|
expect(compositionAPI.supportsComposition(domainObject)).toBe(true);
|
||||||
let composition;
|
delete domainObject.composition;
|
||||||
|
expect(compositionAPI.supportsComposition(domainObject)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
it('loads composition from domain object', function () {
|
||||||
domainObject = {
|
const listener = jasmine.createSpy('addListener');
|
||||||
name: 'test folder',
|
composition.on('add', listener);
|
||||||
|
|
||||||
|
return composition.load().then(function () {
|
||||||
|
expect(listener.calls.count()).toBe(3);
|
||||||
|
expect(listener).toHaveBeenCalledWith({
|
||||||
identifier: {
|
identifier: {
|
||||||
namespace: 'test',
|
namespace: 'test',
|
||||||
key: '1'
|
key: 'a'
|
||||||
},
|
}
|
||||||
composition: [
|
|
||||||
{
|
|
||||||
namespace: 'test',
|
|
||||||
key: 'a'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
namespace: 'test',
|
|
||||||
key: 'b'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
namespace: 'test',
|
|
||||||
key: 'c'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
composition = compositionAPI.get(domainObject);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns composition collection', function () {
|
|
||||||
expect(composition).toBeDefined();
|
|
||||||
expect(composition).toEqual(jasmine.any(CompositionCollection));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('correctly reflects composability', function () {
|
|
||||||
expect(compositionAPI.supportsComposition(domainObject)).toBe(true);
|
|
||||||
delete domainObject.composition;
|
|
||||||
expect(compositionAPI.supportsComposition(domainObject)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('loads composition from domain object', function () {
|
|
||||||
const listener = jasmine.createSpy('addListener');
|
|
||||||
composition.on('add', listener);
|
|
||||||
|
|
||||||
return composition.load().then(function () {
|
|
||||||
expect(listener.calls.count()).toBe(3);
|
|
||||||
expect(listener).toHaveBeenCalledWith({
|
|
||||||
identifier: {
|
|
||||||
namespace: 'test',
|
|
||||||
key: 'a'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('supports reordering of composition', function () {
|
});
|
||||||
let listener;
|
describe('supports reordering of composition', function () {
|
||||||
beforeEach(function () {
|
let listener;
|
||||||
listener = jasmine.createSpy('reorderListener');
|
beforeEach(function () {
|
||||||
composition.on('reorder', listener);
|
listener = jasmine.createSpy('reorderListener');
|
||||||
|
composition.on('reorder', listener);
|
||||||
|
|
||||||
return composition.load();
|
return composition.load();
|
||||||
});
|
});
|
||||||
it('', function () {
|
it('', function () {
|
||||||
composition.reorder(1, 0);
|
composition.reorder(1, 0);
|
||||||
let newComposition =
|
let newComposition =
|
||||||
publicAPI.objects.mutate.calls.mostRecent().args[2];
|
publicAPI.objects.mutate.calls.mostRecent().args[2];
|
||||||
let reorderPlan = listener.calls.mostRecent().args[0][0];
|
let reorderPlan = listener.calls.mostRecent().args[0][0];
|
||||||
|
|
||||||
expect(reorderPlan.oldIndex).toBe(1);
|
expect(reorderPlan.oldIndex).toBe(1);
|
||||||
expect(reorderPlan.newIndex).toBe(0);
|
expect(reorderPlan.newIndex).toBe(0);
|
||||||
expect(newComposition[0].key).toEqual('b');
|
expect(newComposition[0].key).toEqual('b');
|
||||||
expect(newComposition[1].key).toEqual('a');
|
expect(newComposition[1].key).toEqual('a');
|
||||||
expect(newComposition[2].key).toEqual('c');
|
expect(newComposition[2].key).toEqual('c');
|
||||||
});
|
});
|
||||||
it('', function () {
|
it('', function () {
|
||||||
composition.reorder(0, 2);
|
composition.reorder(0, 2);
|
||||||
let newComposition =
|
let newComposition =
|
||||||
publicAPI.objects.mutate.calls.mostRecent().args[2];
|
publicAPI.objects.mutate.calls.mostRecent().args[2];
|
||||||
let reorderPlan = listener.calls.mostRecent().args[0][0];
|
let reorderPlan = listener.calls.mostRecent().args[0][0];
|
||||||
|
|
||||||
expect(reorderPlan.oldIndex).toBe(0);
|
expect(reorderPlan.oldIndex).toBe(0);
|
||||||
expect(reorderPlan.newIndex).toBe(2);
|
expect(reorderPlan.newIndex).toBe(2);
|
||||||
expect(newComposition[0].key).toEqual('b');
|
expect(newComposition[0].key).toEqual('b');
|
||||||
expect(newComposition[1].key).toEqual('c');
|
expect(newComposition[1].key).toEqual('c');
|
||||||
expect(newComposition[2].key).toEqual('a');
|
expect(newComposition[2].key).toEqual('a');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('supports adding an object to composition', function () {
|
||||||
|
let addListener = jasmine.createSpy('addListener');
|
||||||
|
let mockChildObject = {
|
||||||
|
identifier: {
|
||||||
|
key: 'mock-key',
|
||||||
|
namespace: ''
|
||||||
|
}
|
||||||
|
};
|
||||||
|
composition.on('add', addListener);
|
||||||
|
composition.add(mockChildObject);
|
||||||
|
|
||||||
|
expect(domainObject.composition.length).toBe(4);
|
||||||
|
expect(domainObject.composition[3]).toEqual(mockChildObject.identifier);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('static custom composition', function () {
|
||||||
|
let customProvider;
|
||||||
|
let domainObject;
|
||||||
|
let composition;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
// A simple custom provider, returns the same composition for
|
||||||
|
// all objects of a given type.
|
||||||
|
customProvider = {
|
||||||
|
appliesTo: function (object) {
|
||||||
|
return object.type === 'custom-object-type';
|
||||||
|
},
|
||||||
|
load: function (object) {
|
||||||
|
return Promise.resolve([
|
||||||
|
{
|
||||||
|
namespace: 'custom',
|
||||||
|
key: 'thing'
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
add: jasmine.createSpy('add'),
|
||||||
|
remove: jasmine.createSpy('remove')
|
||||||
|
};
|
||||||
|
domainObject = {
|
||||||
|
identifier: {
|
||||||
|
namespace: 'test',
|
||||||
|
key: '1'
|
||||||
|
},
|
||||||
|
type: 'custom-object-type'
|
||||||
|
};
|
||||||
|
compositionAPI.addProvider(customProvider);
|
||||||
|
composition = compositionAPI.get(domainObject);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('supports listening and loading', function () {
|
||||||
|
const addListener = jasmine.createSpy('addListener');
|
||||||
|
composition.on('add', addListener);
|
||||||
|
|
||||||
|
return composition.load().then(function (children) {
|
||||||
|
let listenObject;
|
||||||
|
const loadedObject = children[0];
|
||||||
|
|
||||||
|
expect(addListener).toHaveBeenCalled();
|
||||||
|
|
||||||
|
listenObject = addListener.calls.mostRecent().args[0];
|
||||||
|
expect(listenObject).toEqual(loadedObject);
|
||||||
|
expect(loadedObject).toEqual({
|
||||||
|
identifier: {
|
||||||
|
namespace: 'custom',
|
||||||
|
key: 'thing'
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('supports adding an object to composition', function () {
|
});
|
||||||
let addListener = jasmine.createSpy('addListener');
|
describe('Calling add or remove', function () {
|
||||||
let mockChildObject = {
|
let mockChildObject;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
mockChildObject = {
|
||||||
identifier: {
|
identifier: {
|
||||||
key: 'mock-key',
|
key: 'mock-key',
|
||||||
namespace: ''
|
namespace: ''
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
composition.on('add', addListener);
|
|
||||||
composition.add(mockChildObject);
|
composition.add(mockChildObject);
|
||||||
|
|
||||||
expect(domainObject.composition.length).toBe(4);
|
|
||||||
expect(domainObject.composition[3]).toEqual(mockChildObject.identifier);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('static custom composition', function () {
|
|
||||||
let customProvider;
|
|
||||||
let domainObject;
|
|
||||||
let composition;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
// A simple custom provider, returns the same composition for
|
|
||||||
// all objects of a given type.
|
|
||||||
customProvider = {
|
|
||||||
appliesTo: function (object) {
|
|
||||||
return object.type === 'custom-object-type';
|
|
||||||
},
|
|
||||||
load: function (object) {
|
|
||||||
return Promise.resolve([
|
|
||||||
{
|
|
||||||
namespace: 'custom',
|
|
||||||
key: 'thing'
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
},
|
|
||||||
add: jasmine.createSpy('add'),
|
|
||||||
remove: jasmine.createSpy('remove')
|
|
||||||
};
|
|
||||||
domainObject = {
|
|
||||||
identifier: {
|
|
||||||
namespace: 'test',
|
|
||||||
key: '1'
|
|
||||||
},
|
|
||||||
type: 'custom-object-type'
|
|
||||||
};
|
|
||||||
compositionAPI.addProvider(customProvider);
|
|
||||||
composition = compositionAPI.get(domainObject);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('supports listening and loading', function () {
|
it('calls add on the provider', function () {
|
||||||
const addListener = jasmine.createSpy('addListener');
|
expect(customProvider.add).toHaveBeenCalledWith(domainObject, mockChildObject.identifier);
|
||||||
composition.on('add', addListener);
|
|
||||||
|
|
||||||
return composition.load().then(function (children) {
|
|
||||||
let listenObject;
|
|
||||||
const loadedObject = children[0];
|
|
||||||
|
|
||||||
expect(addListener).toHaveBeenCalled();
|
|
||||||
|
|
||||||
listenObject = addListener.calls.mostRecent().args[0];
|
|
||||||
expect(listenObject).toEqual(loadedObject);
|
|
||||||
expect(loadedObject).toEqual({
|
|
||||||
identifier: {
|
|
||||||
namespace: 'custom',
|
|
||||||
key: 'thing'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('Calling add or remove', function () {
|
|
||||||
let mockChildObject;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
mockChildObject = {
|
|
||||||
identifier: {
|
|
||||||
key: 'mock-key',
|
|
||||||
namespace: ''
|
|
||||||
}
|
|
||||||
};
|
|
||||||
composition.add(mockChildObject);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('calls add on the provider', function () {
|
|
||||||
expect(customProvider.add).toHaveBeenCalledWith(domainObject, mockChildObject.identifier);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('calls remove on the provider', function () {
|
|
||||||
composition.remove(mockChildObject);
|
|
||||||
expect(customProvider.remove).toHaveBeenCalledWith(domainObject, mockChildObject.identifier);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('dynamic custom composition', function () {
|
|
||||||
let customProvider;
|
|
||||||
let domainObject;
|
|
||||||
let composition;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
// A dynamic provider, loads an empty composition and exposes
|
|
||||||
// listener functions.
|
|
||||||
customProvider = jasmine.createSpyObj('dynamicProvider', [
|
|
||||||
'appliesTo',
|
|
||||||
'load',
|
|
||||||
'on',
|
|
||||||
'off'
|
|
||||||
]);
|
|
||||||
|
|
||||||
customProvider.appliesTo.and.returnValue('true');
|
|
||||||
customProvider.load.and.returnValue(Promise.resolve([]));
|
|
||||||
|
|
||||||
domainObject = {
|
|
||||||
identifier: {
|
|
||||||
namespace: 'test',
|
|
||||||
key: '1'
|
|
||||||
},
|
|
||||||
type: 'custom-object-type'
|
|
||||||
};
|
|
||||||
compositionAPI.addProvider(customProvider);
|
|
||||||
composition = compositionAPI.get(domainObject);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('supports listening and loading', function () {
|
it('calls remove on the provider', function () {
|
||||||
const addListener = jasmine.createSpy('addListener');
|
composition.remove(mockChildObject);
|
||||||
const removeListener = jasmine.createSpy('removeListener');
|
expect(customProvider.remove).toHaveBeenCalledWith(domainObject, mockChildObject.identifier);
|
||||||
const addPromise = new Promise(function (resolve) {
|
|
||||||
addListener.and.callFake(resolve);
|
|
||||||
});
|
|
||||||
const removePromise = new Promise(function (resolve) {
|
|
||||||
removeListener.and.callFake(resolve);
|
|
||||||
});
|
|
||||||
|
|
||||||
composition.on('add', addListener);
|
|
||||||
composition.on('remove', removeListener);
|
|
||||||
|
|
||||||
expect(customProvider.on).toHaveBeenCalledWith(
|
|
||||||
domainObject,
|
|
||||||
'add',
|
|
||||||
jasmine.any(Function),
|
|
||||||
jasmine.any(CompositionCollection)
|
|
||||||
);
|
|
||||||
expect(customProvider.on).toHaveBeenCalledWith(
|
|
||||||
domainObject,
|
|
||||||
'remove',
|
|
||||||
jasmine.any(Function),
|
|
||||||
jasmine.any(CompositionCollection)
|
|
||||||
);
|
|
||||||
const add = customProvider.on.calls.all()[0].args[2];
|
|
||||||
const remove = customProvider.on.calls.all()[1].args[2];
|
|
||||||
|
|
||||||
return composition.load()
|
|
||||||
.then(function () {
|
|
||||||
expect(addListener).not.toHaveBeenCalled();
|
|
||||||
expect(removeListener).not.toHaveBeenCalled();
|
|
||||||
add({
|
|
||||||
namespace: 'custom',
|
|
||||||
key: 'thing'
|
|
||||||
});
|
|
||||||
|
|
||||||
return addPromise;
|
|
||||||
}).then(function () {
|
|
||||||
expect(addListener).toHaveBeenCalledWith({
|
|
||||||
identifier: {
|
|
||||||
namespace: 'custom',
|
|
||||||
key: 'thing'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
remove(addListener.calls.mostRecent().args[0]);
|
|
||||||
|
|
||||||
return removePromise;
|
|
||||||
}).then(function () {
|
|
||||||
expect(removeListener).toHaveBeenCalledWith({
|
|
||||||
identifier: {
|
|
||||||
namespace: 'custom',
|
|
||||||
key: 'thing'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('dynamic custom composition', function () {
|
||||||
|
let customProvider;
|
||||||
|
let domainObject;
|
||||||
|
let composition;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
// A dynamic provider, loads an empty composition and exposes
|
||||||
|
// listener functions.
|
||||||
|
customProvider = jasmine.createSpyObj('dynamicProvider', [
|
||||||
|
'appliesTo',
|
||||||
|
'load',
|
||||||
|
'on',
|
||||||
|
'off'
|
||||||
|
]);
|
||||||
|
|
||||||
|
customProvider.appliesTo.and.returnValue('true');
|
||||||
|
customProvider.load.and.returnValue(Promise.resolve([]));
|
||||||
|
|
||||||
|
domainObject = {
|
||||||
|
identifier: {
|
||||||
|
namespace: 'test',
|
||||||
|
key: '1'
|
||||||
|
},
|
||||||
|
type: 'custom-object-type'
|
||||||
|
};
|
||||||
|
compositionAPI.addProvider(customProvider);
|
||||||
|
composition = compositionAPI.get(domainObject);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('supports listening and loading', function () {
|
||||||
|
const addListener = jasmine.createSpy('addListener');
|
||||||
|
const removeListener = jasmine.createSpy('removeListener');
|
||||||
|
const addPromise = new Promise(function (resolve) {
|
||||||
|
addListener.and.callFake(resolve);
|
||||||
|
});
|
||||||
|
const removePromise = new Promise(function (resolve) {
|
||||||
|
removeListener.and.callFake(resolve);
|
||||||
|
});
|
||||||
|
|
||||||
|
composition.on('add', addListener);
|
||||||
|
composition.on('remove', removeListener);
|
||||||
|
|
||||||
|
expect(customProvider.on).toHaveBeenCalledWith(
|
||||||
|
domainObject,
|
||||||
|
'add',
|
||||||
|
jasmine.any(Function),
|
||||||
|
jasmine.any(CompositionCollection)
|
||||||
|
);
|
||||||
|
expect(customProvider.on).toHaveBeenCalledWith(
|
||||||
|
domainObject,
|
||||||
|
'remove',
|
||||||
|
jasmine.any(Function),
|
||||||
|
jasmine.any(CompositionCollection)
|
||||||
|
);
|
||||||
|
const add = customProvider.on.calls.all()[0].args[2];
|
||||||
|
const remove = customProvider.on.calls.all()[1].args[2];
|
||||||
|
|
||||||
|
return composition.load()
|
||||||
|
.then(function () {
|
||||||
|
expect(addListener).not.toHaveBeenCalled();
|
||||||
|
expect(removeListener).not.toHaveBeenCalled();
|
||||||
|
add({
|
||||||
|
namespace: 'custom',
|
||||||
|
key: 'thing'
|
||||||
|
});
|
||||||
|
|
||||||
|
return addPromise;
|
||||||
|
}).then(function () {
|
||||||
|
expect(addListener).toHaveBeenCalledWith({
|
||||||
|
identifier: {
|
||||||
|
namespace: 'custom',
|
||||||
|
key: 'thing'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
remove(addListener.calls.mostRecent().args[0]);
|
||||||
|
|
||||||
|
return removePromise;
|
||||||
|
}).then(function () {
|
||||||
|
expect(removeListener).toHaveBeenCalledWith({
|
||||||
|
identifier: {
|
||||||
|
namespace: 'custom',
|
||||||
|
key: 'thing'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,75 +20,98 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
define([
|
/**
|
||||||
'lodash'
|
* @typedef {import('../objects/ObjectAPI').DomainObject} DomainObject
|
||||||
], function (
|
*/
|
||||||
_
|
|
||||||
) {
|
/**
|
||||||
|
* @typedef {import('./CompositionAPI').default} CompositionAPI
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {import('../../../openmct').OpenMCT} OpenMCT
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} ListenerMap
|
||||||
|
* @property {Array.<any>} add
|
||||||
|
* @property {Array.<any>} remove
|
||||||
|
* @property {Array.<any>} load
|
||||||
|
* @property {Array.<any>} reorder
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A CompositionCollection represents the list of domain objects contained
|
||||||
|
* by another domain object. It provides methods for loading this
|
||||||
|
* list asynchronously, modifying this list, and listening for changes to
|
||||||
|
* this list.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* ```javascript
|
||||||
|
* var myViewComposition = MCT.composition.get(myViewObject);
|
||||||
|
* myViewComposition.on('add', addObjectToView);
|
||||||
|
* myViewComposition.on('remove', removeObjectFromView);
|
||||||
|
* myViewComposition.load(); // will trigger `add` for all loaded objects.
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
export default class CompositionCollection {
|
||||||
|
domainObject;
|
||||||
|
#provider;
|
||||||
|
#publicAPI;
|
||||||
|
#listeners;
|
||||||
|
#mutables;
|
||||||
/**
|
/**
|
||||||
* A CompositionCollection represents the list of domain objects contained
|
* @constructor
|
||||||
* by another domain object. It provides methods for loading this
|
* @param {DomainObject} domainObject the domain object
|
||||||
* list asynchronously, modifying this list, and listening for changes to
|
|
||||||
* this list.
|
|
||||||
*
|
|
||||||
* Usage:
|
|
||||||
* ```javascript
|
|
||||||
* var myViewComposition = MCT.composition.get(myViewObject);
|
|
||||||
* myViewComposition.on('add', addObjectToView);
|
|
||||||
* myViewComposition.on('remove', removeObjectFromView);
|
|
||||||
* myViewComposition.load(); // will trigger `add` for all loaded objects.
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @interface CompositionCollection
|
|
||||||
* @param {module:openmct.DomainObject} domainObject the domain object
|
|
||||||
* whose composition will be contained
|
* whose composition will be contained
|
||||||
* @param {module:openmct.CompositionProvider} provider the provider
|
* @param {import('./CompositionProvider').default} provider the provider
|
||||||
* to use to retrieve other domain objects
|
* to use to retrieve other domain objects
|
||||||
* @param {module:openmct.CompositionAPI} api the composition API, for
|
* @param {OpenMCT} publicAPI the composition API, for
|
||||||
* policy checks
|
* policy checks
|
||||||
* @memberof module:openmct
|
|
||||||
*/
|
*/
|
||||||
function CompositionCollection(domainObject, provider, publicAPI) {
|
constructor(domainObject, provider, publicAPI) {
|
||||||
this.domainObject = domainObject;
|
this.domainObject = domainObject;
|
||||||
this.provider = provider;
|
/** @type {import('./CompositionProvider').default} */
|
||||||
this.publicAPI = publicAPI;
|
this.#provider = provider;
|
||||||
this.listeners = {
|
/** @type {OpenMCT} */
|
||||||
|
this.#publicAPI = publicAPI;
|
||||||
|
/** @type {ListenerMap} */
|
||||||
|
this.#listeners = {
|
||||||
add: [],
|
add: [],
|
||||||
remove: [],
|
remove: [],
|
||||||
load: [],
|
load: [],
|
||||||
reorder: []
|
reorder: []
|
||||||
};
|
};
|
||||||
this.onProviderAdd = this.onProviderAdd.bind(this);
|
this.onProviderAdd = this.#onProviderAdd.bind(this);
|
||||||
this.onProviderRemove = this.onProviderRemove.bind(this);
|
this.onProviderRemove = this.#onProviderRemove.bind(this);
|
||||||
this.mutables = {};
|
this.#mutables = {};
|
||||||
|
|
||||||
if (this.domainObject.isMutable) {
|
if (this.domainObject.isMutable) {
|
||||||
this.returnMutables = true;
|
this.returnMutables = true;
|
||||||
let unobserve = this.domainObject.$on('$_destroy', () => {
|
let unobserve = this.domainObject.$on('$_destroy', () => {
|
||||||
Object.values(this.mutables).forEach(mutable => {
|
Object.values(this.#mutables).forEach(mutable => {
|
||||||
this.publicAPI.objects.destroyMutable(mutable);
|
this.#publicAPI.objects.destroyMutable(mutable);
|
||||||
});
|
});
|
||||||
unobserve();
|
unobserve();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listen for changes to this composition. Supports 'add', 'remove', and
|
* Listen for changes to this composition. Supports 'add', 'remove', and
|
||||||
* 'load' events.
|
* 'load' events.
|
||||||
*
|
*
|
||||||
* @param event event to listen for, either 'add', 'remove' or 'load'.
|
* @param {string} event event to listen for, either 'add', 'remove' or 'load'.
|
||||||
* @param callback to trigger when event occurs.
|
* @param {(...args: any[]) => void} callback to trigger when event occurs.
|
||||||
* @param [context] context to use when invoking callback, optional.
|
* @param {any} [context] to use when invoking callback, optional.
|
||||||
*/
|
*/
|
||||||
CompositionCollection.prototype.on = function (event, callback, context) {
|
on(event, callback, context) {
|
||||||
if (!this.listeners[event]) {
|
if (!this.#listeners[event]) {
|
||||||
throw new Error('Event not supported by composition: ' + event);
|
throw new Error('Event not supported by composition: ' + event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.provider.on && this.provider.off) {
|
if (this.#provider.on && this.#provider.off) {
|
||||||
if (event === 'add') {
|
if (event === 'add') {
|
||||||
this.provider.on(
|
this.#provider.on(
|
||||||
this.domainObject,
|
this.domainObject,
|
||||||
'add',
|
'add',
|
||||||
this.onProviderAdd,
|
this.onProviderAdd,
|
||||||
@@ -97,7 +120,7 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event === 'remove') {
|
if (event === 'remove') {
|
||||||
this.provider.on(
|
this.#provider.on(
|
||||||
this.domainObject,
|
this.domainObject,
|
||||||
'remove',
|
'remove',
|
||||||
this.onProviderRemove,
|
this.onProviderRemove,
|
||||||
@@ -106,36 +129,34 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event === 'reorder') {
|
if (event === 'reorder') {
|
||||||
this.provider.on(
|
this.#provider.on(
|
||||||
this.domainObject,
|
this.domainObject,
|
||||||
'reorder',
|
'reorder',
|
||||||
this.onProviderReorder,
|
this.#onProviderReorder,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.listeners[event].push({
|
this.#listeners[event].push({
|
||||||
callback: callback,
|
callback: callback,
|
||||||
context: context
|
context: context
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a listener. Must be called with same exact parameters as
|
* Remove a listener. Must be called with same exact parameters as
|
||||||
* `off`.
|
* `off`.
|
||||||
*
|
*
|
||||||
* @param event
|
* @param {string} event
|
||||||
* @param callback
|
* @param {(...args: any[]) => void} callback
|
||||||
* @param [context]
|
* @param {any} [context]
|
||||||
*/
|
*/
|
||||||
|
off(event, callback, context) {
|
||||||
CompositionCollection.prototype.off = function (event, callback, context) {
|
if (!this.#listeners[event]) {
|
||||||
if (!this.listeners[event]) {
|
|
||||||
throw new Error('Event not supported by composition: ' + event);
|
throw new Error('Event not supported by composition: ' + event);
|
||||||
}
|
}
|
||||||
|
|
||||||
const index = this.listeners[event].findIndex(l => {
|
const index = this.#listeners[event].findIndex(l => {
|
||||||
return l.callback === callback && l.context === context;
|
return l.callback === callback && l.context === context;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -143,125 +164,116 @@ define([
|
|||||||
throw new Error('Tried to remove a listener that does not exist');
|
throw new Error('Tried to remove a listener that does not exist');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.listeners[event].splice(index, 1);
|
this.#listeners[event].splice(index, 1);
|
||||||
if (this.listeners[event].length === 0) {
|
if (this.#listeners[event].length === 0) {
|
||||||
this._destroy();
|
this._destroy();
|
||||||
|
|
||||||
// Remove provider listener if this is the last callback to
|
// Remove provider listener if this is the last callback to
|
||||||
// be removed.
|
// be removed.
|
||||||
if (this.provider.off && this.provider.on) {
|
if (this.#provider.off && this.#provider.on) {
|
||||||
if (event === 'add') {
|
if (event === 'add') {
|
||||||
this.provider.off(
|
this.#provider.off(
|
||||||
this.domainObject,
|
this.domainObject,
|
||||||
'add',
|
'add',
|
||||||
this.onProviderAdd,
|
this.onProviderAdd,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
} else if (event === 'remove') {
|
} else if (event === 'remove') {
|
||||||
this.provider.off(
|
this.#provider.off(
|
||||||
this.domainObject,
|
this.domainObject,
|
||||||
'remove',
|
'remove',
|
||||||
this.onProviderRemove,
|
this.onProviderRemove,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
} else if (event === 'reorder') {
|
} else if (event === 'reorder') {
|
||||||
this.provider.off(
|
this.#provider.off(
|
||||||
this.domainObject,
|
this.domainObject,
|
||||||
'reorder',
|
'reorder',
|
||||||
this.onProviderReorder,
|
this.#onProviderReorder,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a domain object to this composition.
|
* Add a domain object to this composition.
|
||||||
*
|
*
|
||||||
* A call to [load]{@link module:openmct.CompositionCollection#load}
|
* A call to [load]{@link module:openmct.CompositionCollection#load}
|
||||||
* must have resolved before using this method.
|
* must have resolved before using this method.
|
||||||
*
|
*
|
||||||
* @param {module:openmct.DomainObject} child the domain object to add
|
* **TODO:** Remove `skipMutate` parameter.
|
||||||
* @param {boolean} skipMutate true if the underlying provider should
|
*
|
||||||
* not be updated
|
* @param {DomainObject} child the domain object to add
|
||||||
* @memberof module:openmct.CompositionCollection#
|
* @param {boolean} skipMutate
|
||||||
* @name add
|
* **Intended for internal use ONLY.**
|
||||||
|
* true if the underlying provider should not be updated.
|
||||||
*/
|
*/
|
||||||
CompositionCollection.prototype.add = function (child, skipMutate) {
|
add(child, skipMutate) {
|
||||||
if (!skipMutate) {
|
if (!skipMutate) {
|
||||||
if (!this.publicAPI.composition.checkPolicy(this.domainObject, child)) {
|
if (!this.#publicAPI.composition.checkPolicy(this.domainObject, child)) {
|
||||||
throw `Object of type ${child.type} cannot be added to object of type ${this.domainObject.type}`;
|
throw `Object of type ${child.type} cannot be added to object of type ${this.domainObject.type}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.provider.add(this.domainObject, child.identifier);
|
this.#provider.add(this.domainObject, child.identifier);
|
||||||
} else {
|
} else {
|
||||||
if (this.returnMutables && this.publicAPI.objects.supportsMutation(child.identifier)) {
|
if (this.returnMutables && this.#publicAPI.objects.supportsMutation(child.identifier)) {
|
||||||
let keyString = this.publicAPI.objects.makeKeyString(child.identifier);
|
let keyString = this.#publicAPI.objects.makeKeyString(child.identifier);
|
||||||
|
|
||||||
child = this.publicAPI.objects._toMutable(child);
|
child = this.#publicAPI.objects.toMutable(child);
|
||||||
this.mutables[keyString] = child;
|
this.#mutables[keyString] = child;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emit('add', child);
|
this.#emit('add', child);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the domain objects in this composition.
|
* Load the domain objects in this composition.
|
||||||
*
|
*
|
||||||
* @returns {Promise.<Array.<module:openmct.DomainObject>>} a promise for
|
* @param {AbortSignal} abortSignal
|
||||||
|
* @returns {Promise.<Array.<DomainObject>>} a promise for
|
||||||
* the domain objects in this composition
|
* the domain objects in this composition
|
||||||
* @memberof {module:openmct.CompositionCollection#}
|
* @memberof {module:openmct.CompositionCollection#}
|
||||||
* @name load
|
* @name load
|
||||||
*/
|
*/
|
||||||
CompositionCollection.prototype.load = function (abortSignal) {
|
async load(abortSignal) {
|
||||||
this.cleanUpMutables();
|
this.#cleanUpMutables();
|
||||||
|
const children = await this.#provider.load(this.domainObject);
|
||||||
return this.provider.load(this.domainObject)
|
const childObjects = await Promise.all(children.map((c) => this.#publicAPI.objects.get(c, abortSignal)));
|
||||||
.then(function (children) {
|
childObjects.forEach(c => this.add(c, true));
|
||||||
return Promise.all(children.map((c) => this.publicAPI.objects.get(c, abortSignal)));
|
this.#emit('load');
|
||||||
}.bind(this))
|
|
||||||
.then(function (childObjects) {
|
|
||||||
childObjects.forEach(c => this.add(c, true));
|
|
||||||
|
|
||||||
return childObjects;
|
|
||||||
}.bind(this))
|
|
||||||
.then(function (children) {
|
|
||||||
this.emit('load');
|
|
||||||
|
|
||||||
return children;
|
|
||||||
}.bind(this));
|
|
||||||
};
|
|
||||||
|
|
||||||
|
return childObjects;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Remove a domain object from this composition.
|
* Remove a domain object from this composition.
|
||||||
*
|
*
|
||||||
* A call to [load]{@link module:openmct.CompositionCollection#load}
|
* A call to [load]{@link module:openmct.CompositionCollection#load}
|
||||||
* must have resolved before using this method.
|
* must have resolved before using this method.
|
||||||
*
|
*
|
||||||
* @param {module:openmct.DomainObject} child the domain object to remove
|
* **TODO:** Remove `skipMutate` parameter.
|
||||||
* @param {boolean} skipMutate true if the underlying provider should
|
*
|
||||||
* not be updated
|
* @param {DomainObject} child the domain object to remove
|
||||||
* @memberof module:openmct.CompositionCollection#
|
* @param {boolean} skipMutate
|
||||||
|
* **Intended for internal use ONLY.**
|
||||||
|
* true if the underlying provider should not be updated.
|
||||||
* @name remove
|
* @name remove
|
||||||
*/
|
*/
|
||||||
CompositionCollection.prototype.remove = function (child, skipMutate) {
|
remove(child, skipMutate) {
|
||||||
if (!skipMutate) {
|
if (!skipMutate) {
|
||||||
this.provider.remove(this.domainObject, child.identifier);
|
this.#provider.remove(this.domainObject, child.identifier);
|
||||||
} else {
|
} else {
|
||||||
if (this.returnMutables) {
|
if (this.returnMutables) {
|
||||||
let keyString = this.publicAPI.objects.makeKeyString(child);
|
let keyString = this.#publicAPI.objects.makeKeyString(child);
|
||||||
if (this.mutables[keyString] !== undefined && this.mutables[keyString].isMutable) {
|
if (this.#mutables[keyString] !== undefined && this.#mutables[keyString].isMutable) {
|
||||||
this.publicAPI.objects.destroyMutable(this.mutables[keyString]);
|
this.#publicAPI.objects.destroyMutable(this.#mutables[keyString]);
|
||||||
delete this.mutables[keyString];
|
delete this.#mutables[keyString];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emit('remove', child);
|
this.#emit('remove', child);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reorder the domain objects in this composition.
|
* Reorder the domain objects in this composition.
|
||||||
*
|
*
|
||||||
@@ -270,67 +282,75 @@ define([
|
|||||||
*
|
*
|
||||||
* @param {number} oldIndex
|
* @param {number} oldIndex
|
||||||
* @param {number} newIndex
|
* @param {number} newIndex
|
||||||
* @memberof module:openmct.CompositionCollection#
|
|
||||||
* @name remove
|
* @name remove
|
||||||
*/
|
*/
|
||||||
CompositionCollection.prototype.reorder = function (oldIndex, newIndex, skipMutate) {
|
reorder(oldIndex, newIndex, _skipMutate) {
|
||||||
this.provider.reorder(this.domainObject, oldIndex, newIndex);
|
this.#provider.reorder(this.domainObject, oldIndex, newIndex);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle reorder from provider.
|
* Destroy mutationListener
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
CompositionCollection.prototype.onProviderReorder = function (reorderMap) {
|
_destroy() {
|
||||||
this.emit('reorder', reorderMap);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle adds from provider.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
CompositionCollection.prototype.onProviderAdd = function (childId) {
|
|
||||||
return this.publicAPI.objects.get(childId).then(function (child) {
|
|
||||||
this.add(child, true);
|
|
||||||
|
|
||||||
return child;
|
|
||||||
}.bind(this));
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle removal from provider.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
CompositionCollection.prototype.onProviderRemove = function (child) {
|
|
||||||
this.remove(child, true);
|
|
||||||
};
|
|
||||||
|
|
||||||
CompositionCollection.prototype._destroy = function () {
|
|
||||||
if (this.mutationListener) {
|
if (this.mutationListener) {
|
||||||
this.mutationListener();
|
this.mutationListener();
|
||||||
delete this.mutationListener;
|
delete this.mutationListener;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
/**
|
||||||
|
* Handle reorder from provider.
|
||||||
|
* @private
|
||||||
|
* @param {object} reorderMap
|
||||||
|
*/
|
||||||
|
#onProviderReorder(reorderMap) {
|
||||||
|
this.#emit('reorder', reorderMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle adds from provider.
|
||||||
|
* @private
|
||||||
|
* @param {import('../objects/ObjectAPI').Identifier} childId
|
||||||
|
* @returns {DomainObject}
|
||||||
|
*/
|
||||||
|
#onProviderAdd(childId) {
|
||||||
|
return this.#publicAPI.objects.get(childId).then(function (child) {
|
||||||
|
this.add(child, true);
|
||||||
|
|
||||||
|
return child;
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle removal from provider.
|
||||||
|
* @param {DomainObject} child
|
||||||
|
*/
|
||||||
|
#onProviderRemove(child) {
|
||||||
|
this.remove(child, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emit events.
|
* Emit events.
|
||||||
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @param {string} event
|
||||||
|
* @param {...args.<any>} payload
|
||||||
*/
|
*/
|
||||||
CompositionCollection.prototype.emit = function (event, ...payload) {
|
#emit(event, ...payload) {
|
||||||
this.listeners[event].forEach(function (l) {
|
this.#listeners[event].forEach(function (l) {
|
||||||
if (l.context) {
|
if (l.context) {
|
||||||
l.callback.apply(l.context, payload);
|
l.callback.apply(l.context, payload);
|
||||||
} else {
|
} else {
|
||||||
l.callback(...payload);
|
l.callback(...payload);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
CompositionCollection.prototype.cleanUpMutables = function () {
|
/**
|
||||||
Object.values(this.mutables).forEach(mutable => {
|
* Destroy all mutables.
|
||||||
this.publicAPI.objects.destroyMutable(mutable);
|
* @private
|
||||||
|
*/
|
||||||
|
#cleanUpMutables() {
|
||||||
|
Object.values(this.#mutables).forEach(mutable => {
|
||||||
|
this.#publicAPI.objects.destroyMutable(mutable);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
}
|
||||||
return CompositionCollection;
|
|
||||||
});
|
|
||||||
|
|||||||
262
src/api/composition/CompositionProvider.js
Normal file
@@ -0,0 +1,262 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, 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 _ from 'lodash';
|
||||||
|
import objectUtils from "../objects/object-utils";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {import('../objects/ObjectAPI').DomainObject} DomainObject
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {import('../objects/ObjectAPI').Identifier} Identifier
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {import('./CompositionAPI').default} CompositionAPI
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {import('../../../openmct').OpenMCT} OpenMCT
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A CompositionProvider provides the underlying implementation of
|
||||||
|
* composition-related behavior for certain types of domain object.
|
||||||
|
*
|
||||||
|
* By default, a composition provider will not support composition
|
||||||
|
* modification. You can add support for mutation of composition by
|
||||||
|
* defining `add` and/or `remove` methods.
|
||||||
|
*
|
||||||
|
* If the composition of an object can change over time-- perhaps via
|
||||||
|
* server updates or mutation via the add/remove methods, then one must
|
||||||
|
* trigger events as necessary.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export default class CompositionProvider {
|
||||||
|
#publicAPI;
|
||||||
|
#listeningTo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {OpenMCT} publicAPI
|
||||||
|
* @param {CompositionAPI} compositionAPI
|
||||||
|
*/
|
||||||
|
constructor(publicAPI, compositionAPI) {
|
||||||
|
this.#publicAPI = publicAPI;
|
||||||
|
this.#listeningTo = {};
|
||||||
|
|
||||||
|
compositionAPI.addPolicy(this.#cannotContainItself.bind(this));
|
||||||
|
compositionAPI.addPolicy(this.#supportsComposition.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
get listeningTo() {
|
||||||
|
return this.#listeningTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
get establishTopicListener() {
|
||||||
|
return this.#establishTopicListener.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
get publicAPI() {
|
||||||
|
return this.#publicAPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this provider should be used to load composition for a
|
||||||
|
* particular domain object.
|
||||||
|
* @method appliesTo
|
||||||
|
* @param {import('../objects/ObjectAPI').DomainObject} domainObject the domain object
|
||||||
|
* to check
|
||||||
|
* @returns {boolean} true if this provider can provide composition for a given domain object
|
||||||
|
*/
|
||||||
|
appliesTo(domainObject) {
|
||||||
|
throw new Error("This method must be implemented by a subclass.");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Load any domain objects contained in the composition of this domain
|
||||||
|
* object.
|
||||||
|
* @param {DomainObject} domainObject the domain object
|
||||||
|
* for which to load composition
|
||||||
|
* @returns {Promise<Identifier[]>} a promise for
|
||||||
|
* the Identifiers in this composition
|
||||||
|
* @method load
|
||||||
|
*/
|
||||||
|
load(domainObject) {
|
||||||
|
throw new Error("This method must be implemented by a subclass.");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Attach listeners for changes to the composition of a given domain object.
|
||||||
|
* Supports `add` and `remove` events.
|
||||||
|
*
|
||||||
|
* @param {DomainObject} domainObject to listen to
|
||||||
|
* @param {string} event the event to bind to, either `add` or `remove`.
|
||||||
|
* @param {Function} callback callback to invoke when event is triggered.
|
||||||
|
* @param {any} [context] to use when invoking callback.
|
||||||
|
*/
|
||||||
|
on(domainObject,
|
||||||
|
event,
|
||||||
|
callback,
|
||||||
|
context) {
|
||||||
|
throw new Error("This method must be implemented by a subclass.");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Remove a listener that was previously added for a given domain object.
|
||||||
|
* event name, callback, and context must be the same as when the listener
|
||||||
|
* was originally attached.
|
||||||
|
*
|
||||||
|
* @param {DomainObject} domainObject to remove listener for
|
||||||
|
* @param {string} event event to stop listening to: `add` or `remove`.
|
||||||
|
* @param {Function} callback callback to remove.
|
||||||
|
* @param {any} context of callback to remove.
|
||||||
|
*/
|
||||||
|
off(domainObject,
|
||||||
|
event,
|
||||||
|
callback,
|
||||||
|
context) {
|
||||||
|
throw new Error("This method must be implemented by a subclass.");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Remove a domain object from another domain object's composition.
|
||||||
|
*
|
||||||
|
* This method is optional; if not present, adding to a domain object's
|
||||||
|
* composition using this provider will be disallowed.
|
||||||
|
*
|
||||||
|
* @param {DomainObject} domainObject the domain object
|
||||||
|
* which should have its composition modified
|
||||||
|
* @param {Identifier} childId the domain object to remove
|
||||||
|
* @method remove
|
||||||
|
*/
|
||||||
|
remove(domainObject, childId) {
|
||||||
|
throw new Error("This method must be implemented by a subclass.");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Add a domain object to another domain object's composition.
|
||||||
|
*
|
||||||
|
* This method is optional; if not present, adding to a domain object's
|
||||||
|
* composition using this provider will be disallowed.
|
||||||
|
*
|
||||||
|
* @param {DomainObject} parent the domain object
|
||||||
|
* which should have its composition modified
|
||||||
|
* @param {Identifier} childId the domain object to add
|
||||||
|
* @method add
|
||||||
|
*/
|
||||||
|
add(parent, childId) {
|
||||||
|
throw new Error("This method must be implemented by a subclass.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {DomainObject} parent
|
||||||
|
* @param {Identifier} childId
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
includes(parent, childId) {
|
||||||
|
throw new Error("This method must be implemented by a subclass.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {DomainObject} domainObject
|
||||||
|
* @param {number} oldIndex
|
||||||
|
* @param {number} newIndex
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
reorder(domainObject, oldIndex, newIndex) {
|
||||||
|
throw new Error("This method must be implemented by a subclass.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listens on general mutation topic, using injector to fetch to avoid
|
||||||
|
* circular dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
#establishTopicListener() {
|
||||||
|
if (this.topicListener) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.#publicAPI.objects.eventEmitter.on('mutation', this.#onMutation.bind(this));
|
||||||
|
this.topicListener = () => {
|
||||||
|
this.#publicAPI.objects.eventEmitter.off('mutation', this.#onMutation.bind(this));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @param {DomainObject} parent
|
||||||
|
* @param {DomainObject} child
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
#cannotContainItself(parent, child) {
|
||||||
|
return !(parent.identifier.namespace === child.identifier.namespace
|
||||||
|
&& parent.identifier.key === child.identifier.key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @param {DomainObject} parent
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
#supportsComposition(parent, _child) {
|
||||||
|
return this.#publicAPI.composition.supportsComposition(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles mutation events. If there are active listeners for the mutated
|
||||||
|
* object, detects changes to composition and triggers necessary events.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {DomainObject} oldDomainObject
|
||||||
|
*/
|
||||||
|
#onMutation(oldDomainObject) {
|
||||||
|
const id = objectUtils.makeKeyString(oldDomainObject.identifier);
|
||||||
|
const listeners = this.#listeningTo[id];
|
||||||
|
|
||||||
|
if (!listeners) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const oldComposition = listeners.composition.map(objectUtils.makeKeyString);
|
||||||
|
const newComposition = oldDomainObject.composition.map(objectUtils.makeKeyString);
|
||||||
|
|
||||||
|
const added = _.difference(newComposition, oldComposition).map(objectUtils.parseKeyString);
|
||||||
|
const removed = _.difference(oldComposition, newComposition).map(objectUtils.parseKeyString);
|
||||||
|
|
||||||
|
function notify(value) {
|
||||||
|
return function (listener) {
|
||||||
|
if (listener.context) {
|
||||||
|
listener.callback.call(listener.context, value);
|
||||||
|
} else {
|
||||||
|
listener.callback(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
listeners.composition = newComposition.map(objectUtils.parseKeyString);
|
||||||
|
|
||||||
|
added.forEach(function (addedChild) {
|
||||||
|
listeners.add.forEach(notify(addedChild));
|
||||||
|
});
|
||||||
|
|
||||||
|
removed.forEach(function (removedChild) {
|
||||||
|
listeners.remove.forEach(notify(removedChild));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -19,102 +19,79 @@
|
|||||||
* this source code distribution or the Licensing information page available
|
* this source code distribution or the Licensing information page available
|
||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
import objectUtils from "../objects/object-utils";
|
||||||
|
import CompositionProvider from './CompositionProvider';
|
||||||
|
|
||||||
define([
|
/**
|
||||||
'lodash',
|
* @typedef {import('../objects/ObjectAPI').DomainObject} DomainObject
|
||||||
'objectUtils'
|
*/
|
||||||
], function (
|
|
||||||
_,
|
|
||||||
objectUtils
|
|
||||||
) {
|
|
||||||
/**
|
|
||||||
* A CompositionProvider provides the underlying implementation of
|
|
||||||
* composition-related behavior for certain types of domain object.
|
|
||||||
*
|
|
||||||
* By default, a composition provider will not support composition
|
|
||||||
* modification. You can add support for mutation of composition by
|
|
||||||
* defining `add` and/or `remove` methods.
|
|
||||||
*
|
|
||||||
* If the composition of an object can change over time-- perhaps via
|
|
||||||
* server updates or mutation via the add/remove methods, then one must
|
|
||||||
* trigger events as necessary.
|
|
||||||
*
|
|
||||||
* @interface CompositionProvider
|
|
||||||
* @memberof module:openmct
|
|
||||||
*/
|
|
||||||
|
|
||||||
function DefaultCompositionProvider(publicAPI, compositionAPI) {
|
/**
|
||||||
this.publicAPI = publicAPI;
|
* @typedef {import('../objects/ObjectAPI').Identifier} Identifier
|
||||||
this.listeningTo = {};
|
*/
|
||||||
this.onMutation = this.onMutation.bind(this);
|
|
||||||
|
|
||||||
this.cannotContainItself = this.cannotContainItself.bind(this);
|
/**
|
||||||
this.supportsComposition = this.supportsComposition.bind(this);
|
* @typedef {import('./CompositionAPI').default} CompositionAPI
|
||||||
|
*/
|
||||||
|
|
||||||
compositionAPI.addPolicy(this.cannotContainItself);
|
/**
|
||||||
compositionAPI.addPolicy(this.supportsComposition);
|
* @typedef {import('../../../openmct').OpenMCT} OpenMCT
|
||||||
}
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
DefaultCompositionProvider.prototype.cannotContainItself = function (parent, child) {
|
|
||||||
return !(parent.identifier.namespace === child.identifier.namespace
|
|
||||||
&& parent.identifier.key === child.identifier.key);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
DefaultCompositionProvider.prototype.supportsComposition = function (parent, child) {
|
|
||||||
return this.publicAPI.composition.supportsComposition(parent);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A CompositionProvider provides the underlying implementation of
|
||||||
|
* composition-related behavior for certain types of domain object.
|
||||||
|
*
|
||||||
|
* By default, a composition provider will not support composition
|
||||||
|
* modification. You can add support for mutation of composition by
|
||||||
|
* defining `add` and/or `remove` methods.
|
||||||
|
*
|
||||||
|
* If the composition of an object can change over time-- perhaps via
|
||||||
|
* server updates or mutation via the add/remove methods, then one must
|
||||||
|
* trigger events as necessary.
|
||||||
|
* @extends CompositionProvider
|
||||||
|
*/
|
||||||
|
export default class DefaultCompositionProvider extends CompositionProvider {
|
||||||
/**
|
/**
|
||||||
* Check if this provider should be used to load composition for a
|
* Check if this provider should be used to load composition for a
|
||||||
* particular domain object.
|
* particular domain object.
|
||||||
* @param {module:openmct.DomainObject} domainObject the domain object
|
* @override
|
||||||
|
* @param {DomainObject} domainObject the domain object
|
||||||
* to check
|
* to check
|
||||||
* @returns {boolean} true if this provider can provide
|
* @returns {boolean} true if this provider can provide composition for a given domain object
|
||||||
* composition for a given domain object
|
|
||||||
* @memberof module:openmct.CompositionProvider#
|
|
||||||
* @method appliesTo
|
|
||||||
*/
|
*/
|
||||||
DefaultCompositionProvider.prototype.appliesTo = function (domainObject) {
|
appliesTo(domainObject) {
|
||||||
return Boolean(domainObject.composition);
|
return Boolean(domainObject.composition);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load any domain objects contained in the composition of this domain
|
* Load any domain objects contained in the composition of this domain
|
||||||
* object.
|
* object.
|
||||||
* @param {module:openmct.DomainObject} domainObject the domain object
|
* @override
|
||||||
|
* @param {DomainObject} domainObject the domain object
|
||||||
* for which to load composition
|
* for which to load composition
|
||||||
* @returns {Promise.<Array.<module:openmct.Identifier>>} a promise for
|
* @returns {Promise<Identifier[]>} a promise for
|
||||||
* the Identifiers in this composition
|
* the Identifiers in this composition
|
||||||
* @memberof module:openmct.CompositionProvider#
|
|
||||||
* @method load
|
|
||||||
*/
|
*/
|
||||||
DefaultCompositionProvider.prototype.load = function (domainObject) {
|
load(domainObject) {
|
||||||
return Promise.all(domainObject.composition);
|
return Promise.all(domainObject.composition);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attach listeners for changes to the composition of a given domain object.
|
* Attach listeners for changes to the composition of a given domain object.
|
||||||
* Supports `add` and `remove` events.
|
* Supports `add` and `remove` events.
|
||||||
*
|
*
|
||||||
* @param {module:openmct.DomainObject} domainObject to listen to
|
* @override
|
||||||
* @param String event the event to bind to, either `add` or `remove`.
|
* @param {DomainObject} domainObject to listen to
|
||||||
* @param Function callback callback to invoke when event is triggered.
|
* @param {string} event the event to bind to, either `add` or `remove`.
|
||||||
* @param [context] context to use when invoking callback.
|
* @param {Function} callback callback to invoke when event is triggered.
|
||||||
|
* @param {any} [context] to use when invoking callback.
|
||||||
*/
|
*/
|
||||||
DefaultCompositionProvider.prototype.on = function (
|
on(domainObject,
|
||||||
domainObject,
|
|
||||||
event,
|
event,
|
||||||
callback,
|
callback,
|
||||||
context
|
context) {
|
||||||
) {
|
|
||||||
this.establishTopicListener();
|
this.establishTopicListener();
|
||||||
|
|
||||||
|
/** @type {string} */
|
||||||
const keyString = objectUtils.makeKeyString(domainObject.identifier);
|
const keyString = objectUtils.makeKeyString(domainObject.identifier);
|
||||||
let objectListeners = this.listeningTo[keyString];
|
let objectListeners = this.listeningTo[keyString];
|
||||||
|
|
||||||
@@ -131,24 +108,24 @@ define([
|
|||||||
callback: callback,
|
callback: callback,
|
||||||
context: context
|
context: context
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a listener that was previously added for a given domain object.
|
* Remove a listener that was previously added for a given domain object.
|
||||||
* event name, callback, and context must be the same as when the listener
|
* event name, callback, and context must be the same as when the listener
|
||||||
* was originally attached.
|
* was originally attached.
|
||||||
*
|
*
|
||||||
* @param {module:openmct.DomainObject} domainObject to remove listener for
|
* @override
|
||||||
* @param String event event to stop listening to: `add` or `remove`.
|
* @param {DomainObject} domainObject to remove listener for
|
||||||
* @param Function callback callback to remove.
|
* @param {string} event event to stop listening to: `add` or `remove`.
|
||||||
* @param [context] context of callback to remove.
|
* @param {Function} callback callback to remove.
|
||||||
|
* @param {any} context of callback to remove.
|
||||||
*/
|
*/
|
||||||
DefaultCompositionProvider.prototype.off = function (
|
off(domainObject,
|
||||||
domainObject,
|
|
||||||
event,
|
event,
|
||||||
callback,
|
callback,
|
||||||
context
|
context) {
|
||||||
) {
|
|
||||||
|
/** @type {string} */
|
||||||
const keyString = objectUtils.makeKeyString(domainObject.identifier);
|
const keyString = objectUtils.makeKeyString(domainObject.identifier);
|
||||||
const objectListeners = this.listeningTo[keyString];
|
const objectListeners = this.listeningTo[keyString];
|
||||||
|
|
||||||
@@ -160,57 +137,64 @@ define([
|
|||||||
if (!objectListeners.add.length && !objectListeners.remove.length && !objectListeners.reorder.length) {
|
if (!objectListeners.add.length && !objectListeners.remove.length && !objectListeners.reorder.length) {
|
||||||
delete this.listeningTo[keyString];
|
delete this.listeningTo[keyString];
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a domain object from another domain object's composition.
|
* Remove a domain object from another domain object's composition.
|
||||||
*
|
*
|
||||||
* This method is optional; if not present, adding to a domain object's
|
* This method is optional; if not present, adding to a domain object's
|
||||||
* composition using this provider will be disallowed.
|
* composition using this provider will be disallowed.
|
||||||
*
|
*
|
||||||
* @param {module:openmct.DomainObject} domainObject the domain object
|
* @override
|
||||||
|
* @param {DomainObject} domainObject the domain object
|
||||||
* which should have its composition modified
|
* which should have its composition modified
|
||||||
* @param {module:openmct.DomainObject} child the domain object to remove
|
* @param {Identifier} childId the domain object to remove
|
||||||
* @memberof module:openmct.CompositionProvider#
|
|
||||||
* @method remove
|
* @method remove
|
||||||
*/
|
*/
|
||||||
DefaultCompositionProvider.prototype.remove = function (domainObject, childId) {
|
remove(domainObject, childId) {
|
||||||
let composition = domainObject.composition.filter(function (child) {
|
let composition = domainObject.composition.filter(function (child) {
|
||||||
return !(childId.namespace === child.namespace
|
return !(childId.namespace === child.namespace
|
||||||
&& childId.key === child.key);
|
&& childId.key === child.key);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.publicAPI.objects.mutate(domainObject, 'composition', composition);
|
this.publicAPI.objects.mutate(domainObject, 'composition', composition);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a domain object to another domain object's composition.
|
* Add a domain object to another domain object's composition.
|
||||||
*
|
*
|
||||||
* This method is optional; if not present, adding to a domain object's
|
* This method is optional; if not present, adding to a domain object's
|
||||||
* composition using this provider will be disallowed.
|
* composition using this provider will be disallowed.
|
||||||
*
|
*
|
||||||
* @param {module:openmct.DomainObject} domainObject the domain object
|
* @override
|
||||||
|
* @param {DomainObject} parent the domain object
|
||||||
* which should have its composition modified
|
* which should have its composition modified
|
||||||
* @param {module:openmct.DomainObject} child the domain object to add
|
* @param {Identifier} childId the domain object to add
|
||||||
* @memberof module:openmct.CompositionProvider#
|
|
||||||
* @method add
|
* @method add
|
||||||
*/
|
*/
|
||||||
DefaultCompositionProvider.prototype.add = function (parent, childId) {
|
add(parent, childId) {
|
||||||
if (!this.includes(parent, childId)) {
|
if (!this.includes(parent, childId)) {
|
||||||
parent.composition.push(childId);
|
parent.composition.push(childId);
|
||||||
this.publicAPI.objects.mutate(parent, 'composition', parent.composition);
|
this.publicAPI.objects.mutate(parent, 'composition', parent.composition);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @override
|
||||||
|
* @param {DomainObject} parent
|
||||||
|
* @param {Identifier} childId
|
||||||
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
DefaultCompositionProvider.prototype.includes = function (parent, childId) {
|
includes(parent, childId) {
|
||||||
return parent.composition.some(composee =>
|
return parent.composition.some(composee => this.publicAPI.objects.areIdsEqual(composee, childId));
|
||||||
this.publicAPI.objects.areIdsEqual(composee, childId));
|
}
|
||||||
};
|
|
||||||
|
|
||||||
DefaultCompositionProvider.prototype.reorder = function (domainObject, oldIndex, newIndex) {
|
/**
|
||||||
|
* @override
|
||||||
|
* @param {DomainObject} domainObject
|
||||||
|
* @param {number} oldIndex
|
||||||
|
* @param {number} newIndex
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
reorder(domainObject, oldIndex, newIndex) {
|
||||||
let newComposition = domainObject.composition.slice();
|
let newComposition = domainObject.composition.slice();
|
||||||
let removeId = oldIndex > newIndex ? oldIndex + 1 : oldIndex;
|
let removeId = oldIndex > newIndex ? oldIndex + 1 : oldIndex;
|
||||||
let insertPosition = oldIndex < newIndex ? newIndex + 1 : newIndex;
|
let insertPosition = oldIndex < newIndex ? newIndex + 1 : newIndex;
|
||||||
@@ -241,6 +225,7 @@ define([
|
|||||||
|
|
||||||
this.publicAPI.objects.mutate(domainObject, 'composition', newComposition);
|
this.publicAPI.objects.mutate(domainObject, 'composition', newComposition);
|
||||||
|
|
||||||
|
/** @type {string} */
|
||||||
let id = objectUtils.makeKeyString(domainObject.identifier);
|
let id = objectUtils.makeKeyString(domainObject.identifier);
|
||||||
const listeners = this.listeningTo[id];
|
const listeners = this.listeningTo[id];
|
||||||
|
|
||||||
@@ -257,66 +242,5 @@ define([
|
|||||||
listener.callback(reorderPlan);
|
listener.callback(reorderPlan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Listens on general mutation topic, using injector to fetch to avoid
|
|
||||||
* circular dependencies.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
DefaultCompositionProvider.prototype.establishTopicListener = function () {
|
|
||||||
if (this.topicListener) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.publicAPI.objects.eventEmitter.on('mutation', this.onMutation);
|
|
||||||
this.topicListener = () => {
|
|
||||||
this.publicAPI.objects.eventEmitter.off('mutation', this.onMutation);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles mutation events. If there are active listeners for the mutated
|
|
||||||
* object, detects changes to composition and triggers necessary events.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
DefaultCompositionProvider.prototype.onMutation = function (oldDomainObject) {
|
|
||||||
const id = objectUtils.makeKeyString(oldDomainObject.identifier);
|
|
||||||
const listeners = this.listeningTo[id];
|
|
||||||
|
|
||||||
if (!listeners) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const oldComposition = listeners.composition.map(objectUtils.makeKeyString);
|
|
||||||
const newComposition = oldDomainObject.composition.map(objectUtils.makeKeyString);
|
|
||||||
|
|
||||||
const added = _.difference(newComposition, oldComposition).map(objectUtils.parseKeyString);
|
|
||||||
const removed = _.difference(oldComposition, newComposition).map(objectUtils.parseKeyString);
|
|
||||||
|
|
||||||
function notify(value) {
|
|
||||||
return function (listener) {
|
|
||||||
if (listener.context) {
|
|
||||||
listener.callback.call(listener.context, value);
|
|
||||||
} else {
|
|
||||||
listener.callback(value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
listeners.composition = newComposition.map(objectUtils.parseKeyString);
|
|
||||||
|
|
||||||
added.forEach(function (addedChild) {
|
|
||||||
listeners.add.forEach(notify(addedChild));
|
|
||||||
});
|
|
||||||
|
|
||||||
removed.forEach(function (removedChild) {
|
|
||||||
listeners.remove.forEach(notify(removedChild));
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
return DefaultCompositionProvider;
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -23,13 +23,11 @@
|
|||||||
import FormController from './FormController';
|
import FormController from './FormController';
|
||||||
import FormProperties from './components/FormProperties.vue';
|
import FormProperties from './components/FormProperties.vue';
|
||||||
|
|
||||||
import EventEmitter from 'EventEmitter';
|
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
export default class FormsAPI extends EventEmitter {
|
export default class FormsAPI {
|
||||||
constructor(openmct) {
|
constructor(openmct) {
|
||||||
super();
|
|
||||||
|
|
||||||
this.openmct = openmct;
|
this.openmct = openmct;
|
||||||
this.formController = new FormController(openmct);
|
this.formController = new FormController(openmct);
|
||||||
}
|
}
|
||||||
@@ -92,29 +90,75 @@ export default class FormsAPI extends EventEmitter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Show form inside an Overlay dialog with given form structure
|
* Show form inside an Overlay dialog with given form structure
|
||||||
|
* @public
|
||||||
|
* @param {Array<Section>} formStructure a form structure, array of section
|
||||||
|
* @param {Object} options
|
||||||
|
* @property {function} onChange a callback function when any changes detected
|
||||||
|
*/
|
||||||
|
showForm(formStructure, {
|
||||||
|
onChange
|
||||||
|
} = {}) {
|
||||||
|
let overlay;
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
const overlayEl = document.createElement('div');
|
||||||
|
overlayEl.classList.add('u-contents');
|
||||||
|
|
||||||
|
overlay = self.openmct.overlays.overlay({
|
||||||
|
element: overlayEl,
|
||||||
|
size: 'dialog'
|
||||||
|
});
|
||||||
|
|
||||||
|
let formSave;
|
||||||
|
let formCancel;
|
||||||
|
const promise = new Promise((resolve, reject) => {
|
||||||
|
formSave = resolve;
|
||||||
|
formCancel = reject;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.showCustomForm(formStructure, {
|
||||||
|
element: overlayEl,
|
||||||
|
onChange
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
overlay.dismiss();
|
||||||
|
formSave(response);
|
||||||
|
})
|
||||||
|
.catch((response) => {
|
||||||
|
overlay.dismiss();
|
||||||
|
formCancel(response);
|
||||||
|
});
|
||||||
|
|
||||||
|
return promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show form as a child of the element provided with given form structure
|
||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
* @param {Array<Section>} formStructure a form structure, array of section
|
* @param {Array<Section>} formStructure a form structure, array of section
|
||||||
* @param {Object} options
|
* @param {Object} options
|
||||||
* @property {HTMLElement} element Parent Element to render a Form
|
* @property {HTMLElement} element Parent Element to render a Form
|
||||||
* @property {function} onChange a callback function when any changes detected
|
* @property {function} onChange a callback function when any changes detected
|
||||||
* @property {function} onSave a callback function when form is submitted
|
|
||||||
* @property {function} onDismiss a callback function when form is dismissed
|
|
||||||
*/
|
*/
|
||||||
showForm(formStructure, {
|
showCustomForm(formStructure, {
|
||||||
element,
|
element,
|
||||||
onChange
|
onChange
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const changes = {};
|
if (element === undefined) {
|
||||||
let overlay;
|
throw Error('Required element parameter not provided');
|
||||||
let onDismiss;
|
}
|
||||||
let onSave;
|
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
|
const changes = {};
|
||||||
|
let formSave;
|
||||||
|
let formCancel;
|
||||||
|
|
||||||
const promise = new Promise((resolve, reject) => {
|
const promise = new Promise((resolve, reject) => {
|
||||||
onSave = onFormAction(resolve);
|
formSave = onFormAction(resolve);
|
||||||
onDismiss = onFormAction(reject);
|
formCancel = onFormAction(reject);
|
||||||
});
|
});
|
||||||
|
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
@@ -126,26 +170,17 @@ export default class FormsAPI extends EventEmitter {
|
|||||||
return {
|
return {
|
||||||
formStructure,
|
formStructure,
|
||||||
onChange: onFormPropertyChange,
|
onChange: onFormPropertyChange,
|
||||||
onDismiss,
|
onCancel: formCancel,
|
||||||
onSave
|
onSave: formSave
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
template: '<FormProperties :model="formStructure" @onChange="onChange" @onDismiss="onDismiss" @onSave="onSave"></FormProperties>'
|
template: '<FormProperties :model="formStructure" @onChange="onChange" @onCancel="onCancel" @onSave="onSave"></FormProperties>'
|
||||||
}).$mount();
|
}).$mount();
|
||||||
|
|
||||||
const formElement = vm.$el;
|
const formElement = vm.$el;
|
||||||
if (element) {
|
element.append(formElement);
|
||||||
element.append(formElement);
|
|
||||||
} else {
|
|
||||||
overlay = self.openmct.overlays.overlay({
|
|
||||||
element: vm.$el,
|
|
||||||
size: 'small',
|
|
||||||
onDestroy: () => vm.$destroy()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function onFormPropertyChange(data) {
|
function onFormPropertyChange(data) {
|
||||||
self.emit('onFormPropertyChange', data);
|
|
||||||
if (onChange) {
|
if (onChange) {
|
||||||
onChange(data);
|
onChange(data);
|
||||||
}
|
}
|
||||||
@@ -158,17 +193,14 @@ export default class FormsAPI extends EventEmitter {
|
|||||||
key = property.join('.');
|
key = property.join('.');
|
||||||
}
|
}
|
||||||
|
|
||||||
changes[key] = data.value;
|
_.set(changes, key, data.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFormAction(callback) {
|
function onFormAction(callback) {
|
||||||
return () => {
|
return () => {
|
||||||
if (element) {
|
formElement.remove();
|
||||||
formElement.remove();
|
vm.$destroy();
|
||||||
} else {
|
|
||||||
overlay.dismiss();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(changes);
|
callback(changes);
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ describe('The Forms API', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('when container element is provided', (done) => {
|
it('when container element is provided', (done) => {
|
||||||
openmct.forms.showForm(formStructure, { element }).catch(() => {
|
openmct.forms.showCustomForm(formStructure, { element }).catch(() => {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
const titleElement = element.querySelector('.c-overlay__dialog-title');
|
const titleElement = element.querySelector('.c-overlay__dialog-title');
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
tabindex="0"
|
tabindex="0"
|
||||||
class="c-button js-cancel-button"
|
class="c-button js-cancel-button"
|
||||||
aria-label="Cancel"
|
aria-label="Cancel"
|
||||||
@click="onDismiss"
|
@click="onCancel"
|
||||||
>
|
>
|
||||||
{{ cancelLabel }}
|
{{ cancelLabel }}
|
||||||
</button>
|
</button>
|
||||||
@@ -164,8 +164,8 @@ export default {
|
|||||||
|
|
||||||
this.$emit('onChange', data);
|
this.$emit('onChange', data);
|
||||||
},
|
},
|
||||||
onDismiss() {
|
onCancel() {
|
||||||
this.$emit('onDismiss');
|
this.$emit('onCancel');
|
||||||
},
|
},
|
||||||
onSave() {
|
onSave() {
|
||||||
this.$emit('onSave');
|
this.$emit('onSave');
|
||||||
|
|||||||
@@ -32,53 +32,49 @@
|
|||||||
prevent
|
prevent
|
||||||
class="u-contents"
|
class="u-contents"
|
||||||
>
|
>
|
||||||
<div class="field control date">
|
<input
|
||||||
<input
|
v-model="date"
|
||||||
v-model="date"
|
class="field control date"
|
||||||
:pattern="/\d{4}-\d{2}-\d{2}/"
|
:pattern="/\d{4}-\d{2}-\d{2}/"
|
||||||
:placeholder="format"
|
:placeholder="format"
|
||||||
type="date"
|
type="date"
|
||||||
name="date"
|
name="date"
|
||||||
@change="onChange"
|
@change="onChange"
|
||||||
>
|
>
|
||||||
</div>
|
<input
|
||||||
<div class="field control hour sm">
|
v-model="hour"
|
||||||
<input
|
class="field control hour c-input--sm"
|
||||||
v-model="hour"
|
:pattern="/\d+/"
|
||||||
:pattern="/\d+/"
|
type="number"
|
||||||
type="number"
|
name="hour"
|
||||||
name="hour"
|
maxlength="10"
|
||||||
maxlength="10"
|
min="0"
|
||||||
min="0"
|
max="23"
|
||||||
max="23"
|
@change="onChange"
|
||||||
@change="onChange"
|
>
|
||||||
>
|
<input
|
||||||
</div>
|
v-model="min"
|
||||||
<div class="field control min sm">
|
class="field control min c-input--sm"
|
||||||
<input
|
:pattern="/\d+/"
|
||||||
v-model="min"
|
type="number"
|
||||||
:pattern="/\d+/"
|
name="min"
|
||||||
type="number"
|
maxlength="2"
|
||||||
name="min"
|
min="0"
|
||||||
maxlength="2"
|
max="59"
|
||||||
min="0"
|
@change="onChange"
|
||||||
max="59"
|
>
|
||||||
@change="onChange"
|
<input
|
||||||
>
|
v-model="sec"
|
||||||
</div>
|
class="field control sec c-input--sm"
|
||||||
<div class="field control sec sm">
|
:pattern="/\d+/"
|
||||||
<input
|
type="number"
|
||||||
v-model="sec"
|
name="sec"
|
||||||
:pattern="/\d+/"
|
maxlength="2"
|
||||||
type="number"
|
min="0"
|
||||||
name="sec"
|
max="59"
|
||||||
maxlength="2"
|
@change="onChange"
|
||||||
min="0"
|
>
|
||||||
max="59"
|
<div class="field control hint timezone">
|
||||||
@change="onChange"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="field control timezone">
|
|
||||||
UTC
|
UTC
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
v-model="selected"
|
v-model="selected"
|
||||||
required="model.required"
|
required="model.required"
|
||||||
name="mctControl"
|
name="mctControl"
|
||||||
|
:aria-label="model.ariaLabel || model.name"
|
||||||
@change="onChange($event)"
|
@change="onChange($event)"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
:class="model.cssClass"
|
:class="model.cssClass"
|
||||||
>
|
>
|
||||||
<textarea
|
<textarea
|
||||||
|
:id="`${model.key}-textarea`"
|
||||||
v-model="field"
|
v-model="field"
|
||||||
type="text"
|
type="text"
|
||||||
:size="model.size"
|
:size="model.size"
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
<ToggleSwitch
|
<ToggleSwitch
|
||||||
id="switchId"
|
id="switchId"
|
||||||
:checked="isChecked"
|
:checked="isChecked"
|
||||||
|
:name="model.name"
|
||||||
@change="toggleCheckBox"
|
@change="toggleCheckBox"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -3,39 +3,52 @@
|
|||||||
class="c-menu"
|
class="c-menu"
|
||||||
:class="options.menuClass"
|
:class="options.menuClass"
|
||||||
>
|
>
|
||||||
<ul v-if="options.actions.length && options.actions[0].length">
|
<ul
|
||||||
|
v-if="options.actions.length && options.actions[0].length"
|
||||||
|
role="menu"
|
||||||
|
>
|
||||||
<template
|
<template
|
||||||
v-for="(actionGroups, index) in options.actions"
|
v-for="(actionGroups, index) in options.actions"
|
||||||
>
|
>
|
||||||
<li
|
|
||||||
v-for="action in actionGroups"
|
|
||||||
:key="action.name"
|
|
||||||
:class="[action.cssClass, action.isDisabled ? 'disabled' : '']"
|
|
||||||
:title="action.description"
|
|
||||||
:data-testid="action.testId || false"
|
|
||||||
@click="action.onItemClicked"
|
|
||||||
>
|
|
||||||
{{ action.name }}
|
|
||||||
</li>
|
|
||||||
<div
|
<div
|
||||||
v-if="index !== options.actions.length - 1"
|
|
||||||
:key="index"
|
:key="index"
|
||||||
class="c-menu__section-separator"
|
role="group"
|
||||||
>
|
>
|
||||||
</div>
|
<li
|
||||||
<li
|
v-for="action in actionGroups"
|
||||||
v-if="actionGroups.length === 0"
|
:key="action.name"
|
||||||
:key="index"
|
role="menuitem"
|
||||||
>
|
:class="[action.cssClass, action.isDisabled ? 'disabled' : '']"
|
||||||
No actions defined.
|
:title="action.description"
|
||||||
</li>
|
:data-testid="action.testId || false"
|
||||||
</template>
|
@click="action.onItemClicked"
|
||||||
|
>
|
||||||
|
{{ action.name }}
|
||||||
|
</li>
|
||||||
|
<div
|
||||||
|
v-if="index !== options.actions.length - 1"
|
||||||
|
:key="index"
|
||||||
|
role="separator"
|
||||||
|
class="c-menu__section-separator"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<li
|
||||||
|
v-if="actionGroups.length === 0"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
No actions defined.
|
||||||
|
</li>
|
||||||
|
</div></template>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<ul v-else>
|
<ul
|
||||||
|
v-else
|
||||||
|
role="menu"
|
||||||
|
>
|
||||||
<li
|
<li
|
||||||
v-for="action in options.actions"
|
v-for="action in options.actions"
|
||||||
:key="action.name"
|
:key="action.name"
|
||||||
|
role="menuitem"
|
||||||
:class="[action.cssClass, action.isDisabled ? 'disabled' : '']"
|
:class="[action.cssClass, action.isDisabled ? 'disabled' : '']"
|
||||||
:title="action.description"
|
:title="action.description"
|
||||||
:data-testid="action.testId || false"
|
:data-testid="action.testId || false"
|
||||||
|
|||||||
@@ -5,45 +5,54 @@
|
|||||||
>
|
>
|
||||||
<ul
|
<ul
|
||||||
v-if="options.actions.length && options.actions[0].length"
|
v-if="options.actions.length && options.actions[0].length"
|
||||||
|
role="menu"
|
||||||
class="c-super-menu__menu"
|
class="c-super-menu__menu"
|
||||||
>
|
>
|
||||||
<template
|
<template
|
||||||
v-for="(actionGroups, index) in options.actions"
|
v-for="(actionGroups, index) in options.actions"
|
||||||
>
|
>
|
||||||
<li
|
|
||||||
v-for="action in actionGroups"
|
|
||||||
:key="action.name"
|
|
||||||
:class="[action.cssClass, action.isDisabled ? 'disabled' : '']"
|
|
||||||
:title="action.description"
|
|
||||||
:data-testid="action.testId || false"
|
|
||||||
@click="action.onItemClicked"
|
|
||||||
@mouseover="toggleItemDescription(action)"
|
|
||||||
@mouseleave="toggleItemDescription()"
|
|
||||||
>
|
|
||||||
{{ action.name }}
|
|
||||||
</li>
|
|
||||||
<div
|
<div
|
||||||
v-if="index !== options.actions.length - 1"
|
|
||||||
:key="index"
|
:key="index"
|
||||||
class="c-menu__section-separator"
|
role="group"
|
||||||
>
|
>
|
||||||
</div>
|
<li
|
||||||
<li
|
v-for="action in actionGroups"
|
||||||
v-if="actionGroups.length === 0"
|
:key="action.name"
|
||||||
:key="index"
|
role="menuitem"
|
||||||
>
|
:class="[action.cssClass, action.isDisabled ? 'disabled' : '']"
|
||||||
No actions defined.
|
:title="action.description"
|
||||||
</li>
|
:data-testid="action.testId || false"
|
||||||
</template>
|
@click="action.onItemClicked"
|
||||||
|
@mouseover="toggleItemDescription(action)"
|
||||||
|
@mouseleave="toggleItemDescription()"
|
||||||
|
>
|
||||||
|
{{ action.name }}
|
||||||
|
</li>
|
||||||
|
<div
|
||||||
|
v-if="index !== options.actions.length - 1"
|
||||||
|
:key="index"
|
||||||
|
role="separator"
|
||||||
|
class="c-menu__section-separator"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<li
|
||||||
|
v-if="actionGroups.length === 0"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
No actions defined.
|
||||||
|
</li>
|
||||||
|
</div></template>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<ul
|
<ul
|
||||||
v-else
|
v-else
|
||||||
class="c-super-menu__menu"
|
class="c-super-menu__menu"
|
||||||
|
role="menu"
|
||||||
>
|
>
|
||||||
<li
|
<li
|
||||||
v-for="action in options.actions"
|
v-for="action in options.actions"
|
||||||
:key="action.name"
|
:key="action.name"
|
||||||
|
role="menuitem"
|
||||||
:class="action.cssClass"
|
:class="action.cssClass"
|
||||||
:title="action.description"
|
:title="action.description"
|
||||||
:data-testid="action.testId || false"
|
:data-testid="action.testId || false"
|
||||||
|
|||||||