mirror of
https://github.com/nasa/openmct.git
synced 2025-04-24 04:55:58 +00:00
Compare commits
57 Commits
omm-r5.3.1
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
6a450a0e89 | ||
|
e5631c9f6c | ||
|
15b5d1405d | ||
|
0377788533 | ||
|
28dcff7e89 | ||
|
b191eb9d64 | ||
|
f8e4aba922 | ||
|
28f6987dd7 | ||
|
f3047093d6 | ||
|
34e57ef300 | ||
|
88e6557782 | ||
|
dbd4abebae | ||
|
50ca27e54f | ||
|
2955092c86 | ||
|
28b5d7c41c | ||
|
ecd120387c | ||
|
a6517bb33e | ||
|
1fde0d9e38 | ||
|
5be103ea72 | ||
|
d74e1b19b6 | ||
|
5bb6a18cd4 | ||
|
14b947c101 | ||
|
61b982ab99 | ||
|
ba4d8a428b | ||
|
ea9947cab5 | ||
|
2010f2e377 | ||
|
3241e9ba57 | ||
|
057a5f997c | ||
|
078cd341a5 | ||
|
518b55cf0f | ||
|
3e23dceb64 | ||
|
7f8b5e09e5 | ||
|
7c2bb16bfd | ||
|
890ddcac4e | ||
|
d8c5095ebb | ||
|
ccf7ed91af | ||
|
2b8673941a | ||
|
703186adf1 | ||
|
c43ef64733 | ||
|
f4cf9c756b | ||
|
4415fe7952 | ||
|
83e4a124e2 | ||
|
47f0b66c7e | ||
|
55c023d1eb | ||
|
37b2660f27 | ||
|
43cc963328 | ||
|
ad30a0e2d0 | ||
|
29f1956d1a | ||
|
c498f7d20c | ||
|
a8fbabe695 | ||
|
e792403788 | ||
|
de122b91c2 | ||
|
fa8efa858b | ||
|
26578e849d | ||
|
fccae3bd49 | ||
|
440474b2e3 | ||
|
21a4335c4e |
@ -5,11 +5,11 @@ orbs:
|
|||||||
executors:
|
executors:
|
||||||
pw-focal-development:
|
pw-focal-development:
|
||||||
docker:
|
docker:
|
||||||
- image: mcr.microsoft.com/playwright:v1.45.2-focal
|
- image: mcr.microsoft.com/playwright:v1.48.1-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)
|
PERCY_LOGLEVEL: 'debug' # Enable DEBUG level logging for Percy (Issue: https://github.com/nasa/openmct/issues/5742)
|
||||||
PERCY_PARALLEL_TOTAL: 2
|
PERCY_PARALLEL_TOTAL: 2
|
||||||
ubuntu:
|
ubuntu:
|
||||||
machine:
|
machine:
|
||||||
@ -17,7 +17,7 @@ executors:
|
|||||||
docker_layer_caching: true
|
docker_layer_caching: true
|
||||||
commands:
|
commands:
|
||||||
build_and_install:
|
build_and_install:
|
||||||
description: "All steps used to build and install."
|
description: 'All steps used to build and install.'
|
||||||
parameters:
|
parameters:
|
||||||
node-version:
|
node-version:
|
||||||
type: string
|
type: string
|
||||||
@ -27,7 +27,7 @@ commands:
|
|||||||
node-version: << parameters.node-version >>
|
node-version: << parameters.node-version >>
|
||||||
- node/install-packages
|
- node/install-packages
|
||||||
generate_and_store_version_and_filesystem_artifacts:
|
generate_and_store_version_and_filesystem_artifacts:
|
||||||
description: "Track important packages and files"
|
description: 'Track important packages and files'
|
||||||
steps:
|
steps:
|
||||||
- run: |
|
- run: |
|
||||||
[[ $EUID -ne 0 ]] && (sudo mkdir -p /tmp/artifacts && sudo chmod 777 /tmp/artifacts) || (mkdir -p /tmp/artifacts && chmod 777 /tmp/artifacts)
|
[[ $EUID -ne 0 ]] && (sudo mkdir -p /tmp/artifacts && sudo chmod 777 /tmp/artifacts) || (mkdir -p /tmp/artifacts && chmod 777 /tmp/artifacts)
|
||||||
@ -37,14 +37,45 @@ commands:
|
|||||||
ls -latR >> /tmp/artifacts/dir.txt
|
ls -latR >> /tmp/artifacts/dir.txt
|
||||||
- store_artifacts:
|
- store_artifacts:
|
||||||
path: /tmp/artifacts/
|
path: /tmp/artifacts/
|
||||||
|
download_verify_codecov_cli:
|
||||||
|
description: 'Download and verify Codecov CLI'
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: Download and verify Codecov CLI
|
||||||
|
command: |
|
||||||
|
# Download Codecov CLI
|
||||||
|
curl -Os https://cli.codecov.io/latest/linux/codecov
|
||||||
|
|
||||||
|
# Import Codecov's GPG key
|
||||||
|
curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
|
||||||
|
|
||||||
|
# Download and verify the SHA256SUM and its signature
|
||||||
|
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM
|
||||||
|
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM.sig
|
||||||
|
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
|
||||||
|
|
||||||
|
# Verify the checksum
|
||||||
|
shasum -a 256 -c codecov.SHA256SUM
|
||||||
|
|
||||||
|
# Make the codecov executable
|
||||||
|
[[ $EUID -ne 0 ]] && sudo chmod +x codecov || chmod +x codecov
|
||||||
|
./codecov --help
|
||||||
generate_e2e_code_cov_report:
|
generate_e2e_code_cov_report:
|
||||||
description: "Generate e2e code coverage artifacts and publish to codecov.io. Needed to that we can ignore the exit code status of the npm run test"
|
description: 'Generate e2e code coverage artifacts and publish to codecov.io. Needed to that we can ignore the exit code status of the npm run test'
|
||||||
parameters:
|
parameters:
|
||||||
suite:
|
suite:
|
||||||
type: string
|
type: string
|
||||||
steps:
|
steps:
|
||||||
- run: npm run cov:e2e:report || true
|
- run: npm run cov:e2e:report || true
|
||||||
- run: npm run cov:e2e:<<parameters.suite>>:publish
|
- download_verify_codecov_cli
|
||||||
|
- run:
|
||||||
|
name: Upload coverage report to Codecov
|
||||||
|
command: |
|
||||||
|
./codecov --verbose upload-process --disable-search \
|
||||||
|
-t $CODECOV_TOKEN \
|
||||||
|
-n 'e2e-<<parameters.suite>>'-${CIRCLE_WORKFLOW_ID} \
|
||||||
|
-F e2e-<<parameters.suite>> \
|
||||||
|
-f ./coverage/e2e/lcov.info
|
||||||
jobs:
|
jobs:
|
||||||
npm-audit:
|
npm-audit:
|
||||||
parameters:
|
parameters:
|
||||||
@ -81,7 +112,15 @@ jobs:
|
|||||||
mkdir -p dist/reports/tests/
|
mkdir -p dist/reports/tests/
|
||||||
TESTFILES=$(circleci tests glob "src/**/*Spec.js")
|
TESTFILES=$(circleci tests glob "src/**/*Spec.js")
|
||||||
echo "$TESTFILES" | circleci tests run --command="xargs npm run test" --verbose
|
echo "$TESTFILES" | circleci tests run --command="xargs npm run test" --verbose
|
||||||
- run: npm run cov:unit:publish
|
- download_verify_codecov_cli
|
||||||
|
- run:
|
||||||
|
name: Upload coverage report to Codecov
|
||||||
|
command: |
|
||||||
|
./codecov --verbose upload-process --disable-search \
|
||||||
|
-t $CODECOV_TOKEN \
|
||||||
|
-n 'unit-test'-${CIRCLE_WORKFLOW_ID} \
|
||||||
|
-F unit \
|
||||||
|
-f ./coverage/unit/lcov.info
|
||||||
- store_test_results:
|
- store_test_results:
|
||||||
path: dist/reports/tests/
|
path: dist/reports/tests/
|
||||||
- store_artifacts:
|
- store_artifacts:
|
||||||
@ -96,13 +135,13 @@ jobs:
|
|||||||
suite: #ci or full
|
suite: #ci or full
|
||||||
type: string
|
type: string
|
||||||
executor: pw-focal-development
|
executor: pw-focal-development
|
||||||
parallelism: 7
|
parallelism: 8
|
||||||
steps:
|
steps:
|
||||||
- build_and_install:
|
- build_and_install:
|
||||||
node-version: lts/hydrogen
|
node-version: lts/hydrogen
|
||||||
- when: #Only install chrome-beta when running the 'full' suite to save $$$
|
- when: #Only install chrome-beta when running the 'full' suite to save $$$
|
||||||
condition:
|
condition:
|
||||||
equal: ["full", <<parameters.suite>>]
|
equal: ['full', <<parameters.suite>>]
|
||||||
steps:
|
steps:
|
||||||
- run: npx playwright install chrome-beta
|
- run: npx playwright install chrome-beta
|
||||||
- run:
|
- run:
|
||||||
@ -159,7 +198,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- build_and_install:
|
- build_and_install:
|
||||||
node-version: lts/hydrogen
|
node-version: lts/hydrogen
|
||||||
- run: npx playwright@1.45.2 install #Necessary for bare ubuntu machine
|
- run: npx playwright@1.48.1 install #Necessary for bare ubuntu machine
|
||||||
- run: |
|
- run: |
|
||||||
export $(cat src/plugins/persistence/couch/.env.ci | xargs)
|
export $(cat src/plugins/persistence/couch/.env.ci | xargs)
|
||||||
docker compose -f src/plugins/persistence/couch/couchdb-compose.yaml up --detach
|
docker compose -f src/plugins/persistence/couch/couchdb-compose.yaml up --detach
|
||||||
@ -247,8 +286,8 @@ workflows:
|
|||||||
overall-circleci-commit-status: #These jobs run on every commit
|
overall-circleci-commit-status: #These jobs run on every commit
|
||||||
jobs:
|
jobs:
|
||||||
- lint:
|
- lint:
|
||||||
name: node20-lint
|
name: node22-lint
|
||||||
node-version: lts/iron
|
node-version: '22'
|
||||||
- unit-test:
|
- unit-test:
|
||||||
name: node18-chrome
|
name: node18-chrome
|
||||||
node-version: lts/hydrogen
|
node-version: lts/hydrogen
|
||||||
@ -265,8 +304,8 @@ workflows:
|
|||||||
the-nightly: #These jobs do not run on PRs, but against master at night
|
the-nightly: #These jobs do not run on PRs, but against master at night
|
||||||
jobs:
|
jobs:
|
||||||
- unit-test:
|
- unit-test:
|
||||||
name: node20-chrome-nightly
|
name: node22-chrome-nightly
|
||||||
node-version: lts/iron
|
node-version: '22'
|
||||||
- unit-test:
|
- unit-test:
|
||||||
name: node18-chrome
|
name: node18-chrome
|
||||||
node-version: lts/hydrogen
|
node-version: lts/hydrogen
|
||||||
@ -284,7 +323,7 @@ workflows:
|
|||||||
- e2e-couchdb
|
- e2e-couchdb
|
||||||
triggers:
|
triggers:
|
||||||
- schedule:
|
- schedule:
|
||||||
cron: "0 0 * * *"
|
cron: '0 0 * * *'
|
||||||
filters:
|
filters:
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
|
@ -483,7 +483,8 @@
|
|||||||
"countup",
|
"countup",
|
||||||
"darkmatter",
|
"darkmatter",
|
||||||
"Undeletes",
|
"Undeletes",
|
||||||
"SSSZ"
|
"SSSZ",
|
||||||
|
"pageerror"
|
||||||
],
|
],
|
||||||
"dictionaries": ["npm", "softwareTerms", "node", "html", "css", "bash", "en_US", "en-gb", "misc"],
|
"dictionaries": ["npm", "softwareTerms", "node", "html", "css", "bash", "en_US", "en-gb", "misc"],
|
||||||
"ignorePaths": [
|
"ignorePaths": [
|
||||||
|
23
.github/workflows/e2e-couchdb.yml
vendored
23
.github/workflows/e2e-couchdb.yml
vendored
@ -37,7 +37,7 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- run: npx playwright@1.45.2 install
|
- run: npx playwright@1.48.1 install
|
||||||
|
|
||||||
- name: Start CouchDB Docker Container and Init with Setup Scripts
|
- name: Start CouchDB Docker Container and Init with Setup Scripts
|
||||||
run: |
|
run: |
|
||||||
@ -52,22 +52,33 @@ jobs:
|
|||||||
COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha }}
|
COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha }}
|
||||||
run: npm run test:e2e:couchdb
|
run: npm run test:e2e:couchdb
|
||||||
|
|
||||||
|
- name: Generate Code Coverage Report
|
||||||
|
run: npm run cov:e2e:report
|
||||||
|
|
||||||
- name: Publish Results to Codecov.io
|
- name: Publish Results to Codecov.io
|
||||||
env:
|
uses: codecov/codecov-action@v5
|
||||||
SUPER_SECRET: ${{ secrets.CODECOV_TOKEN }}
|
with:
|
||||||
run: npm run cov:e2e:full:publish
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
files: ./coverage/e2e/lcov.info
|
||||||
|
flags: e2e-full
|
||||||
|
fail_ci_if_error: true
|
||||||
|
verbose: true
|
||||||
|
|
||||||
- name: Archive test results
|
- name: Archive test results
|
||||||
if: success() || failure()
|
if: success() || failure()
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
name: e2e-couchdb-test-results
|
||||||
path: test-results
|
path: test-results
|
||||||
|
overwrite: true
|
||||||
|
|
||||||
- name: Archive html test results
|
- name: Archive html test results
|
||||||
if: success() || failure()
|
if: success() || failure()
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
name: e2e-couchdb-html-test-results
|
||||||
path: html-test-results
|
path: html-test-results
|
||||||
|
overwrite: true
|
||||||
|
|
||||||
- name: Remove pr:e2e:couchdb label (if present)
|
- name: Remove pr:e2e:couchdb label (if present)
|
||||||
if: always()
|
if: always()
|
||||||
|
6
.github/workflows/e2e-flakefinder.yml
vendored
6
.github/workflows/e2e-flakefinder.yml
vendored
@ -30,7 +30,7 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-node-
|
${{ runner.os }}-node-
|
||||||
|
|
||||||
- run: npx playwright@1.45.2 install
|
- run: npx playwright@1.48.1 install
|
||||||
- run: npm ci --no-audit --progress=false
|
- run: npm ci --no-audit --progress=false
|
||||||
|
|
||||||
- name: Run E2E Tests (Repeated 10 Times)
|
- name: Run E2E Tests (Repeated 10 Times)
|
||||||
@ -38,9 +38,11 @@ jobs:
|
|||||||
|
|
||||||
- name: Archive test results
|
- name: Archive test results
|
||||||
if: success() || failure()
|
if: success() || failure()
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
name: e2e-flakefinder-test-results
|
||||||
path: test-results
|
path: test-results
|
||||||
|
overwrite: true
|
||||||
|
|
||||||
- name: Remove pr:e2e:flakefinder label (if present)
|
- name: Remove pr:e2e:flakefinder label (if present)
|
||||||
if: always()
|
if: always()
|
||||||
|
6
.github/workflows/e2e-perf.yml
vendored
6
.github/workflows/e2e-perf.yml
vendored
@ -28,16 +28,18 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-node-
|
${{ runner.os }}-node-
|
||||||
|
|
||||||
- run: npx playwright@1.45.2 install
|
- run: npx playwright@1.48.1 install
|
||||||
- run: npm ci --no-audit --progress=false
|
- run: npm ci --no-audit --progress=false
|
||||||
- run: npm run test:perf:localhost
|
- run: npm run test:perf:localhost
|
||||||
- run: npm run test:perf:contract
|
- run: npm run test:perf:contract
|
||||||
- run: npm run test:perf:memory
|
- run: npm run test:perf:memory
|
||||||
- name: Archive test results
|
- name: Archive test results
|
||||||
if: success() || failure()
|
if: success() || failure()
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
name: e2e-perf-test-results
|
||||||
path: test-results
|
path: test-results
|
||||||
|
overwrite: true
|
||||||
|
|
||||||
- name: Remove pr:e2e:perf label (if present)
|
- name: Remove pr:e2e:perf label (if present)
|
||||||
if: always()
|
if: always()
|
||||||
|
6
.github/workflows/e2e-pr.yml
vendored
6
.github/workflows/e2e-pr.yml
vendored
@ -33,7 +33,7 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-node-
|
${{ runner.os }}-node-
|
||||||
|
|
||||||
- run: npx playwright@1.45.2 install
|
- run: npx playwright@1.47.2 install
|
||||||
- run: npx playwright install chrome-beta
|
- run: npx playwright install chrome-beta
|
||||||
- run: npm ci --no-audit --progress=false
|
- run: npm ci --no-audit --progress=false
|
||||||
- run: npm run test:e2e:full -- --max-failures=40
|
- run: npm run test:e2e:full -- --max-failures=40
|
||||||
@ -45,9 +45,11 @@ jobs:
|
|||||||
npm run cov:e2e:full:publish
|
npm run cov:e2e:full:publish
|
||||||
- name: Archive test results
|
- name: Archive test results
|
||||||
if: success() || failure()
|
if: success() || failure()
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
name: e2e-pr-test-results
|
||||||
path: test-results
|
path: test-results
|
||||||
|
overwrite: true
|
||||||
|
|
||||||
- name: Remove pr:e2e label (if present)
|
- name: Remove pr:e2e label (if present)
|
||||||
if: always()
|
if: always()
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
codecov:
|
codecov:
|
||||||
require_ci_to_pass: false #This setting will update the bot regardless of whether or not tests pass
|
require_ci_to_pass: false #This setting will update the bot regardless of whether or not tests pass
|
||||||
|
|
||||||
|
# Disabling annotations for now. They are incorrectly labelling lines as lacking coverage when they are in fact covered by tests.
|
||||||
|
github_checks:
|
||||||
|
annotations: false
|
||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
status:
|
status:
|
||||||
project:
|
project:
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
extends: ['plugin:playwright/recommended'],
|
extends: ['plugin:playwright/recommended'],
|
||||||
rules: {
|
rules: {
|
||||||
'playwright/max-nested-describe': ['error', { max: 1 }],
|
|
||||||
'playwright/expect-expect': 'off'
|
'playwright/expect-expect': 'off'
|
||||||
},
|
},
|
||||||
overrides: [
|
overrides: [
|
||||||
@ -27,6 +26,12 @@ module.exports = {
|
|||||||
rules: {
|
rules: {
|
||||||
'playwright/no-raw-locators': 'off'
|
'playwright/no-raw-locators': 'off'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['**/*.visual.spec.js'],
|
||||||
|
rules: {
|
||||||
|
'playwright/no-networkidle': 'off' //https://github.com/nasa/openmct/issues/7549
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
@ -469,6 +469,7 @@ By adhering to this principle, we can create tests that are both robust and refl
|
|||||||
//Select from object
|
//Select from object
|
||||||
await percySnapshot(page, `object selected (theme: ${theme})`)
|
await percySnapshot(page, `object selected (theme: ${theme})`)
|
||||||
```
|
```
|
||||||
|
8. **Use `networkidle` to wait for network requests to complete**: This is necessary to ensure that all network requests have completed before taking a snapshot. This ensures that icons are loaded and other assets are available. https://github.com/nasa/openmct/issues/7549
|
||||||
|
|
||||||
#### How to write a great network test
|
#### How to write a great network test
|
||||||
|
|
||||||
|
@ -227,6 +227,37 @@ async function createExampleTelemetryObject(page, parent = 'mine') {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Stable State Telemetry Object (State Generator) for use in visual tests
|
||||||
|
* and tests against plotting telemetry (e.g. logPlot tests). This will change state every 2 seconds.
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {string | import('../src/api/objects/ObjectAPI').Identifier} [parent] the uuid or identifier of the parent object. Defaults to 'mine'
|
||||||
|
* @returns {Promise<CreatedObjectInfo>} An object containing information about the telemetry object.
|
||||||
|
*/
|
||||||
|
async function createStableStateTelemetry(page, parent = 'mine') {
|
||||||
|
const parentUrl = await getHashUrlToDomainObject(page, parent);
|
||||||
|
|
||||||
|
await page.goto(`${parentUrl}`);
|
||||||
|
const createdObject = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'State Generator',
|
||||||
|
name: 'Stable State Generator'
|
||||||
|
});
|
||||||
|
// edit the state generator to have a 1 second update rate
|
||||||
|
await page.getByLabel('More actions').click();
|
||||||
|
await page.getByRole('menuitem', { name: 'Edit Properties...' }).click();
|
||||||
|
await page.getByLabel('State Duration (seconds)', { exact: true }).fill('2');
|
||||||
|
await page.getByLabel('Save').click();
|
||||||
|
// Wait until the URL is updated
|
||||||
|
const uuid = await getFocusedObjectUuid(page);
|
||||||
|
const url = await getHashUrlToDomainObject(page, uuid);
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: createdObject.name,
|
||||||
|
uuid,
|
||||||
|
url
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigates directly to a given object url, in fixed time mode, with the given start and end bounds. Note: does not set
|
* Navigates directly to a given object url, in fixed time mode, with the given start and end bounds. Note: does not set
|
||||||
* default view type.
|
* default view type.
|
||||||
@ -479,6 +510,10 @@ async function setTimeConductorBounds(page, { submitChanges = true, ...bounds })
|
|||||||
// Open the time conductor popup
|
// Open the time conductor popup
|
||||||
await page.getByRole('button', { name: 'Time Conductor Mode', exact: true }).click();
|
await page.getByRole('button', { name: 'Time Conductor Mode', exact: true }).click();
|
||||||
|
|
||||||
|
// FIXME: https://github.com/nasa/openmct/pull/7818
|
||||||
|
// eslint-disable-next-line playwright/no-wait-for-timeout
|
||||||
|
await page.waitForTimeout(500);
|
||||||
|
|
||||||
if (startDate) {
|
if (startDate) {
|
||||||
await page.getByLabel('Start date').fill(startDate);
|
await page.getByLabel('Start date').fill(startDate);
|
||||||
}
|
}
|
||||||
@ -629,15 +664,51 @@ async function getCanvasPixels(page, canvasSelector) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for telemetry and link it to an object. objectName should come from the domainObject.name function.
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {string} parameterName
|
||||||
|
* @param {string} objectName
|
||||||
|
*/
|
||||||
|
async function linkParameterToObject(page, parameterName, objectName) {
|
||||||
|
await page.getByRole('searchbox', { name: 'Search Input' }).click();
|
||||||
|
await page.getByRole('searchbox', { name: 'Search Input' }).fill(parameterName);
|
||||||
|
await page.getByLabel('Object Results').getByText(parameterName).click();
|
||||||
|
await page.getByLabel('More actions').click();
|
||||||
|
await page.getByLabel('Create Link').click();
|
||||||
|
await page.getByLabel('Modal Overlay').getByLabel('Search Input').click();
|
||||||
|
await page.getByLabel('Modal Overlay').getByLabel('Search Input').fill(objectName);
|
||||||
|
await page.getByLabel('Modal Overlay').getByLabel(`Navigate to ${objectName}`).click();
|
||||||
|
await page.getByLabel('Save').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rename the currently viewed `domainObject` from the browse bar.
|
||||||
|
*
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {string} newName
|
||||||
|
*/
|
||||||
|
async function renameCurrentObjectFromBrowseBar(page, newName) {
|
||||||
|
const nameInput = page.getByLabel('Browse bar object name');
|
||||||
|
await nameInput.click();
|
||||||
|
await nameInput.fill('');
|
||||||
|
await nameInput.fill(newName);
|
||||||
|
// Click the browse bar container to save changes
|
||||||
|
await page.getByLabel('Browse bar', { exact: true }).click();
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
createDomainObjectWithDefaults,
|
createDomainObjectWithDefaults,
|
||||||
createExampleTelemetryObject,
|
createExampleTelemetryObject,
|
||||||
createNotification,
|
createNotification,
|
||||||
createPlanFromJSON,
|
createPlanFromJSON,
|
||||||
|
createStableStateTelemetry,
|
||||||
expandEntireTree,
|
expandEntireTree,
|
||||||
getCanvasPixels,
|
getCanvasPixels,
|
||||||
|
linkParameterToObject,
|
||||||
navigateToObjectWithFixedTimeBounds,
|
navigateToObjectWithFixedTimeBounds,
|
||||||
navigateToObjectWithRealTime,
|
navigateToObjectWithRealTime,
|
||||||
|
renameCurrentObjectFromBrowseBar,
|
||||||
setEndOffset,
|
setEndOffset,
|
||||||
setFixedIndependentTimeConductorBounds,
|
setFixedIndependentTimeConductorBounds,
|
||||||
setFixedTimeMode,
|
setFixedTimeMode,
|
||||||
|
@ -103,25 +103,40 @@ const extendedTest = test.extend({
|
|||||||
* Default: `true`
|
* Default: `true`
|
||||||
*/
|
*/
|
||||||
failOnConsoleError: [true, { option: true }],
|
failOnConsoleError: [true, { option: true }],
|
||||||
|
ignore404s: [[], { option: true }],
|
||||||
/**
|
/**
|
||||||
* Extends the base page class to enable console log error detection.
|
* Extends the base page class to enable console log error detection.
|
||||||
* @see {@link https://github.com/microsoft/playwright/discussions/11690 Github Discussion}
|
* @see {@link https://github.com/microsoft/playwright/discussions/11690 Github Discussion}
|
||||||
*/
|
*/
|
||||||
page: async ({ page, failOnConsoleError }, use) => {
|
page: async ({ page, failOnConsoleError, ignore404s }, use) => {
|
||||||
// Capture any console errors during test execution
|
// Capture any console errors during test execution
|
||||||
const messages = [];
|
let messages = [];
|
||||||
page.on('console', (msg) => messages.push(msg));
|
page.on('console', (msg) => messages.push(msg));
|
||||||
|
|
||||||
await use(page);
|
await use(page);
|
||||||
|
|
||||||
|
if (ignore404s.length > 0) {
|
||||||
|
messages = messages.filter((msg) => {
|
||||||
|
let keep = true;
|
||||||
|
|
||||||
|
if (msg.text().match(/404 \((Object )?Not Found\)/) !== null) {
|
||||||
|
keep = ignore404s.every((ignoreRule) => {
|
||||||
|
return msg.location().url.match(ignoreRule) === null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return keep;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Assert against console errors during teardown
|
// Assert against console errors during teardown
|
||||||
if (failOnConsoleError) {
|
if (failOnConsoleError) {
|
||||||
messages.forEach((msg) =>
|
messages.forEach((msg) => {
|
||||||
// eslint-disable-next-line playwright/no-standalone-expect
|
// eslint-disable-next-line playwright/no-standalone-expect
|
||||||
expect
|
expect
|
||||||
.soft(msg.type(), `Console error detected: ${_consoleMessageToString(msg)}`)
|
.soft(msg.type(), `Console error detected: ${_consoleMessageToString(msg)}`)
|
||||||
.not.toEqual('error')
|
.not.toEqual('error');
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -25,6 +25,7 @@ import { expect } from '../pluginFixtures.js';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
export async function navigateToFaultManagementWithExample(page) {
|
export async function navigateToFaultManagementWithExample(page) {
|
||||||
await page.addInitScript({
|
await page.addInitScript({
|
||||||
@ -36,6 +37,7 @@ export async function navigateToFaultManagementWithExample(page) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
export async function navigateToFaultManagementWithStaticExample(page) {
|
export async function navigateToFaultManagementWithStaticExample(page) {
|
||||||
await page.addInitScript({
|
await page.addInitScript({
|
||||||
@ -47,6 +49,7 @@ export async function navigateToFaultManagementWithStaticExample(page) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
export async function navigateToFaultManagementWithoutExample(page) {
|
export async function navigateToFaultManagementWithoutExample(page) {
|
||||||
await page.addInitScript({
|
await page.addInitScript({
|
||||||
@ -58,6 +61,7 @@ export async function navigateToFaultManagementWithoutExample(page) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async function navigateToFaultItemInTree(page) {
|
async function navigateToFaultItemInTree(page) {
|
||||||
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
@ -77,6 +81,8 @@ async function navigateToFaultItemInTree(page) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {number} rowNumber
|
||||||
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
export async function acknowledgeFault(page, rowNumber) {
|
export async function acknowledgeFault(page, rowNumber) {
|
||||||
await openFaultRowMenu(page, rowNumber);
|
await openFaultRowMenu(page, rowNumber);
|
||||||
@ -86,6 +92,8 @@ export async function acknowledgeFault(page, rowNumber) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {...number} nums
|
||||||
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
export async function shelveMultipleFaults(page, ...nums) {
|
export async function shelveMultipleFaults(page, ...nums) {
|
||||||
const selectRows = nums.map((num) => {
|
const selectRows = nums.map((num) => {
|
||||||
@ -99,6 +107,8 @@ export async function shelveMultipleFaults(page, ...nums) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {...number} nums
|
||||||
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
export async function acknowledgeMultipleFaults(page, ...nums) {
|
export async function acknowledgeMultipleFaults(page, ...nums) {
|
||||||
const selectRows = nums.map((num) => {
|
const selectRows = nums.map((num) => {
|
||||||
@ -106,50 +116,43 @@ export async function acknowledgeMultipleFaults(page, ...nums) {
|
|||||||
});
|
});
|
||||||
await Promise.all(selectRows);
|
await Promise.all(selectRows);
|
||||||
|
|
||||||
await page.locator('button:has-text("Acknowledge")').click();
|
await page.getByLabel('Acknowledge selected faults').click();
|
||||||
await page.getByLabel('Save').click();
|
await page.getByLabel('Save').click();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {number} rowNumber
|
||||||
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
export async function shelveFault(page, rowNumber) {
|
export async function shelveFault(page, rowNumber) {
|
||||||
await openFaultRowMenu(page, rowNumber);
|
await openFaultRowMenu(page, rowNumber);
|
||||||
await page.locator('.c-menu >> text="Shelve"').click();
|
await page.getByLabel('Shelve', { exact: true }).click();
|
||||||
// Click [aria-label="Save"]
|
|
||||||
await page.getByLabel('Save').click();
|
await page.getByLabel('Save').click();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
*/
|
* @param {'severity' | 'newest-first' | 'oldest-first'} sort
|
||||||
export async function changeViewTo(page, view) {
|
* @returns {Promise<void>}
|
||||||
await page.locator('.c-fault-mgmt__search-row select').first().selectOption(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {import('@playwright/test').Page} page
|
|
||||||
*/
|
*/
|
||||||
export async function sortFaultsBy(page, sort) {
|
export async function sortFaultsBy(page, sort) {
|
||||||
await page.locator('.c-fault-mgmt__list-header-sortButton select').selectOption(sort);
|
await page.getByTitle('Sort By').getByRole('combobox').selectOption(sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {'acknowledged' | 'shelved' | 'standard view'} view
|
||||||
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
export async function enterSearchTerm(page, term) {
|
export async function changeViewTo(page, view) {
|
||||||
await page.locator('.c-fault-mgmt-search [aria-label="Search Input"]').fill(term);
|
await page.getByTitle('View Filter').getByRole('combobox').selectOption(view);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {import('@playwright/test').Page} page
|
|
||||||
*/
|
|
||||||
export async function clearSearch(page) {
|
|
||||||
await enterSearchTerm(page, '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {number} rowNumber
|
||||||
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
export async function selectFaultItem(page, rowNumber) {
|
export async function selectFaultItem(page, rowNumber) {
|
||||||
await page
|
await page
|
||||||
@ -165,71 +168,37 @@ export async function selectFaultItem(page, rowNumber) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
*/
|
* @param {number} rowNumber
|
||||||
export async function getHighestSeverity(page) {
|
* @returns {import('@playwright/test').Locator}
|
||||||
const criticalCount = await page.locator('[title=CRITICAL]').count();
|
|
||||||
const warningCount = await page.locator('[title=WARNING]').count();
|
|
||||||
|
|
||||||
if (criticalCount > 0) {
|
|
||||||
return 'CRITICAL';
|
|
||||||
} else if (warningCount > 0) {
|
|
||||||
return 'WARNING';
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'WATCH';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {import('@playwright/test').Page} page
|
|
||||||
*/
|
|
||||||
export async function getLowestSeverity(page) {
|
|
||||||
const warningCount = await page.locator('[title=WARNING]').count();
|
|
||||||
const watchCount = await page.locator('[title=WATCH]').count();
|
|
||||||
|
|
||||||
if (watchCount > 0) {
|
|
||||||
return 'WATCH';
|
|
||||||
} else if (warningCount > 0) {
|
|
||||||
return 'WARNING';
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'CRITICAL';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {import('@playwright/test').Page} page
|
|
||||||
*/
|
|
||||||
export async function getFaultResultCount(page) {
|
|
||||||
const count = await page.locator('.c-faults-list-view-item-body > .c-fault-mgmt__list').count();
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {import('@playwright/test').Page} page
|
|
||||||
*/
|
*/
|
||||||
export function getFault(page, rowNumber) {
|
export function getFault(page, rowNumber) {
|
||||||
const fault = page.locator(
|
const fault = page.getByLabel('Fault triggered at').nth(rowNumber - 1);
|
||||||
`.c-faults-list-view-item-body > .c-fault-mgmt__list >> nth=${rowNumber - 1}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return fault;
|
return fault;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {string} name
|
||||||
|
* @returns {import('@playwright/test').Locator}
|
||||||
*/
|
*/
|
||||||
export function getFaultByName(page, name) {
|
export function getFaultByName(page, name) {
|
||||||
const fault = page.locator(`.c-fault-mgmt__list-faultname:has-text("${name}")`);
|
const fault = page.getByLabel('Fault triggered at').filter({
|
||||||
|
hasText: name
|
||||||
|
});
|
||||||
|
|
||||||
return fault;
|
return fault;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {number} rowNumber
|
||||||
|
* @returns {Promise<string>}
|
||||||
*/
|
*/
|
||||||
export async function getFaultName(page, rowNumber) {
|
export async function getFaultName(page, rowNumber) {
|
||||||
const faultName = await page
|
const faultName = await page
|
||||||
.locator(`.c-fault-mgmt__list-faultname >> nth=${rowNumber - 1}`)
|
.getByLabel('Fault name', { exact: true })
|
||||||
|
.nth(rowNumber - 1)
|
||||||
.textContent();
|
.textContent();
|
||||||
|
|
||||||
return faultName;
|
return faultName;
|
||||||
@ -237,21 +206,13 @@ export async function getFaultName(page, rowNumber) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
*/
|
* @param {number} rowNumber
|
||||||
export async function getFaultSeverity(page, rowNumber) {
|
* @returns {Promise<string>}
|
||||||
const faultSeverity = await page
|
|
||||||
.locator(`.c-faults-list-view-item-body .c-fault-mgmt__list-severity >> nth=${rowNumber - 1}`)
|
|
||||||
.getAttribute('title');
|
|
||||||
|
|
||||||
return faultSeverity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {import('@playwright/test').Page} page
|
|
||||||
*/
|
*/
|
||||||
export async function getFaultNamespace(page, rowNumber) {
|
export async function getFaultNamespace(page, rowNumber) {
|
||||||
const faultNamespace = await page
|
const faultNamespace = await page
|
||||||
.locator(`.c-fault-mgmt__list-path >> nth=${rowNumber - 1}`)
|
.getByLabel('Fault namespace')
|
||||||
|
.nth(rowNumber - 1)
|
||||||
.textContent();
|
.textContent();
|
||||||
|
|
||||||
return faultNamespace;
|
return faultNamespace;
|
||||||
@ -259,10 +220,13 @@ export async function getFaultNamespace(page, rowNumber) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {number} rowNumber
|
||||||
|
* @returns {Promise<string>}
|
||||||
*/
|
*/
|
||||||
export async function getFaultTriggerTime(page, rowNumber) {
|
export async function getFaultTriggerTime(page, rowNumber) {
|
||||||
const faultTriggerTime = await page
|
const faultTriggerTime = await page
|
||||||
.locator(`.c-fault-mgmt__list-trigTime >> nth=${rowNumber - 1} >> .c-fault-mgmt-item__value`)
|
.getByLabel('Last Trigger Time')
|
||||||
|
.nth(rowNumber - 1)
|
||||||
.textContent();
|
.textContent();
|
||||||
|
|
||||||
return faultTriggerTime.toString().trim();
|
return faultTriggerTime.toString().trim();
|
||||||
@ -270,11 +234,14 @@ export async function getFaultTriggerTime(page, rowNumber) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {number} rowNumber
|
||||||
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
export async function openFaultRowMenu(page, rowNumber) {
|
export async function openFaultRowMenu(page, rowNumber) {
|
||||||
// select
|
// select
|
||||||
await page
|
await page
|
||||||
.getByLabel('Disposition actions')
|
.getByLabel('Fault triggered at')
|
||||||
.nth(rowNumber - 1)
|
.nth(rowNumber - 1)
|
||||||
|
.getByLabel('Disposition Actions')
|
||||||
.click();
|
.click();
|
||||||
}
|
}
|
||||||
|
33
e2e/helper/imageryUtils.js
Normal file
33
e2e/helper/imageryUtils.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import { createDomainObjectWithDefaults } from '../appActions.js';
|
||||||
|
import { expect } from '../pluginFixtures.js';
|
||||||
|
|
||||||
|
const IMAGE_LOAD_DELAY = 5 * 1000;
|
||||||
|
const FIVE_MINUTES = 1000 * 60 * 5;
|
||||||
|
const THIRTY_SECONDS = 1000 * 30;
|
||||||
|
const MOUSE_WHEEL_DELTA_Y = 120;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
*/
|
||||||
|
async function createImageryViewWithShortDelay(page, { name, parent }) {
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
name,
|
||||||
|
type: 'Example Imagery',
|
||||||
|
parent
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Example Imagery');
|
||||||
|
await page.getByLabel('More actions').click();
|
||||||
|
await page.getByLabel('Edit Properties').click();
|
||||||
|
// Clear and set Image load delay to minimum value
|
||||||
|
await page.locator('input[type="number"]').fill(`${IMAGE_LOAD_DELAY}`);
|
||||||
|
await page.getByLabel('Save').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
createImageryViewWithShortDelay,
|
||||||
|
FIVE_MINUTES,
|
||||||
|
IMAGE_LOAD_DELAY,
|
||||||
|
MOUSE_WHEEL_DELTA_Y,
|
||||||
|
THIRTY_SECONDS
|
||||||
|
};
|
@ -129,6 +129,7 @@ export async function setBoundsToSpanAllActivities(page, planJson, planObjectUrl
|
|||||||
*/
|
*/
|
||||||
export function getEarliestStartTime(planJson) {
|
export function getEarliestStartTime(planJson) {
|
||||||
const activities = Object.values(planJson).flat();
|
const activities = Object.values(planJson).flat();
|
||||||
|
|
||||||
return Math.min(...activities.map((activity) => activity.start));
|
return Math.min(...activities.map((activity) => activity.start));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +140,7 @@ export function getEarliestStartTime(planJson) {
|
|||||||
*/
|
*/
|
||||||
export function getLatestEndTime(planJson) {
|
export function getLatestEndTime(planJson) {
|
||||||
const activities = Object.values(planJson).flat();
|
const activities = Object.values(planJson).flat();
|
||||||
|
|
||||||
return Math.max(...activities.map((activity) => activity.end));
|
return Math.max(...activities.map((activity) => activity.end));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,6 +153,7 @@ export function getFirstActivity(planJson) {
|
|||||||
const groups = Object.keys(planJson);
|
const groups = Object.keys(planJson);
|
||||||
const firstGroupKey = groups[0];
|
const firstGroupKey = groups[0];
|
||||||
const firstGroupItems = planJson[firstGroupKey];
|
const firstGroupItems = planJson[firstGroupKey];
|
||||||
|
|
||||||
return firstGroupItems[0];
|
return firstGroupItems[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "openmct-e2e",
|
"name": "openmct-e2e",
|
||||||
"version": "4.0.0-next",
|
"version": "4.1.0-next",
|
||||||
"description": "The Open MCT e2e framework",
|
"description": "The Open MCT e2e framework",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"module": "index.js",
|
"module": "index.js",
|
||||||
@ -16,7 +16,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@percy/cli": "1.27.4",
|
"@percy/cli": "1.27.4",
|
||||||
"@percy/playwright": "1.0.4",
|
"@percy/playwright": "1.0.4",
|
||||||
"@playwright/test": "1.45.2",
|
"@playwright/test": "1.48.1",
|
||||||
"@axe-core/playwright": "4.8.5"
|
"@axe-core/playwright": "4.8.5"
|
||||||
},
|
},
|
||||||
"author": {
|
"author": {
|
||||||
@ -24,4 +24,4 @@
|
|||||||
"url": "https://www.nasa.gov"
|
"url": "https://www.nasa.gov"
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
}
|
}
|
22
e2e/test-data/condition_set_storage.json
Normal file
22
e2e/test-data/condition_set_storage.json
Normal file
File diff suppressed because one or more lines are too long
BIN
e2e/test-data/rick space roll.jpg
Normal file
BIN
e2e/test-data/rick space roll.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
@ -26,8 +26,10 @@ import {
|
|||||||
createExampleTelemetryObject,
|
createExampleTelemetryObject,
|
||||||
createNotification,
|
createNotification,
|
||||||
createPlanFromJSON,
|
createPlanFromJSON,
|
||||||
|
createStableStateTelemetry,
|
||||||
expandEntireTree,
|
expandEntireTree,
|
||||||
getCanvasPixels,
|
getCanvasPixels,
|
||||||
|
linkParameterToObject,
|
||||||
navigateToObjectWithFixedTimeBounds,
|
navigateToObjectWithFixedTimeBounds,
|
||||||
navigateToObjectWithRealTime,
|
navigateToObjectWithRealTime,
|
||||||
setEndOffset,
|
setEndOffset,
|
||||||
@ -339,4 +341,23 @@ test.describe('AppActions @framework', () => {
|
|||||||
// Expect this step to fail
|
// Expect this step to fail
|
||||||
await waitForPlotsToRender(page, { timeout: 1000 });
|
await waitForPlotsToRender(page, { timeout: 1000 });
|
||||||
});
|
});
|
||||||
|
test('createStableStateTelemetry', async ({ page }) => {
|
||||||
|
const stableStateTelemetry = await createStableStateTelemetry(page);
|
||||||
|
expect(stableStateTelemetry.name).toBe('Stable State Generator');
|
||||||
|
expect(stableStateTelemetry.url).toBe(`./#/browse/mine/${stableStateTelemetry.uuid}`);
|
||||||
|
expect(stableStateTelemetry.uuid).toBeDefined();
|
||||||
|
});
|
||||||
|
test('linkParameterToObject', async ({ page }) => {
|
||||||
|
const displayLayout = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Display Layout',
|
||||||
|
name: 'Test Display Layout'
|
||||||
|
});
|
||||||
|
const exampleTelemetry = await createExampleTelemetryObject(page);
|
||||||
|
|
||||||
|
await linkParameterToObject(page, exampleTelemetry.name, displayLayout.name);
|
||||||
|
await page.goto(displayLayout.url);
|
||||||
|
await expect(page.getByRole('main').getByText('Test Display Layout')).toBeVisible();
|
||||||
|
await expandEntireTree(page);
|
||||||
|
await expect(page.getByLabel('Navigate to VIPER Rover').first()).toBeVisible();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -286,6 +286,55 @@ test.describe('Generate Visual Test Data @localStorage @generatedata @clock', ()
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test.describe('Generate Conditional Styling Data @localStorage @generatedata', () => {
|
||||||
|
test('Generate basic condition set', async ({ page, context }) => {
|
||||||
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
// Create a Condition Set
|
||||||
|
const conditionSet = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Condition Set',
|
||||||
|
name: 'Test Condition Set'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a Telemetry Object (Sine Wave Generator)
|
||||||
|
const swg = await createExampleTelemetryObject(page, conditionSet.uuid);
|
||||||
|
|
||||||
|
// Edit the Telemetry Object to have a 10hz data rate (Gotta go fast!)
|
||||||
|
await page.goto(swg.url);
|
||||||
|
await page.getByLabel('More actions').click();
|
||||||
|
await page.getByRole('menuitem', { name: 'Edit Properties...' }).click();
|
||||||
|
await page.getByLabel('Period', { exact: true }).fill('5');
|
||||||
|
await page.getByLabel('Save').click();
|
||||||
|
|
||||||
|
// Edit the Condition Set
|
||||||
|
await page.goto(conditionSet.url);
|
||||||
|
await page.getByLabel('Edit Object').click();
|
||||||
|
|
||||||
|
// Add a Condition to the Condition Set
|
||||||
|
await page.getByLabel('Add Condition').click();
|
||||||
|
await page.getByLabel('Condition Name Input').first().fill('Test Condition');
|
||||||
|
await page.getByLabel('Condition Output Type').first().selectOption('String');
|
||||||
|
await page.getByLabel('Condition Output String').first().fill('Test Condition Met');
|
||||||
|
|
||||||
|
// Condition: True if sine value > 0 (half the time)
|
||||||
|
await page.getByLabel('Criterion Telemetry Selection').selectOption(swg.name);
|
||||||
|
await page.getByLabel('Criterion Metadata Selection').selectOption('Sine');
|
||||||
|
await page.getByLabel('Criterion Comparison Selection').selectOption('is greater than');
|
||||||
|
await page.getByLabel('Criterion Input').first().fill('0');
|
||||||
|
|
||||||
|
// Rename default condition
|
||||||
|
await page.getByLabel('Condition Output String').nth(1).fill('Test Condition Unmet');
|
||||||
|
await page.getByLabel('Save').click();
|
||||||
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
||||||
|
|
||||||
|
// Save localStorage for future test execution
|
||||||
|
await context.storageState({
|
||||||
|
path: fileURLToPath(
|
||||||
|
new URL('../../../e2e/test-data/condition_set_storage.json', import.meta.url)
|
||||||
|
)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test.describe('Validate Overlay Plot with Telemetry Object @localStorage @generatedata', () => {
|
test.describe('Validate Overlay Plot with Telemetry Object @localStorage @generatedata', () => {
|
||||||
test.use({
|
test.use({
|
||||||
storageState: fileURLToPath(
|
storageState: fileURLToPath(
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2024, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
import { createDomainObjectWithDefaults, setRealTimeMode } from '../../../appActions.js';
|
||||||
|
import { MISSION_TIME } from '../../../constants.js';
|
||||||
|
import { expect, test } from '../../../pluginFixtures.js';
|
||||||
|
|
||||||
|
const TELEMETRY_RATE = 2500;
|
||||||
|
|
||||||
|
test.describe('Example Event Generator Acknowledge with Controlled Clock @clock', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.clock.install({ time: MISSION_TIME });
|
||||||
|
await page.clock.resume();
|
||||||
|
|
||||||
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
|
await setRealTimeMode(page);
|
||||||
|
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Event Message Generator with Acknowledge'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Rows are updatable in place', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/7938'
|
||||||
|
});
|
||||||
|
|
||||||
|
await test.step('First telemetry datum gets added as new row', async () => {
|
||||||
|
await page.clock.fastForward(TELEMETRY_RATE);
|
||||||
|
const rows = page.getByLabel('table content').getByLabel('Table Row');
|
||||||
|
const acknowledgeCell = rows.first().getByLabel('acknowledge table cell');
|
||||||
|
|
||||||
|
await expect(rows).toHaveCount(1);
|
||||||
|
await expect(acknowledgeCell).not.toHaveAttribute('title', 'OK');
|
||||||
|
});
|
||||||
|
|
||||||
|
await test.step('Incoming Telemetry datum matching an existing rows in place update key has data merged to existing row', async () => {
|
||||||
|
await page.clock.fastForward(TELEMETRY_RATE * 2);
|
||||||
|
const rows = page.getByLabel('table content').getByLabel('Table Row');
|
||||||
|
const acknowledgeCell = rows.first().getByLabel('acknowledge table cell');
|
||||||
|
|
||||||
|
await expect(rows).toHaveCount(1);
|
||||||
|
await expect(acknowledgeCell).toHaveAttribute('title', 'OK');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -54,8 +54,7 @@ const examplePlanSmall1 = JSON.parse(
|
|||||||
const TIME_TO_FROM_COLUMN = 2;
|
const TIME_TO_FROM_COLUMN = 2;
|
||||||
const HEADER_ROW = 0;
|
const HEADER_ROW = 0;
|
||||||
const NUM_COLUMNS = 5;
|
const NUM_COLUMNS = 5;
|
||||||
const FULL_CIRCLE_PATH =
|
const FULL_CIRCLE_PATH = 'M0,-50A50,50,0,1,1,0,50A50,50,0,1,1,0,-50Z';
|
||||||
'M3.061616997868383e-15,-50A50,50,0,1,1,-3.061616997868383e-15,50A50,50,0,1,1,3.061616997868383e-15,-50Z';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The regular expression used to parse the countdown string.
|
* The regular expression used to parse the countdown string.
|
||||||
|
@ -24,7 +24,9 @@ import {
|
|||||||
createDomainObjectWithDefaults,
|
createDomainObjectWithDefaults,
|
||||||
createPlanFromJSON,
|
createPlanFromJSON,
|
||||||
navigateToObjectWithFixedTimeBounds,
|
navigateToObjectWithFixedTimeBounds,
|
||||||
setFixedIndependentTimeConductorBounds
|
setFixedIndependentTimeConductorBounds,
|
||||||
|
setFixedTimeMode,
|
||||||
|
setTimeConductorBounds
|
||||||
} from '../../../appActions.js';
|
} from '../../../appActions.js';
|
||||||
import { expect, test } from '../../../pluginFixtures.js';
|
import { expect, test } from '../../../pluginFixtures.js';
|
||||||
|
|
||||||
@ -74,21 +76,14 @@ const testPlan = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test.describe('Time Strip', () => {
|
test.describe('Time Strip', () => {
|
||||||
test('Create two Time Strips, add a single Plan to both, and verify they can have separate Independent Time Contexts', async ({
|
let timestrip;
|
||||||
page
|
let plan;
|
||||||
}) => {
|
|
||||||
test.info().annotations.push({
|
|
||||||
type: 'issue',
|
|
||||||
description: 'https://github.com/nasa/openmct/issues/5627'
|
|
||||||
});
|
|
||||||
|
|
||||||
// Constant locators
|
|
||||||
const activityBounds = page.locator('.activity-bounds');
|
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
// Goto baseURL
|
// Goto baseURL
|
||||||
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
const timestrip = await test.step('Create a Time Strip', async () => {
|
timestrip = await test.step('Create a Time Strip', async () => {
|
||||||
const createdTimeStrip = await createDomainObjectWithDefaults(page, { type: 'Time Strip' });
|
const createdTimeStrip = await createDomainObjectWithDefaults(page, { type: 'Time Strip' });
|
||||||
const objectName = await page.locator('.l-browse-bar__object-name').innerText();
|
const objectName = await page.locator('.l-browse-bar__object-name').innerText();
|
||||||
expect(objectName).toBe(createdTimeStrip.name);
|
expect(objectName).toBe(createdTimeStrip.name);
|
||||||
@ -96,7 +91,7 @@ test.describe('Time Strip', () => {
|
|||||||
return createdTimeStrip;
|
return createdTimeStrip;
|
||||||
});
|
});
|
||||||
|
|
||||||
const plan = await test.step('Create a Plan and add it to the timestrip', async () => {
|
plan = await test.step('Create a Plan and add it to the timestrip', async () => {
|
||||||
const createdPlan = await createPlanFromJSON(page, {
|
const createdPlan = await createPlanFromJSON(page, {
|
||||||
name: 'Test Plan',
|
name: 'Test Plan',
|
||||||
json: testPlan
|
json: testPlan
|
||||||
@ -110,6 +105,22 @@ test.describe('Time Strip', () => {
|
|||||||
.dragTo(page.getByLabel('Object View'));
|
.dragTo(page.getByLabel('Object View'));
|
||||||
await page.getByLabel('Save').click();
|
await page.getByLabel('Save').click();
|
||||||
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
||||||
|
|
||||||
|
return createdPlan;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('Create two Time Strips, add a single Plan to both, and verify they can have separate Independent Time Contexts', async ({
|
||||||
|
page
|
||||||
|
}) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5627'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Constant locators
|
||||||
|
const activityBounds = page.locator('.activity-bounds');
|
||||||
|
|
||||||
|
await test.step('Set time strip to fixed timespan mode and verify activities', async () => {
|
||||||
const startBound = testPlan.TEST_GROUP[0].start;
|
const startBound = testPlan.TEST_GROUP[0].start;
|
||||||
const endBound = testPlan.TEST_GROUP[testPlan.TEST_GROUP.length - 1].end;
|
const endBound = testPlan.TEST_GROUP[testPlan.TEST_GROUP.length - 1].end;
|
||||||
|
|
||||||
@ -119,8 +130,6 @@ test.describe('Time Strip', () => {
|
|||||||
// Verify all events are displayed
|
// Verify all events are displayed
|
||||||
const eventCount = await page.locator('.activity-bounds').count();
|
const eventCount = await page.locator('.activity-bounds').count();
|
||||||
expect(eventCount).toEqual(testPlan.TEST_GROUP.length);
|
expect(eventCount).toEqual(testPlan.TEST_GROUP.length);
|
||||||
|
|
||||||
return createdPlan;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await test.step('TimeStrip can use the Independent Time Conductor', async () => {
|
await test.step('TimeStrip can use the Independent Time Conductor', async () => {
|
||||||
@ -177,4 +186,48 @@ test.describe('Time Strip', () => {
|
|||||||
expect(await activityBounds.count()).toEqual(1);
|
expect(await activityBounds.count()).toEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Time strip now line', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/7817'
|
||||||
|
});
|
||||||
|
|
||||||
|
await test.step('Is displayed in realtime mode', async () => {
|
||||||
|
await expect(page.getByLabel('Now Marker')).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
await test.step('Is hidden when out of bounds of the time axis', async () => {
|
||||||
|
// Switch to fixed timespan mode
|
||||||
|
await setFixedTimeMode(page);
|
||||||
|
// Get the end bounds
|
||||||
|
const endBounds = await page.getByLabel('End bounds').textContent();
|
||||||
|
|
||||||
|
// Add 2 minutes to end bound datetime and use it as the new end time
|
||||||
|
let endTimeStamp = new Date(endBounds);
|
||||||
|
endTimeStamp.setUTCMinutes(endTimeStamp.getUTCMinutes() + 2);
|
||||||
|
const endDate = endTimeStamp.toISOString().split('T')[0];
|
||||||
|
const milliseconds = endTimeStamp.getMilliseconds();
|
||||||
|
const endTime = endTimeStamp.toISOString().split('T')[1].replace(`.${milliseconds}Z`, '');
|
||||||
|
|
||||||
|
// Subtract 1 minute from the end bound and use it as the new start time
|
||||||
|
let startTimeStamp = new Date(endBounds);
|
||||||
|
startTimeStamp.setUTCMinutes(startTimeStamp.getUTCMinutes() + 1);
|
||||||
|
const startDate = startTimeStamp.toISOString().split('T')[0];
|
||||||
|
const startMilliseconds = startTimeStamp.getMilliseconds();
|
||||||
|
const startTime = startTimeStamp
|
||||||
|
.toISOString()
|
||||||
|
.split('T')[1]
|
||||||
|
.replace(`.${startMilliseconds}Z`, '');
|
||||||
|
// Set fixed timespan mode to the future so that "now" is out of bounds.
|
||||||
|
await setTimeConductorBounds(page, {
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
startTime,
|
||||||
|
endTime
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(page.getByLabel('Now Marker')).toBeHidden();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -287,6 +287,41 @@ test.describe('Basic Condition Set Use', () => {
|
|||||||
description: 'https://github.com/nasa/openmct/issues/7484'
|
description: 'https://github.com/nasa/openmct/issues/7484'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('ConditionSet has add criteria button enabled/disabled when composition is and is not available', async ({
|
||||||
|
page
|
||||||
|
}) => {
|
||||||
|
const exampleTelemetry = await createExampleTelemetryObject(page);
|
||||||
|
|
||||||
|
await page.getByLabel('Show selected item in tree').click();
|
||||||
|
await page.goto(conditionSet.url);
|
||||||
|
// Change the object to edit mode
|
||||||
|
await page.getByLabel('Edit Object').click();
|
||||||
|
|
||||||
|
// Create a condition
|
||||||
|
await page.locator('#addCondition').click();
|
||||||
|
await page.locator('#conditionCollection').getByRole('textbox').nth(0).fill('First Condition');
|
||||||
|
|
||||||
|
// Validate that the add criteria button is disabled
|
||||||
|
await expect(page.getByLabel('Add Criteria - Disabled')).toHaveAttribute('disabled');
|
||||||
|
|
||||||
|
// Add Telemetry to ConditionSet
|
||||||
|
const sineWaveGeneratorTreeItem = page
|
||||||
|
.getByRole('tree', {
|
||||||
|
name: 'Main Tree'
|
||||||
|
})
|
||||||
|
.getByRole('treeitem', {
|
||||||
|
name: exampleTelemetry.name
|
||||||
|
});
|
||||||
|
const conditionCollection = page.locator('#conditionCollection');
|
||||||
|
await sineWaveGeneratorTreeItem.dragTo(conditionCollection);
|
||||||
|
|
||||||
|
// Validate that the add criteria button is enabled and adds a new criterion
|
||||||
|
await expect(page.getByLabel('Add Criteria - Enabled')).not.toHaveAttribute('disabled');
|
||||||
|
await page.getByLabel('Add Criteria - Enabled').click();
|
||||||
|
const numOfUnnamedCriteria = await page.getByLabel('Criterion Telemetry Selection').count();
|
||||||
|
expect(numOfUnnamedCriteria).toEqual(2);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe('Condition Set Composition', () => {
|
test.describe('Condition Set Composition', () => {
|
||||||
|
@ -507,8 +507,140 @@ test.describe('Display Layout', () => {
|
|||||||
// In real time mode, we don't fetch annotations at all
|
// In real time mode, we don't fetch annotations at all
|
||||||
await expect.poll(() => networkRequests, { timeout: 10000 }).toHaveLength(0);
|
await expect.poll(() => networkRequests, { timeout: 10000 }).toHaveLength(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Same objects with different request options have unique subscriptions', async ({
|
||||||
|
page
|
||||||
|
}) => {
|
||||||
|
// Expand My Items
|
||||||
|
await page.getByLabel('Expand My Items folder').click();
|
||||||
|
|
||||||
|
// Create a Display Layout
|
||||||
|
const displayLayout = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Display Layout',
|
||||||
|
name: 'Test Display'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a State Generator, set to higher frequency updates
|
||||||
|
const stateGenerator = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'State Generator',
|
||||||
|
name: 'State Generator'
|
||||||
|
});
|
||||||
|
const stateGeneratorTreeItem = page.getByRole('treeitem', {
|
||||||
|
name: stateGenerator.name
|
||||||
|
});
|
||||||
|
await stateGeneratorTreeItem.click({ button: 'right' });
|
||||||
|
await page.getByLabel('Edit Properties...').click();
|
||||||
|
await page.getByLabel('State Duration (seconds)', { exact: true }).fill('0.1');
|
||||||
|
await page.getByLabel('Save').click();
|
||||||
|
|
||||||
|
// Create a Table for filtering ON values
|
||||||
|
const tableFilterOnValue = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Telemetry Table',
|
||||||
|
name: 'Table Filter On Value'
|
||||||
|
});
|
||||||
|
const tableFilterOnTreeItem = page.getByRole('treeitem', {
|
||||||
|
name: tableFilterOnValue.name
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a Table for filtering OFF values
|
||||||
|
const tableFilterOffValue = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Telemetry Table',
|
||||||
|
name: 'Table Filter Off Value'
|
||||||
|
});
|
||||||
|
const tableFilterOffTreeItem = page.getByRole('treeitem', {
|
||||||
|
name: tableFilterOffValue.name
|
||||||
|
});
|
||||||
|
|
||||||
|
// Navigate to ON filtering table and add state generator and setup filters
|
||||||
|
await page.goto(tableFilterOnValue.url);
|
||||||
|
await stateGeneratorTreeItem.dragTo(page.getByLabel('Object View'));
|
||||||
|
await selectFilterOption(page, '1');
|
||||||
|
await page.getByLabel('Save').click();
|
||||||
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
||||||
|
|
||||||
|
// Navigate to OFF filtering table and add state generator and setup filters
|
||||||
|
await page.goto(tableFilterOffValue.url);
|
||||||
|
await stateGeneratorTreeItem.dragTo(page.getByLabel('Object View'));
|
||||||
|
await selectFilterOption(page, '0');
|
||||||
|
await page.getByLabel('Save').click();
|
||||||
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
||||||
|
|
||||||
|
// Navigate to the display layout and edit it
|
||||||
|
await page.goto(displayLayout.url);
|
||||||
|
|
||||||
|
// Add the tables to the display layout
|
||||||
|
await page.getByLabel('Edit Object').click();
|
||||||
|
await tableFilterOffTreeItem.dragTo(page.getByLabel('Layout Grid'), {
|
||||||
|
targetPosition: { x: 10, y: 300 }
|
||||||
|
});
|
||||||
|
await page.locator('.c-frame-edit > div:nth-child(4)').dragTo(page.getByLabel('Layout Grid'), {
|
||||||
|
targetPosition: { x: 400, y: 500 },
|
||||||
|
// eslint-disable-next-line playwright/no-force-option
|
||||||
|
force: true
|
||||||
|
});
|
||||||
|
await tableFilterOnTreeItem.dragTo(page.getByLabel('Layout Grid'), {
|
||||||
|
targetPosition: { x: 10, y: 100 }
|
||||||
|
});
|
||||||
|
await page.locator('.c-frame-edit > div:nth-child(4)').dragTo(page.getByLabel('Layout Grid'), {
|
||||||
|
targetPosition: { x: 400, y: 300 },
|
||||||
|
// eslint-disable-next-line playwright/no-force-option
|
||||||
|
force: true
|
||||||
|
});
|
||||||
|
await page.getByLabel('Save').click();
|
||||||
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
||||||
|
|
||||||
|
// Get the tables so we can verify filtering is working as expected
|
||||||
|
const tableFilterOn = page.getByLabel(`${tableFilterOnValue.name} Frame`, {
|
||||||
|
exact: true
|
||||||
|
});
|
||||||
|
const tableFilterOff = page.getByLabel(`${tableFilterOffValue.name} Frame`, {
|
||||||
|
exact: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// Verify filtering is working correctly
|
||||||
|
|
||||||
|
// Check that no filtered values appear for at least 2 seconds
|
||||||
|
const VERIFICATION_TIME = 2000; // 2 seconds
|
||||||
|
const CHECK_INTERVAL = 100; // Check every 100ms
|
||||||
|
|
||||||
|
// Create a promise that will check for filtered values periodically
|
||||||
|
const checkForCorrectValues = new Promise((resolve, reject) => {
|
||||||
|
const interval = setInterval(async () => {
|
||||||
|
const offCount = await tableFilterOn.locator('td[title="OFF"]').count();
|
||||||
|
const onCount = await tableFilterOff.locator('td[title="ON"]').count();
|
||||||
|
if (offCount > 0 || onCount > 0) {
|
||||||
|
clearInterval(interval);
|
||||||
|
reject(
|
||||||
|
new Error(
|
||||||
|
`Found ${offCount} OFF and ${onCount} ON values when expecting 0 OFF and 0 ON`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, CHECK_INTERVAL);
|
||||||
|
|
||||||
|
// After VERIFICATION_TIME, if no filtered values were found, resolve successfully
|
||||||
|
setTimeout(() => {
|
||||||
|
clearInterval(interval);
|
||||||
|
resolve();
|
||||||
|
}, VERIFICATION_TIME);
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(checkForCorrectValues).resolves.toBeUndefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function selectFilterOption(page, filterOption) {
|
||||||
|
await page.getByRole('tab', { name: 'Filters' }).click();
|
||||||
|
await page
|
||||||
|
.getByLabel('Inspector Views')
|
||||||
|
.locator('li')
|
||||||
|
.filter({ hasText: 'State Generator' })
|
||||||
|
.locator('span')
|
||||||
|
.click();
|
||||||
|
await page.getByRole('switch').click();
|
||||||
|
await page.selectOption('select[name="setSelectionThreshold"]', filterOption);
|
||||||
|
}
|
||||||
|
|
||||||
async function addAndRemoveDrawingObjectAndAssert(page, layoutObject, DISPLAY_LAYOUT_NAME) {
|
async function addAndRemoveDrawingObjectAndAssert(page, layoutObject, DISPLAY_LAYOUT_NAME) {
|
||||||
await expect(page.getByLabel(layoutObject, { exact: true })).toHaveCount(0);
|
await expect(page.getByLabel(layoutObject, { exact: true })).toHaveCount(0);
|
||||||
await addLayoutObject(page, DISPLAY_LAYOUT_NAME, layoutObject);
|
await addLayoutObject(page, DISPLAY_LAYOUT_NAME, layoutObject);
|
||||||
|
@ -24,19 +24,13 @@ import {
|
|||||||
acknowledgeFault,
|
acknowledgeFault,
|
||||||
acknowledgeMultipleFaults,
|
acknowledgeMultipleFaults,
|
||||||
changeViewTo,
|
changeViewTo,
|
||||||
clearSearch,
|
|
||||||
enterSearchTerm,
|
|
||||||
getFault,
|
getFault,
|
||||||
getFaultByName,
|
getFaultByName,
|
||||||
getFaultName,
|
getFaultName,
|
||||||
getFaultNamespace,
|
getFaultNamespace,
|
||||||
getFaultResultCount,
|
|
||||||
getFaultSeverity,
|
|
||||||
getFaultTriggerTime,
|
getFaultTriggerTime,
|
||||||
getHighestSeverity,
|
|
||||||
getLowestSeverity,
|
|
||||||
navigateToFaultManagementWithExample,
|
|
||||||
navigateToFaultManagementWithoutExample,
|
navigateToFaultManagementWithoutExample,
|
||||||
|
navigateToFaultManagementWithStaticExample,
|
||||||
selectFaultItem,
|
selectFaultItem,
|
||||||
shelveFault,
|
shelveFault,
|
||||||
shelveMultipleFaults,
|
shelveMultipleFaults,
|
||||||
@ -46,7 +40,7 @@ import { expect, test } from '../../../../pluginFixtures.js';
|
|||||||
|
|
||||||
test.describe('The Fault Management Plugin using example faults', () => {
|
test.describe('The Fault Management Plugin using example faults', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await navigateToFaultManagementWithExample(page);
|
await navigateToFaultManagementWithStaticExample(page);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Shows a criticality icon for every fault', async ({ page }) => {
|
test('Shows a criticality icon for every fault', async ({ page }) => {
|
||||||
@ -56,7 +50,7 @@ test.describe('The Fault Management Plugin using example faults', () => {
|
|||||||
expect(faultCount).toEqual(criticalityIconCount);
|
expect(faultCount).toEqual(criticalityIconCount);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('When selecting a fault, it has an "is-selected" class and it\'s information shows in the inspector', async ({
|
test('When selecting a fault, it has an "is-selected" class and its information shows in the inspector', async ({
|
||||||
page
|
page
|
||||||
}) => {
|
}) => {
|
||||||
await selectFaultItem(page, 1);
|
await selectFaultItem(page, 1);
|
||||||
@ -67,9 +61,7 @@ test.describe('The Fault Management Plugin using example faults', () => {
|
|||||||
.getByLabel('Source inspector properties')
|
.getByLabel('Source inspector properties')
|
||||||
.getByLabel('inspector property value');
|
.getByLabel('inspector property value');
|
||||||
|
|
||||||
await expect(
|
await expect(page.getByLabel('Fault triggered at').first()).toHaveClass(/is-selected/);
|
||||||
page.locator('.c-faults-list-view-item-body > .c-fault-mgmt__list').first()
|
|
||||||
).toHaveClass(/is-selected/);
|
|
||||||
await expect(inspectorFaultName).toHaveCount(1);
|
await expect(inspectorFaultName).toHaveCount(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -79,23 +71,18 @@ test.describe('The Fault Management Plugin using example faults', () => {
|
|||||||
await selectFaultItem(page, 1);
|
await selectFaultItem(page, 1);
|
||||||
await selectFaultItem(page, 2);
|
await selectFaultItem(page, 2);
|
||||||
|
|
||||||
const selectedRows = page.locator(
|
const selectedRows = page.getByRole('checkbox', { checked: true });
|
||||||
'.c-fault-mgmt__list.is-selected .c-fault-mgmt__list-faultname'
|
await expect(selectedRows).toHaveCount(2);
|
||||||
);
|
|
||||||
expect(await selectedRows.count()).toEqual(2);
|
|
||||||
|
|
||||||
await page.getByRole('tab', { name: 'Config' }).click();
|
await page.getByRole('tab', { name: 'Config' }).click();
|
||||||
const firstSelectedFaultName = await selectedRows.nth(0).textContent();
|
const firstSelectedFaultName = await selectedRows.nth(0).textContent();
|
||||||
const secondSelectedFaultName = await selectedRows.nth(1).textContent();
|
const secondSelectedFaultName = await selectedRows.nth(1).textContent();
|
||||||
const firstNameInInspectorCount = await page
|
await expect(
|
||||||
.locator(`.c-inspector__properties >> :text("${firstSelectedFaultName}")`)
|
page.locator(`.c-inspector__properties >> :text("${firstSelectedFaultName}")`)
|
||||||
.count();
|
).toHaveCount(0);
|
||||||
const secondNameInInspectorCount = await page
|
await expect(
|
||||||
.locator(`.c-inspector__properties >> :text("${secondSelectedFaultName}")`)
|
page.locator(`.c-inspector__properties >> :text("${secondSelectedFaultName}")`)
|
||||||
.count();
|
).toHaveCount(0);
|
||||||
|
|
||||||
expect(firstNameInInspectorCount).toEqual(0);
|
|
||||||
expect(secondNameInInspectorCount).toEqual(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Allows you to shelve a fault', async ({ page }) => {
|
test('Allows you to shelve a fault', async ({ page }) => {
|
||||||
@ -186,44 +173,60 @@ test.describe('The Fault Management Plugin using example faults', () => {
|
|||||||
const faultFiveTriggerTime = await getFaultTriggerTime(page, 5);
|
const faultFiveTriggerTime = await getFaultTriggerTime(page, 5);
|
||||||
|
|
||||||
// should be all faults (5)
|
// should be all faults (5)
|
||||||
let faultResultCount = await getFaultResultCount(page);
|
await expect(page.getByLabel('Fault triggered at')).toHaveCount(5);
|
||||||
expect(faultResultCount).toEqual(5);
|
|
||||||
|
|
||||||
// search namespace
|
// search namespace
|
||||||
await enterSearchTerm(page, faultThreeNamespace);
|
await page
|
||||||
|
.getByLabel('Fault Management Object View')
|
||||||
|
.getByLabel('Search Input')
|
||||||
|
.fill(faultThreeNamespace);
|
||||||
|
|
||||||
faultResultCount = await getFaultResultCount(page);
|
await expect(page.getByLabel('Fault triggered at')).toHaveCount(1);
|
||||||
expect(faultResultCount).toEqual(1);
|
|
||||||
expect(await getFaultNamespace(page, 1)).toEqual(faultThreeNamespace);
|
expect(await getFaultNamespace(page, 1)).toEqual(faultThreeNamespace);
|
||||||
|
|
||||||
// all faults
|
// all faults
|
||||||
await clearSearch(page);
|
await page.getByLabel('Fault Management Object View').getByLabel('Search Input').fill('');
|
||||||
faultResultCount = await getFaultResultCount(page);
|
await expect(page.getByLabel('Fault triggered at')).toHaveCount(5);
|
||||||
expect(faultResultCount).toEqual(5);
|
|
||||||
|
|
||||||
// search name
|
// search name
|
||||||
await enterSearchTerm(page, faultTwoName);
|
await page
|
||||||
|
.getByLabel('Fault Management Object View')
|
||||||
|
.getByLabel('Search Input')
|
||||||
|
.fill(faultTwoName);
|
||||||
|
|
||||||
faultResultCount = await getFaultResultCount(page);
|
await expect(page.getByLabel('Fault triggered at')).toHaveCount(1);
|
||||||
expect(faultResultCount).toEqual(1);
|
|
||||||
expect(await getFaultName(page, 1)).toEqual(faultTwoName);
|
expect(await getFaultName(page, 1)).toEqual(faultTwoName);
|
||||||
|
|
||||||
// all faults
|
// all faults
|
||||||
await clearSearch(page);
|
await page.getByLabel('Fault Management Object View').getByLabel('Search Input').fill('');
|
||||||
faultResultCount = await getFaultResultCount(page);
|
await expect(page.getByLabel('Fault triggered at')).toHaveCount(5);
|
||||||
expect(faultResultCount).toEqual(5);
|
|
||||||
|
|
||||||
// search triggerTime
|
// search triggerTime
|
||||||
await enterSearchTerm(page, faultFiveTriggerTime);
|
await page
|
||||||
|
.getByLabel('Fault Management Object View')
|
||||||
|
.getByLabel('Search Input')
|
||||||
|
.fill(faultFiveTriggerTime);
|
||||||
|
|
||||||
faultResultCount = await getFaultResultCount(page);
|
await expect(page.getByLabel('Fault triggered at')).toHaveCount(1);
|
||||||
expect(faultResultCount).toEqual(1);
|
|
||||||
expect(await getFaultTriggerTime(page, 1)).toEqual(faultFiveTriggerTime);
|
expect(await getFaultTriggerTime(page, 1)).toEqual(faultFiveTriggerTime);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Allows you to sort faults', async ({ page }) => {
|
test('Allows you to sort faults', async ({ page }) => {
|
||||||
const highestSeverity = await getHighestSeverity(page);
|
/**
|
||||||
const lowestSeverity = await getLowestSeverity(page);
|
* Compares two severity levels and returns a number indicating their relative order.
|
||||||
|
*
|
||||||
|
* @param {'CRITICAL' | 'WARNING' | 'WATCH'} severity1 - The first severity level to compare.
|
||||||
|
* @param {'CRITICAL' | 'WARNING' | 'WATCH'} severity2 - The second severity level to compare.
|
||||||
|
* @returns {number} - A negative number if severity1 is less severe than severity2,
|
||||||
|
* a positive number if severity1 is more severe than severity2,
|
||||||
|
* or 0 if they are equally severe.
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line func-style
|
||||||
|
const compareSeverity = (severity1, severity2) => {
|
||||||
|
const severityOrder = ['WATCH', 'WARNING', 'CRITICAL'];
|
||||||
|
return severityOrder.indexOf(severity1) - severityOrder.indexOf(severity2);
|
||||||
|
};
|
||||||
|
|
||||||
const faultOneName = 'Example Fault 1';
|
const faultOneName = 'Example Fault 1';
|
||||||
const faultFiveName = 'Example Fault 5';
|
const faultFiveName = 'Example Fault 5';
|
||||||
let firstFaultName = await getFaultName(page, 1);
|
let firstFaultName = await getFaultName(page, 1);
|
||||||
@ -237,10 +240,19 @@ test.describe('The Fault Management Plugin using example faults', () => {
|
|||||||
|
|
||||||
await sortFaultsBy(page, 'severity');
|
await sortFaultsBy(page, 'severity');
|
||||||
|
|
||||||
const sortedHighestSeverity = await getFaultSeverity(page, 1);
|
const firstFaultSeverityLabel = await page
|
||||||
const sortedLowestSeverity = await getFaultSeverity(page, 5);
|
.getByLabel('Severity:')
|
||||||
expect(sortedHighestSeverity).toEqual(highestSeverity);
|
.first()
|
||||||
expect(sortedLowestSeverity).toEqual(lowestSeverity);
|
.getAttribute('aria-label');
|
||||||
|
const firstFaultSeverity = firstFaultSeverityLabel.split(' ').slice(1).join(' ');
|
||||||
|
|
||||||
|
const lastFaultSeverityLabel = await page
|
||||||
|
.getByLabel('Severity:')
|
||||||
|
.last()
|
||||||
|
.getAttribute('aria-label');
|
||||||
|
const lastFaultSeverity = lastFaultSeverityLabel.split(' ').slice(1).join(' ');
|
||||||
|
|
||||||
|
expect(compareSeverity(firstFaultSeverity, lastFaultSeverity)).toBeGreaterThan(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -250,24 +262,18 @@ test.describe('The Fault Management Plugin without using example faults', () =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Shows no faults when no faults are provided', async ({ page }) => {
|
test('Shows no faults when no faults are provided', async ({ page }) => {
|
||||||
const faultCount = await page.locator('c-fault-mgmt__list').count();
|
await expect(page.getByLabel('Fault triggered at')).toHaveCount(0);
|
||||||
|
|
||||||
expect(faultCount).toEqual(0);
|
|
||||||
|
|
||||||
await changeViewTo(page, 'acknowledged');
|
await changeViewTo(page, 'acknowledged');
|
||||||
const acknowledgedCount = await page.locator('c-fault-mgmt__list').count();
|
await expect(page.getByLabel('Fault triggered at')).toHaveCount(0);
|
||||||
expect(acknowledgedCount).toEqual(0);
|
|
||||||
|
|
||||||
await changeViewTo(page, 'shelved');
|
await changeViewTo(page, 'shelved');
|
||||||
const shelvedCount = await page.locator('c-fault-mgmt__list').count();
|
await expect(page.getByLabel('Fault triggered at')).toHaveCount(0);
|
||||||
expect(shelvedCount).toEqual(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Will return no faults when searching', async ({ page }) => {
|
test('Will return no faults when searching', async ({ page }) => {
|
||||||
await enterSearchTerm(page, 'fault');
|
await page.getByLabel('Fault Management Object View').getByLabel('Search Input').fill('fault');
|
||||||
|
|
||||||
const faultCount = await page.locator('c-fault-mgmt__list').count();
|
await expect(page.getByLabel('Fault triggered at')).toHaveCount(0);
|
||||||
|
|
||||||
expect(faultCount).toEqual(0);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -28,7 +28,9 @@ import { v4 as uuid } from 'uuid';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
createDomainObjectWithDefaults,
|
createDomainObjectWithDefaults,
|
||||||
createExampleTelemetryObject
|
createExampleTelemetryObject,
|
||||||
|
setRealTimeMode,
|
||||||
|
setStartOffset
|
||||||
} from '../../../../appActions.js';
|
} from '../../../../appActions.js';
|
||||||
import { expect, test } from '../../../../pluginFixtures.js';
|
import { expect, test } from '../../../../pluginFixtures.js';
|
||||||
|
|
||||||
@ -166,6 +168,57 @@ test.describe('Gauge', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Gauge does not break when an object is missing', async ({ page }) => {
|
||||||
|
// Set up error listeners
|
||||||
|
const pageErrors = [];
|
||||||
|
|
||||||
|
// Listen for uncaught exceptions
|
||||||
|
page.on('pageerror', (err) => {
|
||||||
|
pageErrors.push(err.message);
|
||||||
|
});
|
||||||
|
|
||||||
|
await setRealTimeMode(page);
|
||||||
|
|
||||||
|
// Create a Gauge
|
||||||
|
const gauge = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Gauge',
|
||||||
|
name: 'Gauge with missing object'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a Sine Wave Generator in the Gauge with a loading delay
|
||||||
|
const missingSWG = await createExampleTelemetryObject(page, gauge.uuid);
|
||||||
|
|
||||||
|
// Remove the object from local storage
|
||||||
|
await page.evaluate(
|
||||||
|
([missingObject]) => {
|
||||||
|
const mct = localStorage.getItem('mct');
|
||||||
|
const mctObjects = JSON.parse(mct);
|
||||||
|
delete mctObjects[missingObject.uuid];
|
||||||
|
localStorage.setItem('mct', JSON.stringify(mctObjects));
|
||||||
|
},
|
||||||
|
[missingSWG]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Verify start bounds
|
||||||
|
await expect(page.getByLabel('Start offset: 00:30:00')).toBeVisible();
|
||||||
|
|
||||||
|
// Nav to the Gauge
|
||||||
|
await page.goto(gauge.url, { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
|
// adjust time bounds and ensure they are updated
|
||||||
|
await setStartOffset(page, {
|
||||||
|
startHours: '00',
|
||||||
|
startMins: '45',
|
||||||
|
startSecs: '00'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Verify start bounds changed
|
||||||
|
await expect(page.getByLabel('Start offset: 00:45:00')).toBeVisible();
|
||||||
|
|
||||||
|
// // Verify no errors were thrown
|
||||||
|
expect(pageErrors).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
test('Gauge enforces composition policy', async ({ page }) => {
|
test('Gauge enforces composition policy', async ({ page }) => {
|
||||||
// Create a Gauge
|
// Create a Gauge
|
||||||
await createDomainObjectWithDefaults(page, {
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
@ -30,16 +30,19 @@ import {
|
|||||||
navigateToObjectWithRealTime,
|
navigateToObjectWithRealTime,
|
||||||
setRealTimeMode
|
setRealTimeMode
|
||||||
} from '../../../../appActions.js';
|
} from '../../../../appActions.js';
|
||||||
import { MISSION_TIME } from '../../../../constants.js';
|
import {
|
||||||
|
createImageryViewWithShortDelay,
|
||||||
|
FIVE_MINUTES,
|
||||||
|
IMAGE_LOAD_DELAY,
|
||||||
|
MOUSE_WHEEL_DELTA_Y,
|
||||||
|
THIRTY_SECONDS
|
||||||
|
} from '../../../../helper/imageryUtils.js';
|
||||||
import { expect, test } from '../../../../pluginFixtures.js';
|
import { expect, test } from '../../../../pluginFixtures.js';
|
||||||
|
|
||||||
const panHotkey = process.platform === 'linux' ? ['Shift', 'Alt'] : ['Alt'];
|
const panHotkey = process.platform === 'linux' ? ['Shift', 'Alt'] : ['Alt'];
|
||||||
const tagHotkey = ['Shift', 'Alt'];
|
const tagHotkey = ['Shift', 'Alt'];
|
||||||
const expectedAltText = process.platform === 'linux' ? 'Shift+Alt drag to pan' : 'Alt drag to pan';
|
const expectedAltText = process.platform === 'linux' ? 'Shift+Alt drag to pan' : 'Alt drag to pan';
|
||||||
const thumbnailUrlParamsRegexp = /\?w=100&h=100/;
|
const thumbnailUrlParamsRegexp = /\?w=100&h=100/;
|
||||||
const IMAGE_LOAD_DELAY = 5 * 1000;
|
|
||||||
const MOUSE_WHEEL_DELTA_Y = 120;
|
|
||||||
const FIVE_MINUTES = 1000 * 60 * 5;
|
|
||||||
const THIRTY_SECONDS = 1000 * 30;
|
|
||||||
|
|
||||||
//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', () => {
|
||||||
@ -93,9 +96,6 @@ test.describe('Example Imagery Object', () => {
|
|||||||
expect(newPage.url()).toContain('.jpg');
|
expect(newPage.url()).toContain('.jpg');
|
||||||
});
|
});
|
||||||
|
|
||||||
// this requires CORS to be enabled in some fashion
|
|
||||||
test.fixme('Can right click on image and save it as a file', async ({ page }) => {});
|
|
||||||
|
|
||||||
test('Can adjust image brightness/contrast by dragging the sliders', async ({
|
test('Can adjust image brightness/contrast by dragging the sliders', async ({
|
||||||
page,
|
page,
|
||||||
browserName
|
browserName
|
||||||
@ -357,15 +357,10 @@ test.describe('Example Imagery Object', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe('Example Imagery in Display Layout @clock', () => {
|
test.describe('Example Imagery in Display Layout', () => {
|
||||||
let displayLayout;
|
let displayLayout;
|
||||||
|
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
// We mock the clock so that we don't need to wait for time driven events
|
|
||||||
// to verify functionality.
|
|
||||||
await page.clock.install({ time: MISSION_TIME });
|
|
||||||
await page.clock.resume();
|
|
||||||
|
|
||||||
// Go to baseURL
|
// Go to baseURL
|
||||||
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
@ -428,12 +423,7 @@ test.describe('Example Imagery in Display Layout @clock', () => {
|
|||||||
await expect.soft(pausePlayButton).toHaveClass(/is-paused/);
|
await expect.soft(pausePlayButton).toHaveClass(/is-paused/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Imagery View operations @clock', async ({ page }) => {
|
test('Imagery View operations', async ({ page }) => {
|
||||||
test.info().annotations.push({
|
|
||||||
type: 'issue',
|
|
||||||
description: 'https://github.com/nasa/openmct/issues/5265'
|
|
||||||
});
|
|
||||||
|
|
||||||
// Edit mode
|
// Edit mode
|
||||||
await page.getByLabel('Edit Object').click();
|
await page.getByLabel('Edit Object').click();
|
||||||
|
|
||||||
@ -526,14 +516,9 @@ test.describe('Example Imagery in Display Layout @clock', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe('Example Imagery in Flexible layout @clock', () => {
|
test.describe('Example Imagery in Flexible layout', () => {
|
||||||
let flexibleLayout;
|
let flexibleLayout;
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
// We mock the clock so that we don't need to wait for time driven events
|
|
||||||
// to verify functionality.
|
|
||||||
await page.clock.install({ time: MISSION_TIME });
|
|
||||||
await page.clock.resume();
|
|
||||||
|
|
||||||
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
flexibleLayout = await createDomainObjectWithDefaults(page, { type: 'Flexible Layout' });
|
flexibleLayout = await createDomainObjectWithDefaults(page, { type: 'Flexible Layout' });
|
||||||
@ -562,7 +547,7 @@ test.describe('Example Imagery in Flexible layout @clock', () => {
|
|||||||
await page.getByRole('button', { name: 'Close' }).click();
|
await page.getByRole('button', { name: 'Close' }).click();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Imagery View operations @clock', async ({ page, browserName }) => {
|
test('Imagery View operations', async ({ page, browserName }) => {
|
||||||
test.fixme(browserName === 'firefox', 'This test needs to be updated to work with firefox');
|
test.fixme(browserName === 'firefox', 'This test needs to be updated to work with firefox');
|
||||||
test.info().annotations.push({
|
test.info().annotations.push({
|
||||||
type: 'issue',
|
type: 'issue',
|
||||||
@ -573,14 +558,10 @@ test.describe('Example Imagery in Flexible layout @clock', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe('Example Imagery in Tabs View @clock', () => {
|
test.describe('Example Imagery in Tabs View', () => {
|
||||||
let tabsView;
|
let tabsView;
|
||||||
test.beforeEach(async ({ page }) => {
|
|
||||||
// We mock the clock so that we don't need to wait for time driven events
|
|
||||||
// to verify functionality.
|
|
||||||
await page.clock.install({ time: MISSION_TIME });
|
|
||||||
await page.clock.resume();
|
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
tabsView = await createDomainObjectWithDefaults(page, { type: 'Tabs View' });
|
tabsView = await createDomainObjectWithDefaults(page, { type: 'Tabs View' });
|
||||||
@ -607,7 +588,8 @@ test.describe('Example Imagery in Tabs View @clock', () => {
|
|||||||
// Wait for image thumbnail auto-scroll to complete
|
// Wait for image thumbnail auto-scroll to complete
|
||||||
await expect(page.getByLabel('Image Thumbnail from').last()).toBeInViewport();
|
await expect(page.getByLabel('Image Thumbnail from').last()).toBeInViewport();
|
||||||
});
|
});
|
||||||
test('Imagery View operations @clock', async ({ page }) => {
|
|
||||||
|
test('Imagery View operations', async ({ page }) => {
|
||||||
await performImageryViewOperationsAndAssert(page, tabsView);
|
await performImageryViewOperationsAndAssert(page, tabsView);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -668,16 +650,19 @@ test.describe('Example Imagery in Time Strip', () => {
|
|||||||
* 3. Can pan the image using the pan hotkey + mouse drag
|
* 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
|
* 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
|
* 5. Imagery is updated as new images stream in, regardless of pause status
|
||||||
* 6. Old images are discarded when new images stream in
|
* 6. Old images are discarded when their timestamps fall out of bounds
|
||||||
* 7. Image brightness/contrast can be adjusted by dragging the sliders
|
* 7. Multiple images can be discarded when their timestamps fall out of bounds
|
||||||
|
* 8. Image brightness/contrast can be adjusted by dragging the sliders
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
*/
|
*/
|
||||||
async function performImageryViewOperationsAndAssert(page, layoutObject) {
|
async function performImageryViewOperationsAndAssert(page, layoutObject) {
|
||||||
// Verify that imagery thumbnails use a thumbnail url
|
await test.step('Verify that imagery thumbnails use a thumbnail url', async () => {
|
||||||
const thumbnailImages = page.getByLabel('Image thumbnail from').locator('.c-thumb__image');
|
const thumbnailImages = page.getByLabel('Image thumbnail from').locator('.c-thumb__image');
|
||||||
const mainImage = page.locator('.c-imagery__main-image__image');
|
const mainImage = page.locator('.c-imagery__main-image__image');
|
||||||
await expect(thumbnailImages.first()).toHaveAttribute('src', thumbnailUrlParamsRegexp);
|
await expect(thumbnailImages.first()).toHaveAttribute('src', thumbnailUrlParamsRegexp);
|
||||||
await expect(mainImage).not.toHaveAttribute('src', thumbnailUrlParamsRegexp);
|
await expect(mainImage).not.toHaveAttribute('src', thumbnailUrlParamsRegexp);
|
||||||
|
});
|
||||||
|
|
||||||
// Click previous image button
|
// Click previous image button
|
||||||
const previousImageButton = page.getByLabel('Previous image');
|
const previousImageButton = page.getByLabel('Previous image');
|
||||||
await expect(previousImageButton).toBeVisible();
|
await expect(previousImageButton).toBeVisible();
|
||||||
@ -736,19 +721,6 @@ async function performImageryViewOperationsAndAssert(page, layoutObject) {
|
|||||||
// Unpause imagery
|
// Unpause imagery
|
||||||
await page.locator('.pause-play').click();
|
await page.locator('.pause-play').click();
|
||||||
|
|
||||||
// verify that old images are discarded
|
|
||||||
const lastImageInBounds = page.getByLabel('Image thumbnail from').first();
|
|
||||||
const lastImageTimestamp = await lastImageInBounds.getAttribute('title');
|
|
||||||
expect(lastImageTimestamp).not.toBeNull();
|
|
||||||
|
|
||||||
// go forward in time to ensure old images are discarded
|
|
||||||
await page.clock.fastForward(IMAGE_LOAD_DELAY);
|
|
||||||
await page.clock.resume();
|
|
||||||
await expect(page.getByLabel(lastImageTimestamp)).toBeHidden();
|
|
||||||
|
|
||||||
//Get background-image url from background-image css prop
|
|
||||||
await assertBackgroundImageUrlFromBackgroundCss(page);
|
|
||||||
|
|
||||||
// Open the image filter menu
|
// Open the image filter menu
|
||||||
await page.locator('[role=toolbar] button[title="Brightness and contrast"]').click();
|
await page.locator('[role=toolbar] button[title="Brightness and contrast"]').click();
|
||||||
|
|
||||||
@ -815,24 +787,6 @@ async function assertBackgroundImageBrightness(page, expected) {
|
|||||||
expect(actual).toBe(expected);
|
expect(actual).toBe(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {import('@playwright/test').Page} page
|
|
||||||
*/
|
|
||||||
async function assertBackgroundImageUrlFromBackgroundCss(page) {
|
|
||||||
const backgroundImage = page.getByLabel('Focused Image Element');
|
|
||||||
const backgroundImageUrl = await backgroundImage.evaluate((el) => {
|
|
||||||
return window
|
|
||||||
.getComputedStyle(el)
|
|
||||||
.getPropertyValue('background-image')
|
|
||||||
.match(/url\(([^)]+)\)/)[1];
|
|
||||||
});
|
|
||||||
|
|
||||||
// go forward in time to ensure old images are discarded
|
|
||||||
await page.clock.fastForward(IMAGE_LOAD_DELAY);
|
|
||||||
await page.clock.resume();
|
|
||||||
await expect(backgroundImage).not.toHaveJSProperty('background-image', backgroundImageUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
*/
|
*/
|
||||||
@ -918,62 +872,66 @@ async function mouseZoomOnImageAndAssert(page, factor = 2) {
|
|||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
*/
|
*/
|
||||||
async function buttonZoomOnImageAndAssert(page) {
|
async function buttonZoomOnImageAndAssert(page) {
|
||||||
// Lock the zoom and pan so it doesn't reset if a new image comes in
|
await test.step('Can zoom using buttons', async () => {
|
||||||
await page.getByLabel('Focused Image Element').hover({ trial: true });
|
// Lock the zoom and pan so it doesn't reset if a new image comes in
|
||||||
const lockButton = page.getByRole('button', {
|
|
||||||
name: 'Lock current zoom and pan across all images'
|
|
||||||
});
|
|
||||||
if (!(await lockButton.isVisible())) {
|
|
||||||
await page.getByLabel('Focused Image Element').hover({ trial: true });
|
await page.getByLabel('Focused Image Element').hover({ trial: true });
|
||||||
}
|
const lockButton = page.getByRole('button', {
|
||||||
await lockButton.click();
|
name: 'Lock current zoom and pan across all images'
|
||||||
|
});
|
||||||
|
|
||||||
await expect(page.getByLabel('Focused Image Element')).toHaveJSProperty(
|
await lockButton.isVisible();
|
||||||
'style.transform',
|
// if (!(await lockButton.isVisible())) {
|
||||||
'scale(1) translate(0px, 0px)'
|
// await page.getByLabel('Focused Image Element').hover({ trial: true });
|
||||||
);
|
// }
|
||||||
|
await lockButton.click();
|
||||||
|
|
||||||
// Get initial image dimensions
|
await expect(page.getByLabel('Focused Image Element')).toHaveJSProperty(
|
||||||
const initialBoundingBox = await page.getByLabel('Focused Image Element').boundingBox();
|
'style.transform',
|
||||||
|
'scale(1) translate(0px, 0px)'
|
||||||
|
);
|
||||||
|
|
||||||
// Zoom in twice via button
|
// Get initial image dimensions
|
||||||
await zoomIntoImageryByButton(page);
|
const initialBoundingBox = await page.getByLabel('Focused Image Element').boundingBox();
|
||||||
await expect(page.getByLabel('Focused Image Element')).toHaveJSProperty(
|
|
||||||
'style.transform',
|
|
||||||
'scale(2) translate(0px, 0px)'
|
|
||||||
);
|
|
||||||
await zoomIntoImageryByButton(page);
|
|
||||||
await expect(page.getByLabel('Focused Image Element')).toHaveJSProperty(
|
|
||||||
'style.transform',
|
|
||||||
'scale(3) translate(0px, 0px)'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get and assert zoomed in image dimensions
|
// Zoom in twice via button
|
||||||
const zoomedInBoundingBox = await page.getByLabel('Focused Image Element').boundingBox();
|
await zoomIntoImageryByButton(page);
|
||||||
expect(zoomedInBoundingBox.height).toBeGreaterThan(initialBoundingBox.height);
|
await expect(page.getByLabel('Focused Image Element')).toHaveJSProperty(
|
||||||
expect(zoomedInBoundingBox.width).toBeGreaterThan(initialBoundingBox.width);
|
'style.transform',
|
||||||
|
'scale(2) translate(0px, 0px)'
|
||||||
|
);
|
||||||
|
await zoomIntoImageryByButton(page);
|
||||||
|
await expect(page.getByLabel('Focused Image Element')).toHaveJSProperty(
|
||||||
|
'style.transform',
|
||||||
|
'scale(3) translate(0px, 0px)'
|
||||||
|
);
|
||||||
|
|
||||||
// Zoom out once via button
|
// Get and assert zoomed in image dimensions
|
||||||
await zoomOutOfImageryByButton(page);
|
const zoomedInBoundingBox = await page.getByLabel('Focused Image Element').boundingBox();
|
||||||
await expect(page.getByLabel('Focused Image Element')).toHaveJSProperty(
|
expect(zoomedInBoundingBox.height).toBeGreaterThan(initialBoundingBox.height);
|
||||||
'style.transform',
|
expect(zoomedInBoundingBox.width).toBeGreaterThan(initialBoundingBox.width);
|
||||||
'scale(2) translate(0px, 0px)'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get and assert zoomed out image dimensions
|
// Zoom out once via button
|
||||||
const zoomedOutBoundingBox = await page.getByLabel('Focused Image Element').boundingBox();
|
await zoomOutOfImageryByButton(page);
|
||||||
expect(zoomedOutBoundingBox.height).toBeLessThan(zoomedInBoundingBox.height);
|
await expect(page.getByLabel('Focused Image Element')).toHaveJSProperty(
|
||||||
expect(zoomedOutBoundingBox.width).toBeLessThan(zoomedInBoundingBox.width);
|
'style.transform',
|
||||||
|
'scale(2) translate(0px, 0px)'
|
||||||
|
);
|
||||||
|
|
||||||
// Zoom out again via button, assert against the initial image dimensions
|
// Get and assert zoomed out image dimensions
|
||||||
await zoomOutOfImageryByButton(page);
|
const zoomedOutBoundingBox = await page.getByLabel('Focused Image Element').boundingBox();
|
||||||
await expect(page.getByLabel('Focused Image Element')).toHaveJSProperty(
|
expect(zoomedOutBoundingBox.height).toBeLessThan(zoomedInBoundingBox.height);
|
||||||
'style.transform',
|
expect(zoomedOutBoundingBox.width).toBeLessThan(zoomedInBoundingBox.width);
|
||||||
'scale(1) translate(0px, 0px)'
|
|
||||||
);
|
|
||||||
|
|
||||||
const finalBoundingBox = await page.getByLabel('Focused Image Element').boundingBox();
|
// Zoom out again via button, assert against the initial image dimensions
|
||||||
expect(finalBoundingBox).toEqual(initialBoundingBox);
|
await zoomOutOfImageryByButton(page);
|
||||||
|
await expect(page.getByLabel('Focused Image Element')).toHaveJSProperty(
|
||||||
|
'style.transform',
|
||||||
|
'scale(1) translate(0px, 0px)'
|
||||||
|
);
|
||||||
|
|
||||||
|
const finalBoundingBox = await page.getByLabel('Focused Image Element').boundingBox();
|
||||||
|
expect(finalBoundingBox).toEqual(initialBoundingBox);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1035,24 +993,6 @@ async function resetImageryPanAndZoom(page) {
|
|||||||
await expect(page.locator('.c-thumb__viewable-area')).toBeHidden();
|
await expect(page.locator('.c-thumb__viewable-area')).toBeHidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {import('@playwright/test').Page} page
|
|
||||||
*/
|
|
||||||
async function createImageryViewWithShortDelay(page, { name, parent }) {
|
|
||||||
await createDomainObjectWithDefaults(page, {
|
|
||||||
name,
|
|
||||||
type: 'Example Imagery',
|
|
||||||
parent
|
|
||||||
});
|
|
||||||
|
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Example Imagery');
|
|
||||||
await page.getByLabel('More actions').click();
|
|
||||||
await page.getByLabel('Edit Properties').click();
|
|
||||||
// Clear and set Image load delay to minimum value
|
|
||||||
await page.locator('input[type="number"]').fill(`${IMAGE_LOAD_DELAY}`);
|
|
||||||
await page.getByLabel('Save').click();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,489 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2024, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
This test suite is dedicated to testing how imagery functions over time.
|
||||||
|
It only assumes that example imagery is present.
|
||||||
|
It uses https://playwright.dev/docs/clock to have control over time
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {
|
||||||
|
createDomainObjectWithDefaults,
|
||||||
|
navigateToObjectWithRealTime,
|
||||||
|
setRealTimeMode,
|
||||||
|
setStartOffset
|
||||||
|
} from '../../../../appActions.js';
|
||||||
|
import { MISSION_TIME } from '../../../../constants.js';
|
||||||
|
import {
|
||||||
|
createImageryViewWithShortDelay,
|
||||||
|
FIVE_MINUTES,
|
||||||
|
IMAGE_LOAD_DELAY,
|
||||||
|
THIRTY_SECONDS
|
||||||
|
} from '../../../../helper/imageryUtils.js';
|
||||||
|
import { expect, test } from '../../../../pluginFixtures.js';
|
||||||
|
|
||||||
|
test.describe('Example Imagery Object with Controlled Clock @clock', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// We mock the clock so that we don't need to wait for time driven events
|
||||||
|
// to verify functionality.
|
||||||
|
await page.clock.install({ time: MISSION_TIME });
|
||||||
|
await page.clock.resume();
|
||||||
|
|
||||||
|
//Go to baseURL
|
||||||
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
|
// Create a default 'Example Imagery' object
|
||||||
|
// Click the Create button
|
||||||
|
await page.getByRole('button', { name: 'Create' }).click();
|
||||||
|
|
||||||
|
// Click text=Example Imagery
|
||||||
|
await page.getByRole('menuitem', { name: 'Example Imagery' }).click();
|
||||||
|
|
||||||
|
// Clear and set Image load delay to minimum value
|
||||||
|
await page.locator('input[type="number"]').clear();
|
||||||
|
await page.locator('input[type="number"]').fill(`${IMAGE_LOAD_DELAY}`);
|
||||||
|
|
||||||
|
await page.getByLabel('Save').click();
|
||||||
|
|
||||||
|
// Verify that the created object is focused
|
||||||
|
await expect(page.locator('.l-browse-bar__object-name')).toContainText(
|
||||||
|
'Unnamed Example Imagery'
|
||||||
|
);
|
||||||
|
await page.getByLabel('Focused Image Element').hover({ trial: true });
|
||||||
|
|
||||||
|
// set realtime mode
|
||||||
|
await setRealTimeMode(page);
|
||||||
|
await setStartOffset(page, { startMins: '05' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Imagery Time Bounding', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5265'
|
||||||
|
});
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/7825'
|
||||||
|
});
|
||||||
|
|
||||||
|
// verify that old images are discarded
|
||||||
|
const lastImageInBounds = page.getByLabel('Image thumbnail from').first();
|
||||||
|
const lastImageTimestamp = await lastImageInBounds.getAttribute('title');
|
||||||
|
expect(lastImageTimestamp).not.toBeNull();
|
||||||
|
|
||||||
|
// go forward in time to ensure old images are discarded
|
||||||
|
await page.clock.fastForward(IMAGE_LOAD_DELAY);
|
||||||
|
await page.clock.resume();
|
||||||
|
await expect(page.getByLabel(lastImageTimestamp)).toBeHidden();
|
||||||
|
|
||||||
|
// go way forward in time to ensure multiple images are discarded
|
||||||
|
const IMAGES_TO_DISCARD_COUNT = 5;
|
||||||
|
|
||||||
|
const lastImageToDiscard = page
|
||||||
|
.getByLabel('Image thumbnail from')
|
||||||
|
.nth(IMAGES_TO_DISCARD_COUNT - 1);
|
||||||
|
const lastImageToDiscardTimestamp = await lastImageToDiscard.getAttribute('title');
|
||||||
|
expect(lastImageToDiscardTimestamp).not.toBeNull();
|
||||||
|
|
||||||
|
const imageAfterLastImageToDiscard = page
|
||||||
|
.getByLabel('Image thumbnail from')
|
||||||
|
.nth(IMAGES_TO_DISCARD_COUNT);
|
||||||
|
const imageAfterLastImageToDiscardTimestamp =
|
||||||
|
await imageAfterLastImageToDiscard.getAttribute('title');
|
||||||
|
expect(imageAfterLastImageToDiscardTimestamp).not.toBeNull();
|
||||||
|
|
||||||
|
await page.clock.fastForward(IMAGE_LOAD_DELAY * IMAGES_TO_DISCARD_COUNT);
|
||||||
|
await page.clock.resume();
|
||||||
|
|
||||||
|
await expect(page.getByLabel(lastImageToDiscardTimestamp)).toBeHidden();
|
||||||
|
await expect(page.getByLabel(imageAfterLastImageToDiscardTimestamp)).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Get background-image url from background-image css prop', async ({ page }) => {
|
||||||
|
await assertBackgroundImageUrlFromBackgroundCss(page);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe('Example Imagery in Display Layout with Controlled Clock @clock', () => {
|
||||||
|
let displayLayout;
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// We mock the clock so that we don't need to wait for time driven events
|
||||||
|
// to verify functionality.
|
||||||
|
await page.clock.install({ time: MISSION_TIME });
|
||||||
|
await page.clock.resume();
|
||||||
|
|
||||||
|
// Go to baseURL
|
||||||
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
|
displayLayout = await createDomainObjectWithDefaults(page, { type: 'Display Layout' });
|
||||||
|
|
||||||
|
// Create Example Imagery inside Display Layout
|
||||||
|
await createImageryViewWithShortDelay(page, {
|
||||||
|
name: 'Unnamed Example Imagery',
|
||||||
|
parent: displayLayout.uuid
|
||||||
|
});
|
||||||
|
|
||||||
|
// set realtime mode
|
||||||
|
await navigateToObjectWithRealTime(
|
||||||
|
page,
|
||||||
|
displayLayout.url,
|
||||||
|
`${FIVE_MINUTES}`,
|
||||||
|
`${THIRTY_SECONDS}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Imagery Time Bounding', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5265'
|
||||||
|
});
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/7825'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Edit mode
|
||||||
|
await page.getByLabel('Edit Object').click();
|
||||||
|
|
||||||
|
// Click on example imagery to expose toolbar
|
||||||
|
await page.locator('.c-so-view__header').click();
|
||||||
|
|
||||||
|
// Adjust object height
|
||||||
|
await page.locator('div[title="Resize object height"] > input').click();
|
||||||
|
await page.locator('div[title="Resize object height"] > input').fill('50');
|
||||||
|
|
||||||
|
// Adjust object width
|
||||||
|
await page.locator('div[title="Resize object width"] > input').click();
|
||||||
|
await page.locator('div[title="Resize object width"] > input').fill('50');
|
||||||
|
|
||||||
|
await expect(page.getByLabel('Image Thumbnail from').last()).toBeInViewport();
|
||||||
|
|
||||||
|
// verify that old images are discarded
|
||||||
|
const lastImageInBounds = page.getByLabel('Image thumbnail from').first();
|
||||||
|
const lastImageTimestamp = await lastImageInBounds.getAttribute('title');
|
||||||
|
expect(lastImageTimestamp).not.toBeNull();
|
||||||
|
|
||||||
|
// go forward in time to ensure old images are discarded
|
||||||
|
await page.clock.fastForward(IMAGE_LOAD_DELAY);
|
||||||
|
await page.clock.resume();
|
||||||
|
await expect(page.getByLabel(lastImageTimestamp)).toBeHidden();
|
||||||
|
|
||||||
|
// go way forward in time to ensure multiple images are discarded
|
||||||
|
const IMAGES_TO_DISCARD_COUNT = 5;
|
||||||
|
|
||||||
|
const lastImageToDiscard = page
|
||||||
|
.getByLabel('Image thumbnail from')
|
||||||
|
.nth(IMAGES_TO_DISCARD_COUNT - 1);
|
||||||
|
const lastImageToDiscardTimestamp = await lastImageToDiscard.getAttribute('title');
|
||||||
|
expect(lastImageToDiscardTimestamp).not.toBeNull();
|
||||||
|
|
||||||
|
const imageAfterLastImageToDiscard = page
|
||||||
|
.getByLabel('Image thumbnail from')
|
||||||
|
.nth(IMAGES_TO_DISCARD_COUNT);
|
||||||
|
const imageAfterLastImageToDiscardTimestamp =
|
||||||
|
await imageAfterLastImageToDiscard.getAttribute('title');
|
||||||
|
expect(imageAfterLastImageToDiscardTimestamp).not.toBeNull();
|
||||||
|
|
||||||
|
await page.clock.fastForward(IMAGE_LOAD_DELAY * IMAGES_TO_DISCARD_COUNT);
|
||||||
|
await page.clock.resume();
|
||||||
|
|
||||||
|
await expect(page.getByLabel(lastImageToDiscardTimestamp)).toBeHidden();
|
||||||
|
await expect(page.getByLabel(imageAfterLastImageToDiscardTimestamp)).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Get background-image url from background-image css prop @clock', async ({ page }) => {
|
||||||
|
await assertBackgroundImageUrlFromBackgroundCss(page);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe('Example Imagery in Flexible layout with Controlled Clock @clock', () => {
|
||||||
|
let flexibleLayout;
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// We mock the clock so that we don't need to wait for time driven events
|
||||||
|
// to verify functionality.
|
||||||
|
await page.clock.install({ time: MISSION_TIME });
|
||||||
|
await page.clock.resume();
|
||||||
|
|
||||||
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
|
flexibleLayout = await createDomainObjectWithDefaults(page, { type: 'Flexible Layout' });
|
||||||
|
|
||||||
|
// Create Example Imagery inside the Flexible Layout
|
||||||
|
await createImageryViewWithShortDelay(page, {
|
||||||
|
name: 'Unnamed Example Imagery',
|
||||||
|
parent: flexibleLayout.uuid
|
||||||
|
});
|
||||||
|
|
||||||
|
// set realtime mode
|
||||||
|
await navigateToObjectWithRealTime(
|
||||||
|
page,
|
||||||
|
flexibleLayout.url,
|
||||||
|
`${FIVE_MINUTES}`,
|
||||||
|
`${THIRTY_SECONDS}`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Wait for image thumbnail auto-scroll to complete
|
||||||
|
await expect(page.getByLabel('Image Thumbnail from').last()).toBeInViewport();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Imagery Time Bounding @clock', 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'
|
||||||
|
});
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/7825'
|
||||||
|
});
|
||||||
|
|
||||||
|
// verify that old images are discarded
|
||||||
|
const lastImageInBounds = page.getByLabel('Image thumbnail from').first();
|
||||||
|
const lastImageTimestamp = await lastImageInBounds.getAttribute('title');
|
||||||
|
expect(lastImageTimestamp).not.toBeNull();
|
||||||
|
|
||||||
|
// go forward in time to ensure old images are discarded
|
||||||
|
await page.clock.fastForward(IMAGE_LOAD_DELAY);
|
||||||
|
await page.clock.resume();
|
||||||
|
await expect(page.getByLabel(lastImageTimestamp)).toBeHidden();
|
||||||
|
|
||||||
|
// go way forward in time to ensure multiple images are discarded
|
||||||
|
const IMAGES_TO_DISCARD_COUNT = 5;
|
||||||
|
|
||||||
|
const lastImageToDiscard = page
|
||||||
|
.getByLabel('Image thumbnail from')
|
||||||
|
.nth(IMAGES_TO_DISCARD_COUNT - 1);
|
||||||
|
const lastImageToDiscardTimestamp = await lastImageToDiscard.getAttribute('title');
|
||||||
|
expect(lastImageToDiscardTimestamp).not.toBeNull();
|
||||||
|
|
||||||
|
const imageAfterLastImageToDiscard = page
|
||||||
|
.getByLabel('Image thumbnail from')
|
||||||
|
.nth(IMAGES_TO_DISCARD_COUNT);
|
||||||
|
const imageAfterLastImageToDiscardTimestamp =
|
||||||
|
await imageAfterLastImageToDiscard.getAttribute('title');
|
||||||
|
expect(imageAfterLastImageToDiscardTimestamp).not.toBeNull();
|
||||||
|
|
||||||
|
await page.clock.fastForward(IMAGE_LOAD_DELAY * IMAGES_TO_DISCARD_COUNT);
|
||||||
|
await page.clock.resume();
|
||||||
|
|
||||||
|
await expect(page.getByLabel(lastImageToDiscardTimestamp)).toBeHidden();
|
||||||
|
await expect(page.getByLabel(imageAfterLastImageToDiscardTimestamp)).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Get background-image url from background-image css prop @clock', async ({ page }) => {
|
||||||
|
await assertBackgroundImageUrlFromBackgroundCss(page);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe('Example Imagery in Tabs View with Controlled Clock @clock', () => {
|
||||||
|
let timeStripObject;
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// We mock the clock so that we don't need to wait for time driven events
|
||||||
|
// to verify functionality.
|
||||||
|
await page.clock.install({ time: MISSION_TIME });
|
||||||
|
await page.clock.resume();
|
||||||
|
|
||||||
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
|
timeStripObject = await createDomainObjectWithDefaults(page, { type: 'Tabs View' });
|
||||||
|
await page.goto(timeStripObject.url);
|
||||||
|
|
||||||
|
/* Create Example Imagery with minimum Image Load Delay */
|
||||||
|
// Click the Create button
|
||||||
|
await page.getByRole('button', { name: 'Create' }).click();
|
||||||
|
|
||||||
|
// Click text=Example Imagery
|
||||||
|
await page.getByRole('menuitem', { name: 'Example Imagery' }).click();
|
||||||
|
|
||||||
|
// Clear and set Image load delay to minimum value
|
||||||
|
await page.locator('input[type="number"]').clear();
|
||||||
|
await page.locator('input[type="number"]').fill(`${IMAGE_LOAD_DELAY}`);
|
||||||
|
|
||||||
|
await page.getByLabel('Save').click();
|
||||||
|
|
||||||
|
await expect(page.locator('.l-browse-bar__object-name')).toContainText(
|
||||||
|
'Unnamed Example Imagery'
|
||||||
|
);
|
||||||
|
|
||||||
|
// set realtime mode
|
||||||
|
await navigateToObjectWithRealTime(
|
||||||
|
page,
|
||||||
|
timeStripObject.url,
|
||||||
|
`${FIVE_MINUTES}`,
|
||||||
|
`${THIRTY_SECONDS}`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Wait for image thumbnail auto-scroll to complete
|
||||||
|
await expect(page.getByLabel('Image Thumbnail from').last()).toBeInViewport();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Imagery Time Bounding @clock', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5265'
|
||||||
|
});
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/7825'
|
||||||
|
});
|
||||||
|
|
||||||
|
// verify that old images are discarded
|
||||||
|
const lastImageInBounds = page.getByLabel('Image thumbnail from').first();
|
||||||
|
const lastImageTimestamp = await lastImageInBounds.getAttribute('title');
|
||||||
|
expect(lastImageTimestamp).not.toBeNull();
|
||||||
|
|
||||||
|
// go forward in time to ensure old images are discarded
|
||||||
|
await page.clock.fastForward(IMAGE_LOAD_DELAY);
|
||||||
|
await page.clock.resume();
|
||||||
|
await expect(page.getByLabel(lastImageTimestamp)).toBeHidden();
|
||||||
|
|
||||||
|
// go way forward in time to ensure multiple images are discarded
|
||||||
|
const IMAGES_TO_DISCARD_COUNT = 5;
|
||||||
|
|
||||||
|
const lastImageToDiscard = page
|
||||||
|
.getByLabel('Image thumbnail from')
|
||||||
|
.nth(IMAGES_TO_DISCARD_COUNT - 1);
|
||||||
|
const lastImageToDiscardTimestamp = await lastImageToDiscard.getAttribute('title');
|
||||||
|
expect(lastImageToDiscardTimestamp).not.toBeNull();
|
||||||
|
|
||||||
|
const imageAfterLastImageToDiscard = page
|
||||||
|
.getByLabel('Image thumbnail from')
|
||||||
|
.nth(IMAGES_TO_DISCARD_COUNT);
|
||||||
|
const imageAfterLastImageToDiscardTimestamp =
|
||||||
|
await imageAfterLastImageToDiscard.getAttribute('title');
|
||||||
|
expect(imageAfterLastImageToDiscardTimestamp).not.toBeNull();
|
||||||
|
|
||||||
|
await page.clock.fastForward(IMAGE_LOAD_DELAY * IMAGES_TO_DISCARD_COUNT);
|
||||||
|
await page.clock.resume();
|
||||||
|
|
||||||
|
await expect(page.getByLabel(lastImageToDiscardTimestamp)).toBeHidden();
|
||||||
|
await expect(page.getByLabel(imageAfterLastImageToDiscardTimestamp)).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Get background-image url from background-image css prop @clock', async ({ page }) => {
|
||||||
|
await assertBackgroundImageUrlFromBackgroundCss(page);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe('Example Imagery in Time Strip with Controlled Clock @clock', () => {
|
||||||
|
let timeStripObject;
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// We mock the clock so that we don't need to wait for time driven events
|
||||||
|
// to verify functionality.
|
||||||
|
await page.clock.install({ time: MISSION_TIME });
|
||||||
|
await page.clock.resume();
|
||||||
|
|
||||||
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
|
timeStripObject = await createDomainObjectWithDefaults(page, { type: 'Time Strip' });
|
||||||
|
await page.goto(timeStripObject.url);
|
||||||
|
|
||||||
|
/* Create Example Imagery with minimum Image Load Delay */
|
||||||
|
// Click the Create button
|
||||||
|
await page.getByRole('button', { name: 'Create' }).click();
|
||||||
|
|
||||||
|
// Click text=Example Imagery
|
||||||
|
await page.getByRole('menuitem', { name: 'Example Imagery' }).click();
|
||||||
|
|
||||||
|
// Clear and set Image load delay to minimum value
|
||||||
|
await page.locator('input[type="number"]').clear();
|
||||||
|
await page.locator('input[type="number"]').fill(`${IMAGE_LOAD_DELAY}`);
|
||||||
|
|
||||||
|
await page.getByLabel('Save').click();
|
||||||
|
|
||||||
|
await expect(page.locator('.l-browse-bar__object-name')).toContainText(
|
||||||
|
'Unnamed Example Imagery'
|
||||||
|
);
|
||||||
|
|
||||||
|
// set realtime mode
|
||||||
|
await navigateToObjectWithRealTime(
|
||||||
|
page,
|
||||||
|
timeStripObject.url,
|
||||||
|
`${FIVE_MINUTES}`,
|
||||||
|
`${THIRTY_SECONDS}`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Wait for image thumbnail auto-scroll to complete
|
||||||
|
await expect(page.getByLabel('wrapper-').last()).toBeInViewport();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Imagery Time Bounding @clock', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5265'
|
||||||
|
});
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/7825'
|
||||||
|
});
|
||||||
|
|
||||||
|
// verify that old images are discarded
|
||||||
|
const lastImageInBounds = page.getByLabel('wrapper-').first();
|
||||||
|
const lastImageTimestamp = await lastImageInBounds.getAttribute('aria-label');
|
||||||
|
expect(lastImageTimestamp).not.toBeNull();
|
||||||
|
|
||||||
|
// go forward in time to ensure old images are discarded
|
||||||
|
await page.clock.fastForward(IMAGE_LOAD_DELAY);
|
||||||
|
await page.clock.resume();
|
||||||
|
await expect(page.getByLabel(lastImageTimestamp)).toBeHidden();
|
||||||
|
|
||||||
|
// go way forward in time to ensure multiple images are discarded
|
||||||
|
const IMAGES_TO_DISCARD_COUNT = 5;
|
||||||
|
|
||||||
|
const lastImageToDiscard = page.getByLabel('wrapper-').nth(IMAGES_TO_DISCARD_COUNT - 1);
|
||||||
|
const lastImageToDiscardTimestamp = await lastImageToDiscard.getAttribute('aria-label');
|
||||||
|
expect(lastImageToDiscardTimestamp).not.toBeNull();
|
||||||
|
|
||||||
|
const imageAfterLastImageToDiscard = page.getByLabel('wrapper-').nth(IMAGES_TO_DISCARD_COUNT);
|
||||||
|
const imageAfterLastImageToDiscardTimestamp =
|
||||||
|
await imageAfterLastImageToDiscard.getAttribute('aria-label');
|
||||||
|
expect(imageAfterLastImageToDiscardTimestamp).not.toBeNull();
|
||||||
|
|
||||||
|
await page.clock.fastForward(IMAGE_LOAD_DELAY * IMAGES_TO_DISCARD_COUNT);
|
||||||
|
await page.clock.resume();
|
||||||
|
|
||||||
|
await expect(page.getByLabel(lastImageToDiscardTimestamp)).toBeHidden();
|
||||||
|
await expect(page.getByLabel(imageAfterLastImageToDiscardTimestamp)).toBeVisible();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
*/
|
||||||
|
async function assertBackgroundImageUrlFromBackgroundCss(page) {
|
||||||
|
const backgroundImage = page.getByLabel('Focused Image Element');
|
||||||
|
const backgroundImageUrl = await backgroundImage.evaluate((el) => {
|
||||||
|
return window
|
||||||
|
.getComputedStyle(el)
|
||||||
|
.getPropertyValue('background-image')
|
||||||
|
.match(/url\(([^)]+)\)/)[1];
|
||||||
|
});
|
||||||
|
|
||||||
|
// go forward in time to ensure old images are discarded
|
||||||
|
await page.clock.fastForward(IMAGE_LOAD_DELAY);
|
||||||
|
await page.clock.resume();
|
||||||
|
await expect(backgroundImage).not.toHaveJSProperty('background-image', backgroundImageUrl);
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2024, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This test suite verifies modifying the image location of the example imagery object.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { createDomainObjectWithDefaults } from '../../../../appActions.js';
|
||||||
|
import { expect, test } from '../../../../pluginFixtures.js';
|
||||||
|
|
||||||
|
test.describe('Example Imagery Object Custom Images', () => {
|
||||||
|
let exampleImagery;
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
//Go to baseURL
|
||||||
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
|
// Create a default 'Example Imagery' object
|
||||||
|
exampleImagery = await createDomainObjectWithDefaults(page, {
|
||||||
|
name: 'Example Imagery',
|
||||||
|
type: 'Example Imagery'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Verify that the created object is focused
|
||||||
|
await expect(page.locator('.l-browse-bar__object-name')).toContainText(exampleImagery.name);
|
||||||
|
await page.getByLabel('Focused Image Element').hover({ trial: true });
|
||||||
|
|
||||||
|
// Wait for image thumbnail auto-scroll to complete
|
||||||
|
await expect(page.getByLabel('Image Thumbnail from').last()).toBeInViewport();
|
||||||
|
});
|
||||||
|
// this requires CORS to be enabled in some fashion
|
||||||
|
test.fixme('Can right click on image and save it as a file', async ({ page }) => {});
|
||||||
|
test('Can provide a custom image location for the example imagery object', async ({ page }) => {
|
||||||
|
// Modify Example Imagery to create a really stable image which will never let us down
|
||||||
|
await page.getByRole('button', { name: 'More actions' }).click();
|
||||||
|
await page.getByRole('menuitem', { name: 'Edit Properties...' }).click();
|
||||||
|
await page
|
||||||
|
.locator('#imageLocation-textarea')
|
||||||
|
.fill(
|
||||||
|
'https://raw.githubusercontent.com/nasa/openmct/554f77c42fec81cf0f63e62b278012cb08d82af9/e2e/test-data/rick.jpg,https://raw.githubusercontent.com/nasa/openmct/554f77c42fec81cf0f63e62b278012cb08d82af9/e2e/test-data/rick.jpg'
|
||||||
|
);
|
||||||
|
await page.getByRole('button', { name: 'Save' }).click();
|
||||||
|
await page.reload({ waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
|
// Wait for the thumbnails to finish their scroll animation
|
||||||
|
// (Wait until the rightmost thumbnail is in view)
|
||||||
|
await expect(page.getByLabel('Image Thumbnail from').last()).toBeInViewport();
|
||||||
|
|
||||||
|
await expect(page.getByLabel('Image Wrapper')).toBeVisible();
|
||||||
|
});
|
||||||
|
test.fixme('Can provide a custom image with spaces in name', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/7903'
|
||||||
|
});
|
||||||
|
await page.goto(exampleImagery.url, { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
|
// Modify Example Imagery to create a really stable image which will never let us down
|
||||||
|
await page.getByRole('button', { name: 'More actions' }).click();
|
||||||
|
await page.getByRole('menuitem', { name: 'Edit Properties...' }).click();
|
||||||
|
await page
|
||||||
|
.locator('#imageLocation-textarea')
|
||||||
|
.fill(
|
||||||
|
'https://raw.githubusercontent.com/nasa/openmct/d8c64f183400afb70137221fc1a035e091bea912/e2e/test-data/rick%20space%20roll.jpg'
|
||||||
|
);
|
||||||
|
await page.getByRole('button', { name: 'Save' }).click();
|
||||||
|
await page.reload({ waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
|
// Wait for the thumbnails to finish their scroll animation
|
||||||
|
// (Wait until the rightmost thumbnail is in view)
|
||||||
|
await expect(page.getByLabel('Image Thumbnail from').last()).toBeInViewport();
|
||||||
|
|
||||||
|
await expect(page.getByLabel('Image Wrapper')).toBeVisible();
|
||||||
|
});
|
||||||
|
});
|
@ -26,7 +26,10 @@ This test suite is dedicated to tests which verify the basic operations surround
|
|||||||
|
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
import { createDomainObjectWithDefaults } from '../../../../appActions.js';
|
import {
|
||||||
|
createDomainObjectWithDefaults,
|
||||||
|
renameCurrentObjectFromBrowseBar
|
||||||
|
} from '../../../../appActions.js';
|
||||||
import { copy, paste, selectAll } from '../../../../helper/hotkeys/hotkeys.js';
|
import { copy, paste, selectAll } from '../../../../helper/hotkeys/hotkeys.js';
|
||||||
import * as nbUtils from '../../../../helper/notebookUtils.js';
|
import * as nbUtils from '../../../../helper/notebookUtils.js';
|
||||||
import { expect, streamToString, test } from '../../../../pluginFixtures.js';
|
import { expect, streamToString, test } from '../../../../pluginFixtures.js';
|
||||||
@ -596,4 +599,61 @@ test.describe('Notebook entry tests', () => {
|
|||||||
await expect(await page.locator(`text="${TEST_TEXT.repeat(1)}"`).count()).toEqual(1);
|
await expect(await page.locator(`text="${TEST_TEXT.repeat(1)}"`).count()).toEqual(1);
|
||||||
await expect(await page.locator(`text="${TEST_TEXT.repeat(2)}"`).count()).toEqual(0);
|
await expect(await page.locator(`text="${TEST_TEXT.repeat(2)}"`).count()).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('When changing the name of a notebook in the browse bar, new notebook changes are not lost', async ({
|
||||||
|
page
|
||||||
|
}) => {
|
||||||
|
const TEST_TEXT = 'Do not lose me!';
|
||||||
|
const FIRST_NEW_NAME = 'New Name';
|
||||||
|
const SECOND_NEW_NAME = 'Second New Name';
|
||||||
|
|
||||||
|
await page.goto(notebookObject.url);
|
||||||
|
|
||||||
|
await page.getByLabel('Expand My Items folder').click();
|
||||||
|
|
||||||
|
await renameCurrentObjectFromBrowseBar(page, FIRST_NEW_NAME);
|
||||||
|
|
||||||
|
// verify the name change in tree and browse bar
|
||||||
|
await verifyNameChange(page, FIRST_NEW_NAME);
|
||||||
|
|
||||||
|
// enter one entry
|
||||||
|
await enterAndCommitTextEntry(page, TEST_TEXT);
|
||||||
|
|
||||||
|
// verify the entry is present
|
||||||
|
await expect(await page.locator(`text="${TEST_TEXT}"`).count()).toEqual(1);
|
||||||
|
|
||||||
|
// change the name
|
||||||
|
await renameCurrentObjectFromBrowseBar(page, SECOND_NEW_NAME);
|
||||||
|
|
||||||
|
// verify the name change in tree and browse bar
|
||||||
|
await verifyNameChange(page, SECOND_NEW_NAME);
|
||||||
|
|
||||||
|
// verify the entry is still present
|
||||||
|
await expect(await page.locator(`text="${TEST_TEXT}"`).count()).toEqual(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter text into the last notebook entry and commit it.
|
||||||
|
*
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {string} text
|
||||||
|
*/
|
||||||
|
async function enterAndCommitTextEntry(page, text) {
|
||||||
|
await nbUtils.addNotebookEntry(page);
|
||||||
|
await nbUtils.enterTextInLastEntry(page, text);
|
||||||
|
await nbUtils.commitEntry(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the name change in the tree and browse bar.
|
||||||
|
*
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {string} newName
|
||||||
|
*/
|
||||||
|
async function verifyNameChange(page, newName) {
|
||||||
|
await expect(
|
||||||
|
page.getByRole('treeitem').locator('.is-navigated-object .c-tree__item__name')
|
||||||
|
).toHaveText(newName);
|
||||||
|
await expect(page.getByLabel('Browse bar object name')).toHaveText(newName);
|
||||||
|
}
|
||||||
|
@ -0,0 +1,72 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2024, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
import { expect, test } from '../../../../pluginFixtures.js';
|
||||||
|
|
||||||
|
test.describe('The performance indicator', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
await page.evaluate(() => {
|
||||||
|
const openmct = window.openmct;
|
||||||
|
openmct.install(openmct.plugins.PerformanceIndicator());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('can be installed', ({ page }) => {
|
||||||
|
const performanceIndicator = page.getByTitle('Performance Indicator');
|
||||||
|
expect(performanceIndicator).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Shows a numerical FPS value', async ({ page }) => {
|
||||||
|
// Frames Per Second. We need to wait at least 1 second to get a value.
|
||||||
|
// eslint-disable-next-line playwright/no-wait-for-timeout
|
||||||
|
await page.waitForTimeout(1000);
|
||||||
|
await expect(page.getByTitle('Performance Indicator')).toHaveText(/\d\d? fps/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Supports showing optional extended performance information in an overlay for debugging', async ({
|
||||||
|
page
|
||||||
|
}) => {
|
||||||
|
const performanceMeasurementLabel = 'Some measurement';
|
||||||
|
const performanceMeasurementValue = 'Some value';
|
||||||
|
|
||||||
|
await page.evaluate(
|
||||||
|
({ performanceMeasurementLabel: label, performanceMeasurementValue: value }) => {
|
||||||
|
const openmct = window.openmct;
|
||||||
|
openmct.performance.measurements.set(label, value);
|
||||||
|
},
|
||||||
|
{ performanceMeasurementLabel, performanceMeasurementValue }
|
||||||
|
);
|
||||||
|
const performanceIndicator = page.getByTitle('Performance Indicator');
|
||||||
|
await performanceIndicator.click();
|
||||||
|
//Performance overlay is a crude debugging tool, it's evaluated once per second.
|
||||||
|
// eslint-disable-next-line playwright/no-wait-for-timeout
|
||||||
|
await page.waitForTimeout(1000);
|
||||||
|
const performanceOverlay = page.getByTitle('Performance Overlay');
|
||||||
|
await expect(performanceOverlay).toBeVisible();
|
||||||
|
await expect(performanceOverlay).toHaveText(new RegExp(`${performanceMeasurementLabel}.*`));
|
||||||
|
await expect(performanceOverlay).toHaveText(new RegExp(`.*${performanceMeasurementValue}`));
|
||||||
|
|
||||||
|
//Confirm that it disappears if we click on it again.
|
||||||
|
await performanceIndicator.click();
|
||||||
|
await expect(performanceOverlay).toBeHidden();
|
||||||
|
});
|
||||||
|
});
|
@ -108,4 +108,42 @@ test.describe('Plot Controls', () => {
|
|||||||
// Expect before and after plot points to match
|
// Expect before and after plot points to match
|
||||||
await expect(plotPixelSizeAtPause).toEqual(plotPixelSizeAfterWait);
|
await expect(plotPixelSizeAtPause).toEqual(plotPixelSizeAfterWait);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
Test to verify that switching a plot's time context from global to
|
||||||
|
its own independent time context and then back to global context works correctly.
|
||||||
|
|
||||||
|
After switching from fixed time mode (ITC) to real time mode (global context),
|
||||||
|
the pause control for the plot should be available, indicating that it is following the right context.
|
||||||
|
*/
|
||||||
|
test('Plots follow the right time context', async ({ page }) => {
|
||||||
|
// Set global time conductor to real-time mode
|
||||||
|
await setRealTimeMode(page);
|
||||||
|
|
||||||
|
// hover over plot for plot controls
|
||||||
|
await page.getByLabel('Plot Canvas').hover();
|
||||||
|
// Ensure pause control is visible since global time conductor is in Real time mode.
|
||||||
|
await expect(page.getByTitle('Pause incoming real-time data')).toBeVisible();
|
||||||
|
|
||||||
|
// Toggle independent time conductor ON
|
||||||
|
await page.getByLabel('Enable Independent Time Conductor').click();
|
||||||
|
|
||||||
|
// Bring up the independent time conductor popup and switch to fixed time mode
|
||||||
|
await page.getByLabel('Independent Time Conductor Settings').click();
|
||||||
|
await page.getByLabel('Independent Time Conductor Mode Menu').click();
|
||||||
|
await page.getByRole('menuitem', { name: /Fixed Timespan/ }).click();
|
||||||
|
|
||||||
|
// hover over plot for plot controls
|
||||||
|
await page.getByLabel('Plot Canvas').hover();
|
||||||
|
// Ensure pause control is no longer visible since the plot is following the independent time context
|
||||||
|
await expect(page.getByTitle('Pause incoming real-time data')).toBeHidden();
|
||||||
|
|
||||||
|
// Toggle independent time conductor OFF - Note that the global time conductor is still in Real time mode
|
||||||
|
await page.getByLabel('Disable Independent Time Conductor').click();
|
||||||
|
|
||||||
|
// hover over plot for plot controls
|
||||||
|
await page.getByLabel('Plot Canvas').hover();
|
||||||
|
// Ensure pause control is visible since the global time conductor is in real time mode
|
||||||
|
await expect(page.getByTitle('Pause incoming real-time data')).toBeVisible();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2025, 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { createDomainObjectWithDefaults } from '../../../../appActions.js';
|
||||||
|
import { expect, test } from '../../../../pluginFixtures.js';
|
||||||
|
|
||||||
|
test.describe('Plot Controls in compact mode', () => {
|
||||||
|
let timeStrip;
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// Open a browser, navigate to the main page, and wait until all networkevents to resolve
|
||||||
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
timeStrip = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Time Strip'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create an overlay plot with a sine wave generator
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Sine Wave Generator',
|
||||||
|
parent: timeStrip.uuid
|
||||||
|
});
|
||||||
|
await page.goto(`${timeStrip.url}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Plots show cursor guides', async ({ page }) => {
|
||||||
|
// hover over plot for plot controls
|
||||||
|
await page.getByLabel('Plot Canvas').hover();
|
||||||
|
// click on cursor guides control
|
||||||
|
await page.getByTitle('Toggle cursor guides').click();
|
||||||
|
await page.getByLabel('Plot Canvas').hover();
|
||||||
|
await expect(page.getByLabel('Vertical cursor guide')).toBeVisible();
|
||||||
|
await expect(page.getByLabel('Horizontal cursor guide')).toBeVisible();
|
||||||
|
});
|
||||||
|
});
|
@ -1,5 +1,5 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Open MCT, Copyright (c) 2014-2023, United States Government
|
* Open MCT, Copyright (c) 2014-2024, United States Government
|
||||||
* as represented by the Administrator of the National Aeronautics and Space
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
* Administration. All rights reserved.
|
* Administration. All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,163 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2024, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
This test suite is dedicated to tests which verify the basic operations surrounding conditionSets and styling
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {
|
||||||
|
createDomainObjectWithDefaults,
|
||||||
|
linkParameterToObject,
|
||||||
|
setRealTimeMode
|
||||||
|
} from '../../../../appActions.js';
|
||||||
|
import { MISSION_TIME } from '../../../../constants.js';
|
||||||
|
import { expect, test } from '../../../../pluginFixtures.js';
|
||||||
|
|
||||||
|
test.describe('Conditionally Styling, using a Condition Set', () => {
|
||||||
|
let stateGenerator;
|
||||||
|
let conditionSet;
|
||||||
|
let displayLayout;
|
||||||
|
const STATE_CHANGE_INTERVAL = '1';
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// Install the clock and set the time to the mission time such that the state generator will be controllable
|
||||||
|
await page.clock.install({ time: MISSION_TIME });
|
||||||
|
await page.clock.resume();
|
||||||
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
// Create Condition Set, State Generator, and Display Layout
|
||||||
|
conditionSet = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Condition Set',
|
||||||
|
name: 'Test Condition Set'
|
||||||
|
});
|
||||||
|
stateGenerator = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'State Generator',
|
||||||
|
name: 'One Second State Generator'
|
||||||
|
});
|
||||||
|
// edit the state generator to have a 1 second update rate
|
||||||
|
await page.getByTitle('More actions').click();
|
||||||
|
await page.getByRole('menuitem', { name: 'Edit Properties...' }).click();
|
||||||
|
await page.getByLabel('State Duration (seconds)', { exact: true }).fill(STATE_CHANGE_INTERVAL);
|
||||||
|
await page.getByLabel('Save').click();
|
||||||
|
|
||||||
|
displayLayout = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Display Layout',
|
||||||
|
name: 'Test Display Layout'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Conditional styling, using a Condition Set, will style correctly based on the output @clock', async ({
|
||||||
|
page
|
||||||
|
}) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/7840'
|
||||||
|
});
|
||||||
|
|
||||||
|
// set up the condition set to use the state generator
|
||||||
|
await page.goto(conditionSet.url, { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
|
// Add the State Generator to the Condition Set by dragging from the main tree
|
||||||
|
await page.getByLabel('Show selected item in tree').click();
|
||||||
|
await page
|
||||||
|
.getByRole('tree', {
|
||||||
|
name: 'Main Tree'
|
||||||
|
})
|
||||||
|
.getByRole('treeitem', {
|
||||||
|
name: stateGenerator.name
|
||||||
|
})
|
||||||
|
.dragTo(page.locator('#conditionCollection'));
|
||||||
|
|
||||||
|
// Add the state generator to the first criterion such that there is a condition named 'OFF' when the state generator is off
|
||||||
|
await page.getByLabel('Add Condition').click();
|
||||||
|
await page
|
||||||
|
.getByLabel('Criterion Telemetry Selection')
|
||||||
|
.selectOption({ label: stateGenerator.name });
|
||||||
|
await page.getByLabel('Criterion Metadata Selection').selectOption({ label: 'State' });
|
||||||
|
await page.getByLabel('Criterion Comparison Selection').selectOption({ label: 'is' });
|
||||||
|
await page.getByLabel('Condition Name Input').first().fill('OFF');
|
||||||
|
await page.getByLabel('Save').click();
|
||||||
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
||||||
|
|
||||||
|
await linkParameterToObject(page, stateGenerator.name, displayLayout.name);
|
||||||
|
|
||||||
|
//Add a box to the display layout
|
||||||
|
await page.goto(displayLayout.url, { waitUntil: 'domcontentloaded' });
|
||||||
|
await page.getByLabel('Edit Object').click();
|
||||||
|
|
||||||
|
//Add a box to the display layout and move it to the right
|
||||||
|
//TEMP: Click the layout such that the state generator is deselected
|
||||||
|
await page.getByLabel('Test Display Layout Layout Grid').locator('div').nth(1).click();
|
||||||
|
await page.getByLabel('Add Drawing Object').click();
|
||||||
|
await page.getByText('Box').click();
|
||||||
|
await page.getByLabel('X:').click();
|
||||||
|
await page.getByLabel('X:').fill('10');
|
||||||
|
await page.getByLabel('X:').press('Enter');
|
||||||
|
|
||||||
|
// set up conditional styling such that the box is red when the state generator condition is 'OFF'
|
||||||
|
await page.getByRole('tab', { name: 'Styles' }).click();
|
||||||
|
await page.getByRole('button', { name: 'Use Conditional Styling...' }).click();
|
||||||
|
await page.getByLabel('Modal Overlay').getByLabel('Expand My Items folder').click();
|
||||||
|
await page.getByLabel('Modal Overlay').getByLabel(`Preview ${conditionSet.name}`).click();
|
||||||
|
await page.getByText('Ok').click();
|
||||||
|
await page.getByLabel('Set background color').first().click();
|
||||||
|
await page.getByLabel('#ff0000').click();
|
||||||
|
await page.getByLabel('Save', { exact: true }).click();
|
||||||
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
||||||
|
|
||||||
|
await setRealTimeMode(page);
|
||||||
|
|
||||||
|
//Pause at a time when the state generator is 'OFF' which is 20 minutes in the future
|
||||||
|
await page.clock.pauseAt(new Date(MISSION_TIME + 1200000));
|
||||||
|
|
||||||
|
const redBG = 'background-color: rgb(255, 0, 0);';
|
||||||
|
const defaultBG = 'background-color: rgb(102, 102, 102);';
|
||||||
|
const textElement = page.getByLabel('Alpha-numeric telemetry value').locator('div:first-child');
|
||||||
|
const styledElement = page.getByLabel('Box', { exact: true });
|
||||||
|
|
||||||
|
await page.clock.resume();
|
||||||
|
|
||||||
|
// Check if the style is red when text is 'OFF'
|
||||||
|
await expect(textElement).toHaveText('OFF');
|
||||||
|
await waitForStyleChange(styledElement, redBG);
|
||||||
|
|
||||||
|
// Fast forward to the next state change
|
||||||
|
await page.clock.fastForward(STATE_CHANGE_INTERVAL * 1000);
|
||||||
|
|
||||||
|
// Check if the style is not red when text is 'ON'
|
||||||
|
await expect(textElement).toHaveText('ON');
|
||||||
|
await waitForStyleChange(styledElement, defaultBG);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait for the style of an element to change to the expected style.
|
||||||
|
* @param {import('@playwright/test').Locator} element - The element to check.
|
||||||
|
* @param {string} expectedStyle - The expected style to wait for.
|
||||||
|
* @param {number} timeout - The timeout in milliseconds.
|
||||||
|
*/
|
||||||
|
async function waitForStyleChange(element, expectedStyle, timeout = 0) {
|
||||||
|
await expect(async () => {
|
||||||
|
const style = await element.getAttribute('style');
|
||||||
|
|
||||||
|
// eslint-disable-next-line playwright/prefer-web-first-assertions
|
||||||
|
expect(style).toBe(expectedStyle);
|
||||||
|
}).toPass({ timeout: 1000 }); // timeout allows for the style to be applied
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2024, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
import {
|
||||||
|
createDomainObjectWithDefaults,
|
||||||
|
navigateToObjectWithRealTime
|
||||||
|
} from '../../../../../appActions.js';
|
||||||
|
import { expect, test } from '../../../../../pluginFixtures.js';
|
||||||
|
|
||||||
|
const TINY_IMAGE_BASE64 =
|
||||||
|
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII';
|
||||||
|
|
||||||
|
test.describe('Display Layout Conditional Styling', () => {
|
||||||
|
test.use({
|
||||||
|
storageState: fileURLToPath(
|
||||||
|
new URL('../../../../../test-data/condition_set_storage.json', import.meta.url)
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
let displayLayout;
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
|
displayLayout = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Display Layout',
|
||||||
|
name: 'Test Display Layout'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Image Drawing Object can have visibility toggled conditionally', async ({ page }) => {
|
||||||
|
await page.getByLabel('Edit Object').click();
|
||||||
|
|
||||||
|
// Add Image Drawing Object to the layout
|
||||||
|
await page.getByLabel('Add Drawing Object').click();
|
||||||
|
await page.getByLabel('Image').click();
|
||||||
|
await page.getByLabel('Image URL').fill(TINY_IMAGE_BASE64);
|
||||||
|
await page.getByText('Ok').click();
|
||||||
|
|
||||||
|
// Use the "Test Condition Set" for conditional styling on the image
|
||||||
|
await page.getByRole('tab', { name: 'Styles' }).click();
|
||||||
|
await page.getByRole('button', { name: 'Use Conditional Styling...' }).click();
|
||||||
|
await page.getByLabel('Modal Overlay').getByLabel('Expand My Items folder').click();
|
||||||
|
await page.getByLabel('Modal Overlay').getByLabel('Preview Test Condition Set').click();
|
||||||
|
await page.getByText('Ok').click();
|
||||||
|
|
||||||
|
// Set the image to be hidden when the condition is met
|
||||||
|
await page.getByTitle('Visible').first().click();
|
||||||
|
await page.getByLabel('Save Style').first().click();
|
||||||
|
await page.getByLabel('Save', { exact: true }).click();
|
||||||
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
||||||
|
|
||||||
|
// Switch to real-time mode and verify that the image toggles visibility
|
||||||
|
await navigateToObjectWithRealTime(page, displayLayout.url);
|
||||||
|
await expect(page.getByLabel('Image View')).toBeVisible();
|
||||||
|
await expect(page.getByLabel('Image View')).toBeHidden();
|
||||||
|
|
||||||
|
// Reload the page and verify that the image toggles visibility
|
||||||
|
await page.reload({ waitUntil: 'domcontentloaded' });
|
||||||
|
await expect(page.getByLabel('Image View')).toBeVisible();
|
||||||
|
await expect(page.getByLabel('Image View')).toBeHidden();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Alphanumeric object can have visibility toggled conditionally', async ({ page }) => {
|
||||||
|
await page.getByLabel('Edit Object').click();
|
||||||
|
|
||||||
|
// Add Alphanumeric Object to the layout
|
||||||
|
await page.getByLabel('Expand My Items folder').click();
|
||||||
|
await page.getByLabel('Expand Test Condition Set').click();
|
||||||
|
await page.getByLabel('Preview VIPER Rover Heading').dragTo(page.getByLabel('Layout Grid'));
|
||||||
|
|
||||||
|
// Use the "Test Condition Set" for conditional styling on the alphanumeric
|
||||||
|
await page.getByRole('tab', { name: 'Styles' }).click();
|
||||||
|
await page.getByRole('button', { name: 'Use Conditional Styling...' }).click();
|
||||||
|
await page.getByLabel('Modal Overlay').getByLabel('Expand My Items folder').click();
|
||||||
|
await page.getByLabel('Modal Overlay').getByLabel('Preview Test Condition Set').click();
|
||||||
|
await page.getByText('Ok').click();
|
||||||
|
|
||||||
|
// Set the alphanumeric to be hidden when the condition is met
|
||||||
|
await page.getByTitle('Visible').first().click();
|
||||||
|
await page.getByLabel('Save Style').first().click();
|
||||||
|
await page.getByLabel('Save', { exact: true }).click();
|
||||||
|
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
||||||
|
|
||||||
|
// Switch to real-time mode and verify that the image toggles visibility
|
||||||
|
await navigateToObjectWithRealTime(page, displayLayout.url);
|
||||||
|
await expect(page.getByLabel('Alpha-numeric telemetry', { exact: true })).toBeVisible();
|
||||||
|
await expect(page.getByLabel('Alpha-numeric telemetry', { exact: true })).toBeHidden();
|
||||||
|
|
||||||
|
// Reload the page and verify that the alphanumeric toggles visibility
|
||||||
|
await page.reload({ waitUntil: 'domcontentloaded' });
|
||||||
|
await expect(page.getByLabel('Alpha-numeric telemetry', { exact: true })).toBeVisible();
|
||||||
|
await expect(page.getByLabel('Alpha-numeric telemetry', { exact: true })).toBeHidden();
|
||||||
|
});
|
||||||
|
});
|
@ -117,7 +117,8 @@ test.describe('Telemetry Table', () => {
|
|||||||
|
|
||||||
endTimeStamp.setUTCMinutes(endTimeStamp.getUTCMinutes() - 5);
|
endTimeStamp.setUTCMinutes(endTimeStamp.getUTCMinutes() - 5);
|
||||||
const endDate = endTimeStamp.toISOString().split('T')[0];
|
const endDate = endTimeStamp.toISOString().split('T')[0];
|
||||||
const endTime = endTimeStamp.toISOString().split('T')[1];
|
const milliseconds = endTimeStamp.getMilliseconds();
|
||||||
|
const endTime = endTimeStamp.toISOString().split('T')[1].replace(`.${milliseconds}Z`, '');
|
||||||
|
|
||||||
await setTimeConductorBounds(page, { endDate, endTime });
|
await setTimeConductorBounds(page, { endDate, endTime });
|
||||||
|
|
||||||
|
@ -24,65 +24,210 @@ import {
|
|||||||
setEndOffset,
|
setEndOffset,
|
||||||
setFixedTimeMode,
|
setFixedTimeMode,
|
||||||
setRealTimeMode,
|
setRealTimeMode,
|
||||||
setStartOffset,
|
setStartOffset
|
||||||
setTimeConductorBounds
|
|
||||||
} from '../../../../appActions.js';
|
} from '../../../../appActions.js';
|
||||||
import { expect, test } from '../../../../pluginFixtures.js';
|
import { expect, test } from '../../../../pluginFixtures.js';
|
||||||
|
|
||||||
test.describe('Time conductor operations', () => {
|
test.describe('Time conductor operations', () => {
|
||||||
test('validate start time does not exceed end time', async ({ page }) => {
|
const DAY = '2024-01-01';
|
||||||
|
const DAY_AFTER = '2024-01-02';
|
||||||
|
const ONE_O_CLOCK = '01:00:00';
|
||||||
|
const TWO_O_CLOCK = '02:00:00';
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
// Go to baseURL
|
// Go to baseURL
|
||||||
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||||
const year = new Date().getFullYear();
|
});
|
||||||
|
|
||||||
// Set initial valid time bounds
|
test('validate date and time inputs are validated on input event', async ({ page }) => {
|
||||||
const startDate = `${year}-01-01`;
|
const submitButtonLocator = page.getByLabel('Submit time bounds');
|
||||||
const startTime = '01:00:00';
|
|
||||||
const endDate = `${year}-01-01`;
|
|
||||||
const endTime = '02:00:00';
|
|
||||||
await setTimeConductorBounds(page, { startDate, startTime, endDate, endTime });
|
|
||||||
|
|
||||||
// Open the time conductor popup
|
// Open the time conductor popup
|
||||||
await page.getByRole('button', { name: 'Time Conductor Mode', exact: true }).click();
|
await page.getByRole('button', { name: 'Time Conductor Mode', exact: true }).click();
|
||||||
|
|
||||||
// Test invalid start date
|
await test.step('invalid start date disables submit button', async () => {
|
||||||
const invalidStartDate = `${year}-01-02`;
|
const initialStartDate = await page.getByLabel('Start date').inputValue();
|
||||||
await page.getByLabel('Start date').fill(invalidStartDate);
|
const invalidStartDate = `${initialStartDate.substring(0, 5)}${initialStartDate.substring(6)}`;
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeDisabled();
|
|
||||||
await page.getByLabel('Start date').fill(startDate);
|
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeEnabled();
|
|
||||||
|
|
||||||
// Test invalid end date
|
await page.getByLabel('Start date').fill(invalidStartDate);
|
||||||
const invalidEndDate = `${year - 1}-12-31`;
|
await expect(submitButtonLocator).toBeDisabled();
|
||||||
await page.getByLabel('End date').fill(invalidEndDate);
|
await page.getByLabel('Start date').fill(initialStartDate);
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeDisabled();
|
await expect(submitButtonLocator).toBeEnabled();
|
||||||
await page.getByLabel('End date').fill(endDate);
|
});
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeEnabled();
|
|
||||||
|
|
||||||
// Test invalid start time
|
await test.step('invalid start time disables submit button', async () => {
|
||||||
const invalidStartTime = '42:00:00';
|
const initialStartTime = await page.getByLabel('Start time').inputValue();
|
||||||
await page.getByLabel('Start time').fill(invalidStartTime);
|
const invalidStartTime = `${initialStartTime.substring(0, 5)}${initialStartTime.substring(6)}`;
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeDisabled();
|
|
||||||
await page.getByLabel('Start time').fill(startTime);
|
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeEnabled();
|
|
||||||
|
|
||||||
// Test invalid end time
|
await page.getByLabel('Start time').fill(invalidStartTime);
|
||||||
const invalidEndTime = '43:00:00';
|
await expect(submitButtonLocator).toBeDisabled();
|
||||||
await page.getByLabel('End time').fill(invalidEndTime);
|
await page.getByLabel('Start time').fill(initialStartTime);
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeDisabled();
|
await expect(submitButtonLocator).toBeEnabled();
|
||||||
await page.getByLabel('End time').fill(endTime);
|
});
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeEnabled();
|
|
||||||
|
|
||||||
// Submit valid time bounds
|
await test.step('disable/enable submit button also works with multiple invalid inputs', async () => {
|
||||||
|
const initialEndDate = await page.getByLabel('End date').inputValue();
|
||||||
|
const invalidEndDate = `${initialEndDate.substring(0, 5)}${initialEndDate.substring(6)}`;
|
||||||
|
const initialStartTime = await page.getByLabel('Start time').inputValue();
|
||||||
|
const invalidStartTime = `${initialStartTime.substring(0, 5)}${initialStartTime.substring(6)}`;
|
||||||
|
|
||||||
|
await page.getByLabel('Start time').fill(invalidStartTime);
|
||||||
|
await expect(submitButtonLocator).toBeDisabled();
|
||||||
|
await page.getByLabel('End date').fill(invalidEndDate);
|
||||||
|
await expect(submitButtonLocator).toBeDisabled();
|
||||||
|
await page.getByLabel('End date').fill(initialEndDate);
|
||||||
|
await expect(submitButtonLocator).toBeDisabled();
|
||||||
|
await page.getByLabel('Start time').fill(initialStartTime);
|
||||||
|
await expect(submitButtonLocator).toBeEnabled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('validate date and time inputs validation is reported on change event', async ({ page }) => {
|
||||||
|
// Open the time conductor popup
|
||||||
|
await page.getByRole('button', { name: 'Time Conductor Mode', exact: true }).click();
|
||||||
|
|
||||||
|
await test.step('invalid start date is reported on change event, not on input event', async () => {
|
||||||
|
const initialStartDate = await page.getByLabel('Start date').inputValue();
|
||||||
|
const invalidStartDate = `${initialStartDate.substring(0, 5)}${initialStartDate.substring(6)}`;
|
||||||
|
|
||||||
|
await page.getByLabel('Start date').fill(invalidStartDate);
|
||||||
|
await expect(page.getByLabel('Start date')).not.toHaveAttribute('title', 'Invalid Date');
|
||||||
|
await page.getByLabel('Start date').press('Tab');
|
||||||
|
await expect(page.getByLabel('Start date')).toHaveAttribute('title', 'Invalid Date');
|
||||||
|
await page.getByLabel('Start date').fill(initialStartDate);
|
||||||
|
await expect(page.getByLabel('Start date')).not.toHaveAttribute('title', 'Invalid Date');
|
||||||
|
});
|
||||||
|
|
||||||
|
await test.step('invalid start time is reported on change event, not on input event', async () => {
|
||||||
|
const initialStartTime = await page.getByLabel('Start time').inputValue();
|
||||||
|
const invalidStartTime = `${initialStartTime.substring(0, 5)}${initialStartTime.substring(6)}`;
|
||||||
|
|
||||||
|
await page.getByLabel('Start time').fill(invalidStartTime);
|
||||||
|
await expect(page.getByLabel('Start time')).not.toHaveAttribute('title', 'Invalid Time');
|
||||||
|
await page.getByLabel('Start time').press('Tab');
|
||||||
|
await expect(page.getByLabel('Start time')).toHaveAttribute('title', 'Invalid Time');
|
||||||
|
await page.getByLabel('Start time').fill(initialStartTime);
|
||||||
|
await expect(page.getByLabel('Start time')).not.toHaveAttribute('title', 'Invalid Time');
|
||||||
|
});
|
||||||
|
|
||||||
|
await test.step('invalid end date is reported on change event, not on input event', async () => {
|
||||||
|
const initialEndDate = await page.getByLabel('End date').inputValue();
|
||||||
|
const invalidEndDate = `${initialEndDate.substring(0, 5)}${initialEndDate.substring(6)}`;
|
||||||
|
|
||||||
|
await page.getByLabel('End date').fill(invalidEndDate);
|
||||||
|
await expect(page.getByLabel('End date')).not.toHaveAttribute('title', 'Invalid Date');
|
||||||
|
await page.getByLabel('End date').press('Tab');
|
||||||
|
await expect(page.getByLabel('End date')).toHaveAttribute('title', 'Invalid Date');
|
||||||
|
await page.getByLabel('End date').fill(initialEndDate);
|
||||||
|
await expect(page.getByLabel('End date')).not.toHaveAttribute('title', 'Invalid Date');
|
||||||
|
});
|
||||||
|
|
||||||
|
await test.step('invalid end time is reported on change event, not on input event', async () => {
|
||||||
|
const initialEndTime = await page.getByLabel('End time').inputValue();
|
||||||
|
const invalidEndTime = `${initialEndTime.substring(0, 5)}${initialEndTime.substring(6)}`;
|
||||||
|
|
||||||
|
await page.getByLabel('End time').fill(invalidEndTime);
|
||||||
|
await expect(page.getByLabel('End time')).not.toHaveAttribute('title', 'Invalid Time');
|
||||||
|
await page.getByLabel('End time').press('Tab');
|
||||||
|
await expect(page.getByLabel('End time')).toHaveAttribute('title', 'Invalid Time');
|
||||||
|
await page.getByLabel('End time').fill(initialEndTime);
|
||||||
|
await expect(page.getByLabel('End time')).not.toHaveAttribute('title', 'Invalid Time');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('validate start time does not exceed end time on submit', async ({ page }) => {
|
||||||
|
// Open the time conductor popup
|
||||||
|
await page.getByRole('button', { name: 'Time Conductor Mode', exact: true }).click();
|
||||||
|
|
||||||
|
// FIXME: https://github.com/nasa/openmct/pull/7818
|
||||||
|
// eslint-disable-next-line playwright/no-wait-for-timeout
|
||||||
|
await page.waitForTimeout(500);
|
||||||
|
|
||||||
|
await page.getByLabel('Start date').fill(DAY);
|
||||||
|
await page.getByLabel('Start time').fill(TWO_O_CLOCK);
|
||||||
|
await page.getByLabel('End date').fill(DAY);
|
||||||
|
await page.getByLabel('End time').fill(ONE_O_CLOCK);
|
||||||
await page.getByLabel('Submit time bounds').click();
|
await page.getByLabel('Submit time bounds').click();
|
||||||
|
|
||||||
// Verify the submitted time bounds
|
await expect(page.getByLabel('Start date')).toHaveAttribute(
|
||||||
await expect(page.getByLabel('Start bounds')).toHaveText(
|
'title',
|
||||||
new RegExp(`${startDate} ${startTime}.000Z`)
|
'Specified start date exceeds end bound'
|
||||||
);
|
);
|
||||||
await expect(page.getByLabel('End bounds')).toHaveText(
|
await expect(page.getByLabel('Start bounds')).not.toHaveText(`${DAY} ${TWO_O_CLOCK}.000Z`);
|
||||||
new RegExp(`${endDate} ${endTime}.000Z`)
|
await expect(page.getByLabel('End bounds')).not.toHaveText(`${DAY} ${ONE_O_CLOCK}.000Z`);
|
||||||
|
|
||||||
|
await page.getByLabel('Start date').fill(DAY);
|
||||||
|
await page.getByLabel('Start time').fill(ONE_O_CLOCK);
|
||||||
|
await page.getByLabel('End date').fill(DAY);
|
||||||
|
await page.getByLabel('End time').fill(TWO_O_CLOCK);
|
||||||
|
await page.getByLabel('Submit time bounds').click();
|
||||||
|
|
||||||
|
await expect(page.getByLabel('Start bounds')).toHaveText(`${DAY} ${ONE_O_CLOCK}.000Z`);
|
||||||
|
await expect(page.getByLabel('End bounds')).toHaveText(`${DAY} ${TWO_O_CLOCK}.000Z`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('validate start datetime does not exceed end datetime on submit', async ({ page }) => {
|
||||||
|
// Open the time conductor popup
|
||||||
|
await page.getByRole('button', { name: 'Time Conductor Mode', exact: true }).click();
|
||||||
|
|
||||||
|
// FIXME: https://github.com/nasa/openmct/pull/7818
|
||||||
|
// eslint-disable-next-line playwright/no-wait-for-timeout
|
||||||
|
await page.waitForTimeout(500);
|
||||||
|
|
||||||
|
await page.getByLabel('Start date').fill(DAY_AFTER);
|
||||||
|
await page.getByLabel('Start time').fill(ONE_O_CLOCK);
|
||||||
|
await page.getByLabel('End date').fill(DAY);
|
||||||
|
await page.getByLabel('End time').fill(ONE_O_CLOCK);
|
||||||
|
await page.getByLabel('Submit time bounds').click();
|
||||||
|
|
||||||
|
await expect(page.getByLabel('Start date')).toHaveAttribute(
|
||||||
|
'title',
|
||||||
|
'Specified start date exceeds end bound'
|
||||||
);
|
);
|
||||||
|
await expect(page.getByLabel('Start bounds')).not.toHaveText(
|
||||||
|
`${DAY_AFTER} ${ONE_O_CLOCK}.000Z`
|
||||||
|
);
|
||||||
|
await expect(page.getByLabel('End bounds')).not.toHaveText(`${DAY} ${ONE_O_CLOCK}.000Z`);
|
||||||
|
|
||||||
|
await page.getByLabel('Start date').fill(DAY);
|
||||||
|
await page.getByLabel('Start time').fill(ONE_O_CLOCK);
|
||||||
|
await page.getByLabel('End date').fill(DAY_AFTER);
|
||||||
|
await page.getByLabel('End time').fill(ONE_O_CLOCK);
|
||||||
|
await page.getByLabel('Submit time bounds').click();
|
||||||
|
|
||||||
|
await expect(page.getByLabel('Start bounds')).toHaveText(`${DAY} ${ONE_O_CLOCK}.000Z`);
|
||||||
|
await expect(page.getByLabel('End bounds')).toHaveText(`${DAY_AFTER} ${ONE_O_CLOCK}.000Z`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('cancelling form does not set bounds', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/7791'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Open the time conductor popup
|
||||||
|
await page.getByRole('button', { name: 'Time Conductor Mode', exact: true }).click();
|
||||||
|
|
||||||
|
await page.getByLabel('Start date').fill(DAY);
|
||||||
|
await page.getByLabel('Start time').fill(ONE_O_CLOCK);
|
||||||
|
await page.getByLabel('End date').fill(DAY_AFTER);
|
||||||
|
await page.getByLabel('End time').fill(ONE_O_CLOCK);
|
||||||
|
await page.getByLabel('Discard changes and close time popup').click();
|
||||||
|
|
||||||
|
await expect(page.getByLabel('Start bounds')).not.toHaveText(`${DAY} ${ONE_O_CLOCK}.000Z`);
|
||||||
|
await expect(page.getByLabel('End bounds')).not.toHaveText(`${DAY_AFTER} ${ONE_O_CLOCK}.000Z`);
|
||||||
|
|
||||||
|
// Open the time conductor popup
|
||||||
|
await page.getByRole('button', { name: 'Time Conductor Mode', exact: true }).click();
|
||||||
|
|
||||||
|
await page.getByLabel('Start date').fill(DAY);
|
||||||
|
await page.getByLabel('Start time').fill(ONE_O_CLOCK);
|
||||||
|
await page.getByLabel('End date').fill(DAY_AFTER);
|
||||||
|
await page.getByLabel('End time').fill(ONE_O_CLOCK);
|
||||||
|
await page.getByLabel('Submit time bounds').click();
|
||||||
|
|
||||||
|
await expect(page.getByLabel('Start bounds')).toHaveText(`${DAY} ${ONE_O_CLOCK}.000Z`);
|
||||||
|
await expect(page.getByLabel('End bounds')).toHaveText(`${DAY_AFTER} ${ONE_O_CLOCK}.000Z`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -131,77 +276,6 @@ test.describe('Global Time Conductor', () => {
|
|||||||
await expect(page.getByLabel('End offset: 01:30:31')).toBeVisible();
|
await expect(page.getByLabel('End offset: 01:30:31')).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Input field validation: fixed time mode', async ({ page }) => {
|
|
||||||
test.info().annotations.push({
|
|
||||||
type: 'issue',
|
|
||||||
description: 'https://github.com/nasa/openmct/issues/7791'
|
|
||||||
});
|
|
||||||
// Switch to fixed time mode
|
|
||||||
await setFixedTimeMode(page);
|
|
||||||
|
|
||||||
// Define valid time bounds for testing
|
|
||||||
const validBounds = {
|
|
||||||
startDate: '2024-04-20',
|
|
||||||
startTime: '00:04:20',
|
|
||||||
endDate: '2024-04-20',
|
|
||||||
endTime: '16:04:20'
|
|
||||||
};
|
|
||||||
// Set valid time conductor bounds ✌️
|
|
||||||
await setTimeConductorBounds(page, validBounds);
|
|
||||||
|
|
||||||
// Verify that the time bounds are set correctly
|
|
||||||
await expect(page.getByLabel(`Start bounds: 2024-04-20 00:04:20.000Z`)).toBeVisible();
|
|
||||||
await expect(page.getByLabel(`End bounds: 2024-04-20 16:04:20.000Z`)).toBeVisible();
|
|
||||||
|
|
||||||
// Open the Time Conductor Mode popup
|
|
||||||
await page.getByLabel('Time Conductor Mode').click();
|
|
||||||
|
|
||||||
// Test invalid start date
|
|
||||||
const invalidStartDate = '2024-04-21';
|
|
||||||
await page.getByLabel('Start date').fill(invalidStartDate);
|
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeDisabled();
|
|
||||||
await page.getByLabel('Start date').fill(validBounds.startDate);
|
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeEnabled();
|
|
||||||
|
|
||||||
// Test invalid end date
|
|
||||||
const invalidEndDate = '2024-04-19';
|
|
||||||
await page.getByLabel('End date').fill(invalidEndDate);
|
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeDisabled();
|
|
||||||
await page.getByLabel('End date').fill(validBounds.endDate);
|
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeEnabled();
|
|
||||||
|
|
||||||
// Test invalid start time
|
|
||||||
const invalidStartTime = '16:04:21';
|
|
||||||
await page.getByLabel('Start time').fill(invalidStartTime);
|
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeDisabled();
|
|
||||||
await page.getByLabel('Start time').fill(validBounds.startTime);
|
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeEnabled();
|
|
||||||
|
|
||||||
// Test invalid end time
|
|
||||||
const invalidEndTime = '00:04:19';
|
|
||||||
await page.getByLabel('End time').fill(invalidEndTime);
|
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeDisabled();
|
|
||||||
await page.getByLabel('End time').fill(validBounds.endTime);
|
|
||||||
await expect(page.getByLabel('Submit time bounds')).toBeEnabled();
|
|
||||||
|
|
||||||
// Verify that the time bounds remain unchanged after invalid inputs
|
|
||||||
await expect(page.getByLabel(`Start bounds: 2024-04-20 00:04:20.000Z`)).toBeVisible();
|
|
||||||
await expect(page.getByLabel(`End bounds: 2024-04-20 16:04:20.000Z`)).toBeVisible();
|
|
||||||
|
|
||||||
// Discard changes and verify that bounds remain unchanged
|
|
||||||
await setTimeConductorBounds(page, {
|
|
||||||
startDate: validBounds.startDate,
|
|
||||||
startTime: '04:20:00',
|
|
||||||
endDate: validBounds.endDate,
|
|
||||||
endTime: '04:20:20',
|
|
||||||
submitChanges: false
|
|
||||||
});
|
|
||||||
|
|
||||||
// Verify that the original time bounds are still displayed after discarding changes
|
|
||||||
await expect(page.getByLabel(`Start bounds: 2024-04-20 00:04:20.000Z`)).toBeVisible();
|
|
||||||
await expect(page.getByLabel(`End bounds: 2024-04-20 16:04:20.000Z`)).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify that offsets and url params are preserved when switching
|
* Verify that offsets and url params are preserved when switching
|
||||||
* between fixed timespan and real-time mode.
|
* between fixed timespan and real-time mode.
|
||||||
|
@ -31,6 +31,8 @@ import { expect, test } from '../../pluginFixtures.js';
|
|||||||
test.describe('Grand Search', () => {
|
test.describe('Grand Search', () => {
|
||||||
let grandSearchInput;
|
let grandSearchInput;
|
||||||
|
|
||||||
|
test.use({ ignore404s: [/_design\/object_names\/_view\/object_names$/] });
|
||||||
|
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
grandSearchInput = page
|
grandSearchInput = page
|
||||||
.getByLabel('OpenMCT Search')
|
.getByLabel('OpenMCT Search')
|
||||||
@ -191,7 +193,88 @@ test.describe('Grand Search', () => {
|
|||||||
await expect(searchResults).toContainText(folderName);
|
await expect(searchResults).toContainText(folderName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test.describe('Search will test for the presence of the object_names index, and', () => {
|
||||||
|
test('use index if available @couchdb @network', async ({ page }) => {
|
||||||
|
await createObjectsForSearch(page);
|
||||||
|
|
||||||
|
let isObjectNamesViewAvailable = false;
|
||||||
|
let isObjectNamesUsedForSearch = false;
|
||||||
|
|
||||||
|
page.on('request', async (request) => {
|
||||||
|
const isObjectNamesRequest = request.url().endsWith('_view/object_names');
|
||||||
|
const isHeadRequest = request.method().toLowerCase() === 'head';
|
||||||
|
|
||||||
|
if (isObjectNamesRequest && isHeadRequest) {
|
||||||
|
const response = await request.response();
|
||||||
|
isObjectNamesViewAvailable = response.status() === 200;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
page.on('request', (request) => {
|
||||||
|
const isObjectNamesRequest = request.url().endsWith('_view/object_names');
|
||||||
|
const isPostRequest = request.method().toLowerCase() === 'post';
|
||||||
|
|
||||||
|
if (isObjectNamesRequest && isPostRequest) {
|
||||||
|
isObjectNamesUsedForSearch = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Full search for object
|
||||||
|
await grandSearchInput.pressSequentially('Clock', { delay: 100 });
|
||||||
|
|
||||||
|
// Wait for search to finish
|
||||||
|
await waitForSearchCompletion(page);
|
||||||
|
|
||||||
|
expect(isObjectNamesViewAvailable).toBe(true);
|
||||||
|
expect(isObjectNamesUsedForSearch).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('fall-back on base index if index not available @couchdb @network', async ({ page }) => {
|
||||||
|
await page.route('**/_view/object_names', (route) => {
|
||||||
|
route.fulfill({
|
||||||
|
status: 404
|
||||||
|
});
|
||||||
|
});
|
||||||
|
await createObjectsForSearch(page);
|
||||||
|
|
||||||
|
let isObjectNamesViewAvailable = false;
|
||||||
|
let isFindUsedForSearch = false;
|
||||||
|
|
||||||
|
page.on('request', async (request) => {
|
||||||
|
const isObjectNamesRequest = request.url().endsWith('_view/object_names');
|
||||||
|
const isHeadRequest = request.method().toLowerCase() === 'head';
|
||||||
|
|
||||||
|
if (isObjectNamesRequest && isHeadRequest) {
|
||||||
|
const response = await request.response();
|
||||||
|
isObjectNamesViewAvailable = response.status() === 200;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
page.on('request', (request) => {
|
||||||
|
const isFindRequest = request.url().endsWith('_find');
|
||||||
|
const isPostRequest = request.method().toLowerCase() === 'post';
|
||||||
|
|
||||||
|
if (isFindRequest && isPostRequest) {
|
||||||
|
isFindUsedForSearch = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Full search for object
|
||||||
|
await grandSearchInput.pressSequentially('Clock', { delay: 100 });
|
||||||
|
|
||||||
|
// Wait for search to finish
|
||||||
|
await waitForSearchCompletion(page);
|
||||||
|
console.info(
|
||||||
|
`isObjectNamesViewAvailable: ${isObjectNamesViewAvailable} | isFindUsedForSearch: ${isFindUsedForSearch}`
|
||||||
|
);
|
||||||
|
expect(isObjectNamesViewAvailable).toBe(false);
|
||||||
|
expect(isFindUsedForSearch).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('Search results are debounced @couchdb @network', async ({ page }) => {
|
test('Search results are debounced @couchdb @network', async ({ page }) => {
|
||||||
|
// Unfortunately 404s are always logged to the JavaScript console and can't be suppressed
|
||||||
|
// A 404 is now thrown when we test for the presence of the object names view used by search.
|
||||||
test.info().annotations.push({
|
test.info().annotations.push({
|
||||||
type: 'issue',
|
type: 'issue',
|
||||||
description: 'https://github.com/nasa/openmct/issues/6179'
|
description: 'https://github.com/nasa/openmct/issues/6179'
|
||||||
@ -199,11 +282,17 @@ test.describe('Grand Search', () => {
|
|||||||
await createObjectsForSearch(page);
|
await createObjectsForSearch(page);
|
||||||
|
|
||||||
let networkRequests = [];
|
let networkRequests = [];
|
||||||
|
|
||||||
page.on('request', (request) => {
|
page.on('request', (request) => {
|
||||||
const searchRequest =
|
const isSearchRequest =
|
||||||
request.url().endsWith('_find') || request.url().includes('by_keystring');
|
request.url().endsWith('object_names') ||
|
||||||
const fetchRequest = request.resourceType() === 'fetch';
|
request.url().endsWith('_find') ||
|
||||||
if (searchRequest && fetchRequest) {
|
request.url().includes('by_keystring');
|
||||||
|
const isFetchRequest = request.resourceType() === 'fetch';
|
||||||
|
// CouchDB search results in a one-time head request to test for the presence of an index.
|
||||||
|
const isHeadRequest = request.method().toLowerCase() === 'head';
|
||||||
|
|
||||||
|
if (isSearchRequest && isFetchRequest && !isHeadRequest) {
|
||||||
networkRequests.push(request);
|
networkRequests.push(request);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Open MCT, Copyright (c) 2014-2023, United States Government
|
* Open MCT, Copyright (c) 2014-2024, United States Government
|
||||||
* as represented by the Administrator of the National Aeronautics and Space
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
* Administration. All rights reserved.
|
* Administration. All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Open MCT, Copyright (c) 2014-2023, United States Government
|
* Open MCT, Copyright (c) 2014-2024, United States Government
|
||||||
* as represented by the Administrator of the National Aeronautics and Space
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
* Administration. All rights reserved.
|
* Administration. All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -213,7 +213,6 @@ test.describe('Navigation memory leak is not detected in', () => {
|
|||||||
page,
|
page,
|
||||||
'example-imagery-memory-leak-test'
|
'example-imagery-memory-leak-test'
|
||||||
);
|
);
|
||||||
|
|
||||||
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
// If we got here without timing out, then the root view object was garbage collected and no memory leak was detected.
|
||||||
expect(result).toBe(true);
|
expect(result).toBe(true);
|
||||||
});
|
});
|
||||||
@ -317,6 +316,12 @@ test.describe('Navigation memory leak is not detected in', () => {
|
|||||||
|
|
||||||
// Manually invoke the garbage collector once all references are removed.
|
// Manually invoke the garbage collector once all references are removed.
|
||||||
window.gc();
|
window.gc();
|
||||||
|
window.gc();
|
||||||
|
window.gc();
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
window.gc();
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
return gcPromise;
|
return gcPromise;
|
||||||
});
|
});
|
||||||
|
@ -85,16 +85,6 @@ test.describe('Visual - Default @a11y', () => {
|
|||||||
await percySnapshot(page, `Display Layout Create Menu (theme: '${theme}')`);
|
await percySnapshot(page, `Display Layout Create Menu (theme: '${theme}')`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Visual - Default Gauge', async ({ page, theme }) => {
|
|
||||||
await createDomainObjectWithDefaults(page, {
|
|
||||||
type: 'Gauge',
|
|
||||||
name: 'Default Gauge'
|
|
||||||
});
|
|
||||||
|
|
||||||
// Take a snapshot of the newly created Gauge object
|
|
||||||
await percySnapshot(page, `Default Gauge (theme: '${theme}')`);
|
|
||||||
});
|
|
||||||
|
|
||||||
test.afterEach(async ({ page }, testInfo) => {
|
test.afterEach(async ({ page }, testInfo) => {
|
||||||
await scanForA11yViolations(page, testInfo.title);
|
await scanForA11yViolations(page, testInfo.title);
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,11 @@
|
|||||||
|
|
||||||
import percySnapshot from '@percy/playwright';
|
import percySnapshot from '@percy/playwright';
|
||||||
|
|
||||||
import { createDomainObjectWithDefaults } from '../../appActions.js';
|
import {
|
||||||
|
createDomainObjectWithDefaults,
|
||||||
|
createStableStateTelemetry,
|
||||||
|
linkParameterToObject
|
||||||
|
} from '../../appActions.js';
|
||||||
import { MISSION_TIME, VISUAL_FIXED_URL } from '../../constants.js';
|
import { MISSION_TIME, VISUAL_FIXED_URL } from '../../constants.js';
|
||||||
import { test } from '../../pluginFixtures.js';
|
import { test } from '../../pluginFixtures.js';
|
||||||
|
|
||||||
@ -47,16 +51,13 @@ test.describe('Visual - Display Layout @clock', () => {
|
|||||||
name: 'Child Right Layout',
|
name: 'Child Right Layout',
|
||||||
parent: parentLayout.uuid
|
parent: parentLayout.uuid
|
||||||
});
|
});
|
||||||
await createDomainObjectWithDefaults(page, {
|
|
||||||
type: 'Sine Wave Generator',
|
const stableStateTelemetry = await createStableStateTelemetry(page);
|
||||||
name: 'SWG 1',
|
await linkParameterToObject(page, stableStateTelemetry.name, child1Layout.name);
|
||||||
parent: child1Layout.uuid
|
await linkParameterToObject(page, stableStateTelemetry.name, child2Layout.name);
|
||||||
});
|
|
||||||
await createDomainObjectWithDefaults(page, {
|
// Pause the clock at a time where the telemetry is stable 20 minutes in the future
|
||||||
type: 'Sine Wave Generator',
|
await page.clock.pauseAt(new Date(MISSION_TIME + 1200000));
|
||||||
name: 'SWG 2',
|
|
||||||
parent: child2Layout.uuid
|
|
||||||
});
|
|
||||||
|
|
||||||
await page.goto(parentLayout.url, { waitUntil: 'domcontentloaded' });
|
await page.goto(parentLayout.url, { waitUntil: 'domcontentloaded' });
|
||||||
await page.getByRole('button', { name: 'Edit Object' }).click();
|
await page.getByRole('button', { name: 'Edit Object' }).click();
|
||||||
|
81
e2e/tests/visual-a11y/gauge.visual.spec.js
Normal file
81
e2e/tests/visual-a11y/gauge.visual.spec.js
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2024, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
import percySnapshot from '@percy/playwright';
|
||||||
|
|
||||||
|
import { createDomainObjectWithDefaults } from '../../appActions.js';
|
||||||
|
import { scanForA11yViolations, test } from '../../avpFixtures.js';
|
||||||
|
import { VISUAL_FIXED_URL } from '../../constants.js';
|
||||||
|
|
||||||
|
test.describe('Visual - Gauges', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto(VISUAL_FIXED_URL, { waitUntil: 'domcontentloaded' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Visual - Default Gauge', async ({ page, theme }) => {
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Gauge',
|
||||||
|
name: 'Default Gauge'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Take a snapshot of the newly created Gauge object
|
||||||
|
await percySnapshot(page, `Default Gauge (theme: '${theme}')`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Visual - Needle Gauge with State Generator', async ({ page, theme }) => {
|
||||||
|
const needleGauge = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Gauge',
|
||||||
|
name: 'Needle Gauge'
|
||||||
|
});
|
||||||
|
|
||||||
|
//Modify the Gauge to be a Needle Gauge
|
||||||
|
await page.getByLabel('More actions').click();
|
||||||
|
await page.getByLabel('Edit Properties...').click();
|
||||||
|
await page.getByLabel('Gauge type', { exact: true }).selectOption('dial-needle');
|
||||||
|
await page.getByText('Ok').click();
|
||||||
|
|
||||||
|
//Add a State Generator to the Gauge
|
||||||
|
await page.goto(needleGauge.url + '?hideTree=true&hideInspector=true', {
|
||||||
|
waitUntil: 'domcontentloaded'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Take a snapshot of the newly created Gauge object
|
||||||
|
await percySnapshot(page, `Needle Gauge with no telemetry source (theme: '${theme}')`);
|
||||||
|
|
||||||
|
//Add a State Generator to the Gauge. Note this requires that snapshots are taken within 5 seconds
|
||||||
|
await page.getByLabel('Create', { exact: true }).click();
|
||||||
|
await page.getByLabel('State Generator').click();
|
||||||
|
await page.getByLabel('Modal Overlay').getByLabel('Navigate to Needle Gauge').click();
|
||||||
|
await page.getByLabel('Save').click();
|
||||||
|
|
||||||
|
//Add a State Generator to the Gauge
|
||||||
|
await page.goto(needleGauge.url + '?hideTree=true&hideInspector=true', {
|
||||||
|
waitUntil: 'domcontentloaded'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Take a snapshot of the newly created Gauge object
|
||||||
|
await percySnapshot(page, `Needle Gauge with State Generator (theme: '${theme}')`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.afterEach(async ({ page }, testInfo) => {
|
||||||
|
await scanForA11yViolations(page, testInfo.title);
|
||||||
|
});
|
||||||
|
});
|
@ -98,7 +98,7 @@ test.describe('Visual - Notebook @a11y', () => {
|
|||||||
|
|
||||||
await page.getByLabel('Expand My Items folder').click();
|
await page.getByLabel('Expand My Items folder').click();
|
||||||
|
|
||||||
await page.goto(notebook.url);
|
await page.goto(notebook.url, { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
await page
|
await page
|
||||||
.getByLabel('Navigate to Dropped Overlay Plot')
|
.getByLabel('Navigate to Dropped Overlay Plot')
|
||||||
|
@ -26,14 +26,25 @@ import fs from 'fs';
|
|||||||
import { createDomainObjectWithDefaults, createPlanFromJSON } from '../../appActions.js';
|
import { createDomainObjectWithDefaults, createPlanFromJSON } from '../../appActions.js';
|
||||||
import { scanForA11yViolations, test } from '../../avpFixtures.js';
|
import { scanForA11yViolations, test } from '../../avpFixtures.js';
|
||||||
import { VISUAL_FIXED_URL } from '../../constants.js';
|
import { VISUAL_FIXED_URL } from '../../constants.js';
|
||||||
import { setBoundsToSpanAllActivities, setDraftStatusForPlan } from '../../helper/planningUtils.js';
|
import {
|
||||||
|
getFirstActivity,
|
||||||
|
setBoundsToSpanAllActivities,
|
||||||
|
setDraftStatusForPlan
|
||||||
|
} from '../../helper/planningUtils.js';
|
||||||
|
|
||||||
const examplePlanSmall2 = JSON.parse(
|
const examplePlanSmall2 = JSON.parse(
|
||||||
fs.readFileSync(new URL('../../test-data/examplePlans/ExamplePlan_Small2.json', import.meta.url))
|
fs.readFileSync(new URL('../../test-data/examplePlans/ExamplePlan_Small2.json', import.meta.url))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const FIRST_ACTIVITY_SMALL_2 = getFirstActivity(examplePlanSmall2);
|
||||||
|
|
||||||
test.describe('Visual - Gantt Chart @a11y', () => {
|
test.describe('Visual - Gantt Chart @a11y', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// Set the clock to the end of the first activity in the plan
|
||||||
|
// This is so we can see the "now" line in the plan view
|
||||||
|
await page.clock.install({ time: FIRST_ACTIVITY_SMALL_2.end + 10000 });
|
||||||
|
await page.clock.resume();
|
||||||
|
|
||||||
await page.goto(VISUAL_FIXED_URL, { waitUntil: 'domcontentloaded' });
|
await page.goto(VISUAL_FIXED_URL, { waitUntil: 'domcontentloaded' });
|
||||||
});
|
});
|
||||||
test('Gantt Chart View', async ({ page, theme }) => {
|
test('Gantt Chart View', async ({ page, theme }) => {
|
||||||
|
@ -27,14 +27,21 @@ import { createDomainObjectWithDefaults, createPlanFromJSON } from '../../appAct
|
|||||||
import { scanForA11yViolations, test } from '../../avpFixtures.js';
|
import { scanForA11yViolations, test } from '../../avpFixtures.js';
|
||||||
import { waitForAnimations } from '../../baseFixtures.js';
|
import { waitForAnimations } from '../../baseFixtures.js';
|
||||||
import { VISUAL_FIXED_URL } from '../../constants.js';
|
import { VISUAL_FIXED_URL } from '../../constants.js';
|
||||||
import { setBoundsToSpanAllActivities } from '../../helper/planningUtils.js';
|
import { getFirstActivity, setBoundsToSpanAllActivities } from '../../helper/planningUtils.js';
|
||||||
|
|
||||||
const examplePlanSmall2 = JSON.parse(
|
const examplePlanSmall2 = JSON.parse(
|
||||||
fs.readFileSync(new URL('../../test-data/examplePlans/ExamplePlan_Small2.json', import.meta.url))
|
fs.readFileSync(new URL('../../test-data/examplePlans/ExamplePlan_Small2.json', import.meta.url))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const FIRST_ACTIVITY_SMALL_2 = getFirstActivity(examplePlanSmall2);
|
||||||
|
|
||||||
test.describe('Visual - Time Strip @a11y', () => {
|
test.describe('Visual - Time Strip @a11y', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// Set the clock to the end of the first activity in the plan
|
||||||
|
// This is so we can see the "now" line in the plan view
|
||||||
|
await page.clock.install({ time: FIRST_ACTIVITY_SMALL_2.end + 10000 });
|
||||||
|
await page.clock.resume();
|
||||||
|
|
||||||
await page.goto(VISUAL_FIXED_URL, { waitUntil: 'domcontentloaded' });
|
await page.goto(VISUAL_FIXED_URL, { waitUntil: 'domcontentloaded' });
|
||||||
});
|
});
|
||||||
test('Time Strip View', async ({ page, theme }) => {
|
test('Time Strip View', async ({ page, theme }) => {
|
||||||
|
@ -42,6 +42,7 @@ const examplePlanSmall2 = JSON.parse(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const FIRST_ACTIVITY_SMALL_1 = getFirstActivity(examplePlanSmall1);
|
const FIRST_ACTIVITY_SMALL_1 = getFirstActivity(examplePlanSmall1);
|
||||||
|
const FIRST_ACTIVITY_SMALL_2 = getFirstActivity(examplePlanSmall2);
|
||||||
|
|
||||||
test.describe('Visual - Timelist progress bar @clock @a11y', () => {
|
test.describe('Visual - Timelist progress bar @clock @a11y', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
@ -59,6 +60,11 @@ test.describe('Visual - Timelist progress bar @clock @a11y', () => {
|
|||||||
|
|
||||||
test.describe('Visual - Plan View @a11y', () => {
|
test.describe('Visual - Plan View @a11y', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// Set the clock to the end of the first activity in the plan
|
||||||
|
// This is so we can see the "now" line in the plan view
|
||||||
|
await page.clock.install({ time: FIRST_ACTIVITY_SMALL_2.end + 10000 });
|
||||||
|
await page.clock.resume();
|
||||||
|
|
||||||
await page.goto(VISUAL_FIXED_URL, { waitUntil: 'domcontentloaded' });
|
await page.goto(VISUAL_FIXED_URL, { waitUntil: 'domcontentloaded' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ test.describe('Grand Search @a11y', () => {
|
|||||||
theme
|
theme
|
||||||
}) => {
|
}) => {
|
||||||
// Navigate to display layout
|
// Navigate to display layout
|
||||||
await page.goto(displayLayout.url);
|
await page.goto(displayLayout.url, { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
// Search for the object
|
// Search for the object
|
||||||
await page.getByRole('searchbox', { name: 'Search Input' }).click();
|
await page.getByRole('searchbox', { name: 'Search Input' }).click();
|
||||||
|
@ -46,6 +46,24 @@ class EventMetadataProvider {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const inPlaceUpdateMetadataValue = {
|
||||||
|
key: 'messageId',
|
||||||
|
name: 'row identifier',
|
||||||
|
format: 'string',
|
||||||
|
useToUpdateInPlace: true
|
||||||
|
};
|
||||||
|
const eventAcknowledgeMetadataValue = {
|
||||||
|
key: 'acknowledge',
|
||||||
|
name: 'Acknowledge',
|
||||||
|
format: 'string'
|
||||||
|
};
|
||||||
|
|
||||||
|
const eventGeneratorWithAcknowledge = structuredClone(this.METADATA_BY_TYPE.eventGenerator);
|
||||||
|
eventGeneratorWithAcknowledge.values.push(inPlaceUpdateMetadataValue);
|
||||||
|
eventGeneratorWithAcknowledge.values.push(eventAcknowledgeMetadataValue);
|
||||||
|
|
||||||
|
this.METADATA_BY_TYPE.eventGeneratorWithAcknowledge = eventGeneratorWithAcknowledge;
|
||||||
}
|
}
|
||||||
|
|
||||||
supportsMetadata(domainObject) {
|
supportsMetadata(domainObject) {
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2024, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module defining EventTelemetryProvider. Created by chacskaylo on 06/18/2015.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import EventTelemetryProvider from './EventTelemetryProvider.js';
|
||||||
|
|
||||||
|
class EventWithAcknowledgeTelemetryProvider extends EventTelemetryProvider {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.unAcknowledgedData = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
generateData(firstObservedTime, count, startTime, duration, name) {
|
||||||
|
if (this.unAcknowledgedData === undefined) {
|
||||||
|
const unAcknowledgedData = super.generateData(
|
||||||
|
firstObservedTime,
|
||||||
|
count,
|
||||||
|
startTime,
|
||||||
|
duration,
|
||||||
|
name
|
||||||
|
);
|
||||||
|
unAcknowledgedData.messageId = unAcknowledgedData.message;
|
||||||
|
this.unAcknowledgedData = unAcknowledgedData;
|
||||||
|
|
||||||
|
return this.unAcknowledgedData;
|
||||||
|
} else {
|
||||||
|
const acknowledgedData = {
|
||||||
|
...this.unAcknowledgedData,
|
||||||
|
acknowledge: 'OK'
|
||||||
|
};
|
||||||
|
|
||||||
|
this.unAcknowledgedData = undefined;
|
||||||
|
|
||||||
|
return acknowledgedData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
supportsRequest(domainObject) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
supportsSubscribe(domainObject) {
|
||||||
|
return domainObject.type === 'eventGeneratorWithAcknowledge';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default EventWithAcknowledgeTelemetryProvider;
|
@ -21,6 +21,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
import EventMetadataProvider from './EventMetadataProvider.js';
|
import EventMetadataProvider from './EventMetadataProvider.js';
|
||||||
import EventTelemetryProvider from './EventTelemetryProvider.js';
|
import EventTelemetryProvider from './EventTelemetryProvider.js';
|
||||||
|
import EventWithAcknowledgeTelemetryProvider from './EventWithAcknowledgeTelemetryProvider.js';
|
||||||
|
|
||||||
export default function EventGeneratorPlugin(options) {
|
export default function EventGeneratorPlugin(options) {
|
||||||
return function install(openmct) {
|
return function install(openmct) {
|
||||||
@ -38,5 +39,20 @@ export default function EventGeneratorPlugin(options) {
|
|||||||
});
|
});
|
||||||
openmct.telemetry.addProvider(new EventTelemetryProvider());
|
openmct.telemetry.addProvider(new EventTelemetryProvider());
|
||||||
openmct.telemetry.addProvider(new EventMetadataProvider());
|
openmct.telemetry.addProvider(new EventMetadataProvider());
|
||||||
|
|
||||||
|
openmct.types.addType('eventGeneratorWithAcknowledge', {
|
||||||
|
name: 'Event Message Generator with Acknowledge',
|
||||||
|
description:
|
||||||
|
'For development use. Creates sample event message data stream and updates the event row with an acknowledgement.',
|
||||||
|
cssClass: 'icon-generator-events',
|
||||||
|
creatable: true,
|
||||||
|
initialize: function (object) {
|
||||||
|
object.telemetry = {
|
||||||
|
duration: 2.5
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
openmct.telemetry.addProvider(new EventWithAcknowledgeTelemetryProvider());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
import { DEFAULT_SHELVE_DURATIONS } from '../../src/api/faultmanagement/FaultManagementAPI.js';
|
||||||
import { acknowledgeFault, randomFaults, shelveFault } from './utils.js';
|
import { acknowledgeFault, randomFaults, shelveFault } from './utils.js';
|
||||||
|
|
||||||
export default function (staticFaults = false) {
|
export default function (staticFaults = false) {
|
||||||
@ -56,6 +57,9 @@ export default function (staticFaults = false) {
|
|||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
success: true
|
success: true
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
getShelveDurations() {
|
||||||
|
return DEFAULT_SHELVE_DURATIONS;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,27 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2024, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
const SEVERITIES = ['WATCH', 'WARNING', 'CRITICAL'];
|
const SEVERITIES = ['WATCH', 'WARNING', 'CRITICAL'];
|
||||||
|
const MOONWALK_TIMESTAMP = 14159040000;
|
||||||
const NAMESPACE = '/Example/fault-';
|
const NAMESPACE = '/Example/fault-';
|
||||||
const getRandom = {
|
const getRandom = {
|
||||||
severity: () => SEVERITIES[Math.floor(Math.random() * 3)],
|
severity: () => SEVERITIES[Math.floor(Math.random() * 3)],
|
||||||
@ -13,7 +36,8 @@ const getRandom = {
|
|||||||
|
|
||||||
val = num;
|
val = num;
|
||||||
severity = SEVERITIES[severityIndex - 1];
|
severity = SEVERITIES[severityIndex - 1];
|
||||||
time = num;
|
// Subtract `num` from the timestamp so that the faults are in order
|
||||||
|
time = MOONWALK_TIMESTAMP - num; // Mon, 21 Jul 1969 02:56:00 GMT 🌔👨🚀👨🚀👨🚀
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -43,14 +67,7 @@ const getRandom = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export function shelveFault(
|
export function shelveFault(fault, opts = { shelved: true, comment: '', shelveDuration: 90000 }) {
|
||||||
fault,
|
|
||||||
opts = {
|
|
||||||
shelved: true,
|
|
||||||
comment: '',
|
|
||||||
shelveDuration: 90000
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
fault.shelved = true;
|
fault.shelved = true;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -65,8 +82,8 @@ export function acknowledgeFault(fault) {
|
|||||||
export function randomFaults(staticFaults, count = 5) {
|
export function randomFaults(staticFaults, count = 5) {
|
||||||
let faults = [];
|
let faults = [];
|
||||||
|
|
||||||
for (let x = 1, y = count + 1; x < y; x++) {
|
for (let i = 1; i <= count; i++) {
|
||||||
faults.push(getRandom.fault(x, staticFaults));
|
faults.push(getRandom.fault(i, staticFaults));
|
||||||
}
|
}
|
||||||
|
|
||||||
return faults;
|
return faults;
|
||||||
|
@ -108,6 +108,16 @@ const METADATA_BY_TYPE = {
|
|||||||
string: 'ON'
|
string: 'ON'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
filters: [
|
||||||
|
{
|
||||||
|
singleSelectionThreshold: true,
|
||||||
|
comparator: 'equals',
|
||||||
|
possibleValues: [
|
||||||
|
{ label: 'OFF', value: 0 },
|
||||||
|
{ label: 'ON', value: 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
hints: {
|
hints: {
|
||||||
range: 1
|
range: 1
|
||||||
}
|
}
|
||||||
|
@ -34,14 +34,16 @@ StateGeneratorProvider.prototype.supportsSubscribe = function (domainObject) {
|
|||||||
return domainObject.type === 'example.state-generator';
|
return domainObject.type === 'example.state-generator';
|
||||||
};
|
};
|
||||||
|
|
||||||
StateGeneratorProvider.prototype.subscribe = function (domainObject, callback) {
|
StateGeneratorProvider.prototype.subscribe = function (domainObject, callback, options) {
|
||||||
var duration = domainObject.telemetry.duration * 1000;
|
var duration = domainObject.telemetry.duration * 1000;
|
||||||
|
|
||||||
var interval = setInterval(function () {
|
var interval = setInterval(() => {
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
var datum = pointForTimestamp(now, duration, domainObject.name);
|
var datum = pointForTimestamp(now, duration, domainObject.name);
|
||||||
datum.value = String(datum.value);
|
if (!this.shouldBeFiltered(datum, options)) {
|
||||||
callback(datum);
|
datum.value = String(datum.value);
|
||||||
|
callback(datum);
|
||||||
|
}
|
||||||
}, duration);
|
}, duration);
|
||||||
|
|
||||||
return function () {
|
return function () {
|
||||||
@ -63,9 +65,25 @@ StateGeneratorProvider.prototype.request = function (domainObject, options) {
|
|||||||
|
|
||||||
var data = [];
|
var data = [];
|
||||||
while (start <= end && data.length < 5000) {
|
while (start <= end && data.length < 5000) {
|
||||||
data.push(pointForTimestamp(start, duration, domainObject.name));
|
const point = pointForTimestamp(start, duration, domainObject.name);
|
||||||
|
|
||||||
|
if (!this.shouldBeFiltered(point, options)) {
|
||||||
|
data.push(point);
|
||||||
|
}
|
||||||
start += duration;
|
start += duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve(data);
|
return Promise.resolve(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StateGeneratorProvider.prototype.shouldBeFiltered = function (point, options) {
|
||||||
|
const valueToFilter = options?.filters?.state?.equals?.[0];
|
||||||
|
|
||||||
|
if (!valueToFilter) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { value } = point;
|
||||||
|
|
||||||
|
return value !== Number(valueToFilter);
|
||||||
|
};
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
import { seededRandom } from 'utils/random.js';
|
||||||
|
|
||||||
const DEFAULT_IMAGE_SAMPLES = [
|
const DEFAULT_IMAGE_SAMPLES = [
|
||||||
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18731.jpg',
|
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18731.jpg',
|
||||||
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18732.jpg',
|
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18732.jpg',
|
||||||
@ -162,8 +164,8 @@ export default function () {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCompassValues(min, max) {
|
function getCompassValues(min, max, timestamp) {
|
||||||
return min + Math.random() * (max - min);
|
return min + seededRandom(timestamp) * (max - min);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImageSamples(configuration) {
|
function getImageSamples(configuration) {
|
||||||
@ -283,9 +285,9 @@ function pointForTimestamp(timestamp, name, imageSamples, delay) {
|
|||||||
utc: Math.floor(timestamp / delay) * delay,
|
utc: Math.floor(timestamp / delay) * delay,
|
||||||
local: Math.floor(timestamp / delay) * delay,
|
local: Math.floor(timestamp / delay) * delay,
|
||||||
url,
|
url,
|
||||||
sunOrientation: getCompassValues(0, 360),
|
sunOrientation: getCompassValues(0, 360, timestamp),
|
||||||
cameraAzimuth: getCompassValues(0, 360),
|
cameraAzimuth: getCompassValues(0, 360, timestamp),
|
||||||
heading: getCompassValues(0, 360),
|
heading: getCompassValues(0, 360, timestamp),
|
||||||
transformations: navCamTransformations,
|
transformations: navCamTransformations,
|
||||||
imageDownloadName
|
imageDownloadName
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Open MCT, Copyright (c) 2014-2023, United States Government
|
* Open MCT, Copyright (c) 2014-2024, United States Government
|
||||||
* as represented by the Administrator of the National Aeronautics and Space
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
* Administration. All rights reserved.
|
* Administration. All rights reserved.
|
||||||
*
|
*
|
||||||
|
1509
package-lock.json
generated
1509
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
43
package.json
43
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "openmct",
|
"name": "openmct",
|
||||||
"version": "4.0.0",
|
"version": "4.1.0-next",
|
||||||
"description": "The Open MCT core platform",
|
"description": "The Open MCT core platform",
|
||||||
"module": "dist/openmct.js",
|
"module": "dist/openmct.js",
|
||||||
"main": "dist/openmct.js",
|
"main": "dist/openmct.js",
|
||||||
@ -16,26 +16,25 @@
|
|||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/eslint-parser": "7.23.3",
|
"@babel/eslint-parser": "7.23.3",
|
||||||
"@braintree/sanitize-url": "6.0.4",
|
"@braintree/sanitize-url": "7.1.1",
|
||||||
"@types/d3-axis": "3.0.6",
|
"@types/d3-axis": "3.0.6",
|
||||||
"@types/d3-scale": "4.0.8",
|
"@types/d3-scale": "4.0.8",
|
||||||
"@types/d3-selection": "3.0.10",
|
"@types/d3-selection": "3.0.10",
|
||||||
"@types/d3-shape": "3.0.0",
|
"@types/d3-shape": "3.1.7",
|
||||||
"@types/eventemitter3": "1.2.0",
|
"@types/eventemitter3": "1.2.0",
|
||||||
"@types/jasmine": "5.1.2",
|
"@types/jasmine": "5.1.2",
|
||||||
"@types/lodash": "4.17.0",
|
"@types/lodash": "4.17.0",
|
||||||
"@vue/compiler-sfc": "3.4.3",
|
"@vue/compiler-sfc": "3.4.3",
|
||||||
"babel-loader": "9.1.0",
|
"babel-loader": "9.1.0",
|
||||||
"babel-plugin-istanbul": "6.1.1",
|
"babel-plugin-istanbul": "7.0.0",
|
||||||
"codecov": "3.8.3",
|
|
||||||
"comma-separated-values": "3.6.4",
|
"comma-separated-values": "3.6.4",
|
||||||
"copy-webpack-plugin": "12.0.2",
|
"copy-webpack-plugin": "13.0.0",
|
||||||
"cspell": "7.3.8",
|
"cspell": "7.3.8",
|
||||||
"css-loader": "6.10.0",
|
"css-loader": "6.10.0",
|
||||||
"d3-axis": "3.0.0",
|
"d3-axis": "3.0.0",
|
||||||
"d3-scale": "4.0.2",
|
"d3-scale": "4.0.2",
|
||||||
"d3-selection": "3.0.0",
|
"d3-selection": "3.0.0",
|
||||||
"d3-shape": "3.0.0",
|
"d3-shape": "3.2.0",
|
||||||
"eslint": "8.56.0",
|
"eslint": "8.56.0",
|
||||||
"eslint-config-prettier": "9.1.0",
|
"eslint-config-prettier": "9.1.0",
|
||||||
"eslint-plugin-compat": "4.2.0",
|
"eslint-plugin-compat": "4.2.0",
|
||||||
@ -52,7 +51,7 @@
|
|||||||
"git-rev-sync": "3.0.2",
|
"git-rev-sync": "3.0.2",
|
||||||
"html2canvas": "1.4.1",
|
"html2canvas": "1.4.1",
|
||||||
"imports-loader": "5.0.0",
|
"imports-loader": "5.0.0",
|
||||||
"jasmine-core": "5.1.1",
|
"jasmine-core": "5.6.0",
|
||||||
"karma": "6.4.2",
|
"karma": "6.4.2",
|
||||||
"karma-chrome-launcher": "3.2.0",
|
"karma-chrome-launcher": "3.2.0",
|
||||||
"karma-cli": "2.0.0",
|
"karma-cli": "2.0.0",
|
||||||
@ -65,13 +64,14 @@
|
|||||||
"karma-webpack": "5.0.1",
|
"karma-webpack": "5.0.1",
|
||||||
"location-bar": "3.0.1",
|
"location-bar": "3.0.1",
|
||||||
"lodash": "4.17.21",
|
"lodash": "4.17.21",
|
||||||
"marked": "12.0.0",
|
"marked": "15.0.7",
|
||||||
"mini-css-extract-plugin": "2.7.6",
|
"mini-css-extract-plugin": "2.9.2",
|
||||||
"moment": "2.30.1",
|
"moment": "2.30.1",
|
||||||
"moment-duration-format": "2.3.2",
|
"moment-duration-format": "2.3.2",
|
||||||
"moment-timezone": "0.5.41",
|
"moment-timezone": "0.5.41",
|
||||||
"npm-run-all2": "6.1.2",
|
"nano": "10.1.4",
|
||||||
"nyc": "15.1.0",
|
"npm-run-all2": "7.0.2",
|
||||||
|
"nyc": "17.1.0",
|
||||||
"painterro": "1.2.87",
|
"painterro": "1.2.87",
|
||||||
"plotly.js-basic-dist-min": "2.29.1",
|
"plotly.js-basic-dist-min": "2.29.1",
|
||||||
"plotly.js-gl2d-dist-min": "2.20.0",
|
"plotly.js-gl2d-dist-min": "2.20.0",
|
||||||
@ -79,21 +79,21 @@
|
|||||||
"prettier-eslint": "16.3.0",
|
"prettier-eslint": "16.3.0",
|
||||||
"printj": "1.3.1",
|
"printj": "1.3.1",
|
||||||
"resolve-url-loader": "5.0.0",
|
"resolve-url-loader": "5.0.0",
|
||||||
"sanitize-html": "2.12.1",
|
"sanitize-html": "2.15.0",
|
||||||
"sass": "1.71.1",
|
"sass": "1.71.1",
|
||||||
"sass-loader": "14.1.1",
|
"sass-loader": "14.1.1",
|
||||||
"style-loader": "3.3.3",
|
"style-loader": "4.0.0",
|
||||||
"terser-webpack-plugin": "5.3.9",
|
"terser-webpack-plugin": "5.3.9",
|
||||||
"tiny-emitter": "2.1.0",
|
"tiny-emitter": "2.1.0",
|
||||||
"typescript": "5.3.3",
|
"typescript": "5.3.3",
|
||||||
"uuid": "9.0.1",
|
"uuid": "11.1.0",
|
||||||
"vue": "3.4.24",
|
"vue": "3.4.24",
|
||||||
"vue-eslint-parser": "9.4.2",
|
"vue-eslint-parser": "9.4.2",
|
||||||
"vue-loader": "16.8.3",
|
"vue-loader": "16.8.3",
|
||||||
"webpack": "5.90.3",
|
"webpack": "5.98.0",
|
||||||
"webpack-cli": "5.1.1",
|
"webpack-cli": "5.1.1",
|
||||||
"webpack-dev-server": "5.0.2",
|
"webpack-dev-server": "5.0.2",
|
||||||
"webpack-merge": "5.10.0"
|
"webpack-merge": "6.0.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rm -rf ./dist ./node_modules ./coverage ./html-test-results ./e2e/test-results ./.nyc_output ./e2e/.nyc_output",
|
"clean": "rm -rf ./dist ./node_modules ./coverage ./html-test-results ./e2e/test-results ./.nyc_output ./e2e/.nyc_output",
|
||||||
@ -128,12 +128,9 @@
|
|||||||
"test:perf:contract": "npm test --workspace e2e -- --config=playwright-performance-dev.config.js",
|
"test:perf:contract": "npm test --workspace e2e -- --config=playwright-performance-dev.config.js",
|
||||||
"test:perf:localhost": "npm test --workspace e2e -- --config=playwright-performance-prod.config.js --project=chrome",
|
"test:perf:localhost": "npm test --workspace e2e -- --config=playwright-performance-prod.config.js --project=chrome",
|
||||||
"test:perf:memory": "npm test --workspace e2e -- --config=playwright-performance-prod.config.js --project=chrome-memory",
|
"test:perf:memory": "npm test --workspace e2e -- --config=playwright-performance-prod.config.js --project=chrome-memory",
|
||||||
"update-about-dialog-copyright": "perl -pi -e 's/20\\d\\d\\-202\\d/2014\\-2023/gm' ./src/ui/layout/AboutDialog.vue",
|
"update-about-dialog-copyright": "perl -pi -e 's/20\\d\\d\\-202\\d/2014\\-2024/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\\-2024/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\\-2024/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:ci:publish": "codecov --disable=gcov -f ./coverage/e2e/lcov.info -F e2e-ci",
|
|
||||||
"cov:unit:publish": "codecov --disable=gcov -f ./coverage/unit/lcov.info -F unit",
|
|
||||||
"prepare": "npm run build:prod && npx tsc"
|
"prepare": "npm run build:prod && npx tsc"
|
||||||
},
|
},
|
||||||
"homepage": "https://nasa.github.io/openmct",
|
"homepage": "https://nasa.github.io/openmct",
|
||||||
@ -142,7 +139,7 @@
|
|||||||
"url": "git+https://github.com/nasa/openmct.git"
|
"url": "git+https://github.com/nasa/openmct.git"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.14.2 <22"
|
"node": ">=18.14.2 <23"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"Firefox ESR",
|
"Firefox ESR",
|
||||||
@ -160,4 +157,4 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"nasa"
|
"nasa"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
import { isIdentifier } from '../objects/object-utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import('openmct').DomainObject} DomainObject
|
* @typedef {import('openmct').DomainObject} DomainObject
|
||||||
*/
|
*/
|
||||||
@ -209,9 +211,15 @@ export default class CompositionCollection {
|
|||||||
this.#cleanUpMutables();
|
this.#cleanUpMutables();
|
||||||
const children = await this.#provider.load(this.domainObject);
|
const children = await this.#provider.load(this.domainObject);
|
||||||
const childObjects = await Promise.all(
|
const childObjects = await Promise.all(
|
||||||
children.map((c) => this.#publicAPI.objects.get(c, abortSignal))
|
children.map((child) => {
|
||||||
|
if (isIdentifier(child)) {
|
||||||
|
return this.#publicAPI.objects.get(child, abortSignal);
|
||||||
|
} else {
|
||||||
|
return Promise.resolve(child);
|
||||||
|
}
|
||||||
|
})
|
||||||
);
|
);
|
||||||
childObjects.forEach((c) => this.add(c, true));
|
childObjects.forEach((child) => this.add(child, true));
|
||||||
this.#emit('load');
|
this.#emit('load');
|
||||||
|
|
||||||
return childObjects;
|
return childObjects;
|
||||||
|
@ -96,8 +96,9 @@ export default class CompositionProvider {
|
|||||||
* object.
|
* object.
|
||||||
* @param {DomainObject} domainObject the domain object
|
* @param {DomainObject} domainObject the domain object
|
||||||
* for which to load composition
|
* for which to load composition
|
||||||
* @returns {Promise<Identifier[]>} a promise for
|
* @returns {Promise<Identifier[] | DomainObject[]>} a promise for
|
||||||
* the Identifiers in this composition
|
* the Identifiers or Domain Objects in this composition. If Identifiers are returned,
|
||||||
|
* they will be automatically resolved to domain objects by the API.
|
||||||
*/
|
*/
|
||||||
load(domainObject) {
|
load(domainObject) {
|
||||||
throw new Error('This method must be implemented by a subclass.');
|
throw new Error('This method must be implemented by a subclass.');
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
import { toRaw } from 'vue';
|
import { toRaw } from 'vue';
|
||||||
|
|
||||||
import { makeKeyString } from '../objects/object-utils.js';
|
import { makeKeyString, parseKeyString } from '../objects/object-utils.js';
|
||||||
import CompositionProvider from './CompositionProvider.js';
|
import CompositionProvider from './CompositionProvider.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +75,11 @@ export default class DefaultCompositionProvider extends CompositionProvider {
|
|||||||
* the Identifiers in this composition
|
* the Identifiers in this composition
|
||||||
*/
|
*/
|
||||||
load(domainObject) {
|
load(domainObject) {
|
||||||
return Promise.all(domainObject.composition);
|
const identifiers = domainObject.composition
|
||||||
|
.filter((idOrKeystring) => idOrKeystring !== null && idOrKeystring !== undefined)
|
||||||
|
.map((idOrKeystring) => parseKeyString(idOrKeystring));
|
||||||
|
|
||||||
|
return Promise.all(identifiers);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Attach listeners for changes to the composition of a given domain object.
|
* Attach listeners for changes to the composition of a given domain object.
|
||||||
|
@ -20,6 +20,32 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/** @type {ShelveDuration[]} */
|
||||||
|
export const DEFAULT_SHELVE_DURATIONS = [
|
||||||
|
{
|
||||||
|
name: '5 Minutes',
|
||||||
|
value: 300000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '10 Minutes',
|
||||||
|
value: 600000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '15 Minutes',
|
||||||
|
value: 900000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Unlimited',
|
||||||
|
value: null
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides an API for managing faults within Open MCT.
|
||||||
|
* It allows for the addition of a fault provider, checking for provider support, and
|
||||||
|
* performing various operations such as requesting, subscribing to, acknowledging,
|
||||||
|
* and shelving faults.
|
||||||
|
*/
|
||||||
export default class FaultManagementAPI {
|
export default class FaultManagementAPI {
|
||||||
/**
|
/**
|
||||||
* @param {import("openmct").OpenMCT} openmct
|
* @param {import("openmct").OpenMCT} openmct
|
||||||
@ -29,14 +55,20 @@ export default class FaultManagementAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {*} provider
|
* Sets the provider for the Fault Management API.
|
||||||
|
* The provider should implement methods for acknowledging and shelving faults.
|
||||||
|
*
|
||||||
|
* @param {*} provider - The provider to be set.
|
||||||
*/
|
*/
|
||||||
addProvider(provider) {
|
addProvider(provider) {
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {boolean}
|
* Checks if the current provider supports fault management actions.
|
||||||
|
* Specifically, it checks if the provider has methods for acknowledging and shelving faults.
|
||||||
|
*
|
||||||
|
* @returns {boolean} - Returns true if the provider supports fault management actions, otherwise false.
|
||||||
*/
|
*/
|
||||||
supportsActions() {
|
supportsActions() {
|
||||||
return (
|
return (
|
||||||
@ -45,48 +77,82 @@ export default class FaultManagementAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('openmct').DomainObject} domainObject
|
* Requests fault data for a given domain object.
|
||||||
* @returns {Promise.<FaultAPIResponse[]>}
|
* This method checks if the current provider supports the request operation for the given domain object.
|
||||||
|
* If supported, it delegates the request to the provider's request method.
|
||||||
|
* If not supported, it returns a rejected promise.
|
||||||
|
*
|
||||||
|
* @param {import('openmct').DomainObject} domainObject - The domain object for which fault data is requested.
|
||||||
|
* @returns {Promise.<FaultAPIResponse[]>} - A promise that resolves to an array of fault API responses.
|
||||||
*/
|
*/
|
||||||
request(domainObject) {
|
request(domainObject) {
|
||||||
if (!this.provider?.supportsRequest(domainObject)) {
|
if (!this.provider?.supportsRequest(domainObject)) {
|
||||||
return Promise.reject();
|
return Promise.reject('Provider does not support request operation');
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.provider.request(domainObject);
|
return this.provider.request(domainObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('openmct').DomainObject} domainObject
|
* Subscribes to fault data updates for a given domain object.
|
||||||
* @param {Function} callback
|
* This method checks if the current provider supports the subscribe operation for the given domain object.
|
||||||
* @returns {Function} unsubscribe
|
* If supported, it delegates the subscription to the provider's subscribe method.
|
||||||
|
* If not supported, it returns a rejected promise.
|
||||||
|
*
|
||||||
|
* @param {import('openmct').DomainObject} domainObject - The domain object for which to subscribe to fault data updates.
|
||||||
|
* @param {Function} callback - The callback function to be called with fault data updates.
|
||||||
|
* @returns {Function} unsubscribe - A function to unsubscribe from the fault data updates.
|
||||||
*/
|
*/
|
||||||
subscribe(domainObject, callback) {
|
subscribe(domainObject, callback) {
|
||||||
if (!this.provider?.supportsSubscribe(domainObject)) {
|
if (!this.provider?.supportsSubscribe(domainObject)) {
|
||||||
return Promise.reject();
|
return Promise.reject('Provider does not support subscribe operation');
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.provider.subscribe(domainObject, callback);
|
return this.provider.subscribe(domainObject, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Fault} fault
|
* Acknowledges a fault using the provider's acknowledgeFault method.
|
||||||
* @param {*} ackData
|
*
|
||||||
|
* @param {Fault} fault - The fault object to be acknowledged.
|
||||||
|
* @param {*} ackData - Additional data required for acknowledging the fault.
|
||||||
|
* @returns {Promise.<T>} - A promise that resolves when the fault is acknowledged.
|
||||||
*/
|
*/
|
||||||
acknowledgeFault(fault, ackData) {
|
acknowledgeFault(fault, ackData) {
|
||||||
return this.provider.acknowledgeFault(fault, ackData);
|
return this.provider.acknowledgeFault(fault, ackData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Fault} fault
|
* Shelves a fault using the provider's shelveFault method.
|
||||||
* @param {*} shelveData
|
*
|
||||||
* @returns {Promise.<T>}
|
* @param {Fault} fault - The fault object to be shelved.
|
||||||
|
* @param {*} shelveData - Additional data required for shelving the fault.
|
||||||
|
* @returns {Promise.<T>} - A promise that resolves when the fault is shelved.
|
||||||
*/
|
*/
|
||||||
shelveFault(fault, shelveData) {
|
shelveFault(fault, shelveData) {
|
||||||
return this.provider.shelveFault(fault, shelveData);
|
return this.provider.shelveFault(fault, shelveData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the available shelve durations from the provider, or the default durations if the
|
||||||
|
* provider does not provide any.
|
||||||
|
* @returns {ShelveDuration[] | undefined}
|
||||||
|
*/
|
||||||
|
getShelveDurations() {
|
||||||
|
if (!this.provider) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.provider.getShelveDurations?.() ?? DEFAULT_SHELVE_DURATIONS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} ShelveDuration
|
||||||
|
* @property {string} name - The name of the shelve duration
|
||||||
|
* @property {number|null} value - The value of the shelve duration in milliseconds, or null for unlimited
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} TriggerValueInfo
|
* @typedef {Object} TriggerValueInfo
|
||||||
* @property {number} value
|
* @property {number} value
|
||||||
|
@ -27,6 +27,7 @@ import ConflictError from './ConflictError.js';
|
|||||||
import InMemorySearchProvider from './InMemorySearchProvider.js';
|
import InMemorySearchProvider from './InMemorySearchProvider.js';
|
||||||
import InterceptorRegistry from './InterceptorRegistry.js';
|
import InterceptorRegistry from './InterceptorRegistry.js';
|
||||||
import MutableDomainObject from './MutableDomainObject.js';
|
import MutableDomainObject from './MutableDomainObject.js';
|
||||||
|
import { isIdentifier, isKeyString } from './object-utils.js';
|
||||||
import RootObjectProvider from './RootObjectProvider.js';
|
import RootObjectProvider from './RootObjectProvider.js';
|
||||||
import RootRegistry from './RootRegistry.js';
|
import RootRegistry from './RootRegistry.js';
|
||||||
import Transaction from './Transaction.js';
|
import Transaction from './Transaction.js';
|
||||||
@ -742,11 +743,19 @@ export default class ObjectAPI {
|
|||||||
* @param {AbortSignal} abortSignal (optional) signal to abort fetch requests
|
* @param {AbortSignal} abortSignal (optional) signal to abort fetch requests
|
||||||
* @returns {Promise<Array<DomainObject>>} a promise containing an array of domain objects
|
* @returns {Promise<Array<DomainObject>>} a promise containing an array of domain objects
|
||||||
*/
|
*/
|
||||||
async getOriginalPath(identifier, path = [], abortSignal = null) {
|
async getOriginalPath(identifierOrObject, path = [], abortSignal = null) {
|
||||||
const domainObject = await this.get(identifier, abortSignal);
|
let domainObject;
|
||||||
|
|
||||||
|
if (isKeyString(identifierOrObject) || isIdentifier(identifierOrObject)) {
|
||||||
|
domainObject = await this.get(identifierOrObject, abortSignal);
|
||||||
|
} else {
|
||||||
|
domainObject = identifierOrObject;
|
||||||
|
}
|
||||||
|
|
||||||
if (!domainObject) {
|
if (!domainObject) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
path.push(domainObject);
|
path.push(domainObject);
|
||||||
const { location } = domainObject;
|
const { location } = domainObject;
|
||||||
if (location && !this.#pathContainsDomainObject(location, path)) {
|
if (location && !this.#pathContainsDomainObject(location, path)) {
|
||||||
|
@ -20,25 +20,46 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
import installWorker from './WebSocketWorker.js';
|
import installWorker from './WebSocketWorker.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes the strategy to be used when batching WebSocket messages
|
* @typedef RequestIdleCallbackOptions
|
||||||
*
|
* @prop {Number} timeout If the number of milliseconds represented by this
|
||||||
* @typedef BatchingStrategy
|
* parameter has elapsed and the callback has not already been called, invoke
|
||||||
* @property {Function} shouldBatchMessage a function that accepts a single
|
* the callback.
|
||||||
* argument - the raw message received from the websocket. Every message
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback
|
||||||
* received will be evaluated against this function so it should be performant.
|
|
||||||
* Note also that this function is executed in a worker, so it must be
|
|
||||||
* completely self-contained with no external dependencies. The function
|
|
||||||
* should return `true` if the message should be batched, and `false` if not.
|
|
||||||
* @property {Function} getBatchIdFromMessage a function that accepts a
|
|
||||||
* single argument - the raw message received from the websocket. Only messages
|
|
||||||
* where `shouldBatchMessage` has evaluated to true will be passed into this
|
|
||||||
* function. The function should return a unique value on which to batch the
|
|
||||||
* messages. For example a telemetry, channel, or parameter identifier.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a reliable and convenient WebSocket abstraction layer that handles
|
* Mocks requestIdleCallback for Safari using setTimeout. Functionality will be
|
||||||
* a lot of boilerplate common to managing WebSocket connections such as:
|
* identical to setTimeout in Safari, which is to fire the callback function
|
||||||
|
* after the provided timeout period.
|
||||||
|
*
|
||||||
|
* In browsers that support requestIdleCallback, this const is just a
|
||||||
|
* pointer to the native function.
|
||||||
|
*
|
||||||
|
* @param {Function} callback a callback to be invoked during the next idle period, or
|
||||||
|
* after the specified timeout
|
||||||
|
* @param {RequestIdleCallbackOptions} options
|
||||||
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function requestIdleCallbackPolyfill(callback, options) {
|
||||||
|
return (
|
||||||
|
// eslint-disable-next-line compat/compat
|
||||||
|
window.requestIdleCallback ??
|
||||||
|
((fn, { timeout }) =>
|
||||||
|
setTimeout(() => {
|
||||||
|
fn({ didTimeout: false });
|
||||||
|
}, timeout))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const requestIdleCallback = requestIdleCallbackPolyfill();
|
||||||
|
|
||||||
|
const ONE_SECOND = 1000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a WebSocket abstraction layer that handles a lot of boilerplate common
|
||||||
|
* to managing WebSocket connections such as:
|
||||||
* - Establishing a WebSocket connection to a server
|
* - Establishing a WebSocket connection to a server
|
||||||
* - Reconnecting on error, with a fallback strategy
|
* - Reconnecting on error, with a fallback strategy
|
||||||
* - Queuing messages so that clients can send messages without concern for the current
|
* - Queuing messages so that clients can send messages without concern for the current
|
||||||
@ -49,22 +70,19 @@ import installWorker from './WebSocketWorker.js';
|
|||||||
* and batching of messages without blocking either the UI or server.
|
* and batching of messages without blocking either the UI or server.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
// Shim for Internet Explorer, I mean Safari. It doesn't support requestIdleCallback, but it's in a tech preview, so it will be dropping soon.
|
|
||||||
const requestIdleCallback =
|
|
||||||
// eslint-disable-next-line compat/compat
|
|
||||||
window.requestIdleCallback ?? ((fn, { timeout }) => setTimeout(fn, timeout));
|
|
||||||
const ONE_SECOND = 1000;
|
|
||||||
const FIVE_SECONDS = 5 * ONE_SECOND;
|
|
||||||
|
|
||||||
class BatchingWebSocket extends EventTarget {
|
class BatchingWebSocket extends EventTarget {
|
||||||
#worker;
|
#worker;
|
||||||
#openmct;
|
#openmct;
|
||||||
#showingRateLimitNotification;
|
#showingRateLimitNotification;
|
||||||
#maxBatchSize;
|
#maxBufferSize;
|
||||||
#applicationIsInitializing;
|
#throttleRate;
|
||||||
#maxBatchWait;
|
|
||||||
#firstBatchReceived;
|
#firstBatchReceived;
|
||||||
|
#lastBatchReceived;
|
||||||
|
#peakBufferSize = Number.NEGATIVE_INFINITY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('openmct.js').OpenMCT} openmct
|
||||||
|
*/
|
||||||
constructor(openmct) {
|
constructor(openmct) {
|
||||||
super();
|
super();
|
||||||
// Install worker, register listeners etc.
|
// Install worker, register listeners etc.
|
||||||
@ -74,9 +92,8 @@ class BatchingWebSocket extends EventTarget {
|
|||||||
this.#worker = new Worker(workerUrl);
|
this.#worker = new Worker(workerUrl);
|
||||||
this.#openmct = openmct;
|
this.#openmct = openmct;
|
||||||
this.#showingRateLimitNotification = false;
|
this.#showingRateLimitNotification = false;
|
||||||
this.#maxBatchSize = Number.POSITIVE_INFINITY;
|
this.#maxBufferSize = Number.POSITIVE_INFINITY;
|
||||||
this.#maxBatchWait = ONE_SECOND;
|
this.#throttleRate = ONE_SECOND;
|
||||||
this.#applicationIsInitializing = true;
|
|
||||||
this.#firstBatchReceived = false;
|
this.#firstBatchReceived = false;
|
||||||
|
|
||||||
const routeMessageToHandler = this.#routeMessageToHandler.bind(this);
|
const routeMessageToHandler = this.#routeMessageToHandler.bind(this);
|
||||||
@ -89,20 +106,6 @@ class BatchingWebSocket extends EventTarget {
|
|||||||
},
|
},
|
||||||
{ once: true }
|
{ once: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
openmct.once('start', () => {
|
|
||||||
// An idle callback is a pretty good indication that a complex display is done loading. At that point set the batch size more conservatively.
|
|
||||||
// Force it after 5 seconds if it hasn't happened yet.
|
|
||||||
requestIdleCallback(
|
|
||||||
() => {
|
|
||||||
this.#applicationIsInitializing = false;
|
|
||||||
this.setMaxBatchSize(this.#maxBatchSize);
|
|
||||||
},
|
|
||||||
{
|
|
||||||
timeout: FIVE_SECONDS
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,57 +140,48 @@ class BatchingWebSocket extends EventTarget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the strategy used to both decide which raw messages to batch, and how to group
|
* @param {number} maxBufferSize the maximum length of the receive buffer in characters.
|
||||||
* them.
|
|
||||||
* @param {BatchingStrategy} strategy The batching strategy to use when evaluating
|
|
||||||
* raw messages from the WebSocket.
|
|
||||||
*/
|
|
||||||
setBatchingStrategy(strategy) {
|
|
||||||
const serializedStrategy = {
|
|
||||||
shouldBatchMessage: strategy.shouldBatchMessage.toString(),
|
|
||||||
getBatchIdFromMessage: strategy.getBatchIdFromMessage.toString()
|
|
||||||
};
|
|
||||||
|
|
||||||
this.#worker.postMessage({
|
|
||||||
type: 'setBatchingStrategy',
|
|
||||||
serializedStrategy
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} maxBatchSize the maximum length of a batch of messages. For example,
|
|
||||||
* the maximum number of telemetry values to batch before dropping them
|
|
||||||
* Note that this is a fail-safe that is only invoked if performance drops to the
|
* Note that this is a fail-safe that is only invoked if performance drops to the
|
||||||
* point where Open MCT cannot keep up with the amount of telemetry it is receiving.
|
* point where Open MCT cannot keep up with the amount of telemetry it is receiving.
|
||||||
* In this event it will sacrifice the oldest telemetry in the batch in favor of the
|
* In this event it will sacrifice the oldest telemetry in the batch in favor of the
|
||||||
* most recent telemetry. The user will be informed that telemetry has been dropped.
|
* most recent telemetry. The user will be informed that telemetry has been dropped.
|
||||||
*
|
*
|
||||||
* This should be set appropriately for the expected data rate. eg. If telemetry
|
* This should be set appropriately for the expected data rate. eg. If typical usage
|
||||||
* is received at 10Hz for each telemetry point, then a minimal combination of batch
|
* sees 2000 messages arriving at a client per second, with an average message size
|
||||||
* size and rate is 10 and 1000 respectively. Ideally you would add some margin, so
|
* of 500 bytes, then 2000 * 500 = 1000000 characters will be right on the limit.
|
||||||
* 15 would probably be a better batch size.
|
* In this scenario, a buffer size of 1500000 character might be more appropriate
|
||||||
|
* to allow some overhead for bursty telemetry, and temporary UI load during page
|
||||||
|
* load.
|
||||||
|
*
|
||||||
|
* The PerformanceIndicator plugin (openmct.plugins.PerformanceIndicator) gives
|
||||||
|
* statistics on buffer utilization. It can be used to scale the buffer appropriately.
|
||||||
*/
|
*/
|
||||||
setMaxBatchSize(maxBatchSize) {
|
setMaxBufferSize(maxBatchSize) {
|
||||||
this.#maxBatchSize = maxBatchSize;
|
this.#maxBufferSize = maxBatchSize;
|
||||||
if (!this.#applicationIsInitializing) {
|
this.#sendMaxBufferSizeToWorker(this.#maxBufferSize);
|
||||||
this.#sendMaxBatchSizeToWorker(this.#maxBatchSize);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
setMaxBatchWait(wait) {
|
setThrottleRate(throttleRate) {
|
||||||
this.#maxBatchWait = wait;
|
this.#throttleRate = throttleRate;
|
||||||
this.#sendBatchWaitToWorker(this.#maxBatchWait);
|
this.#sendThrottleRateToWorker(this.#throttleRate);
|
||||||
}
|
}
|
||||||
#sendMaxBatchSizeToWorker(maxBatchSize) {
|
setThrottleMessagePattern(throttleMessagePattern) {
|
||||||
this.#worker.postMessage({
|
this.#worker.postMessage({
|
||||||
type: 'setMaxBatchSize',
|
type: 'setThrottleMessagePattern',
|
||||||
maxBatchSize
|
throttleMessagePattern
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#sendBatchWaitToWorker(maxBatchWait) {
|
#sendMaxBufferSizeToWorker(maxBufferSize) {
|
||||||
this.#worker.postMessage({
|
this.#worker.postMessage({
|
||||||
type: 'setMaxBatchWait',
|
type: 'setMaxBufferSize',
|
||||||
maxBatchWait
|
maxBufferSize
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#sendThrottleRateToWorker(throttleRate) {
|
||||||
|
this.#worker.postMessage({
|
||||||
|
type: 'setThrottleRate',
|
||||||
|
throttleRate
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,9 +197,38 @@ class BatchingWebSocket extends EventTarget {
|
|||||||
|
|
||||||
#routeMessageToHandler(message) {
|
#routeMessageToHandler(message) {
|
||||||
if (message.data.type === 'batch') {
|
if (message.data.type === 'batch') {
|
||||||
this.start = Date.now();
|
|
||||||
const batch = message.data.batch;
|
const batch = message.data.batch;
|
||||||
if (batch.dropped === true && !this.#showingRateLimitNotification) {
|
const now = performance.now();
|
||||||
|
|
||||||
|
let currentBufferLength = message.data.currentBufferLength;
|
||||||
|
let maxBufferSize = message.data.maxBufferSize;
|
||||||
|
let parameterCount = batch.length;
|
||||||
|
if (this.#peakBufferSize < currentBufferLength) {
|
||||||
|
this.#peakBufferSize = currentBufferLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.#openmct.performance !== undefined) {
|
||||||
|
if (!isNaN(this.#lastBatchReceived)) {
|
||||||
|
const elapsed = (now - this.#lastBatchReceived) / 1000;
|
||||||
|
this.#lastBatchReceived = now;
|
||||||
|
this.#openmct.performance.measurements.set(
|
||||||
|
'Parameters/s',
|
||||||
|
Math.floor(parameterCount / elapsed)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
this.#openmct.performance.measurements.set(
|
||||||
|
'Buff. Util. (bytes)',
|
||||||
|
`${currentBufferLength} / ${maxBufferSize}`
|
||||||
|
);
|
||||||
|
this.#openmct.performance.measurements.set(
|
||||||
|
'Peak Buff. Util. (bytes)',
|
||||||
|
`${this.#peakBufferSize} / ${maxBufferSize}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.start = Date.now();
|
||||||
|
const dropped = message.data.dropped;
|
||||||
|
if (dropped === true && !this.#showingRateLimitNotification) {
|
||||||
const notification = this.#openmct.notifications.alert(
|
const notification = this.#openmct.notifications.alert(
|
||||||
'Telemetry dropped due to client rate limiting.',
|
'Telemetry dropped due to client rate limiting.',
|
||||||
{ hint: 'Refresh individual telemetry views to retrieve dropped telemetry if needed.' }
|
{ hint: 'Refresh individual telemetry views to retrieve dropped telemetry if needed.' }
|
||||||
@ -240,18 +263,16 @@ class BatchingWebSocket extends EventTarget {
|
|||||||
console.warn(`Event loop is too busy to process batch.`);
|
console.warn(`Event loop is too busy to process batch.`);
|
||||||
this.#waitUntilIdleAndRequestNextBatch(batch);
|
this.#waitUntilIdleAndRequestNextBatch(batch);
|
||||||
} else {
|
} else {
|
||||||
// After ingesting a telemetry batch, wait until the event loop is idle again before
|
|
||||||
// informing the worker we are ready for another batch.
|
|
||||||
this.#readyForNextBatch();
|
this.#readyForNextBatch();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (waitedFor > ONE_SECOND) {
|
if (waitedFor > this.#throttleRate) {
|
||||||
console.warn(`Warning, batch processing took ${waitedFor}ms`);
|
console.warn(`Warning, batch processing took ${waitedFor}ms`);
|
||||||
}
|
}
|
||||||
this.#readyForNextBatch();
|
this.#readyForNextBatch();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ timeout: ONE_SECOND }
|
{ timeout: this.#throttleRate }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,6 +250,90 @@ export default class TelemetryAPI {
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanitizes objects for consistent serialization by:
|
||||||
|
* 1. Removing non-plain objects (class instances) and functions
|
||||||
|
* 2. Sorting object keys alphabetically to ensure consistent ordering
|
||||||
|
*/
|
||||||
|
sanitizeForSerialization(key, value) {
|
||||||
|
// Handle null and primitives directly
|
||||||
|
if (value === null || typeof value !== 'object') {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove functions and non-plain objects (except arrays)
|
||||||
|
if (
|
||||||
|
typeof value === 'function' ||
|
||||||
|
(Object.getPrototypeOf(value) !== Object.prototype && !Array.isArray(value))
|
||||||
|
) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
// For plain objects, just sort the keys
|
||||||
|
if (!Array.isArray(value)) {
|
||||||
|
const sortedObject = {};
|
||||||
|
const sortedKeys = Object.keys(value).sort();
|
||||||
|
|
||||||
|
sortedKeys.forEach((objectKey) => {
|
||||||
|
sortedObject[objectKey] = value[objectKey];
|
||||||
|
});
|
||||||
|
|
||||||
|
return sortedObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a numeric hash value for an options object. The hash is consistent
|
||||||
|
* for equivalent option objects regardless of property order.
|
||||||
|
*
|
||||||
|
* This is used to create compact, unique cache keys for telemetry subscriptions with
|
||||||
|
* different options configurations. The hash function ensures that identical options
|
||||||
|
* objects will always generate the same hash value, while different options objects
|
||||||
|
* (even with small differences) will generate different hash values.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Object} options The options object to hash
|
||||||
|
* @returns {number} A positive integer hash of the options object
|
||||||
|
*/
|
||||||
|
#hashOptions(options) {
|
||||||
|
const sanitizedOptionsString = JSON.stringify(
|
||||||
|
options,
|
||||||
|
this.sanitizeForSerialization.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
let hash = 0;
|
||||||
|
const prime = 31;
|
||||||
|
const modulus = 1e9 + 9; // Large prime number
|
||||||
|
|
||||||
|
for (let i = 0; i < sanitizedOptionsString.length; i++) {
|
||||||
|
const char = sanitizedOptionsString.charCodeAt(i);
|
||||||
|
// Calculate new hash value while keeping numbers manageable
|
||||||
|
hash = Math.floor((hash * prime + char) % modulus);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.abs(hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a unique cache key for a telemetry subscription based on the
|
||||||
|
* domain object identifier and options (which includes strategy).
|
||||||
|
*
|
||||||
|
* Uses a hash of the options object to create compact cache keys while still
|
||||||
|
* ensuring unique keys for different subscription configurations.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {import('openmct').DomainObject} domainObject The domain object being subscribed to
|
||||||
|
* @param {Object} options The subscription options object (including strategy)
|
||||||
|
* @returns {string} A unique key string for caching the subscription
|
||||||
|
*/
|
||||||
|
#getSubscriptionCacheKey(domainObject, options) {
|
||||||
|
const keyString = makeKeyString(domainObject.identifier);
|
||||||
|
|
||||||
|
return `${keyString}:${this.#hashOptions(options)}`;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a request interceptor that transforms a request via module:openmct.TelemetryAPI.request
|
* Register a request interceptor that transforms a request via module:openmct.TelemetryAPI.request
|
||||||
* The request will be modified when it is received and will be returned in it's modified state
|
* The request will be modified when it is received and will be returned in it's modified state
|
||||||
@ -418,16 +502,14 @@ export default class TelemetryAPI {
|
|||||||
this.#subscribeCache = {};
|
this.#subscribeCache = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const keyString = makeKeyString(domainObject.identifier);
|
|
||||||
const supportedStrategy = supportsBatching ? requestedStrategy : SUBSCRIBE_STRATEGY.LATEST;
|
const supportedStrategy = supportsBatching ? requestedStrategy : SUBSCRIBE_STRATEGY.LATEST;
|
||||||
// Override the requested strategy with the strategy supported by the provider
|
// Override the requested strategy with the strategy supported by the provider
|
||||||
const optionsWithSupportedStrategy = {
|
const optionsWithSupportedStrategy = {
|
||||||
...options,
|
...options,
|
||||||
strategy: supportedStrategy
|
strategy: supportedStrategy
|
||||||
};
|
};
|
||||||
// If batching is supported, we need to cache a subscription for each strategy -
|
|
||||||
// latest and batched.
|
const cacheKey = this.#getSubscriptionCacheKey(domainObject, optionsWithSupportedStrategy);
|
||||||
const cacheKey = `${keyString}:${supportedStrategy}`;
|
|
||||||
let subscriber = this.#subscribeCache[cacheKey];
|
let subscriber = this.#subscribeCache[cacheKey];
|
||||||
|
|
||||||
if (!subscriber) {
|
if (!subscriber) {
|
||||||
|
@ -116,8 +116,7 @@ export default class TelemetryCollection extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will start the requests for historical and realtime data,
|
* @returns {Array} All bounded telemetry
|
||||||
* as well as setting up initial values and watchers
|
|
||||||
*/
|
*/
|
||||||
getAll() {
|
getAll() {
|
||||||
return this.boundedTelemetry;
|
return this.boundedTelemetry;
|
||||||
|
@ -24,10 +24,6 @@ export default function installWorker() {
|
|||||||
const ONE_SECOND = 1000;
|
const ONE_SECOND = 1000;
|
||||||
const FALLBACK_AND_WAIT_MS = [1000, 5000, 5000, 10000, 10000, 30000];
|
const FALLBACK_AND_WAIT_MS = [1000, 5000, 5000, 10000, 10000, 30000];
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {import('./BatchingWebSocket').BatchingStrategy} BatchingStrategy
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a WebSocket connection that is resilient to errors and dropouts.
|
* Provides a WebSocket connection that is resilient to errors and dropouts.
|
||||||
* On an error or dropout, will automatically reconnect.
|
* On an error or dropout, will automatically reconnect.
|
||||||
@ -215,17 +211,17 @@ export default function installWorker() {
|
|||||||
case 'message':
|
case 'message':
|
||||||
this.#websocket.enqueueMessage(message.data.message);
|
this.#websocket.enqueueMessage(message.data.message);
|
||||||
break;
|
break;
|
||||||
case 'setBatchingStrategy':
|
|
||||||
this.setBatchingStrategy(message);
|
|
||||||
break;
|
|
||||||
case 'readyForNextBatch':
|
case 'readyForNextBatch':
|
||||||
this.#messageBatcher.readyForNextBatch();
|
this.#messageBatcher.readyForNextBatch();
|
||||||
break;
|
break;
|
||||||
case 'setMaxBatchSize':
|
case 'setMaxBufferSize':
|
||||||
this.#messageBatcher.setMaxBatchSize(message.data.maxBatchSize);
|
this.#messageBatcher.setMaxBufferSize(message.data.maxBufferSize);
|
||||||
break;
|
break;
|
||||||
case 'setMaxBatchWait':
|
case 'setThrottleRate':
|
||||||
this.#messageBatcher.setMaxBatchWait(message.data.maxBatchWait);
|
this.#messageBatcher.setThrottleRate(message.data.throttleRate);
|
||||||
|
break;
|
||||||
|
case 'setThrottleMessagePattern':
|
||||||
|
this.#messageBatcher.setThrottleMessagePattern(message.data.throttleMessagePattern);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unknown message type: ${type}`);
|
throw new Error(`Unknown message type: ${type}`);
|
||||||
@ -238,122 +234,69 @@ export default function installWorker() {
|
|||||||
disconnect() {
|
disconnect() {
|
||||||
this.#websocket.disconnect();
|
this.#websocket.disconnect();
|
||||||
}
|
}
|
||||||
setBatchingStrategy(message) {
|
|
||||||
const { serializedStrategy } = message.data;
|
|
||||||
const batchingStrategy = {
|
|
||||||
// eslint-disable-next-line no-new-func
|
|
||||||
shouldBatchMessage: new Function(`return ${serializedStrategy.shouldBatchMessage}`)(),
|
|
||||||
// eslint-disable-next-line no-new-func
|
|
||||||
getBatchIdFromMessage: new Function(`return ${serializedStrategy.getBatchIdFromMessage}`)()
|
|
||||||
// Will also include maximum batch length here
|
|
||||||
};
|
|
||||||
this.#messageBatcher.setBatchingStrategy(batchingStrategy);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Received messages from the WebSocket, and passes them along to the
|
* Responsible for buffering messages
|
||||||
* Worker interface and back to the main thread.
|
|
||||||
*/
|
*/
|
||||||
class WebSocketToWorkerMessageBroker {
|
class MessageBuffer {
|
||||||
#worker;
|
#buffer;
|
||||||
#messageBatcher;
|
#currentBufferLength;
|
||||||
|
#dropped;
|
||||||
constructor(messageBatcher, worker) {
|
#maxBufferSize;
|
||||||
this.#messageBatcher = messageBatcher;
|
|
||||||
this.#worker = worker;
|
|
||||||
}
|
|
||||||
|
|
||||||
routeMessageToHandler(data) {
|
|
||||||
if (this.#messageBatcher.shouldBatchMessage(data)) {
|
|
||||||
this.#messageBatcher.addMessageToBatch(data);
|
|
||||||
} else {
|
|
||||||
this.#worker.postMessage({
|
|
||||||
type: 'message',
|
|
||||||
message: data
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Responsible for batching messages according to the defined batching strategy.
|
|
||||||
*/
|
|
||||||
class MessageBatcher {
|
|
||||||
#batch;
|
|
||||||
#batchingStrategy;
|
|
||||||
#hasBatch = false;
|
|
||||||
#maxBatchSize;
|
|
||||||
#readyForNextBatch;
|
#readyForNextBatch;
|
||||||
#worker;
|
#worker;
|
||||||
#throttledSendNextBatch;
|
#throttledSendNextBatch;
|
||||||
|
#throttleMessagePattern;
|
||||||
|
|
||||||
constructor(worker) {
|
constructor(worker) {
|
||||||
// No dropping telemetry unless we're explicitly told to.
|
// No dropping telemetry unless we're explicitly told to.
|
||||||
this.#maxBatchSize = Number.POSITIVE_INFINITY;
|
this.#maxBufferSize = Number.POSITIVE_INFINITY;
|
||||||
this.#readyForNextBatch = false;
|
this.#readyForNextBatch = false;
|
||||||
this.#worker = worker;
|
this.#worker = worker;
|
||||||
this.#resetBatch();
|
this.#resetBatch();
|
||||||
this.setMaxBatchWait(ONE_SECOND);
|
this.setThrottleRate(ONE_SECOND);
|
||||||
}
|
}
|
||||||
#resetBatch() {
|
#resetBatch() {
|
||||||
this.#batch = {};
|
//this.#batch = {};
|
||||||
this.#hasBatch = false;
|
this.#buffer = [];
|
||||||
|
this.#currentBufferLength = 0;
|
||||||
|
this.#dropped = false;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param {BatchingStrategy} strategy
|
addMessageToBuffer(message) {
|
||||||
*/
|
this.#buffer.push(message);
|
||||||
setBatchingStrategy(strategy) {
|
this.#currentBufferLength += message.length;
|
||||||
this.#batchingStrategy = strategy;
|
|
||||||
}
|
for (
|
||||||
/**
|
let i = 0;
|
||||||
* Applies the `shouldBatchMessage` function from the supplied batching strategy
|
this.#currentBufferLength > this.#maxBufferSize && i < this.#buffer.length;
|
||||||
* to each message to determine if it should be added to a batch. If not batched,
|
i++
|
||||||
* the message is immediately sent over the worker to the main thread.
|
) {
|
||||||
* @param {any} message the message received from the WebSocket. See the WebSocket
|
const messageToConsider = this.#buffer[i];
|
||||||
* documentation for more details -
|
if (this.#shouldThrottle(messageToConsider)) {
|
||||||
* https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data
|
this.#buffer.splice(i, 1);
|
||||||
* @returns
|
this.#currentBufferLength -= messageToConsider.length;
|
||||||
*/
|
this.#dropped = true;
|
||||||
shouldBatchMessage(message) {
|
}
|
||||||
return (
|
|
||||||
this.#batchingStrategy.shouldBatchMessage &&
|
|
||||||
this.#batchingStrategy.shouldBatchMessage(message)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Adds the given message to a batch. The batch group that the message is added
|
|
||||||
* to will be determined by the value returned by `getBatchIdFromMessage`.
|
|
||||||
* @param {any} message the message received from the WebSocket. See the WebSocket
|
|
||||||
* documentation for more details -
|
|
||||||
* https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data
|
|
||||||
*/
|
|
||||||
addMessageToBatch(message) {
|
|
||||||
const batchId = this.#batchingStrategy.getBatchIdFromMessage(message);
|
|
||||||
let batch = this.#batch[batchId];
|
|
||||||
if (batch === undefined) {
|
|
||||||
this.#hasBatch = true;
|
|
||||||
batch = this.#batch[batchId] = [message];
|
|
||||||
} else {
|
|
||||||
batch.push(message);
|
|
||||||
}
|
|
||||||
if (batch.length > this.#maxBatchSize) {
|
|
||||||
console.warn(
|
|
||||||
`Exceeded max batch size of ${this.#maxBatchSize} for ${batchId}. Dropping value.`
|
|
||||||
);
|
|
||||||
batch.shift();
|
|
||||||
this.#batch.dropped = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.#readyForNextBatch) {
|
if (this.#readyForNextBatch) {
|
||||||
this.#throttledSendNextBatch();
|
this.#throttledSendNextBatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setMaxBatchSize(maxBatchSize) {
|
|
||||||
this.#maxBatchSize = maxBatchSize;
|
#shouldThrottle(message) {
|
||||||
|
return (
|
||||||
|
this.#throttleMessagePattern !== undefined && this.#throttleMessagePattern.test(message)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
setMaxBatchWait(maxBatchWait) {
|
|
||||||
this.#throttledSendNextBatch = throttle(this.#sendNextBatch.bind(this), maxBatchWait);
|
setMaxBufferSize(maxBufferSize) {
|
||||||
|
this.#maxBufferSize = maxBufferSize;
|
||||||
|
}
|
||||||
|
setThrottleRate(throttleRate) {
|
||||||
|
this.#throttledSendNextBatch = throttle(this.#sendNextBatch.bind(this), throttleRate);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Indicates that client code is ready to receive the next batch of
|
* Indicates that client code is ready to receive the next batch of
|
||||||
@ -362,21 +305,33 @@ export default function installWorker() {
|
|||||||
* any new data is available.
|
* any new data is available.
|
||||||
*/
|
*/
|
||||||
readyForNextBatch() {
|
readyForNextBatch() {
|
||||||
if (this.#hasBatch) {
|
if (this.#hasData()) {
|
||||||
this.#throttledSendNextBatch();
|
this.#throttledSendNextBatch();
|
||||||
} else {
|
} else {
|
||||||
this.#readyForNextBatch = true;
|
this.#readyForNextBatch = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#sendNextBatch() {
|
#sendNextBatch() {
|
||||||
const batch = this.#batch;
|
const buffer = this.#buffer;
|
||||||
|
const dropped = this.#dropped;
|
||||||
|
const currentBufferLength = this.#currentBufferLength;
|
||||||
|
|
||||||
this.#resetBatch();
|
this.#resetBatch();
|
||||||
this.#worker.postMessage({
|
this.#worker.postMessage({
|
||||||
type: 'batch',
|
type: 'batch',
|
||||||
batch
|
dropped,
|
||||||
|
currentBufferLength: currentBufferLength,
|
||||||
|
maxBufferSize: this.#maxBufferSize,
|
||||||
|
batch: buffer
|
||||||
});
|
});
|
||||||
|
|
||||||
this.#readyForNextBatch = false;
|
this.#readyForNextBatch = false;
|
||||||
this.#hasBatch = false;
|
}
|
||||||
|
#hasData() {
|
||||||
|
return this.#currentBufferLength > 0;
|
||||||
|
}
|
||||||
|
setThrottleMessagePattern(priorityMessagePattern) {
|
||||||
|
this.#throttleMessagePattern = new RegExp(priorityMessagePattern, 'm');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,15 +363,14 @@ export default function installWorker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const websocket = new ResilientWebSocket(self);
|
const websocket = new ResilientWebSocket(self);
|
||||||
const messageBatcher = new MessageBatcher(self);
|
const messageBuffer = new MessageBuffer(self);
|
||||||
const workerBroker = new WorkerToWebSocketMessageBroker(websocket, messageBatcher);
|
const workerBroker = new WorkerToWebSocketMessageBroker(websocket, messageBuffer);
|
||||||
const websocketBroker = new WebSocketToWorkerMessageBroker(messageBatcher, self);
|
|
||||||
|
|
||||||
self.addEventListener('message', (message) => {
|
self.addEventListener('message', (message) => {
|
||||||
workerBroker.routeMessageToHandler(message);
|
workerBroker.routeMessageToHandler(message);
|
||||||
});
|
});
|
||||||
websocket.registerMessageCallback((data) => {
|
websocket.registerMessageCallback((data) => {
|
||||||
websocketBroker.routeMessageToHandler(data);
|
messageBuffer.addMessageToBuffer(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
self.websocketInstance = websocket;
|
self.websocketInstance = websocket;
|
||||||
|
@ -321,16 +321,8 @@ class IndependentTimeContext extends TimeContext {
|
|||||||
return this.upstreamTimeContext.setMode(...arguments);
|
return this.upstreamTimeContext.setMode(...arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode === MODES.realtime) {
|
if (mode === MODES.realtime && this.activeClock === undefined) {
|
||||||
// TODO: This should probably happen up front in creating an independent time context
|
throw `Unknown clock. Has a clock been registered with 'addClock'?`;
|
||||||
// TODO: not just in time every time setMode is called
|
|
||||||
if (this.activeClock === undefined) {
|
|
||||||
this.activeClock = this.globalTimeContext.getClock();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.activeClock === undefined) {
|
|
||||||
throw `Unknown clock. Has a clock been registered with 'addClock'?`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode !== this.mode) {
|
if (mode !== this.mode) {
|
||||||
@ -367,6 +359,18 @@ class IndependentTimeContext extends TimeContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {boolean}
|
||||||
|
* @override
|
||||||
|
*/
|
||||||
|
isFixed() {
|
||||||
|
if (this.upstreamTimeContext) {
|
||||||
|
return this.upstreamTimeContext.isFixed(...arguments);
|
||||||
|
} else {
|
||||||
|
return super.isFixed(...arguments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
* @override
|
* @override
|
||||||
@ -408,7 +412,7 @@ class IndependentTimeContext extends TimeContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the time context to the global time context
|
* Reset the time context from the global time context
|
||||||
*/
|
*/
|
||||||
resetContext() {
|
resetContext() {
|
||||||
if (this.upstreamTimeContext) {
|
if (this.upstreamTimeContext) {
|
||||||
@ -436,6 +440,10 @@ class IndependentTimeContext extends TimeContext {
|
|||||||
// Emit bounds so that views that are changing context get the upstream bounds
|
// Emit bounds so that views that are changing context get the upstream bounds
|
||||||
this.emit('bounds', this.getBounds());
|
this.emit('bounds', this.getBounds());
|
||||||
this.emit(TIME_CONTEXT_EVENTS.boundsChanged, this.getBounds());
|
this.emit(TIME_CONTEXT_EVENTS.boundsChanged, this.getBounds());
|
||||||
|
// Also emit the mode in case it's different from previous time context
|
||||||
|
if (this.getMode()) {
|
||||||
|
this.emit(TIME_CONTEXT_EVENTS.modeChanged, this.#copy(this.getMode()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -510,6 +518,10 @@ class IndependentTimeContext extends TimeContext {
|
|||||||
// Emit bounds so that views that are changing context get the upstream bounds
|
// Emit bounds so that views that are changing context get the upstream bounds
|
||||||
this.emit('bounds', this.getBounds());
|
this.emit('bounds', this.getBounds());
|
||||||
this.emit(TIME_CONTEXT_EVENTS.boundsChanged, this.getBounds());
|
this.emit(TIME_CONTEXT_EVENTS.boundsChanged, this.getBounds());
|
||||||
|
// Also emit the mode in case it's different from the global time context
|
||||||
|
if (this.getMode()) {
|
||||||
|
this.emit(TIME_CONTEXT_EVENTS.modeChanged, this.#copy(this.getMode()));
|
||||||
|
}
|
||||||
// now that the view's context is set, tell others to check theirs in case they were following this view's context.
|
// now that the view's context is set, tell others to check theirs in case they were following this view's context.
|
||||||
this.globalTimeContext.emit('refreshContext', viewKey);
|
this.globalTimeContext.emit('refreshContext', viewKey);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
import { FIXED_MODE_KEY, REALTIME_MODE_KEY } from '@/api/time/constants';
|
import { FIXED_MODE_KEY, REALTIME_MODE_KEY } from '@/api/time/constants';
|
||||||
import IndependentTimeContext from '@/api/time/IndependentTimeContext';
|
import IndependentTimeContext from '@/api/time/IndependentTimeContext';
|
||||||
|
|
||||||
|
import { TIME_CONTEXT_EVENTS } from './constants';
|
||||||
import GlobalTimeContext from './GlobalTimeContext.js';
|
import GlobalTimeContext from './GlobalTimeContext.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -134,30 +135,33 @@ class TimeAPI extends GlobalTimeContext {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get or set an independent time context which follows the TimeAPI timeSystem,
|
* Get or set an independent time context which follows the TimeAPI timeSystem,
|
||||||
* but with different bounds for a given domain object
|
* but with different offsets for a given domain object
|
||||||
* @param {string} keyString The keyString identifier of the domain object these offsets are set for
|
* @param {string} key The identifier key of the domain object these offsets are set for
|
||||||
* @param {TimeConductorBounds | ClockOffsets} boundsOrOffsets either bounds if in fixed mode, or offsets if in realtime mode
|
* @param {ClockOffsets | TimeConductorBounds} value This maintains a sliding time window of a fixed width that automatically updates
|
||||||
* @param {string} clockKey the key for the real time clock to use
|
* @param {key | string} clockKey the real time clock key currently in use
|
||||||
*/
|
*/
|
||||||
addIndependentContext(keyString, boundsOrOffsets, clockKey) {
|
addIndependentContext(key, value, clockKey) {
|
||||||
let timeContext = this.getIndependentContext(keyString);
|
let timeContext = this.getIndependentContext(key);
|
||||||
|
|
||||||
//stop following upstream time context since the view has it's own
|
//stop following upstream time context since the view has its own
|
||||||
timeContext.resetContext();
|
timeContext.resetContext();
|
||||||
|
|
||||||
if (clockKey) {
|
if (clockKey) {
|
||||||
timeContext.setClock(clockKey);
|
timeContext.setClock(clockKey);
|
||||||
timeContext.setMode(REALTIME_MODE_KEY, boundsOrOffsets);
|
timeContext.setMode(REALTIME_MODE_KEY, value);
|
||||||
} else {
|
} else {
|
||||||
timeContext.setMode(FIXED_MODE_KEY, boundsOrOffsets);
|
timeContext.setMode(FIXED_MODE_KEY, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Also emit the mode in case it's different from the previous time context
|
||||||
|
timeContext.emit(TIME_CONTEXT_EVENTS.modeChanged, structuredClone(timeContext.getMode()));
|
||||||
|
|
||||||
// Notify any nested views to update, pass in the viewKey so that particular view can skip getting an upstream context
|
// Notify any nested views to update, pass in the viewKey so that particular view can skip getting an upstream context
|
||||||
this.emit('refreshContext', keyString);
|
this.emit('refreshContext', key);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
//follow any upstream time context
|
//follow any upstream time context
|
||||||
this.emit('removeOwnContext', keyString);
|
this.emit('removeOwnContext', key);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ class TimeContext extends EventEmitter {
|
|||||||
} else if (bounds.start > bounds.end) {
|
} else if (bounds.start > bounds.end) {
|
||||||
return {
|
return {
|
||||||
valid: false,
|
valid: false,
|
||||||
message: 'Start bound exceeds end bound'
|
message: 'Specified start date exceeds end bound'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,9 @@ export default function (folderName, couchPlugin, searchFilter) {
|
|||||||
location: 'ROOT'
|
location: 'ROOT'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
search() {
|
||||||
|
return Promise.resolve([]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -35,9 +38,17 @@ export default function (folderName, couchPlugin, searchFilter) {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
load() {
|
load() {
|
||||||
return couchProvider.getObjectsByFilter(searchFilter).then((objects) => {
|
let searchResults;
|
||||||
return objects.map((object) => object.identifier);
|
|
||||||
});
|
if (searchFilter.viewName !== undefined) {
|
||||||
|
// Use a view to search, instead of an _all_docs find
|
||||||
|
searchResults = couchProvider.getObjectsByView(searchFilter);
|
||||||
|
} else {
|
||||||
|
// Use the _find endpoint to search _all_docs
|
||||||
|
searchResults = couchProvider.getObjectsByFilter(searchFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return searchResults;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -257,7 +257,9 @@ export default {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
end,
|
end,
|
||||||
start
|
start,
|
||||||
|
size: 1,
|
||||||
|
strategy: 'latest'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
loadComposition() {
|
loadComposition() {
|
||||||
@ -330,7 +332,11 @@ export default {
|
|||||||
this.domainObject.configuration.axes.xKey === undefined ||
|
this.domainObject.configuration.axes.xKey === undefined ||
|
||||||
this.domainObject.configuration.axes.yKey === undefined
|
this.domainObject.configuration.axes.yKey === undefined
|
||||||
) {
|
) {
|
||||||
return;
|
const { xKey, yKey } = this.identifyAxesKeys(axisMetadata);
|
||||||
|
this.openmct.objects.mutate(this.domainObject, 'configuration.axes', {
|
||||||
|
xKey,
|
||||||
|
yKey
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let xValues = [];
|
let xValues = [];
|
||||||
@ -429,6 +435,30 @@ export default {
|
|||||||
subscribeToAll() {
|
subscribeToAll() {
|
||||||
const telemetryObjects = Object.values(this.telemetryObjects);
|
const telemetryObjects = Object.values(this.telemetryObjects);
|
||||||
telemetryObjects.forEach(this.subscribeToObject);
|
telemetryObjects.forEach(this.subscribeToObject);
|
||||||
|
},
|
||||||
|
identifyAxesKeys(metadata) {
|
||||||
|
const { xAxisMetadata, yAxisMetadata } = metadata;
|
||||||
|
|
||||||
|
let xKey;
|
||||||
|
let yKey;
|
||||||
|
|
||||||
|
// If xAxisMetadata contains array values, use the first one for xKey
|
||||||
|
const arrayValues = xAxisMetadata.filter((metaDatum) => metaDatum.isArrayValue);
|
||||||
|
const nonArrayValues = xAxisMetadata.filter((metaDatum) => !metaDatum.isArrayValue);
|
||||||
|
|
||||||
|
if (arrayValues.length > 0) {
|
||||||
|
xKey = arrayValues[0].key;
|
||||||
|
yKey = arrayValues.length > 1 ? arrayValues[1].key : yAxisMetadata.key;
|
||||||
|
} else if (nonArrayValues.length > 0) {
|
||||||
|
xKey = nonArrayValues[0].key;
|
||||||
|
yKey = 'none';
|
||||||
|
} else {
|
||||||
|
// Fallback if no valid xKey or yKey is found
|
||||||
|
xKey = 'none';
|
||||||
|
yKey = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
return { xKey, yKey };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -39,7 +39,7 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
this.shouldEvaluateNewTelemetry = this.shouldEvaluateNewTelemetry.bind(this);
|
this.shouldEvaluateNewTelemetry = this.shouldEvaluateNewTelemetry.bind(this);
|
||||||
|
|
||||||
this.compositionLoad = this.composition.load();
|
this.compositionLoad = this.composition.load();
|
||||||
this.subscriptions = {};
|
this.telemetryCollections = {};
|
||||||
this.telemetryObjects = {};
|
this.telemetryObjects = {};
|
||||||
this.testData = {
|
this.testData = {
|
||||||
conditionTestInputs: this.conditionSetDomainObject.configuration.conditionTestData,
|
conditionTestInputs: this.conditionSetDomainObject.configuration.conditionTestData,
|
||||||
@ -48,55 +48,46 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
this.initialize();
|
this.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
async requestLatestValue(endpoint) {
|
subscribeToTelemetry(telemetryObject) {
|
||||||
const options = {
|
const keyString = this.openmct.objects.makeKeyString(telemetryObject.identifier);
|
||||||
|
|
||||||
|
if (this.telemetryCollections[keyString]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestOptions = {
|
||||||
size: 1,
|
size: 1,
|
||||||
strategy: 'latest'
|
strategy: 'latest'
|
||||||
};
|
};
|
||||||
const latestData = await this.openmct.telemetry.request(endpoint, options);
|
|
||||||
|
|
||||||
if (!latestData) {
|
this.telemetryCollections[keyString] = this.openmct.telemetry.requestCollection(
|
||||||
throw new Error('Telemetry request failed by returning a falsy response');
|
telemetryObject,
|
||||||
}
|
requestOptions
|
||||||
if (latestData.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.telemetryReceived(endpoint, latestData[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
subscribeToTelemetry(endpoint) {
|
|
||||||
const telemetryKeyString = this.openmct.objects.makeKeyString(endpoint.identifier);
|
|
||||||
if (this.subscriptions[telemetryKeyString]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const metadata = this.openmct.telemetry.getMetadata(endpoint);
|
|
||||||
|
|
||||||
this.telemetryObjects[telemetryKeyString] = Object.assign({}, endpoint, {
|
|
||||||
telemetryMetaData: metadata ? metadata.valueMetadatas : []
|
|
||||||
});
|
|
||||||
|
|
||||||
// get latest telemetry value (in case subscription is cached and no new data is coming in)
|
|
||||||
this.requestLatestValue(endpoint);
|
|
||||||
|
|
||||||
this.subscriptions[telemetryKeyString] = this.openmct.telemetry.subscribe(
|
|
||||||
endpoint,
|
|
||||||
this.telemetryReceived.bind(this, endpoint)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const metadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
||||||
|
const telemetryMetaData = metadata ? metadata.valueMetadatas : [];
|
||||||
|
|
||||||
|
this.telemetryObjects[keyString] = { ...telemetryObject, telemetryMetaData };
|
||||||
|
|
||||||
|
this.telemetryCollections[keyString].on(
|
||||||
|
'add',
|
||||||
|
this.telemetryReceived.bind(this, telemetryObject)
|
||||||
|
);
|
||||||
|
this.telemetryCollections[keyString].load();
|
||||||
|
|
||||||
this.updateConditionTelemetryObjects();
|
this.updateConditionTelemetryObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsubscribeFromTelemetry(endpointIdentifier) {
|
unsubscribeFromTelemetry(endpointIdentifier) {
|
||||||
const id = this.openmct.objects.makeKeyString(endpointIdentifier);
|
const keyString = this.openmct.objects.makeKeyString(endpointIdentifier);
|
||||||
if (!this.subscriptions[id]) {
|
if (!this.telemetryCollections[keyString]) {
|
||||||
console.log('no subscription to remove');
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.subscriptions[id]();
|
this.telemetryCollections[keyString].destroy();
|
||||||
delete this.subscriptions[id];
|
this.telemetryCollections[keyString] = null;
|
||||||
delete this.telemetryObjects[id];
|
this.telemetryObjects[keyString] = null;
|
||||||
this.removeConditionTelemetryObjects();
|
this.removeConditionTelemetryObjects();
|
||||||
|
|
||||||
//force re-computation of condition set result as we might be in a state where
|
//force re-computation of condition set result as we might be in a state where
|
||||||
@ -107,7 +98,7 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
this.timeSystems,
|
this.timeSystems,
|
||||||
this.openmct.time.getTimeSystem()
|
this.openmct.time.getTimeSystem()
|
||||||
);
|
);
|
||||||
this.updateConditionResults({ id: id });
|
this.updateConditionResults({ id: keyString });
|
||||||
this.updateCurrentCondition(latestTimestamp);
|
this.updateCurrentCondition(latestTimestamp);
|
||||||
|
|
||||||
if (Object.keys(this.telemetryObjects).length === 0) {
|
if (Object.keys(this.telemetryObjects).length === 0) {
|
||||||
@ -410,11 +401,13 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
return this.openmct.time.getBounds().end >= currentTimestamp;
|
return this.openmct.time.getBounds().end >= currentTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
telemetryReceived(endpoint, datum) {
|
telemetryReceived(endpoint, data) {
|
||||||
if (!this.isTelemetryUsed(endpoint)) {
|
if (!this.isTelemetryUsed(endpoint)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const datum = data[0];
|
||||||
|
|
||||||
const normalizedDatum = this.createNormalizedDatum(datum, endpoint);
|
const normalizedDatum = this.createNormalizedDatum(datum, endpoint);
|
||||||
const timeSystemKey = this.openmct.time.getTimeSystem().key;
|
const timeSystemKey = this.openmct.time.getTimeSystem().key;
|
||||||
let timestamp = {};
|
let timestamp = {};
|
||||||
@ -507,8 +500,9 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
destroy() {
|
destroy() {
|
||||||
this.composition.off('add', this.subscribeToTelemetry, this);
|
this.composition.off('add', this.subscribeToTelemetry, this);
|
||||||
this.composition.off('remove', this.unsubscribeFromTelemetry, this);
|
this.composition.off('remove', this.unsubscribeFromTelemetry, this);
|
||||||
Object.values(this.subscriptions).forEach((unsubscribe) => unsubscribe());
|
Object.values(this.telemetryCollections).forEach((telemetryCollection) =>
|
||||||
delete this.subscriptions;
|
telemetryCollection.destroy()
|
||||||
|
);
|
||||||
|
|
||||||
this.conditions.forEach((condition) => {
|
this.conditions.forEach((condition) => {
|
||||||
condition.destroy();
|
condition.destroy();
|
||||||
|
@ -27,14 +27,16 @@
|
|||||||
aria-label="Condition Set Condition Collection"
|
aria-label="Condition Set Condition Collection"
|
||||||
>
|
>
|
||||||
<div class="c-cs__header c-section__header">
|
<div class="c-cs__header c-section__header">
|
||||||
<span
|
<button
|
||||||
class="c-disclosure-triangle c-tree__item__view-control is-enabled"
|
class="c-disclosure-triangle c-tree__item__view-control is-enabled"
|
||||||
:class="{ 'c-disclosure-triangle--expanded': expanded }"
|
:class="{ 'c-disclosure-triangle--expanded': expanded }"
|
||||||
@click="expanded = !expanded"
|
:aria-expanded="expanded"
|
||||||
></span>
|
aria-controls="conditionContent"
|
||||||
|
@click="toggleExpanded"
|
||||||
|
></button>
|
||||||
<div class="c-cs__header-label c-section__label">Conditions</div>
|
<div class="c-cs__header-label c-section__label">Conditions</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="expanded" class="c-cs__content">
|
<div v-if="expanded" id="conditionContent" class="c-cs__content">
|
||||||
<div
|
<div
|
||||||
v-show="isEditing"
|
v-show="isEditing"
|
||||||
class="hint"
|
class="hint"
|
||||||
@ -54,9 +56,10 @@
|
|||||||
v-show="isEditing"
|
v-show="isEditing"
|
||||||
id="addCondition"
|
id="addCondition"
|
||||||
class="c-button c-button--major icon-plus labeled"
|
class="c-button c-button--major icon-plus labeled"
|
||||||
|
aria-labelledby="addConditionButtonLabel"
|
||||||
@click="addCondition"
|
@click="addCondition"
|
||||||
>
|
>
|
||||||
<span class="c-cs-button__label">Add Condition</span>
|
<span id="addConditionButtonLabel" class="c-cs-button__label">Add Condition</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div class="c-cs__conditions-h" :class="{ 'is-active-dragging': isDragging }">
|
<div class="c-cs__conditions-h" :class="{ 'is-active-dragging': isDragging }">
|
||||||
|
@ -160,8 +160,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div class="c-cdef__separator c-row-separator"></div>
|
<div class="c-cdef__separator c-row-separator"></div>
|
||||||
<div class="c-cdef__controls" :disabled="!telemetry.length">
|
<div class="c-cdef__controls">
|
||||||
<button
|
<button
|
||||||
|
:disabled="!telemetry.length"
|
||||||
|
:aria-label="`Add Criteria - ${!telemetry.length ? 'Disabled' : 'Enabled'}`"
|
||||||
class="c-cdef__add-criteria-button c-button c-button--labeled icon-plus"
|
class="c-cdef__add-criteria-button c-button c-button--labeled icon-plus"
|
||||||
@click="addCriteria"
|
@click="addCriteria"
|
||||||
>
|
>
|
||||||
|
@ -28,11 +28,7 @@
|
|||||||
{ 'is-style-invisible': styleItem.style && styleItem.style.isStyleInvisible },
|
{ 'is-style-invisible': styleItem.style && styleItem.style.isStyleInvisible },
|
||||||
{ 'c-style-thumb--mixed': mixedStyles.indexOf('backgroundColor') > -1 }
|
{ 'c-style-thumb--mixed': mixedStyles.indexOf('backgroundColor') > -1 }
|
||||||
]"
|
]"
|
||||||
:style="[
|
:style="[encodedImageUrl ? { backgroundImage: 'url(' + encodedImageUrl + ')' } : itemStyle]"
|
||||||
styleItem.style.imageUrl
|
|
||||||
? { backgroundImage: 'url(' + styleItem.style.imageUrl + ')' }
|
|
||||||
: itemStyle
|
|
||||||
]"
|
|
||||||
class="c-style-thumb"
|
class="c-style-thumb"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@ -62,7 +58,7 @@
|
|||||||
@change="updateStyleValue"
|
@change="updateStyleValue"
|
||||||
/>
|
/>
|
||||||
<ToolbarButton
|
<ToolbarButton
|
||||||
v-if="hasProperty(styleItem.style.imageUrl)"
|
v-if="hasProperty(encodedImageUrl)"
|
||||||
class="c-style__toolbar-button--image-url"
|
class="c-style__toolbar-button--image-url"
|
||||||
:options="imageUrlOption"
|
:options="imageUrlOption"
|
||||||
@change="updateStyleValue"
|
@change="updateStyleValue"
|
||||||
@ -93,6 +89,8 @@ import ToolbarButton from '@/ui/toolbar/components/ToolbarButton.vue';
|
|||||||
import ToolbarColorPicker from '@/ui/toolbar/components/ToolbarColorPicker.vue';
|
import ToolbarColorPicker from '@/ui/toolbar/components/ToolbarColorPicker.vue';
|
||||||
import ToolbarToggleButton from '@/ui/toolbar/components/ToolbarToggleButton.vue';
|
import ToolbarToggleButton from '@/ui/toolbar/components/ToolbarToggleButton.vue';
|
||||||
|
|
||||||
|
import { encode_url } from '../../../../utils/encoding';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'StyleEditor',
|
name: 'StyleEditor',
|
||||||
components: {
|
components: {
|
||||||
@ -183,11 +181,14 @@ export default {
|
|||||||
},
|
},
|
||||||
property: 'imageUrl',
|
property: 'imageUrl',
|
||||||
formKeys: ['url'],
|
formKeys: ['url'],
|
||||||
value: { url: this.styleItem.style.imageUrl },
|
value: { url: this.encodedImageUrl },
|
||||||
isEditing: this.isEditing,
|
isEditing: this.isEditing,
|
||||||
nonSpecific: this.mixedStyles.indexOf('imageUrl') > -1
|
nonSpecific: this.mixedStyles.indexOf('imageUrl') > -1
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
encodedImageUrl() {
|
||||||
|
return encode_url(this.styleItem.style.imageUrl);
|
||||||
|
},
|
||||||
isStyleInvisibleOption() {
|
isStyleInvisibleOption() {
|
||||||
return {
|
return {
|
||||||
value: this.styleItem.style.isStyleInvisible,
|
value: this.styleItem.style.isStyleInvisible,
|
||||||
|
@ -720,50 +720,69 @@ describe('the plugin', function () {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should evaluate as old when telemetry is not received in the allotted time', (done) => {
|
it('should evaluate as old when telemetry is not received in the allotted time', async () => {
|
||||||
|
let onAddResolve;
|
||||||
|
const onAddCalledPromise = new Promise((resolve) => {
|
||||||
|
onAddResolve = resolve;
|
||||||
|
});
|
||||||
|
const mockTelemetryCollection = {
|
||||||
|
load: jasmine.createSpy('load'),
|
||||||
|
on: jasmine.createSpy('on').and.callFake((event, callback) => {
|
||||||
|
if (event === 'add') {
|
||||||
|
onAddResolve();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
openmct.telemetry = jasmine.createSpyObj('telemetry', [
|
openmct.telemetry = jasmine.createSpyObj('telemetry', [
|
||||||
'subscribe',
|
|
||||||
'getMetadata',
|
'getMetadata',
|
||||||
'request',
|
'request',
|
||||||
'getValueFormatter',
|
'getValueFormatter',
|
||||||
'abortAllRequests'
|
'abortAllRequests',
|
||||||
|
'requestCollection'
|
||||||
]);
|
]);
|
||||||
|
openmct.telemetry.request.and.returnValue(Promise.resolve([]));
|
||||||
openmct.telemetry.getMetadata.and.returnValue({
|
openmct.telemetry.getMetadata.and.returnValue({
|
||||||
...testTelemetryObject.telemetry,
|
...testTelemetryObject.telemetry,
|
||||||
valueMetadatas: []
|
valueMetadatas: testTelemetryObject.telemetry.values,
|
||||||
|
valuesForHints: jasmine
|
||||||
|
.createSpy('valuesForHints')
|
||||||
|
.and.returnValue(testTelemetryObject.telemetry.values),
|
||||||
|
value: jasmine.createSpy('value').and.callFake((key) => {
|
||||||
|
return testTelemetryObject.telemetry.values.find((value) => value.key === key);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
openmct.telemetry.request.and.returnValue(Promise.resolve([]));
|
openmct.telemetry.requestCollection.and.returnValue(mockTelemetryCollection);
|
||||||
openmct.telemetry.getValueFormatter.and.returnValue({
|
openmct.telemetry.getValueFormatter.and.returnValue({
|
||||||
parse: function (value) {
|
parse: function (value) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let conditionMgr = new ConditionManager(conditionSetDomainObject, openmct);
|
let conditionMgr = new ConditionManager(conditionSetDomainObject, openmct);
|
||||||
conditionMgr.on('conditionSetResultUpdated', mockListener);
|
conditionMgr.on('conditionSetResultUpdated', mockListener);
|
||||||
conditionMgr.telemetryObjects = {
|
conditionMgr.telemetryObjects = {
|
||||||
'test-object': testTelemetryObject
|
'test-object': testTelemetryObject
|
||||||
};
|
};
|
||||||
conditionMgr.updateConditionTelemetryObjects();
|
conditionMgr.updateConditionTelemetryObjects();
|
||||||
setTimeout(() => {
|
// Wait for the 'on' callback to be called
|
||||||
expect(mockListener).toHaveBeenCalledWith({
|
await onAddCalledPromise;
|
||||||
output: 'Any old telemetry',
|
|
||||||
id: {
|
// Simulate the passage of time and no data received
|
||||||
namespace: '',
|
await new Promise((resolve) => setTimeout(resolve, 400));
|
||||||
key: 'cf4456a9-296a-4e6b-b182-62ed29cd15b9'
|
|
||||||
},
|
expect(mockListener).toHaveBeenCalledWith({
|
||||||
conditionId: '39584410-cbf9-499e-96dc-76f27e69885d',
|
output: 'Any old telemetry',
|
||||||
utc: undefined
|
id: {
|
||||||
});
|
namespace: '',
|
||||||
done();
|
key: 'cf4456a9-296a-4e6b-b182-62ed29cd15b9'
|
||||||
}, 400);
|
},
|
||||||
|
conditionId: '39584410-cbf9-499e-96dc-76f27e69885d',
|
||||||
|
utc: undefined
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not evaluate as old when telemetry is received in the allotted time', (done) => {
|
it('should not evaluate as old when telemetry is received in the allotted time', async () => {
|
||||||
openmct.telemetry.getMetadata = jasmine.createSpy('getMetadata');
|
|
||||||
openmct.telemetry.getMetadata.and.returnValue({
|
|
||||||
...testTelemetryObject.telemetry,
|
|
||||||
valueMetadatas: testTelemetryObject.telemetry.values
|
|
||||||
});
|
|
||||||
const testDatum = {
|
const testDatum = {
|
||||||
'some-key2': '',
|
'some-key2': '',
|
||||||
utc: 1,
|
utc: 1,
|
||||||
@ -771,8 +790,49 @@ describe('the plugin', function () {
|
|||||||
'some-key': null,
|
'some-key': null,
|
||||||
id: 'test-object'
|
id: 'test-object'
|
||||||
};
|
};
|
||||||
openmct.telemetry.request = jasmine.createSpy('request');
|
|
||||||
|
let onAddResolve;
|
||||||
|
let onAddCallback;
|
||||||
|
const onAddCalledPromise = new Promise((resolve) => {
|
||||||
|
onAddResolve = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockTelemetryCollection = {
|
||||||
|
load: jasmine.createSpy('load'),
|
||||||
|
on: jasmine.createSpy('on').and.callFake((event, callback) => {
|
||||||
|
if (event === 'add') {
|
||||||
|
onAddCallback = callback;
|
||||||
|
onAddResolve();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
openmct.telemetry = jasmine.createSpyObj('telemetry', [
|
||||||
|
'getMetadata',
|
||||||
|
'getValueFormatter',
|
||||||
|
'request',
|
||||||
|
'subscribe',
|
||||||
|
'requestCollection'
|
||||||
|
]);
|
||||||
|
openmct.telemetry.subscribe.and.returnValue(function () {});
|
||||||
openmct.telemetry.request.and.returnValue(Promise.resolve([testDatum]));
|
openmct.telemetry.request.and.returnValue(Promise.resolve([testDatum]));
|
||||||
|
openmct.telemetry.getMetadata.and.returnValue({
|
||||||
|
...testTelemetryObject.telemetry,
|
||||||
|
valueMetadatas: testTelemetryObject.telemetry.values,
|
||||||
|
valuesForHints: jasmine
|
||||||
|
.createSpy('valuesForHints')
|
||||||
|
.and.returnValue(testTelemetryObject.telemetry.values),
|
||||||
|
value: jasmine.createSpy('value').and.callFake((key) => {
|
||||||
|
return testTelemetryObject.telemetry.values.find((value) => value.key === key);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
openmct.telemetry.requestCollection.and.returnValue(mockTelemetryCollection);
|
||||||
|
openmct.telemetry.getValueFormatter.and.returnValue({
|
||||||
|
parse: function (value) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const date = 1;
|
const date = 1;
|
||||||
conditionSetDomainObject.configuration.conditionCollection[0].configuration.criteria[0].input =
|
conditionSetDomainObject.configuration.conditionCollection[0].configuration.criteria[0].input =
|
||||||
['0.4'];
|
['0.4'];
|
||||||
@ -782,19 +842,25 @@ describe('the plugin', function () {
|
|||||||
'test-object': testTelemetryObject
|
'test-object': testTelemetryObject
|
||||||
};
|
};
|
||||||
conditionMgr.updateConditionTelemetryObjects();
|
conditionMgr.updateConditionTelemetryObjects();
|
||||||
conditionMgr.telemetryReceived(testTelemetryObject, testDatum);
|
|
||||||
setTimeout(() => {
|
// Wait for the 'on' callback to be called
|
||||||
expect(mockListener).toHaveBeenCalledWith({
|
await onAddCalledPromise;
|
||||||
output: 'Default',
|
|
||||||
id: {
|
// Simulate receiving telemetry data
|
||||||
namespace: '',
|
onAddCallback([testDatum]);
|
||||||
key: 'cf4456a9-296a-4e6b-b182-62ed29cd15b9'
|
|
||||||
},
|
// Wait a bit for the condition manager to process the data
|
||||||
conditionId: '2532d90a-e0d6-4935-b546-3123522da2de',
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||||
utc: date
|
|
||||||
});
|
expect(mockListener).toHaveBeenCalledWith({
|
||||||
done();
|
output: 'Default',
|
||||||
}, 300);
|
id: {
|
||||||
|
namespace: '',
|
||||||
|
key: 'cf4456a9-296a-4e6b-b182-62ed29cd15b9'
|
||||||
|
},
|
||||||
|
conditionId: '2532d90a-e0d6-4935-b546-3123522da2de',
|
||||||
|
utc: date
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -902,17 +968,25 @@ describe('the plugin', function () {
|
|||||||
openmct.telemetry.getMetadata = jasmine.createSpy('getMetadata');
|
openmct.telemetry.getMetadata = jasmine.createSpy('getMetadata');
|
||||||
openmct.telemetry.getMetadata.and.returnValue({
|
openmct.telemetry.getMetadata.and.returnValue({
|
||||||
...testTelemetryObject.telemetry,
|
...testTelemetryObject.telemetry,
|
||||||
valueMetadatas: []
|
valueMetadatas: testTelemetryObject.telemetry.values,
|
||||||
|
valuesForHints: jasmine
|
||||||
|
.createSpy('valuesForHints')
|
||||||
|
.and.returnValue(testTelemetryObject.telemetry.values),
|
||||||
|
value: jasmine.createSpy('value').and.callFake((key) => {
|
||||||
|
return testTelemetryObject.telemetry.values.find((value) => value.key === key);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
conditionMgr.on('conditionSetResultUpdated', mockListener);
|
conditionMgr.on('conditionSetResultUpdated', mockListener);
|
||||||
conditionMgr.telemetryObjects = {
|
conditionMgr.telemetryObjects = {
|
||||||
'test-object': testTelemetryObject
|
'test-object': testTelemetryObject
|
||||||
};
|
};
|
||||||
conditionMgr.updateConditionTelemetryObjects();
|
conditionMgr.updateConditionTelemetryObjects();
|
||||||
conditionMgr.telemetryReceived(testTelemetryObject, {
|
conditionMgr.telemetryReceived(testTelemetryObject, [
|
||||||
'some-key': 2,
|
{
|
||||||
utc: date
|
'some-key': 2,
|
||||||
});
|
utc: date
|
||||||
|
}
|
||||||
|
]);
|
||||||
let result = conditionMgr.conditions.map((condition) => condition.result);
|
let result = conditionMgr.conditions.map((condition) => condition.result);
|
||||||
expect(result[2]).toBeUndefined();
|
expect(result[2]).toBeUndefined();
|
||||||
});
|
});
|
||||||
@ -1002,26 +1076,37 @@ describe('the plugin', function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
openmct.$injector = jasmine.createSpyObj('$injector', ['get']);
|
openmct.$injector = jasmine.createSpyObj('$injector', ['get']);
|
||||||
// const mockTransactionService = jasmine.createSpyObj(
|
|
||||||
// 'transactionService',
|
|
||||||
// ['commit']
|
|
||||||
// );
|
|
||||||
openmct.telemetry = jasmine.createSpyObj('telemetry', [
|
openmct.telemetry = jasmine.createSpyObj('telemetry', [
|
||||||
'isTelemetryObject',
|
'isTelemetryObject',
|
||||||
|
'request',
|
||||||
'subscribe',
|
'subscribe',
|
||||||
'getMetadata',
|
'getMetadata',
|
||||||
'getValueFormatter',
|
'getValueFormatter',
|
||||||
'request'
|
'requestCollection'
|
||||||
]);
|
]);
|
||||||
openmct.telemetry.isTelemetryObject.and.returnValue(true);
|
|
||||||
openmct.telemetry.subscribe.and.returnValue(function () {});
|
openmct.telemetry.subscribe.and.returnValue(function () {});
|
||||||
|
openmct.telemetry.request.and.returnValue(Promise.resolve([]));
|
||||||
|
openmct.telemetry.isTelemetryObject.and.returnValue(true);
|
||||||
|
openmct.telemetry.getMetadata.and.returnValue(testTelemetryObject.telemetry);
|
||||||
|
openmct.telemetry.getMetadata.and.returnValue({
|
||||||
|
...testTelemetryObject.telemetry,
|
||||||
|
valueMetadatas: testTelemetryObject.telemetry.values,
|
||||||
|
valuesForHints: jasmine
|
||||||
|
.createSpy('valuesForHints')
|
||||||
|
.and.returnValue(testTelemetryObject.telemetry.values),
|
||||||
|
value: jasmine.createSpy('value').and.callFake((key) => {
|
||||||
|
return testTelemetryObject.telemetry.values.find((value) => value.key === key);
|
||||||
|
})
|
||||||
|
});
|
||||||
openmct.telemetry.getValueFormatter.and.returnValue({
|
openmct.telemetry.getValueFormatter.and.returnValue({
|
||||||
parse: function (value) {
|
parse: function (value) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
openmct.telemetry.getMetadata.and.returnValue(testTelemetryObject.telemetry);
|
openmct.telemetry.requestCollection.and.returnValue({
|
||||||
openmct.telemetry.request.and.returnValue(Promise.resolve([]));
|
load: jasmine.createSpy('load'),
|
||||||
|
on: jasmine.createSpy('on')
|
||||||
|
});
|
||||||
|
|
||||||
const styleRuleManger = new StyleRuleManager(stylesObject, openmct, null, true);
|
const styleRuleManger = new StyleRuleManager(stylesObject, openmct, null, true);
|
||||||
spyOn(styleRuleManger, 'subscribeToConditionSet');
|
spyOn(styleRuleManger, 'subscribeToConditionSet');
|
||||||
|
@ -29,12 +29,13 @@
|
|||||||
@end-move="endMove"
|
@end-move="endMove"
|
||||||
>
|
>
|
||||||
<template #content>
|
<template #content>
|
||||||
<div class="c-image-view" :style="style"></div>
|
<div v-show="showImage" aria-label="Image View" class="c-image-view" :style="style"></div>
|
||||||
</template>
|
</template>
|
||||||
</LayoutFrame>
|
</LayoutFrame>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { encode_url } from '../../../utils/encoding';
|
||||||
import conditionalStylesMixin from '../mixins/objectStyles-mixin.js';
|
import conditionalStylesMixin from '../mixins/objectStyles-mixin.js';
|
||||||
import LayoutFrame from './LayoutFrame.vue';
|
import LayoutFrame from './LayoutFrame.vue';
|
||||||
|
|
||||||
@ -76,13 +77,16 @@ export default {
|
|||||||
},
|
},
|
||||||
emits: ['move', 'end-move'],
|
emits: ['move', 'end-move'],
|
||||||
computed: {
|
computed: {
|
||||||
|
showImage() {
|
||||||
|
return this.isEditing || !this.itemStyle?.isStyleInvisible;
|
||||||
|
},
|
||||||
style() {
|
style() {
|
||||||
let backgroundImage = 'url(' + this.item.url + ')';
|
let backgroundImage = `url('${encode_url(this.item.url)}')`;
|
||||||
let border = '1px solid ' + this.item.stroke;
|
let border = '1px solid ' + this.item.stroke;
|
||||||
|
|
||||||
if (this.itemStyle) {
|
if (this.itemStyle) {
|
||||||
if (this.itemStyle.imageUrl !== undefined) {
|
if (this.itemStyle.imageUrl !== undefined) {
|
||||||
backgroundImage = 'url(' + this.itemStyle.imageUrl + ')';
|
backgroundImage = `url('${encode_url(this.itemStyle.imageUrl)}')`;
|
||||||
}
|
}
|
||||||
|
|
||||||
border = this.itemStyle.border;
|
border = this.itemStyle.border;
|
||||||
|
@ -31,9 +31,10 @@
|
|||||||
<template #content>
|
<template #content>
|
||||||
<div
|
<div
|
||||||
v-if="domainObject"
|
v-if="domainObject"
|
||||||
|
v-show="showTelemetry"
|
||||||
ref="telemetryViewWrapper"
|
ref="telemetryViewWrapper"
|
||||||
class="c-telemetry-view u-style-receiver"
|
class="c-telemetry-view u-style-receiver"
|
||||||
:class="[itemClasses]"
|
:class="classNames"
|
||||||
:style="styleObject"
|
:style="styleObject"
|
||||||
:data-font-size="item.fontSize"
|
:data-font-size="item.fontSize"
|
||||||
:data-font="item.font"
|
:data-font="item.font"
|
||||||
@ -151,7 +152,10 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
itemClasses() {
|
showTelemetry() {
|
||||||
|
return this.isEditing || !this.itemStyle?.isStyleInvisible;
|
||||||
|
},
|
||||||
|
classNames() {
|
||||||
let classes = [];
|
let classes = [];
|
||||||
|
|
||||||
if (this.status) {
|
if (this.status) {
|
||||||
|
@ -109,8 +109,9 @@ class DuplicateAction {
|
|||||||
let currentParentKeystring = this.openmct.objects.makeKeyString(currentParent.identifier);
|
let currentParentKeystring = this.openmct.objects.makeKeyString(currentParent.identifier);
|
||||||
let parentCandidateKeystring = this.openmct.objects.makeKeyString(parentCandidate.identifier);
|
let parentCandidateKeystring = this.openmct.objects.makeKeyString(parentCandidate.identifier);
|
||||||
let objectKeystring = this.openmct.objects.makeKeyString(this.object.identifier);
|
let objectKeystring = this.openmct.objects.makeKeyString(this.object.identifier);
|
||||||
|
const isLocked = parentCandidate.locked === true;
|
||||||
|
|
||||||
if (!this.openmct.objects.isPersistable(parentCandidate.identifier)) {
|
if (isLocked || !this.openmct.objects.isPersistable(parentCandidate.identifier)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,10 +140,9 @@ class DuplicateAction {
|
|||||||
const parentType = parent && this.openmct.types.get(parent.type);
|
const parentType = parent && this.openmct.types.get(parent.type);
|
||||||
const child = objectPath[0];
|
const child = objectPath[0];
|
||||||
const childType = child && this.openmct.types.get(child.type);
|
const childType = child && this.openmct.types.get(child.type);
|
||||||
const locked = child.locked ? child.locked : parent && parent.locked;
|
|
||||||
const isPersistable = this.openmct.objects.isPersistable(child.identifier);
|
const isPersistable = this.openmct.objects.isPersistable(child.identifier);
|
||||||
|
|
||||||
if (locked || !isPersistable) {
|
if (!isPersistable) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,12 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="c-fault-mgmt__list data-selectable" :class="classesFromState">
|
<div
|
||||||
|
role="listitem"
|
||||||
|
:aria-label="listItemAriaLabel"
|
||||||
|
class="c-fault-mgmt__list data-selectable"
|
||||||
|
:class="classesFromState"
|
||||||
|
>
|
||||||
<div class="c-fault-mgmt-item c-fault-mgmt__list-checkbox">
|
<div class="c-fault-mgmt-item c-fault-mgmt__list-checkbox">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
@ -33,29 +38,44 @@
|
|||||||
<div class="c-fault-mgmt-item">
|
<div class="c-fault-mgmt-item">
|
||||||
<div
|
<div
|
||||||
class="c-fault-mgmt__list-severity"
|
class="c-fault-mgmt__list-severity"
|
||||||
:aria-label="fault.severity"
|
:aria-label="severityAriaLabel"
|
||||||
:title="fault.severity"
|
|
||||||
:class="['is-severity-' + severity]"
|
:class="['is-severity-' + severity]"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="c-fault-mgmt-item c-fault-mgmt__list-content">
|
<div class="c-fault-mgmt-item c-fault-mgmt__list-content">
|
||||||
<div class="c-fault-mgmt-item c-fault-mgmt__list-pathname">
|
<div class="c-fault-mgmt-item c-fault-mgmt__list-pathname">
|
||||||
<div class="c-fault-mgmt__list-path">{{ fault.namespace }}</div>
|
<div class="c-fault-mgmt__list-path" aria-label="Fault namespace">
|
||||||
<div class="c-fault-mgmt__list-faultname">{{ fault.name }}</div>
|
{{ fault.namespace }}
|
||||||
|
</div>
|
||||||
|
<div class="c-fault-mgmt__list-faultname" aria-label="Fault name">{{ fault.name }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="c-fault-mgmt__list-content-right">
|
<div class="c-fault-mgmt__list-content-right">
|
||||||
<div class="c-fault-mgmt-item c-fault-mgmt__list-trigVal">
|
<div class="c-fault-mgmt-item c-fault-mgmt__list-trigVal">
|
||||||
<div class="c-fault-mgmt-item__value" :class="tripValueClassname" title="Trip Value">
|
<div
|
||||||
|
class="c-fault-mgmt-item__value"
|
||||||
|
:class="tripValueClassname"
|
||||||
|
title="Trip Value"
|
||||||
|
aria-label="Trip Value"
|
||||||
|
>
|
||||||
{{ fault.triggerValueInfo.value }}
|
{{ fault.triggerValueInfo.value }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="c-fault-mgmt-item c-fault-mgmt__list-curVal">
|
<div class="c-fault-mgmt-item c-fault-mgmt__list-curVal">
|
||||||
<div class="c-fault-mgmt-item__value" :class="liveValueClassname" title="Live Value">
|
<div
|
||||||
|
class="c-fault-mgmt-item__value"
|
||||||
|
:class="liveValueClassname"
|
||||||
|
title="Live Value"
|
||||||
|
aria-label="Live Value"
|
||||||
|
>
|
||||||
{{ fault.currentValueInfo.value }}
|
{{ fault.currentValueInfo.value }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="c-fault-mgmt-item c-fault-mgmt__list-trigTime">
|
<div class="c-fault-mgmt-item c-fault-mgmt__list-trigTime">
|
||||||
<div class="c-fault-mgmt-item__value" title="Last Trigger Time">
|
<div
|
||||||
|
class="c-fault-mgmt-item__value"
|
||||||
|
title="Last Trigger Time"
|
||||||
|
aria-label="Last Trigger Time"
|
||||||
|
>
|
||||||
{{ fault.triggerTime }}
|
{{ fault.triggerTime }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -98,7 +118,7 @@ export default {
|
|||||||
emits: ['acknowledge-selected', 'shelve-selected', 'toggle-selected', 'clear-all-selected'],
|
emits: ['acknowledge-selected', 'shelve-selected', 'toggle-selected', 'clear-all-selected'],
|
||||||
computed: {
|
computed: {
|
||||||
checkBoxAriaLabel() {
|
checkBoxAriaLabel() {
|
||||||
return `Select fault: ${this.fault.name}`;
|
return `Select fault: ${this.fault.name || 'Unknown'} in ${this.fault.namespace || 'Unknown'}`;
|
||||||
},
|
},
|
||||||
classesFromState() {
|
classesFromState() {
|
||||||
const exclusiveStates = [
|
const exclusiveStates = [
|
||||||
@ -165,6 +185,12 @@ export default {
|
|||||||
classname += SEVERITY_CLASS[triggerValueInfo.monitoringResult] || '';
|
classname += SEVERITY_CLASS[triggerValueInfo.monitoringResult] || '';
|
||||||
|
|
||||||
return classname.trim();
|
return classname.trim();
|
||||||
|
},
|
||||||
|
listItemAriaLabel() {
|
||||||
|
return `Fault triggered at ${this.fault.triggerTime || 'Unknown'} with severity ${this.fault.severity || 'Unknown'} in ${this.fault.namespace || 'Unknown'}`;
|
||||||
|
},
|
||||||
|
severityAriaLabel() {
|
||||||
|
return `Severity: ${this.fault.severity || 'Unknown'}`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -68,7 +68,6 @@
|
|||||||
import {
|
import {
|
||||||
FAULT_MANAGEMENT_ALARMS,
|
FAULT_MANAGEMENT_ALARMS,
|
||||||
FAULT_MANAGEMENT_GLOBAL_ALARMS,
|
FAULT_MANAGEMENT_GLOBAL_ALARMS,
|
||||||
FAULT_MANAGEMENT_SHELVE_DURATIONS_IN_MS,
|
|
||||||
FILTER_ITEMS,
|
FILTER_ITEMS,
|
||||||
SORT_ITEMS
|
SORT_ITEMS
|
||||||
} from './constants.js';
|
} from './constants.js';
|
||||||
@ -88,6 +87,13 @@ const SEARCH_KEYS = [
|
|||||||
'namespace'
|
'namespace'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Helper function for filtering faults
|
||||||
|
function filterFaultsByTerm(faults, searchTerm) {
|
||||||
|
return faults.filter((fault) =>
|
||||||
|
SEARCH_KEYS.some((key) => fault[key]?.toString().toLowerCase().includes(searchTerm))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
FaultManagementListHeader,
|
FaultManagementListHeader,
|
||||||
@ -111,23 +117,18 @@ export default {
|
|||||||
},
|
},
|
||||||
filteredFaultsList() {
|
filteredFaultsList() {
|
||||||
const filterName = FILTER_ITEMS[this.filterIndex];
|
const filterName = FILTER_ITEMS[this.filterIndex];
|
||||||
let list = this.faultsList;
|
let list = this.faultsList.filter((fault) =>
|
||||||
|
filterName === 'Shelved' ? fault.shelved : !fault.shelved
|
||||||
// Exclude shelved alarms from all views except the Shelved view
|
);
|
||||||
if (filterName !== 'Shelved') {
|
|
||||||
list = list.filter((fault) => fault.shelved !== true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filterName === 'Acknowledged') {
|
if (filterName === 'Acknowledged') {
|
||||||
list = list.filter((fault) => fault.acknowledged);
|
list = list.filter((fault) => fault.acknowledged);
|
||||||
} else if (filterName === 'Unacknowledged') {
|
} else if (filterName === 'Unacknowledged') {
|
||||||
list = list.filter((fault) => !fault.acknowledged);
|
list = list.filter((fault) => !fault.acknowledged);
|
||||||
} else if (filterName === 'Shelved') {
|
|
||||||
list = list.filter((fault) => fault.shelved);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.searchTerm.length > 0) {
|
if (this.searchTerm.length > 0) {
|
||||||
list = list.filter(this.filterUsingSearchTerm);
|
list = filterFaultsByTerm(list, this.searchTerm);
|
||||||
}
|
}
|
||||||
|
|
||||||
list.sort(SORT_ITEMS[this.sortBy].sortFunction);
|
list.sort(SORT_ITEMS[this.sortBy].sortFunction);
|
||||||
@ -138,6 +139,9 @@ export default {
|
|||||||
return this.openmct.faults.supportsActions();
|
return this.openmct.faults.supportsActions();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.shelveDurations = this.openmct.faults.getShelveDurations();
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.unsubscribe = this.openmct.faults.subscribe(this.domainObject, this.updateFault);
|
this.unsubscribe = this.openmct.faults.subscribe(this.domainObject, this.updateFault);
|
||||||
},
|
},
|
||||||
@ -158,14 +162,13 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateFaultList() {
|
async updateFaultList() {
|
||||||
this.openmct.faults.request(this.domainObject).then((faultsData) => {
|
const faultsData = await this.openmct.faults.request(this.domainObject);
|
||||||
if (faultsData?.length > 0) {
|
if (faultsData?.length > 0) {
|
||||||
this.faultsList = faultsData.map((fd) => fd.fault);
|
this.faultsList = faultsData.map((fd) => fd.fault);
|
||||||
} else {
|
} else {
|
||||||
this.faultsList = [];
|
this.faultsList = [];
|
||||||
}
|
}
|
||||||
});
|
|
||||||
},
|
},
|
||||||
filterUsingSearchTerm(fault) {
|
filterUsingSearchTerm(fault) {
|
||||||
if (!fault) {
|
if (!fault) {
|
||||||
@ -223,14 +226,29 @@ export default {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
async toggleAcknowledgeSelected(faults = this.selectedFaults) {
|
async toggleAcknowledgeSelected(faults = this.selectedFaults) {
|
||||||
let title = '';
|
const title = this.getAcknowledgeTitle(faults);
|
||||||
if (faults.length > 1) {
|
|
||||||
title = `Acknowledge ${faults.length} selected faults`;
|
|
||||||
} else if (faults.length === 1) {
|
|
||||||
title = `Acknowledge fault: ${faults[0].name}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const formStructure = {
|
const formStructure = this.getAcknowledgeFormStructure(title);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = await this.openmct.forms.showForm(formStructure);
|
||||||
|
this.acknowledgeFaults(faults, data);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
} finally {
|
||||||
|
this.resetSelectedFaultMap();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getAcknowledgeTitle(faults) {
|
||||||
|
if (faults.length > 1) {
|
||||||
|
return `Acknowledge ${faults.length} selected faults`;
|
||||||
|
} else if (faults.length === 1) {
|
||||||
|
return `Acknowledge fault: ${faults[0].name}`;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
getAcknowledgeFormStructure(title) {
|
||||||
|
return {
|
||||||
title,
|
title,
|
||||||
sections: [
|
sections: [
|
||||||
{
|
{
|
||||||
@ -253,17 +271,11 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
},
|
||||||
try {
|
acknowledgeFaults(faults, data) {
|
||||||
const data = await this.openmct.forms.showForm(formStructure);
|
faults.forEach((fault) => {
|
||||||
faults.forEach((fault) => {
|
this.openmct.faults.acknowledgeFault(fault, data);
|
||||||
this.openmct.faults.acknowledgeFault(fault, data);
|
});
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
} finally {
|
|
||||||
this.resetSelectedFaultMap();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
resetSelectedFaultMap() {
|
resetSelectedFaultMap() {
|
||||||
Object.keys(this.selectedFaultMap).forEach((key) => {
|
Object.keys(this.selectedFaultMap).forEach((key) => {
|
||||||
@ -273,7 +285,7 @@ export default {
|
|||||||
async toggleShelveSelected(faults = this.selectedFaults, shelveData = {}) {
|
async toggleShelveSelected(faults = this.selectedFaults, shelveData = {}) {
|
||||||
const { shelved = true } = shelveData;
|
const { shelved = true } = shelveData;
|
||||||
if (shelved) {
|
if (shelved) {
|
||||||
let title =
|
const title =
|
||||||
faults.length > 1
|
faults.length > 1
|
||||||
? `Shelve ${faults.length} selected faults`
|
? `Shelve ${faults.length} selected faults`
|
||||||
: `Shelve fault: ${faults[0].name}`;
|
: `Shelve fault: ${faults[0].name}`;
|
||||||
@ -295,10 +307,10 @@ export default {
|
|||||||
key: 'shelveDuration',
|
key: 'shelveDuration',
|
||||||
control: 'select',
|
control: 'select',
|
||||||
name: 'Shelve duration',
|
name: 'Shelve duration',
|
||||||
options: FAULT_MANAGEMENT_SHELVE_DURATIONS_IN_MS,
|
options: this.shelveDurations,
|
||||||
required: false,
|
required: false,
|
||||||
cssClass: 'l-input-lg',
|
cssClass: 'l-input-lg',
|
||||||
value: FAULT_MANAGEMENT_SHELVE_DURATIONS_IN_MS[0].value
|
value: this.shelveDurations[0].value
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -319,18 +331,16 @@ export default {
|
|||||||
|
|
||||||
shelveData.comment = data.comment || '';
|
shelveData.comment = data.comment || '';
|
||||||
shelveData.shelveDuration =
|
shelveData.shelveDuration =
|
||||||
data.shelveDuration !== undefined
|
data.shelveDuration === undefined ? this.shelveDurations[0].value : data.shelveDuration;
|
||||||
? data.shelveDuration
|
|
||||||
: FAULT_MANAGEMENT_SHELVE_DURATIONS_IN_MS[0].value;
|
|
||||||
} else {
|
} else {
|
||||||
shelveData = {
|
shelveData = {
|
||||||
shelved: false
|
shelved: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.values(faults).forEach((selectedFault) => {
|
await Promise.all(
|
||||||
this.openmct.faults.shelveFault(selectedFault, shelveData);
|
faults.map((selectedFault) => this.openmct.faults.shelveFault(selectedFault, shelveData))
|
||||||
});
|
);
|
||||||
|
|
||||||
this.selectedFaultMap = {};
|
this.selectedFaultMap = {};
|
||||||
},
|
},
|
||||||
|
@ -42,24 +42,6 @@ export const FAULT_MANAGEMENT_TYPE = 'faultManagement';
|
|||||||
export const FAULT_MANAGEMENT_INSPECTOR = 'faultManagementInspector';
|
export const FAULT_MANAGEMENT_INSPECTOR = 'faultManagementInspector';
|
||||||
export const FAULT_MANAGEMENT_ALARMS = 'alarms';
|
export const FAULT_MANAGEMENT_ALARMS = 'alarms';
|
||||||
export const FAULT_MANAGEMENT_GLOBAL_ALARMS = 'global-alarm-status';
|
export const FAULT_MANAGEMENT_GLOBAL_ALARMS = 'global-alarm-status';
|
||||||
export const FAULT_MANAGEMENT_SHELVE_DURATIONS_IN_MS = [
|
|
||||||
{
|
|
||||||
name: '5 Minutes',
|
|
||||||
value: 300000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '10 Minutes',
|
|
||||||
value: 600000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '15 Minutes',
|
|
||||||
value: 900000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Indefinite',
|
|
||||||
value: 0
|
|
||||||
}
|
|
||||||
];
|
|
||||||
export const FAULT_MANAGEMENT_VIEW = 'faultManagement.view';
|
export const FAULT_MANAGEMENT_VIEW = 'faultManagement.view';
|
||||||
export const FAULT_MANAGEMENT_NAMESPACE = 'faults.taxonomy';
|
export const FAULT_MANAGEMENT_NAMESPACE = 'faults.taxonomy';
|
||||||
export const FILTER_ITEMS = ['Standard View', 'Acknowledged', 'Unacknowledged', 'Shelved'];
|
export const FILTER_ITEMS = ['Standard View', 'Acknowledged', 'Unacknowledged', 'Shelved'];
|
||||||
|
@ -27,9 +27,9 @@ To define a filter, you'll need to add a new `filter` property to the domain obj
|
|||||||
singleSelectionThreshold: true,
|
singleSelectionThreshold: true,
|
||||||
comparator: 'equals',
|
comparator: 'equals',
|
||||||
possibleValues: [
|
possibleValues: [
|
||||||
{ name: 'Apple', value: 'apple' },
|
{ label: 'Apple', value: 'apple' },
|
||||||
{ name: 'Banana', value: 'banana' },
|
{ label: 'Banana', value: 'banana' },
|
||||||
{ name: 'Orange', value: 'orange' }
|
{ label: 'Orange', value: 'orange' }
|
||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ class EditPropertiesAction extends PropertiesAction {
|
|||||||
const definition = this._getTypeDefinition(object.type);
|
const definition = this._getTypeDefinition(object.type);
|
||||||
const persistable = this.openmct.objects.isPersistable(object.identifier);
|
const persistable = this.openmct.objects.isPersistable(object.identifier);
|
||||||
|
|
||||||
return persistable && definition && definition.creatable;
|
return persistable && definition && definition.creatable && !object.locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
invoke(objectPath) {
|
invoke(objectPath) {
|
||||||
|
@ -649,6 +649,11 @@ export default {
|
|||||||
},
|
},
|
||||||
request(domainObject = this.telemetryObject) {
|
request(domainObject = this.telemetryObject) {
|
||||||
this.metadata = this.openmct.telemetry.getMetadata(domainObject);
|
this.metadata = this.openmct.telemetry.getMetadata(domainObject);
|
||||||
|
|
||||||
|
if (!this.metadata) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.formats = this.openmct.telemetry.getFormatMap(this.metadata);
|
this.formats = this.openmct.telemetry.getFormatMap(this.metadata);
|
||||||
const LimitEvaluator = this.openmct.telemetry.getLimits(domainObject);
|
const LimitEvaluator = this.openmct.telemetry.getLimits(domainObject);
|
||||||
LimitEvaluator.limits().then(this.updateLimits);
|
LimitEvaluator.limits().then(this.updateLimits);
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
<img
|
<img
|
||||||
ref="img"
|
ref="img"
|
||||||
class="c-thumb__image"
|
class="c-thumb__image"
|
||||||
:src="`${image.thumbnailUrl || image.url}`"
|
:src="imageSrc"
|
||||||
fetchpriority="low"
|
fetchpriority="low"
|
||||||
@load="imageLoadCompleted"
|
@load="imageLoadCompleted"
|
||||||
/>
|
/>
|
||||||
@ -54,6 +54,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { encode_url } from '../../../utils/encoding';
|
||||||
|
|
||||||
const THUMB_PADDING = 4;
|
const THUMB_PADDING = 4;
|
||||||
const BORDER_WIDTH = 2;
|
const BORDER_WIDTH = 2;
|
||||||
|
|
||||||
@ -96,6 +98,9 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
imageSrc() {
|
||||||
|
return `${encode_url(this.image.thumbnailUrl) || encode_url(this.image.url)}`;
|
||||||
|
},
|
||||||
ariaLabel() {
|
ariaLabel() {
|
||||||
return `Image thumbnail from ${this.image.formattedTime}${this.showAnnotationIndicator ? ', has annotations' : ''}`;
|
return `Image thumbnail from ${this.image.formattedTime}${this.showAnnotationIndicator ? ', has annotations' : ''}`;
|
||||||
},
|
},
|
||||||
|
@ -370,6 +370,7 @@ export default {
|
|||||||
createImageWrapper(index, image, showImagePlaceholders) {
|
createImageWrapper(index, image, showImagePlaceholders) {
|
||||||
const id = `${ID_PREFIX}${image.time}`;
|
const id = `${ID_PREFIX}${image.time}`;
|
||||||
let imageWrapper = document.createElement('div');
|
let imageWrapper = document.createElement('div');
|
||||||
|
imageWrapper.ariaLabel = id;
|
||||||
imageWrapper.classList.add(IMAGE_WRAPPER_CLASS);
|
imageWrapper.classList.add(IMAGE_WRAPPER_CLASS);
|
||||||
imageWrapper.style.left = `${this.xScale(image.time)}px`;
|
imageWrapper.style.left = `${this.xScale(image.time)}px`;
|
||||||
this.setNSAttributesForElement(imageWrapper, {
|
this.setNSAttributesForElement(imageWrapper, {
|
||||||
|
@ -222,6 +222,7 @@ import { TIME_CONTEXT_EVENTS } from '@/api/time/constants.js';
|
|||||||
import imageryData from '@/plugins/imagery/mixins/imageryData.js';
|
import imageryData from '@/plugins/imagery/mixins/imageryData.js';
|
||||||
import { VIEW_LARGE_ACTION_KEY } from '@/plugins/viewLargeAction/viewLargeAction.js';
|
import { VIEW_LARGE_ACTION_KEY } from '@/plugins/viewLargeAction/viewLargeAction.js';
|
||||||
|
|
||||||
|
import { encode_url } from '../../../utils/encoding';
|
||||||
import eventHelpers from '../lib/eventHelpers.js';
|
import eventHelpers from '../lib/eventHelpers.js';
|
||||||
import AnnotationsCanvas from './AnnotationsCanvas.vue';
|
import AnnotationsCanvas from './AnnotationsCanvas.vue';
|
||||||
import Compass from './Compass/CompassComponent.vue';
|
import Compass from './Compass/CompassComponent.vue';
|
||||||
@ -364,7 +365,7 @@ export default {
|
|||||||
filter: `brightness(${this.filters.brightness}%) contrast(${this.filters.contrast}%)`,
|
filter: `brightness(${this.filters.brightness}%) contrast(${this.filters.contrast}%)`,
|
||||||
backgroundImage: `${
|
backgroundImage: `${
|
||||||
this.imageUrl
|
this.imageUrl
|
||||||
? `url(${this.imageUrl}),
|
? `url(${encode_url(this.imageUrl)}),
|
||||||
repeating-linear-gradient(
|
repeating-linear-gradient(
|
||||||
45deg,
|
45deg,
|
||||||
transparent,
|
transparent,
|
||||||
@ -620,7 +621,7 @@ export default {
|
|||||||
if (matchIndex > -1) {
|
if (matchIndex > -1) {
|
||||||
this.setFocusedImage(matchIndex);
|
this.setFocusedImage(matchIndex);
|
||||||
} else {
|
} else {
|
||||||
this.paused();
|
this.paused(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -789,7 +790,7 @@ export default {
|
|||||||
},
|
},
|
||||||
getVisibleLayerStyles(layer) {
|
getVisibleLayerStyles(layer) {
|
||||||
return {
|
return {
|
||||||
backgroundImage: `url(${layer.source})`,
|
backgroundImage: `url(${encode_url(layer.source)})`,
|
||||||
transform: `scale(${this.zoomFactor}) translate(${this.imageTranslateX / 2}px, ${
|
transform: `scale(${this.zoomFactor}) translate(${this.imageTranslateX / 2}px, ${
|
||||||
this.imageTranslateY / 2
|
this.imageTranslateY / 2
|
||||||
}px)`,
|
}px)`,
|
||||||
@ -1082,7 +1083,7 @@ export default {
|
|||||||
paused(state) {
|
paused(state) {
|
||||||
this.isPaused = Boolean(state);
|
this.isPaused = Boolean(state);
|
||||||
|
|
||||||
if (!state) {
|
if (!this.isPaused) {
|
||||||
this.previousFocusedImage = null;
|
this.previousFocusedImage = null;
|
||||||
this.setFocusedImage(this.nextImageIndex);
|
this.setFocusedImage(this.nextImageIndex);
|
||||||
this.autoScroll = true;
|
this.autoScroll = true;
|
||||||
|
@ -90,16 +90,17 @@ export default {
|
|||||||
dataCleared() {
|
dataCleared() {
|
||||||
this.imageHistory = [];
|
this.imageHistory = [];
|
||||||
},
|
},
|
||||||
dataRemoved(dataToRemove) {
|
dataRemoved(removed) {
|
||||||
this.imageHistory = this.imageHistory.filter((existingDatum) => {
|
const removedTimestamps = {};
|
||||||
const shouldKeep = dataToRemove.some((datumToRemove) => {
|
removed.forEach((_removed) => {
|
||||||
const existingDatumTimestamp = this.parseTime(existingDatum);
|
const removedTimestamp = this.parseTime(_removed);
|
||||||
const datumToRemoveTimestamp = this.parseTime(datumToRemove);
|
removedTimestamps[removedTimestamp] = true;
|
||||||
|
});
|
||||||
|
|
||||||
return existingDatumTimestamp !== datumToRemoveTimestamp;
|
this.imageHistory = this.imageHistory.filter((image) => {
|
||||||
});
|
const imageTimestamp = this.parseTime(image);
|
||||||
|
|
||||||
return shouldKeep;
|
return !removedTimestamps[imageTimestamp];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
setDataTimeContext() {
|
setDataTimeContext() {
|
||||||
|
@ -96,6 +96,8 @@ export default {
|
|||||||
const createdTimestamp = this.domainObject.created;
|
const createdTimestamp = this.domainObject.created;
|
||||||
const createdBy = this.domainObject.createdBy ? this.domainObject.createdBy : UNKNOWN_USER;
|
const createdBy = this.domainObject.createdBy ? this.domainObject.createdBy : UNKNOWN_USER;
|
||||||
const modifiedBy = this.domainObject.modifiedBy ? this.domainObject.modifiedBy : UNKNOWN_USER;
|
const modifiedBy = this.domainObject.modifiedBy ? this.domainObject.modifiedBy : UNKNOWN_USER;
|
||||||
|
const locked = this.domainObject.locked;
|
||||||
|
const lockedBy = this.domainObject.lockedBy ?? UNKNOWN_USER;
|
||||||
const modifiedTimestamp = this.domainObject.modified
|
const modifiedTimestamp = this.domainObject.modified
|
||||||
? this.domainObject.modified
|
? this.domainObject.modified
|
||||||
: this.domainObject.created;
|
: this.domainObject.created;
|
||||||
@ -148,6 +150,13 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (locked === true) {
|
||||||
|
details.push({
|
||||||
|
name: 'Locked By',
|
||||||
|
value: lockedBy
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (version) {
|
if (version) {
|
||||||
details.push({
|
details.push({
|
||||||
name: 'Version',
|
name: 'Version',
|
||||||
|
@ -344,12 +344,19 @@ export default {
|
|||||||
},
|
},
|
||||||
beforeMount() {
|
beforeMount() {
|
||||||
this.marked = new Marked();
|
this.marked = new Marked();
|
||||||
this.renderer = new this.marked.Renderer();
|
this.marked.use({
|
||||||
|
breaks: true,
|
||||||
|
extensions: [
|
||||||
|
{
|
||||||
|
name: 'link',
|
||||||
|
renderer: (options) => {
|
||||||
|
return this.validateLink(options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
const originalLinkRenderer = this.renderer.link;
|
|
||||||
this.renderer.link = this.validateLink.bind(this, originalLinkRenderer);
|
|
||||||
|
|
||||||
this.manageEmbedLayout = _.debounce(this.manageEmbedLayout, 400);
|
this.manageEmbedLayout = _.debounce(this.manageEmbedLayout, 400);
|
||||||
|
|
||||||
if (this.$refs.embedsWrapper) {
|
if (this.$refs.embedsWrapper) {
|
||||||
@ -437,10 +444,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
convertMarkDownToHtml(text = '') {
|
convertMarkDownToHtml(text = '') {
|
||||||
let markDownHtml = this.marked.parse(text, {
|
let markDownHtml = this.marked.parse(text);
|
||||||
breaks: true,
|
|
||||||
renderer: this.renderer
|
|
||||||
});
|
|
||||||
markDownHtml = sanitizeHtml(markDownHtml, SANITIZATION_SCHEMA);
|
markDownHtml = sanitizeHtml(markDownHtml, SANITIZATION_SCHEMA);
|
||||||
return markDownHtml;
|
return markDownHtml;
|
||||||
},
|
},
|
||||||
@ -451,21 +455,19 @@ export default {
|
|||||||
this.$refs.entryInput.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
this.$refs.entryInput.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
validateLink(originalLinkRenderer, href, title, text) {
|
validateLink(options) {
|
||||||
|
const { href, text } = options;
|
||||||
try {
|
try {
|
||||||
const domain = new URL(href).hostname;
|
const domain = new URL(href).hostname;
|
||||||
const urlIsWhitelisted = this.urlWhitelist.some((partialDomain) => {
|
const urlIsWhitelisted = this.urlWhitelist.some((partialDomain) => {
|
||||||
return domain.endsWith(partialDomain);
|
return domain.endsWith(partialDomain);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!urlIsWhitelisted) {
|
if (!urlIsWhitelisted) {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
const linkHtml = originalLinkRenderer.call(this.renderer, href, title, text);
|
|
||||||
const linkHtmlWithTarget = linkHtml.replace(
|
return `<a class="c-hyperlink" target="_blank" href="${href}">${text}</a>`;
|
||||||
/^<a /,
|
|
||||||
'<a class="c-hyperlink" target="_blank"'
|
|
||||||
);
|
|
||||||
return linkHtmlWithTarget;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// had error parsing this URL, just return the text
|
// had error parsing this URL, just return the text
|
||||||
return text;
|
return text;
|
||||||
|
@ -19,14 +19,23 @@
|
|||||||
* 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.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
const PERFORMANCE_OVERLAY_RENDER_INTERVAL = 1000;
|
||||||
|
|
||||||
export default function PerformanceIndicator() {
|
export default function PerformanceIndicator() {
|
||||||
return function install(openmct) {
|
return function install(openmct) {
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
let lastCalculated = performance.now();
|
let lastCalculated = performance.now();
|
||||||
const indicator = openmct.indicators.simpleIndicator();
|
openmct.performance = {
|
||||||
|
measurements: new Map()
|
||||||
|
};
|
||||||
|
|
||||||
|
const indicator = openmct.indicators.simpleIndicator();
|
||||||
|
indicator.key = 'performance-indicator';
|
||||||
indicator.text('~ fps');
|
indicator.text('~ fps');
|
||||||
|
indicator.description('Performance Indicator');
|
||||||
indicator.statusClass('s-status-info');
|
indicator.statusClass('s-status-info');
|
||||||
|
indicator.on('click', showOverlay);
|
||||||
|
|
||||||
openmct.indicators.add(indicator);
|
openmct.indicators.add(indicator);
|
||||||
|
|
||||||
let rafHandle = requestAnimationFrame(incrementFrames);
|
let rafHandle = requestAnimationFrame(incrementFrames);
|
||||||
@ -58,5 +67,58 @@ export default function PerformanceIndicator() {
|
|||||||
indicator.statusClass('s-status-error');
|
indicator.statusClass('s-status-error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showOverlay() {
|
||||||
|
const overlayStylesText = `
|
||||||
|
#c-performance-indicator--overlay {
|
||||||
|
background-color:rgba(0,0,0,0.5);
|
||||||
|
position: absolute;
|
||||||
|
width: 300px;
|
||||||
|
left: calc(50% - 300px);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
const overlayMarkup = `
|
||||||
|
<div id="c-performance-indicator--overlay" title="Performance Overlay">
|
||||||
|
<table id="c-performance-indicator--table">
|
||||||
|
<tr class="c-performance-indicator--row"><td class="c-performance-indicator--measurement-name"></td><td class="c-performance-indicator--measurement-value"></td></tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
const overlayTemplate = document.createElement('div');
|
||||||
|
overlayTemplate.innerHTML = overlayMarkup;
|
||||||
|
const overlay = overlayTemplate.cloneNode(true);
|
||||||
|
overlay.querySelector('.c-performance-indicator--row').remove();
|
||||||
|
const overlayStyles = document.createElement('style');
|
||||||
|
overlayStyles.appendChild(document.createTextNode(overlayStylesText));
|
||||||
|
|
||||||
|
document.head.appendChild(overlayStyles);
|
||||||
|
document.body.appendChild(overlay);
|
||||||
|
|
||||||
|
indicator.off('click', showOverlay);
|
||||||
|
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
overlay.querySelector('#c-performance-indicator--table').innerHTML = '';
|
||||||
|
|
||||||
|
for (const [name, value] of openmct.performance.measurements.entries()) {
|
||||||
|
const newRow = overlayTemplate
|
||||||
|
.querySelector('.c-performance-indicator--row')
|
||||||
|
.cloneNode(true);
|
||||||
|
newRow.querySelector('.c-performance-indicator--measurement-name').innerText = name;
|
||||||
|
newRow.querySelector('.c-performance-indicator--measurement-value').innerText = value;
|
||||||
|
overlay.querySelector('#c-performance-indicator--table').appendChild(newRow);
|
||||||
|
}
|
||||||
|
}, PERFORMANCE_OVERLAY_RENDER_INTERVAL);
|
||||||
|
|
||||||
|
indicator.on(
|
||||||
|
'click',
|
||||||
|
() => {
|
||||||
|
overlayStyles.remove();
|
||||||
|
overlay.remove();
|
||||||
|
indicator.on('click', showOverlay);
|
||||||
|
clearInterval(interval);
|
||||||
|
},
|
||||||
|
{ once: true, capture: true }
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -434,16 +434,63 @@ class CouchObjectProvider {
|
|||||||
return Promise.resolve([]);
|
return Promise.resolve([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getObjectsByView({ designDoc, viewName, keysToSearch }, abortSignal) {
|
async isViewDefined(designDoc, viewName) {
|
||||||
const stringifiedKeys = JSON.stringify(keysToSearch);
|
const url = `${this.url}/_design/${designDoc}/_view/${viewName}`;
|
||||||
const url = `${this.url}/_design/${designDoc}/_view/${viewName}?keys=${stringifiedKeys}&include_docs=true`;
|
const response = await fetch(url, {
|
||||||
|
method: 'HEAD'
|
||||||
|
});
|
||||||
|
|
||||||
|
return response.ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef GetObjectByViewOptions
|
||||||
|
* @property {String} designDoc the name of the design document that the view belongs to
|
||||||
|
* @property {String} viewName
|
||||||
|
* @property {Array.<String>} [keysToSearch] a list of discrete view keys to search for. View keys are not object identifiers.
|
||||||
|
* @property {String} [startKey] limit the search to a range of keys starting with the provided `startKey`. One of `keysToSearch` OR `startKey` AND `endKey` must be provided
|
||||||
|
* @property {String} [endKey] limit the search to a range of keys ending with the provided `endKey`. One of `keysToSearch` OR `startKey` AND `endKey` must be provided
|
||||||
|
* @property {Number} [limit] limit the number of results returned
|
||||||
|
* @property {String} [objectIdField] The field (either key or value) to treat as an object key. If provided, include_docs will be set to false in the request, and the field will be used as an object identifier. A bulk request will be used to resolve objects from identifiers
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Return objects based on a call to a view. See https://docs.couchdb.org/en/stable/api/ddoc/views.html.
|
||||||
|
* @param {GetObjectByViewOptions} options
|
||||||
|
* @param {AbortSignal} abortSignal
|
||||||
|
* @returns {Promise<Array.<import('openmct.js').DomainObject>>}
|
||||||
|
*/
|
||||||
|
async getObjectsByView(
|
||||||
|
{ designDoc, viewName, keysToSearch, startKey, endKey, limit, objectIdField },
|
||||||
|
abortSignal
|
||||||
|
) {
|
||||||
|
let stringifiedKeys = JSON.stringify(keysToSearch);
|
||||||
|
const url = `${this.url}/_design/${designDoc}/_view/${viewName}`;
|
||||||
|
const requestBody = {};
|
||||||
|
if (objectIdField === undefined) {
|
||||||
|
requestBody.include_docs = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startKey !== undefined && endKey !== undefined) {
|
||||||
|
/* spell-checker: disable */
|
||||||
|
requestBody.startkey = startKey;
|
||||||
|
requestBody.endkey = endKey;
|
||||||
|
/* spell-checker: enable */
|
||||||
|
} else {
|
||||||
|
requestBody.keys = stringifiedKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (limit !== undefined) {
|
||||||
|
requestBody.limit = limit;
|
||||||
|
}
|
||||||
|
|
||||||
let objectModels = [];
|
let objectModels = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
method: 'GET',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
signal: abortSignal
|
signal: abortSignal,
|
||||||
|
body: JSON.stringify(requestBody)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@ -454,13 +501,21 @@ class CouchObjectProvider {
|
|||||||
|
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
const couchRows = result.rows;
|
const couchRows = result.rows;
|
||||||
couchRows.forEach((couchRow) => {
|
if (objectIdField !== undefined) {
|
||||||
const couchDoc = couchRow.doc;
|
const objectIdsToResolve = [];
|
||||||
const objectModel = this.#getModel(couchDoc);
|
couchRows.forEach((couchRow) => {
|
||||||
if (objectModel) {
|
objectIdsToResolve.push(couchRow[objectIdField]);
|
||||||
objectModels.push(objectModel);
|
});
|
||||||
}
|
objectModels = Object.values(await this.#bulkGet(objectIdsToResolve), abortSignal);
|
||||||
});
|
} else {
|
||||||
|
couchRows.forEach((couchRow) => {
|
||||||
|
const couchDoc = couchRow.doc;
|
||||||
|
const objectModel = this.#getModel(couchDoc);
|
||||||
|
if (objectModel) {
|
||||||
|
objectModels.push(objectModel);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,11 @@ class CouchSearchProvider {
|
|||||||
#bulkPromise;
|
#bulkPromise;
|
||||||
#batchIds;
|
#batchIds;
|
||||||
#lastAbortSignal;
|
#lastAbortSignal;
|
||||||
|
#isSearchByNameViewDefined;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {import('./CouchObjectProvider').default} couchObjectProvider
|
||||||
|
*/
|
||||||
constructor(couchObjectProvider) {
|
constructor(couchObjectProvider) {
|
||||||
this.couchObjectProvider = couchObjectProvider;
|
this.couchObjectProvider = couchObjectProvider;
|
||||||
this.searchTypes = couchObjectProvider.openmct.objects.SEARCH_TYPES;
|
this.searchTypes = couchObjectProvider.openmct.objects.SEARCH_TYPES;
|
||||||
@ -67,18 +71,47 @@ class CouchSearchProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchForObjects(query, abortSignal) {
|
#isOptimizedSearchByNameSupported() {
|
||||||
const filter = {
|
let isOptimizedSearchAvailable;
|
||||||
selector: {
|
|
||||||
model: {
|
if (this.#isSearchByNameViewDefined === undefined) {
|
||||||
name: {
|
isOptimizedSearchAvailable = this.#isSearchByNameViewDefined =
|
||||||
$regex: `(?i)${query}`
|
this.couchObjectProvider.isViewDefined('object_names', 'object_names');
|
||||||
|
} else {
|
||||||
|
isOptimizedSearchAvailable = this.#isSearchByNameViewDefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isOptimizedSearchAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
async searchForObjects(query, abortSignal) {
|
||||||
|
const preparedQuery = query.toLowerCase().trim();
|
||||||
|
const supportsOptimizedSearchByName = await this.#isOptimizedSearchByNameSupported();
|
||||||
|
|
||||||
|
if (supportsOptimizedSearchByName) {
|
||||||
|
return this.couchObjectProvider.getObjectsByView(
|
||||||
|
{
|
||||||
|
designDoc: 'object_names',
|
||||||
|
viewName: 'object_names',
|
||||||
|
startKey: preparedQuery,
|
||||||
|
endKey: preparedQuery + '\\ufff0',
|
||||||
|
objectIdField: 'value',
|
||||||
|
limit: 1000
|
||||||
|
},
|
||||||
|
abortSignal
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const filter = {
|
||||||
|
selector: {
|
||||||
|
model: {
|
||||||
|
name: {
|
||||||
|
$regex: `(?i)${query}`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
return this.couchObjectProvider.getObjectsByFilter(filter);
|
||||||
|
}
|
||||||
return this.couchObjectProvider.getObjectsByFilter(filter, abortSignal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async #deferBatchAnnotationSearch() {
|
async #deferBatchAnnotationSearch() {
|
||||||
|
@ -373,44 +373,6 @@ describe('the plugin', () => {
|
|||||||
expect(requestMethod).toEqual('PUT');
|
expect(requestMethod).toEqual('PUT');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('implements server-side search', () => {
|
|
||||||
let mockPromise;
|
|
||||||
beforeEach(() => {
|
|
||||||
mockPromise = Promise.resolve({
|
|
||||||
body: {
|
|
||||||
getReader() {
|
|
||||||
return {
|
|
||||||
read() {
|
|
||||||
return Promise.resolve({
|
|
||||||
done: true,
|
|
||||||
value: undefined
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fetch.and.returnValue(mockPromise);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("using Couch's 'find' endpoint", async () => {
|
|
||||||
await Promise.all(openmct.objects.search('test'));
|
|
||||||
const requestUrl = fetch.calls.mostRecent().args[0];
|
|
||||||
|
|
||||||
// we only want one call to fetch, not 2!
|
|
||||||
// see https://github.com/nasa/openmct/issues/4667
|
|
||||||
expect(fetch).toHaveBeenCalledTimes(1);
|
|
||||||
expect(requestUrl.endsWith('_find')).toBeTrue();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('and supports search by object name', async () => {
|
|
||||||
await Promise.all(openmct.objects.search('test'));
|
|
||||||
const requestPayload = JSON.parse(fetch.calls.mostRecent().args[1].body);
|
|
||||||
|
|
||||||
expect(requestPayload).toBeDefined();
|
|
||||||
expect(requestPayload.selector.model.name.$regex).toEqual('(?i)test');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('the view', () => {
|
describe('the view', () => {
|
||||||
|
191
src/plugins/persistence/couch/scripts/lockObjects.mjs
Normal file
191
src/plugins/persistence/couch/scripts/lockObjects.mjs
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
import http from 'http';
|
||||||
|
import nano from 'nano';
|
||||||
|
import { parseArgs } from 'util';
|
||||||
|
|
||||||
|
const COUCH_URL = process.env.OPENMCT_COUCH_URL || 'http://127.0.0.1:5984';
|
||||||
|
const COUCH_DB_NAME = process.env.OPENMCT_DATABASE_NAME || 'openmct';
|
||||||
|
|
||||||
|
const {
|
||||||
|
values: { couchUrl, database, lock, unlock, startObjectKeystring, user, pass }
|
||||||
|
} = parseArgs({
|
||||||
|
options: {
|
||||||
|
couchUrl: {
|
||||||
|
type: 'string',
|
||||||
|
default: COUCH_URL
|
||||||
|
},
|
||||||
|
database: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'd',
|
||||||
|
default: COUCH_DB_NAME
|
||||||
|
},
|
||||||
|
lock: {
|
||||||
|
type: 'boolean',
|
||||||
|
short: 'l'
|
||||||
|
},
|
||||||
|
unlock: {
|
||||||
|
type: 'boolean',
|
||||||
|
short: 'u'
|
||||||
|
},
|
||||||
|
startObjectKeystring: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'o',
|
||||||
|
default: 'mine'
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
pass: {
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const BATCH_SIZE = 100;
|
||||||
|
const SOCKET_POOL_SIZE = 100;
|
||||||
|
|
||||||
|
const locked = lock === true;
|
||||||
|
console.info(`Connecting to ${couchUrl}/${database}`);
|
||||||
|
console.info(`${locked ? 'Locking' : 'Unlocking'} all children of ${startObjectKeystring}`);
|
||||||
|
|
||||||
|
const poolingAgent = new http.Agent({
|
||||||
|
keepAlive: true,
|
||||||
|
maxSockets: SOCKET_POOL_SIZE
|
||||||
|
});
|
||||||
|
|
||||||
|
const db = nano({
|
||||||
|
url: couchUrl,
|
||||||
|
requestDefaults: {
|
||||||
|
agent: poolingAgent
|
||||||
|
}
|
||||||
|
}).use(database);
|
||||||
|
db.auth(user, pass);
|
||||||
|
|
||||||
|
if (!unlock && !lock) {
|
||||||
|
throw new Error('Either -l or -u option is required');
|
||||||
|
}
|
||||||
|
|
||||||
|
const startObjectIdentifier = keystringToIdentifier(startObjectKeystring);
|
||||||
|
const documentBatch = [];
|
||||||
|
const alreadySeen = new Set();
|
||||||
|
let updatedDocumentCount = 0;
|
||||||
|
|
||||||
|
await processObjectTreeFrom(startObjectIdentifier);
|
||||||
|
//Persist final batch
|
||||||
|
await persistBatch();
|
||||||
|
console.log(`Processed ${updatedDocumentCount} documents`);
|
||||||
|
|
||||||
|
function processObjectTreeFrom(parentObjectIdentifier) {
|
||||||
|
//1. Fetch document for identifier;
|
||||||
|
return fetchDocument(parentObjectIdentifier)
|
||||||
|
.then(async (document) => {
|
||||||
|
if (document !== undefined) {
|
||||||
|
if (!alreadySeen.has(document._id)) {
|
||||||
|
alreadySeen.add(document._id);
|
||||||
|
//2. Lock or unlock object
|
||||||
|
document.model.locked = locked;
|
||||||
|
document.model.disallowUnlock = locked;
|
||||||
|
|
||||||
|
if (locked) {
|
||||||
|
document.model.lockedBy = 'script';
|
||||||
|
} else {
|
||||||
|
delete document.model.lockedBy;
|
||||||
|
}
|
||||||
|
//3. Push document to a batch
|
||||||
|
documentBatch.push(document);
|
||||||
|
//4. Persist batch if necessary, reporting failures
|
||||||
|
await persistBatchIfNeeded();
|
||||||
|
//5. Repeat for each composee
|
||||||
|
const composition = document.model.composition || [];
|
||||||
|
return Promise.all(
|
||||||
|
composition.map((composee) => {
|
||||||
|
return processObjectTreeFrom(composee);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log(`Error ${error}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchDocument(identifierOrKeystring) {
|
||||||
|
let keystring;
|
||||||
|
if (typeof identifierOrKeystring === 'object') {
|
||||||
|
keystring = identifierToKeystring(identifierOrKeystring);
|
||||||
|
} else {
|
||||||
|
keystring = identifierOrKeystring;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const document = await db.get(keystring);
|
||||||
|
|
||||||
|
return document;
|
||||||
|
} catch (error) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function persistBatchIfNeeded() {
|
||||||
|
if (documentBatch.length >= BATCH_SIZE) {
|
||||||
|
return persistBatch();
|
||||||
|
} else {
|
||||||
|
//Noop - batch is not big enough yet
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function persistBatch() {
|
||||||
|
try {
|
||||||
|
const localBatch = [].concat(documentBatch);
|
||||||
|
|
||||||
|
//Immediately clear the shared batch array. This asynchronous process is non-blocking, and
|
||||||
|
//we don't want to try and persist the same batch multiple times while we are waiting for
|
||||||
|
//the subsequent bulk operation to complete.
|
||||||
|
updatedDocumentCount += documentBatch.length;
|
||||||
|
|
||||||
|
documentBatch.splice(0, documentBatch.length);
|
||||||
|
const response = await db.bulk({ docs: localBatch });
|
||||||
|
|
||||||
|
if (response instanceof Array) {
|
||||||
|
response.forEach((r) => {
|
||||||
|
console.info(JSON.stringify(r));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.info(JSON.stringify(response));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof Array) {
|
||||||
|
error.forEach((e) => console.error(JSON.stringify(e)));
|
||||||
|
} else {
|
||||||
|
console.error(`${error.statusCode} - ${error.reason}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function keystringToIdentifier(keystring) {
|
||||||
|
const tokens = keystring.split(':');
|
||||||
|
if (tokens.length === 2) {
|
||||||
|
return {
|
||||||
|
namespace: tokens[0],
|
||||||
|
key: tokens[1]
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
namespace: '',
|
||||||
|
key: tokens[0]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function identifierToKeystring(identifier) {
|
||||||
|
if (typeof identifier === 'string') {
|
||||||
|
return identifier;
|
||||||
|
} else if (typeof identifier === 'object') {
|
||||||
|
if (identifier.namespace) {
|
||||||
|
return `${identifier.namespace}:${identifier.key}`;
|
||||||
|
} else {
|
||||||
|
return identifier.key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user