Compare commits
	
		
			49 Commits
		
	
	
		
			composable
			...
			hex-values
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 6633c0557a | ||
|   | e449fd0eda | ||
|   | 7d25c967a5 | ||
|   | dc9bd8bcb1 | ||
|   | 29d83e9c6d | ||
|   | 6393a77c19 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 6bbabf9c45 | ||
|   | f18d1d2a51 | ||
|   | 5894c66df1 | ||
|   | 6ff8c42041 | ||
|   | 9870a6bc9c | ||
|   | 317ea8c275 | ||
|   | bc36a93b9b | ||
|   | 847232d64b | ||
|   | 4fbccd4c91 | ||
|   | cd560bceed | ||
|   | e08633214e | ||
|   | a9ad0bf38a | ||
|   | 5f8d6899d2 | ||
|   | cd6adbadde | ||
|   | 539b43325a | ||
|   | eeb8e9704b | ||
|   | 0aceb4b590 | ||
|   | 82fa4c1597 | ||
|   | ee5081f807 | ||
|   | 3cbaa7bf07 | ||
|   | 18e4b9da65 | ||
|   | d42aa545bb | ||
|   | 69b81c00ca | ||
|   | 068ac4899d | ||
|   | f8d936a834 | ||
|   | 5c21c34568 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 0eea2e0bbc | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 61acc91200 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | a52982d2bf | ||
|   | 1d40b134b6 | ||
|   | 735c8236e5 | ||
|   | dc5a3236b3 | ||
|   | 60e1eeba8e | ||
|   | 1fc6056c51 | ||
|   | b9df97e2bc | ||
|   | b985619d16 | ||
|   | 3e31bbef97 | ||
|   | 3e5ada8f5f | ||
|   | 2b2c74da9c | ||
|   | 450cab428f | ||
|   | 0340fe18fa | ||
|   | 114864429a | ||
|   | 4cf63062c0 | 
| @@ -5,20 +5,20 @@ executors: | ||||
|       - image: mcr.microsoft.com/playwright:v1.39.0-focal | ||||
|     environment: | ||||
|       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_LOGLEVEL: 'debug' # Enable DEBUG level logging for Percy (Issue: https://github.com/nasa/openmct/issues/5742) | ||||
|       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) | ||||
|   ubuntu: | ||||
|     machine: | ||||
|       image: ubuntu-2204:current | ||||
|       docker_layer_caching: true | ||||
| parameters: | ||||
|   BUST_CACHE: | ||||
|     description: 'Set this with the CircleCI UI Trigger Workflow button (boolean = true) to bust the cache!' | ||||
|     description: "Set this with the CircleCI UI Trigger Workflow button (boolean = true) to bust the cache!" | ||||
|     default: false | ||||
|     type: boolean | ||||
| commands: | ||||
|   build_and_install: | ||||
|     description: 'All steps used to build and install. Will use cache if found' | ||||
|     description: "All steps used to build and install. Will use cache if found" | ||||
|     parameters: | ||||
|       node-version: | ||||
|         type: string | ||||
| @@ -30,7 +30,7 @@ commands: | ||||
|           node-version: << parameters.node-version >> | ||||
|       - run: npm install --no-audit --progress=false | ||||
|   restore_cache_cmd: | ||||
|     description: 'Custom command for restoring cache with the ability to bust cache. When BUST_CACHE is set to true, jobs will not restore cache' | ||||
|     description: "Custom command for restoring cache with the ability to bust cache. When BUST_CACHE is set to true, jobs will not restore cache" | ||||
|     parameters: | ||||
|       node-version: | ||||
|         type: string | ||||
| @@ -42,7 +42,7 @@ commands: | ||||
|             - restore_cache: | ||||
|                 key: deps--{{ arch }}--{{ .Branch }}--<< parameters.node-version >>--{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }} | ||||
|   save_cache_cmd: | ||||
|     description: 'Custom command for saving cache.' | ||||
|     description: "Custom command for saving cache." | ||||
|     parameters: | ||||
|       node-version: | ||||
|         type: string | ||||
| @@ -53,7 +53,7 @@ commands: | ||||
|             - ~/.npm | ||||
|             - node_modules | ||||
|   generate_and_store_version_and_filesystem_artifacts: | ||||
|     description: 'Track important packages and files' | ||||
|     description: "Track important packages and files" | ||||
|     steps: | ||||
|       - run: | | ||||
|           [[ $EUID -ne 0 ]] && (sudo mkdir -p /tmp/artifacts && sudo chmod 777 /tmp/artifacts) || (mkdir -p /tmp/artifacts && chmod 777 /tmp/artifacts) | ||||
| @@ -64,7 +64,7 @@ commands: | ||||
|       - store_artifacts: | ||||
|           path: /tmp/artifacts/ | ||||
|   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: | ||||
|       suite: | ||||
|         type: string | ||||
| @@ -105,7 +105,11 @@ jobs: | ||||
|           node-version: <<parameters.node-version>> | ||||
|       - browser-tools/install-chrome: | ||||
|           replace-existing: false | ||||
|       - run: npm run test | ||||
|       - run: | ||||
|           command: | | ||||
|             mkdir -p dist/reports/tests/ | ||||
|             TESTFILES=$(circleci tests glob "src/**/*Spec.js") | ||||
|             echo "$TESTFILES" | circleci tests run --command="xargs npm run test" --verbose | ||||
|       - run: npm run cov:unit:publish | ||||
|       - save_cache_cmd: | ||||
|           node-version: <<parameters.node-version>> | ||||
| @@ -123,16 +127,20 @@ jobs: | ||||
|       suite: #stable or full | ||||
|         type: string | ||||
|     executor: pw-focal-development | ||||
|     parallelism: 6 | ||||
|     parallelism: 7 | ||||
|     steps: | ||||
|       - build_and_install: | ||||
|           node-version: lts/hydrogen | ||||
|       - when: #Only install chrome-beta when running the 'full' suite to save $$$ | ||||
|           condition: | ||||
|             equal: ['full', <<parameters.suite>>] | ||||
|             equal: ["full", <<parameters.suite>>] | ||||
|           steps: | ||||
|             - run: npx playwright install chrome-beta | ||||
|       - run: SHARD="$((${CIRCLE_NODE_INDEX}+1))"; npm run test:e2e:<<parameters.suite>> -- --shard=${SHARD}/${CIRCLE_NODE_TOTAL} | ||||
|       - run: | ||||
|           command: | | ||||
|             mkdir test-results | ||||
|             TESTFILES=$(circleci tests glob "e2e/**/*.spec.js") | ||||
|             echo "$TESTFILES" | circleci tests run --command="xargs npm run test:e2e:<<parameters.suite>>" --verbose --split-by=timings | ||||
|       - when: | ||||
|           condition: | ||||
|             equal: [42, 42] # Always run codecov reports regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2 | ||||
| @@ -152,6 +160,31 @@ jobs: | ||||
|             equal: [42, 42] # Always generate version artifacts regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2 | ||||
|           steps: | ||||
|             - generate_and_store_version_and_filesystem_artifacts | ||||
|   e2e-mobile: | ||||
|     executor: pw-focal-development | ||||
|     steps: | ||||
|       - build_and_install: | ||||
|           node-version: lts/hydrogen | ||||
|       - run: npm run test:e2e:mobile | ||||
|       - when: | ||||
|           condition: | ||||
|             equal: [42, 42] # Always run codecov reports regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2 | ||||
|           steps: | ||||
|             - generate_e2e_code_cov_report: | ||||
|                 suite: full | ||||
|       - store_test_results: | ||||
|           path: test-results/results.xml | ||||
|       - store_artifacts: | ||||
|           path: test-results | ||||
|       - store_artifacts: | ||||
|           path: coverage | ||||
|       - store_artifacts: | ||||
|           path: html-test-results | ||||
|       - when: | ||||
|           condition: | ||||
|             equal: [42, 42] # Always generate version artifacts regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2 | ||||
|           steps: | ||||
|             - generate_and_store_version_and_filesystem_artifacts | ||||
|   e2e-couchdb: | ||||
|     executor: ubuntu | ||||
|     steps: | ||||
| @@ -239,6 +272,7 @@ jobs: | ||||
|             equal: [42, 42] # Always generate version artifacts regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2 | ||||
|           steps: | ||||
|             - generate_and_store_version_and_filesystem_artifacts | ||||
|  | ||||
| workflows: | ||||
|   overall-circleci-commit-status: #These jobs run on every commit | ||||
|     jobs: | ||||
| @@ -251,10 +285,9 @@ workflows: | ||||
|       - e2e-test: | ||||
|           name: e2e-stable | ||||
|           suite: stable | ||||
|       - mem-test | ||||
|       - perf-test | ||||
|       - e2e-mobile | ||||
|       - visual-a11y-tests: | ||||
|           name: visual-test-ci | ||||
|           name: visual-a11y-test-ci | ||||
|           suite: ci | ||||
|  | ||||
|   the-nightly: #These jobs do not run on PRs, but against master at night | ||||
| @@ -270,15 +303,16 @@ workflows: | ||||
|       - e2e-test: | ||||
|           name: e2e-full-nightly | ||||
|           suite: full | ||||
|       - mem-test | ||||
|       - e2e-mobile | ||||
|       - perf-test | ||||
|       - mem-test | ||||
|       - visual-a11y-tests: | ||||
|           name: visual-test-nightly | ||||
|           name: visual-a11y-test-nightly | ||||
|           suite: full | ||||
|       - e2e-couchdb | ||||
|     triggers: | ||||
|       - schedule: | ||||
|           cron: '0 0 * * *' | ||||
|           cron: "0 0 * * *" | ||||
|           filters: | ||||
|             branches: | ||||
|               only: | ||||
|   | ||||
| @@ -493,10 +493,13 @@ | ||||
|     "WCAG", | ||||
|     "stackedplot", | ||||
|     "Andale", | ||||
|     "unnormalized", | ||||
|     "checksnapshots", | ||||
|     "specced", | ||||
|     "composables", | ||||
|     "composable" | ||||
|     "countup" | ||||
|   ], | ||||
|   "dictionaries": ["npm", "softwareTerms", "node", "html", "css", "bash", "en_US"], | ||||
|   "dictionaries": ["npm", "softwareTerms", "node", "html", "css", "bash", "en_US", "en-gb", "misc"], | ||||
|   "ignorePaths": [ | ||||
|     "package.json", | ||||
|     "dist/**", | ||||
|   | ||||
							
								
								
									
										2
									
								
								.github/PULL_REQUEST_TEMPLATE.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/PULL_REQUEST_TEMPLATE.md
									
									
									
									
										vendored
									
									
								
							| @@ -8,7 +8,7 @@ Closes <!--- Insert Issue Number(s) this PR addresses. Start by typing # will op | ||||
|  | ||||
| * [ ] Have you followed the guidelines in our [Contributing document](https://github.com/nasa/openmct/blob/master/CONTRIBUTING.md)? | ||||
| * [ ] Have you checked to ensure there aren't other open [Pull Requests](https://github.com/nasa/openmct/pulls) for the same update/change? | ||||
| * [ ] Is this change backwards compatible? For example, developers won't need to change how they are calling the API or how they've extended core plugins such as Tables or Plots. | ||||
| * [ ] Is this a notable change that will require a special callout in the release notes [Notable Change](../docs/src/process/release.md) ? For example, will this break compatibility with existing APIs or projects which source these plugins? | ||||
|  | ||||
| ### Author Checklist | ||||
|  | ||||
|   | ||||
							
								
								
									
										5
									
								
								.github/release.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.github/release.yml
									
									
									
									
										vendored
									
									
								
							| @@ -1,5 +1,8 @@ | ||||
| changelog: | ||||
|   categories: | ||||
|     - title: 💥 Notable Changes | ||||
|       labels: | ||||
|         - notable_change | ||||
|     - title: 🏕 Features | ||||
|       labels: | ||||
|         - type:feature | ||||
| @@ -20,4 +23,4 @@ changelog: | ||||
|         - dependencies | ||||
|     - title: 🐛 Bug Fixes | ||||
|       labels: | ||||
|         - '*' | ||||
|         - "*" | ||||
|   | ||||
							
								
								
									
										61
									
								
								.github/workflows/e2e-flakefinder.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								.github/workflows/e2e-flakefinder.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| name: 'pr:e2e:flakefinder' | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: master | ||||
|   workflow_dispatch: | ||||
|   pull_request: | ||||
|     types: | ||||
|       - labeled | ||||
|       - opened | ||||
|   schedule: | ||||
|     - cron: '0 0 * * *' | ||||
|  | ||||
| jobs: | ||||
|   e2e-flakefinder: | ||||
|     if: contains(github.event.pull_request.labels.*.name, 'pr:e2e:flakefinder') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event.action == 'opened' | ||||
|     runs-on: ubuntu-latest | ||||
|     timeout-minutes: 120 | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|       - uses: actions/setup-node@v4 | ||||
|         with: | ||||
|           node-version: 'lts/hydrogen' | ||||
|  | ||||
|       - name: Cache NPM dependencies | ||||
|         uses: actions/cache@v3 | ||||
|         with: | ||||
|           path: ~/.npm | ||||
|           key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} | ||||
|           restore-keys: | | ||||
|             ${{ runner.os }}-node- | ||||
|  | ||||
|       - run: npx playwright@1.39.0 install | ||||
|       - run: npm install --cache ~/.npm --no-audit --progress=false | ||||
|  | ||||
|       - name: Run E2E Tests (Repeated 10 Times) | ||||
|         run: npm run test:e2e:stable -- --retries=0 --repeat-each=10 --max-failures=50 | ||||
|  | ||||
|       - name: Archive test results | ||||
|         if: success() || failure() | ||||
|         uses: actions/upload-artifact@v3 | ||||
|         with: | ||||
|           path: test-results | ||||
|  | ||||
|       - name: Remove pr:e2e:flakefinder label (if present) | ||||
|         if: always() | ||||
|         uses: actions/github-script@v6 | ||||
|         with: | ||||
|           script: | | ||||
|             const { owner, repo, number } = context.issue; | ||||
|             const labelToRemove = 'pr:e2e:flakefinder'; | ||||
|             try { | ||||
|                 await github.rest.issues.removeLabel({ | ||||
|                 owner, | ||||
|                 repo, | ||||
|                 issue_number: number, | ||||
|                 name: labelToRemove | ||||
|                 }); | ||||
|             } catch (error) { | ||||
|                 core.warning(`Failed to remove ' + labelToRemove + ' label: ${error.message}`); | ||||
|             } | ||||
							
								
								
									
										58
									
								
								.github/workflows/e2e-perf.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								.github/workflows/e2e-perf.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| name: 'e2e-perf' | ||||
| on: | ||||
|   push: | ||||
|     branches: master | ||||
|   workflow_dispatch: | ||||
|   pull_request: | ||||
|     types: | ||||
|       - labeled | ||||
|       - opened | ||||
|   schedule: | ||||
|     - cron: '0 0 * * *' | ||||
| jobs: | ||||
|   e2e-full: | ||||
|     if: contains(github.event.pull_request.labels.*.name, 'pr:e2e:perf') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | ||||
|     runs-on: ubuntu-latest | ||||
|     timeout-minutes: 60 | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|       - uses: actions/setup-node@v4 | ||||
|         with: | ||||
|           node-version: 'lts/hydrogen' | ||||
|  | ||||
|       - name: Cache NPM dependencies | ||||
|         uses: actions/cache@v3 | ||||
|         with: | ||||
|           path: ~/.npm | ||||
|           key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} | ||||
|           restore-keys: | | ||||
|             ${{ runner.os }}-node- | ||||
|  | ||||
|       - run: npx playwright@1.39.0 install | ||||
|       - run: npm install --cache ~/.npm --no-audit --progress=false | ||||
|       - run: npm run test:perf:localhost | ||||
|       - run: npm run test:perf:contract | ||||
|       - run: npm run test:perf:memory | ||||
|       - name: Archive test results | ||||
|         if: success() || failure() | ||||
|         uses: actions/upload-artifact@v3 | ||||
|         with: | ||||
|           path: test-results | ||||
|  | ||||
|       - name: Remove pr:e2e:perf label (if present) | ||||
|         if: always() | ||||
|         uses: actions/github-script@v6 | ||||
|         with: | ||||
|           script: | | ||||
|             const { owner, repo, number } = context.issue; | ||||
|             const labelToRemove = 'pr:e2e:perf'; | ||||
|             try { | ||||
|               await github.rest.issues.removeLabel({ | ||||
|                 owner, | ||||
|                 repo, | ||||
|                 issue_number: number, | ||||
|                 name: labelToRemove | ||||
|               }); | ||||
|             } catch (error) { | ||||
|               core.warning(`Failed to remove ' + labelToRemove + ' label: ${error.message}`); | ||||
|             } | ||||
							
								
								
									
										14
									
								
								.vscode/extensions.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								.vscode/extensions.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| { | ||||
|   // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. | ||||
|   // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp | ||||
|  | ||||
|   // List of extensions which should be recommended for users of this workspace. | ||||
|   "recommendations": [ | ||||
|     "Vue.volar", | ||||
|     "Vue.vscode-typescript-vue-plugin", | ||||
|     "dbaeumer.vscode-eslint", | ||||
|     "rvest.vs-code-prettier-eslint" | ||||
|   ], | ||||
|   // List of extensions recommended by VS Code that should not be recommended for users of this workspace. | ||||
|   "unwantedRecommendations": ["octref.vetur"] | ||||
| } | ||||
| @@ -15,5 +15,5 @@ export default merge(common, { | ||||
|       __OPENMCT_ROOT_RELATIVE__: '""' | ||||
|     }) | ||||
|   ], | ||||
|   devtool: 'source-map' | ||||
|   devtool: 'eval-source-map' | ||||
| }); | ||||
|   | ||||
							
								
								
									
										30
									
								
								docs/src/process/release.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								docs/src/process/release.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
|  | ||||
| # Release of NASA Open MCT NPM Package | ||||
|  | ||||
| This document outlines the process and key considerations for releasing a new version of the NASA Open MCT project as an NPM (Node Package Manager) package. | ||||
|  | ||||
| ## 1. Pre-requisites | ||||
|  | ||||
| Before releasing a new version of the NASA Open MCT NPM package, ensure all dependencies are updated, and comprehensive tests are performed. This ensures compatibility and performance of the Open MCT within the Node.js ecosystem. | ||||
|  | ||||
| ## 2. Versioning | ||||
|  | ||||
| Versioning is a critical step for package release. The Open MCT team follows [Semantic Versioning (SemVer)](https://semver.org) that consists of three major components: MAJOR.MINOR.PATCH. These ensure a structured process for updating, bug fixes, backward compatibility, and software progress. | ||||
|  | ||||
| ## 3. Changelog Maintenance | ||||
|  | ||||
| A comprehensive changelog file, `CHANGELOG.md`, documents any changes, adding a high level of transparencies for anyone desiring to look into the status of new and past progress. It includes the summation of any major new enhancements, changes, bug fixes, and the credits to the users responsible for each unique progress. | ||||
|  | ||||
| ## 4. Notable Changes Labels on GitHub PRs | ||||
|  | ||||
| For the Open MCT package, we leverage GitHub's Pull Request (PR) mechanisms extensively, with three important PR labels dedicated to signifying 'notable_changes': | ||||
|  | ||||
| - **Breaking Change** Highlights the integration of changes that are suspected to break, or without a doubt will break, backward compatibility. These should signal to users the upgrade might be seamless only if dependency and integration factors are properly managed, if not, one should expect to manage atypical technical snags. | ||||
| - **API change** Signifies when a contribution makes any complete or under layer changes to the communication or its supporting access processes. This label flags required see-through insight on how the web-based control panel sees and manipulates any value and or network logs. | ||||
| - **Default Behavior Change:** In the incident an update either adjusts a form to or integrates a not previously kept setting or plugin. i.e. autoscale is enabled by default when working with plots. | ||||
|  | ||||
| ## 6. Community & Contributions | ||||
|  | ||||
| A flat community and the rounded center are kept in continuous celebration, with the given station open for two open-specifying dialogues, research, and all-for development probing. State the ownership for a handed looped, a welcome for even structure-core and architectural draft and impend. | ||||
|  | ||||
| Thank you for your collaboration and commitment to moving the project onto a text big club.  | ||||
| @@ -109,7 +109,7 @@ For those interested in the mechanics of snapshot testing with Playwright, you c | ||||
| // from our package.json or circleCI configuration file | ||||
| docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v{X.X.X}-focal /bin/bash | ||||
| npm install | ||||
| npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @snapshot | ||||
| npm run test:e2e:checksnapshots | ||||
| ``` | ||||
|  | ||||
| ### Updating Snapshots | ||||
| @@ -134,6 +134,12 @@ npm install | ||||
| npm run test:e2e:updatesnapshots | ||||
| ``` | ||||
|  | ||||
| Once that's done, you'll need to run the following to verify that the changes do not cause more problems: | ||||
|  | ||||
| ```sh | ||||
| npm run test:e2e:checksnapshots | ||||
| ``` | ||||
|  | ||||
| ## Automated Accessibility (a11y) Testing | ||||
|  | ||||
| Open MCT incorporates accessibility testing through two primary methods to ensure its compliance with accessibility standards: | ||||
| @@ -223,7 +229,7 @@ Current list of test tags: | ||||
|  | ||||
| |Test Tag|Description| | ||||
| |:-:|-| | ||||
| |`@ipad` | Test case or test suite is compatible with Playwright's iPad support and Open MCT's read-only mobile view (i.e. no create button).| | ||||
| |`@mobile` | Test case or test suite is compatible with Playwright's iPad support and Open MCT's read-only mobile view (i.e. no create button).| | ||||
| |`@a11y` | Test case or test suite to execute playwright-axe accessibility checks and generate a11y reports.| | ||||
| |`@gds` | Denotes a GDS Test Case used in the VIPER Mission.| | ||||
| |`@addInit` | Initializes the browser with an injected and artificial state. Useful for loading non-default plugins. Likely will not work outside of `npm start`.| | ||||
| @@ -323,9 +329,15 @@ In terms of operating system testing, we're only limited by what the CI provider | ||||
|  | ||||
| #### **Mobile** | ||||
|  | ||||
| We have the Mission-need to support iPad. To run our iPad suite, please see our `playwright-*.config.js` with the 'iPad' project. | ||||
| We have a Mission-need to support iPad and mobile devices. To run our test suites with mobile devices, please see our `playwright-mobile.config.js` projects. | ||||
|  | ||||
| In general, our test suite is not designed to run against mobile devices as the mobile experience is a focused version of the application. Core functionality is missing (chiefly the 'Create' button) and so this will likely turn into a separate suite. | ||||
| In general, our test suite is not designed to run against mobile devices as the mobile experience is a focused version of the application. Core functionality is missing (chiefly the 'Create' button). To bypass the object creation, we leverage the `storageState` properties for starting the mobile tests with localstorage. | ||||
|  | ||||
| For now, the mobile tests will exist in the /tests/mobile/ suites and be executed with the | ||||
| ```sh | ||||
| npm run test:e2e:mobile | ||||
| ``` | ||||
| command. | ||||
|  | ||||
| #### **Skipping or executing tests based on browser, os, and/os browser version:** | ||||
|  | ||||
|   | ||||
| @@ -284,7 +284,7 @@ async function navigateToObjectWithFixedTimeBounds(page, url, start, end) { | ||||
|  */ | ||||
| async function openObjectTreeContextMenu(page, url) { | ||||
|   await page.goto(url); | ||||
|   await page.click('button[title="Show selected item in tree"]'); | ||||
|   await page.getByLabel('Show selected item in tree').click(); | ||||
|   await page.locator('.is-navigated-object').click({ | ||||
|     button: 'right' | ||||
|   }); | ||||
|   | ||||
| @@ -61,7 +61,6 @@ export async function scanForA11yViolations(page, testCaseName, options = {}) { | ||||
|   const builder = new AxeBuilder({ page }); | ||||
|   builder.withTags(['wcag2aa']); | ||||
|   // https://github.com/dequelabs/axe-core/blob/develop/doc/rule-descriptions.md | ||||
|   builder.disableRules(['color-contrast']); | ||||
|   const accessibilityScanResults = await builder.analyze(); | ||||
|  | ||||
|   // Assert that no violations should be present | ||||
|   | ||||
| @@ -49,7 +49,7 @@ async function dragAndDropEmbed(page, notebookObject) { | ||||
|   // Navigate to notebook | ||||
|   await page.goto(notebookObject.url); | ||||
|   // Expand the tree to reveal the notebook | ||||
|   await page.click('button[title="Show selected item in tree"]'); | ||||
|   await page.getByLabel('Show selected item in tree').click(); | ||||
|   // Drag and drop the SWG into the notebook | ||||
|   await page.dragAndDrop(`text=${swg.name}`, NOTEBOOK_DROP_AREA); | ||||
|   await commitEntry(page); | ||||
|   | ||||
| @@ -10,6 +10,7 @@ const NUM_WORKERS = 2; | ||||
| const config = { | ||||
|   retries: 2, //Retries 2 times for a total of 3 runs. When running sharded and with max-failures=5, this should ensure that flake is managed without failing the full suite | ||||
|   testDir: 'tests', | ||||
|   grepInvert: /@mobile/, //Ignore mobile tests | ||||
|   testIgnore: '**/*.perf.spec.js', //Ignore performance tests and define in playwright-perfromance.config.js | ||||
|   timeout: 60 * 1000, | ||||
|   webServer: { | ||||
|   | ||||
| @@ -1,13 +1,11 @@ | ||||
| // playwright.config.js | ||||
| // @ts-check | ||||
|  | ||||
| // eslint-disable-next-line no-unused-vars | ||||
| import { devices } from '@playwright/test'; | ||||
|  | ||||
| /** @type {import('@playwright/test').PlaywrightTestConfig} */ | ||||
| const config = { | ||||
|   retries: 0, | ||||
|   testDir: 'tests', | ||||
|   testMatch: '**/*.e2e.spec.js', // only run e2e tests | ||||
|   testIgnore: '**/*.perf.spec.js', | ||||
|   timeout: 30 * 1000, | ||||
|   webServer: { | ||||
| @@ -35,7 +33,6 @@ const config = { | ||||
|     }, | ||||
|     { | ||||
|       name: 'MMOC', | ||||
|       testMatch: '**/*.e2e.spec.js', // only run e2e tests | ||||
|       grepInvert: /@snapshot/, | ||||
|       use: { | ||||
|         browserName: 'chromium', | ||||
| @@ -47,8 +44,6 @@ const config = { | ||||
|     }, | ||||
|     { | ||||
|       name: 'safari', | ||||
|       testMatch: '**/*.e2e.spec.js', // only run e2e tests | ||||
|       grep: /@ipad/, // only run ipad tests due to this bug https://github.com/microsoft/playwright/issues/8340 | ||||
|       grepInvert: /@snapshot/, | ||||
|       use: { | ||||
|         browserName: 'webkit' | ||||
| @@ -56,7 +51,6 @@ const config = { | ||||
|     }, | ||||
|     { | ||||
|       name: 'firefox', | ||||
|       testMatch: '**/*.e2e.spec.js', // only run e2e tests | ||||
|       grepInvert: /@snapshot/, | ||||
|       use: { | ||||
|         browserName: 'firefox' | ||||
| @@ -64,7 +58,6 @@ const config = { | ||||
|     }, | ||||
|     { | ||||
|       name: 'canary', | ||||
|       testMatch: '**/*.e2e.spec.js', // only run e2e tests | ||||
|       grepInvert: /@snapshot/, | ||||
|       use: { | ||||
|         browserName: 'chromium', | ||||
| @@ -73,22 +66,11 @@ const config = { | ||||
|     }, | ||||
|     { | ||||
|       name: 'chrome-beta', | ||||
|       testMatch: '**/*.e2e.spec.js', // only run e2e tests | ||||
|       grepInvert: /@snapshot/, | ||||
|       use: { | ||||
|         browserName: 'chromium', | ||||
|         channel: 'chrome-beta' | ||||
|       } | ||||
|     }, | ||||
|     { | ||||
|       name: 'ipad', | ||||
|       testMatch: '**/*.e2e.spec.js', // only run e2e tests | ||||
|       grep: /@ipad/, | ||||
|       grepInvert: /@snapshot/, | ||||
|       use: { | ||||
|         browserName: 'webkit', | ||||
|         ...devices['iPad (gen 7) landscape'] // Complete List https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/deviceDescriptorsSource.json | ||||
|       } | ||||
|     } | ||||
|   ], | ||||
|   reporter: [ | ||||
|   | ||||
							
								
								
									
										69
									
								
								e2e/playwright-mobile.config.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								e2e/playwright-mobile.config.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,69 @@ | ||||
| // playwright.config.js | ||||
| // @ts-check | ||||
|  | ||||
| import { devices } from '@playwright/test'; | ||||
| const MAX_FAILURES = 5; | ||||
| const NUM_WORKERS = 2; | ||||
|  | ||||
| import { fileURLToPath } from 'url'; | ||||
|  | ||||
| /** @type {import('@playwright/test').PlaywrightTestConfig} */ | ||||
| const config = { | ||||
|   retries: 1, //Retries 2 times for a total of 3 runs. When running sharded and with max-failures=5, this should ensure that flake is managed without failing the full suite | ||||
|   testDir: 'tests', | ||||
|   testIgnore: '**/*.perf.spec.js', //Ignore performance tests and define in playwright-perfromance.config.js | ||||
|   timeout: 30 * 1000, | ||||
|   webServer: { | ||||
|     command: 'npm run start:coverage', | ||||
|     url: 'http://localhost:8080/#', | ||||
|     timeout: 200 * 1000, | ||||
|     reuseExistingServer: true //This was originally disabled to prevent differences in local debugging vs. CI. However, it significantly speeds up local debugging. | ||||
|   }, | ||||
|   maxFailures: MAX_FAILURES, //Limits failures to 5 to reduce CI Waste | ||||
|   workers: NUM_WORKERS, //Limit to 2 for CircleCI Agent | ||||
|   use: { | ||||
|     baseURL: 'http://localhost:8080/', | ||||
|     headless: true, | ||||
|     ignoreHTTPSErrors: true, | ||||
|     screenshot: 'only-on-failure', | ||||
|     trace: 'on-first-retry', | ||||
|     video: 'off' | ||||
|   }, | ||||
|   projects: [ | ||||
|     { | ||||
|       name: 'ipad', | ||||
|       grep: /@mobile/, | ||||
|       use: { | ||||
|         storageState: fileURLToPath( | ||||
|           new URL('./test-data/display_layout_with_child_layouts.json', import.meta.url) | ||||
|         ), | ||||
|         browserName: 'webkit', | ||||
|         ...devices['iPad (gen 7) landscape'] // Complete List https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/deviceDescriptorsSource.json | ||||
|       } | ||||
|     }, | ||||
|     { | ||||
|       name: 'iphone', | ||||
|       grep: /@mobile/, | ||||
|       use: { | ||||
|         storageState: fileURLToPath( | ||||
|           new URL('./test-data/display_layout_with_child_layouts.json', import.meta.url) | ||||
|         ), | ||||
|         browserName: 'webkit', | ||||
|         ...devices['iPhone 14 Pro'] // Complete List https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/deviceDescriptorsSource.json | ||||
|       } | ||||
|     } | ||||
|   ], | ||||
|   reporter: [ | ||||
|     ['list'], | ||||
|     [ | ||||
|       'html', | ||||
|       { | ||||
|         open: 'never', | ||||
|         outputFolder: '../html-test-results' //Must be in different location due to https://github.com/microsoft/playwright/issues/12840 | ||||
|       } | ||||
|     ], | ||||
|     ['junit', { outputFile: '../test-results/results.xml' }] | ||||
|   ] | ||||
| }; | ||||
|  | ||||
| export default config; | ||||
| @@ -1,6 +1,9 @@ | ||||
| // playwright.config.js | ||||
| // @ts-check | ||||
|  | ||||
| import { devices } from '@playwright/test'; | ||||
| import { fileURLToPath } from 'url'; | ||||
|  | ||||
| /** @type {import('@playwright/test').PlaywrightTestConfig} */ | ||||
| const config = { | ||||
|   retries: 0, //Retries are not needed with watch mode | ||||
| @@ -28,6 +31,28 @@ const config = { | ||||
|       use: { | ||||
|         browserName: 'chromium' | ||||
|       } | ||||
|     }, | ||||
|     { | ||||
|       name: 'ipad', | ||||
|       grep: /@mobile/, | ||||
|       use: { | ||||
|         storageState: fileURLToPath( | ||||
|           new URL('./test-data/display_layout_with_child_layouts.json', import.meta.url) | ||||
|         ), | ||||
|         browserName: 'webkit', | ||||
|         ...devices['iPad (gen 7) landscape'] // Complete List https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/deviceDescriptorsSource.json | ||||
|       } | ||||
|     }, | ||||
|     { | ||||
|       name: 'iphone', | ||||
|       grep: /@mobile/, | ||||
|       use: { | ||||
|         storageState: fileURLToPath( | ||||
|           new URL('./test-data/display_layout_with_child_layouts.json', import.meta.url) | ||||
|         ), | ||||
|         browserName: 'webkit', | ||||
|         ...devices['iPhone 14 Pro'] // Complete List https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/deviceDescriptorsSource.json | ||||
|       } | ||||
|     } | ||||
|   ], | ||||
|   reporter: [ | ||||
|   | ||||
| @@ -6,7 +6,8 @@ | ||||
|       "end": 1660343797000, | ||||
|       "type": "Group 1", | ||||
|       "color": "orange", | ||||
|       "textColor": "white" | ||||
|       "textColor": "white", | ||||
|       "id": 1 | ||||
|     }, | ||||
|     { | ||||
|       "name": "Past event 2", | ||||
| @@ -14,7 +15,8 @@ | ||||
|       "end": 1660429160000, | ||||
|       "type": "Group 1", | ||||
|       "color": "orange", | ||||
|       "textColor": "white" | ||||
|       "textColor": "white", | ||||
|       "id": 2 | ||||
|     }, | ||||
|     { | ||||
|       "name": "Past event 3", | ||||
| @@ -22,7 +24,8 @@ | ||||
|       "end": 1660503981000, | ||||
|       "type": "Group 1", | ||||
|       "color": "orange", | ||||
|       "textColor": "white" | ||||
|       "textColor": "white", | ||||
|       "id": 3 | ||||
|     }, | ||||
|     { | ||||
|       "name": "Past event 4", | ||||
| @@ -30,7 +33,8 @@ | ||||
|       "end": 1660624108000, | ||||
|       "type": "Group 1", | ||||
|       "color": "orange", | ||||
|       "textColor": "white" | ||||
|       "textColor": "white", | ||||
|       "id": 4 | ||||
|     }, | ||||
|     { | ||||
|       "name": "Past event 5", | ||||
| @@ -38,7 +42,8 @@ | ||||
|       "end": 1660681529000, | ||||
|       "type": "Group 1", | ||||
|       "color": "orange", | ||||
|       "textColor": "white" | ||||
|       "textColor": "white", | ||||
|       "id": 5 | ||||
|     } | ||||
|   ] | ||||
| } | ||||
|   | ||||
| @@ -6,7 +6,8 @@ | ||||
|       "end": 1660343797000, | ||||
|       "type": "Group 1", | ||||
|       "color": "orange", | ||||
|       "textColor": "white" | ||||
|       "textColor": "white", | ||||
|       "id": 1 | ||||
|     }, | ||||
|     { | ||||
|       "name": "Time until supper", | ||||
| @@ -14,7 +15,8 @@ | ||||
|       "end": 1650420410000, | ||||
|       "type": "Group 2", | ||||
|       "color": "blue", | ||||
|       "textColor": "white" | ||||
|       "textColor": "white", | ||||
|       "id": 2 | ||||
|     } | ||||
|   ], | ||||
|   "Group 2": [ | ||||
| @@ -24,7 +26,8 @@ | ||||
|       "end": 1650320102001, | ||||
|       "type": "Group 2", | ||||
|       "color": "green", | ||||
|       "textColor": "white" | ||||
|       "textColor": "white", | ||||
|       "id": 3 | ||||
|     }, | ||||
|     { | ||||
|       "name": "Time since last accident", | ||||
| @@ -32,7 +35,8 @@ | ||||
|       "end": 1650320102002, | ||||
|       "type": "Group 1", | ||||
|       "color": "yellow", | ||||
|       "textColor": "white" | ||||
|       "textColor": "white", | ||||
|       "id": 4 | ||||
|     } | ||||
|   ] | ||||
| } | ||||
|   | ||||
| @@ -23,7 +23,8 @@ | ||||
| import { | ||||
|   createDomainObjectWithDefaults, | ||||
|   createNotification, | ||||
|   expandEntireTree | ||||
|   expandEntireTree, | ||||
|   openObjectTreeContextMenu | ||||
| } from '../../appActions.js'; | ||||
| import { expect, test } from '../../pluginFixtures.js'; | ||||
|  | ||||
| @@ -166,4 +167,13 @@ test.describe('AppActions', () => { | ||||
|     const locatorTreeCollapsedItems = locatorTree.locator('role=treeitem[expanded=false]'); | ||||
|     expect(await locatorTreeCollapsedItems.count()).toBe(0); | ||||
|   }); | ||||
|   test('openObjectTreeContextMenu', async ({ page }) => { | ||||
|     await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|  | ||||
|     const folder = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Folder' | ||||
|     }); | ||||
|     await openObjectTreeContextMenu(page, folder.url); | ||||
|     await expect(page.getByLabel('Menu')).toBeVisible(); | ||||
|   }); | ||||
| }); | ||||
|   | ||||
							
								
								
									
										127
									
								
								e2e/tests/functional/missionStatus.e2e.spec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										127
									
								
								e2e/tests/functional/missionStatus.e2e.spec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,127 @@ | ||||
| /***************************************************************************** | ||||
|  * 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 persistability checks | ||||
| */ | ||||
|  | ||||
| import { fileURLToPath } from 'url'; | ||||
|  | ||||
| import { expect, test } from '../../baseFixtures.js'; | ||||
|  | ||||
| test.describe('Mission Status @addInit', () => { | ||||
|   const NO_GO = '0'; | ||||
|   const GO = '1'; | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     // FIXME: determine if plugins will be added to index.html or need to be injected | ||||
|     await page.addInitScript({ | ||||
|       path: fileURLToPath(new URL('../../helper/addInitExampleUser.js', import.meta.url)) | ||||
|     }); | ||||
|     await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|     await expect(page.getByText('Select Role')).toBeVisible(); | ||||
|     // Description should be empty https://github.com/nasa/openmct/issues/6978 | ||||
|     await expect(page.getByLabel('Dialog message')).toBeHidden(); | ||||
|     // set role | ||||
|     await page.getByRole('button', { name: 'Select', exact: true }).click(); | ||||
|     // dismiss role confirmation popup | ||||
|     await page.getByRole('button', { name: 'Dismiss' }).click(); | ||||
|   }); | ||||
|  | ||||
|   test('Basic functionality', async ({ page }) => { | ||||
|     const imageryStatusSelect = page.getByRole('combobox', { name: 'Imagery' }); | ||||
|     const commandingStatusSelect = page.getByRole('combobox', { name: 'Commanding' }); | ||||
|     const drivingStatusSelect = page.getByRole('combobox', { name: 'Driving' }); | ||||
|     const missionStatusPanel = page.getByRole('dialog', { name: 'User Control Panel' }); | ||||
|  | ||||
|     await test.step('Mission status panel shows/hides when toggled', async () => { | ||||
|       // Ensure that clicking the button toggles the dialog | ||||
|       await page.getByLabel('Toggle Mission Status Panel').click(); | ||||
|       await expect(missionStatusPanel).toBeVisible(); | ||||
|       await page.getByLabel('Toggle Mission Status Panel').click(); | ||||
|       await expect(missionStatusPanel).toBeHidden(); | ||||
|       await page.getByLabel('Toggle Mission Status Panel').click(); | ||||
|       await expect(missionStatusPanel).toBeVisible(); | ||||
|  | ||||
|       // Ensure that clicking the close button closes the dialog | ||||
|       await page.getByLabel('Close Mission Status Panel').click(); | ||||
|       await expect(missionStatusPanel).toBeHidden(); | ||||
|       await page.getByLabel('Toggle Mission Status Panel').click(); | ||||
|       await expect(missionStatusPanel).toBeVisible(); | ||||
|  | ||||
|       // Ensure clicking off the dialog also closes it | ||||
|       await page.getByLabel('My Items Grid View').click(); | ||||
|       await expect(missionStatusPanel).toBeHidden(); | ||||
|       await page.getByLabel('Toggle Mission Status Panel').click(); | ||||
|       await expect(missionStatusPanel).toBeVisible(); | ||||
|     }); | ||||
|  | ||||
|     await test.step('Mission action statuses have correct defaults and can be set', async () => { | ||||
|       await expect(imageryStatusSelect).toHaveValue(NO_GO); | ||||
|       await expect(commandingStatusSelect).toHaveValue(NO_GO); | ||||
|       await expect(drivingStatusSelect).toHaveValue(NO_GO); | ||||
|  | ||||
|       await setMissionStatus(page, 'Imagery', GO); | ||||
|       await expect(imageryStatusSelect).toHaveValue(GO); | ||||
|       await expect(commandingStatusSelect).toHaveValue(NO_GO); | ||||
|       await expect(drivingStatusSelect).toHaveValue(NO_GO); | ||||
|  | ||||
|       await setMissionStatus(page, 'Commanding', GO); | ||||
|       await expect(imageryStatusSelect).toHaveValue(GO); | ||||
|       await expect(commandingStatusSelect).toHaveValue(GO); | ||||
|       await expect(drivingStatusSelect).toHaveValue(NO_GO); | ||||
|  | ||||
|       await setMissionStatus(page, 'Driving', GO); | ||||
|       await expect(imageryStatusSelect).toHaveValue(GO); | ||||
|       await expect(commandingStatusSelect).toHaveValue(GO); | ||||
|       await expect(drivingStatusSelect).toHaveValue(GO); | ||||
|  | ||||
|       await setMissionStatus(page, 'Imagery', NO_GO); | ||||
|       await expect(imageryStatusSelect).toHaveValue(NO_GO); | ||||
|       await expect(commandingStatusSelect).toHaveValue(GO); | ||||
|       await expect(drivingStatusSelect).toHaveValue(GO); | ||||
|  | ||||
|       await setMissionStatus(page, 'Commanding', NO_GO); | ||||
|       await expect(imageryStatusSelect).toHaveValue(NO_GO); | ||||
|       await expect(commandingStatusSelect).toHaveValue(NO_GO); | ||||
|       await expect(drivingStatusSelect).toHaveValue(GO); | ||||
|  | ||||
|       await setMissionStatus(page, 'Driving', NO_GO); | ||||
|       await expect(imageryStatusSelect).toHaveValue(NO_GO); | ||||
|       await expect(commandingStatusSelect).toHaveValue(NO_GO); | ||||
|       await expect(drivingStatusSelect).toHaveValue(NO_GO); | ||||
|     }); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * @param {import('@playwright/test').Page} page | ||||
|  * @param {'Commanding'|'Imagery'|'Driving'} action | ||||
|  * @param {'0'|'1'} status | ||||
|  */ | ||||
| async function setMissionStatus(page, action, status) { | ||||
|   await page.getByRole('combobox', { name: action }).selectOption(status); | ||||
|   await expect( | ||||
|     page.getByRole('alert').filter({ hasText: 'Successfully set mission status' }) | ||||
|   ).toBeVisible(); | ||||
|   await page.getByLabel('Dismiss').click(); | ||||
| } | ||||
| @@ -27,7 +27,7 @@ import { | ||||
|   assertPlanActivities, | ||||
|   assertPlanOrderedSwimLanes | ||||
| } from '../../../helper/planningUtils.js'; | ||||
| import { test } from '../../../pluginFixtures.js'; | ||||
| import { expect, test } from '../../../pluginFixtures.js'; | ||||
|  | ||||
| const testPlan1 = JSON.parse( | ||||
|   fs.readFileSync( | ||||
| @@ -63,4 +63,47 @@ test.describe('Plan', () => { | ||||
|     }); | ||||
|     await assertPlanOrderedSwimLanes(page, testPlanWithOrderedLanes, planWithSwimLanes.url); | ||||
|   }); | ||||
|  | ||||
|   test('Allows setting the state of an activity when selected.', async ({ page }) => { | ||||
|     const groups = Object.keys(testPlan1); | ||||
|     const firstGroupKey = groups[0]; | ||||
|     const firstGroupItems = testPlan1[firstGroupKey]; | ||||
|     const firstActivity = firstGroupItems[0]; | ||||
|     const lastActivity = firstGroupItems[firstGroupItems.length - 1]; | ||||
|     const startBound = firstActivity.start; | ||||
|     // Set the endBound to the end time of the current activity | ||||
|     let endBound = lastActivity.end; | ||||
|     // eslint-disable-next-line playwright/no-conditional-in-test | ||||
|     if (endBound === startBound) { | ||||
|       // Prevent oddities with setting start and end bound equal | ||||
|       // via URL params | ||||
|       endBound += 1; | ||||
|     } | ||||
|  | ||||
|     // Switch to fixed time mode with all plan events within the bounds | ||||
|     await page.goto( | ||||
|       `${plan.url}?tc.mode=fixed&tc.startBound=${startBound}&tc.endBound=${endBound}&tc.timeSystem=utc&view=plan.view` | ||||
|     ); | ||||
|  | ||||
|     // select the first activity in the list | ||||
|     await page.getByText('Past event 1').click(); | ||||
|  | ||||
|     // Find the activity state section in the inspector | ||||
|     await page.getByRole('tab', { name: 'Activity' }).click(); | ||||
|  | ||||
|     // Check that activity state dropdown selection shows the `set status` option by default | ||||
|     await expect(page.getByLabel('Activity Status').locator("[aria-selected='true']")).toHaveText( | ||||
|       'Not started' | ||||
|     ); | ||||
|  | ||||
|     // Change the selection of the activity status | ||||
|     await page.getByRole('combobox').selectOption({ label: 'Aborted' }); | ||||
|     // select a different activity and back to the previous one | ||||
|     await page.getByText('Past event 2').click(); | ||||
|     await page.getByText('Past event 1').click(); | ||||
|     // Check that activity state dropdown selection shows the previously selected option by default | ||||
|     await expect(page.getByLabel('Activity Status').locator("[aria-selected='true']")).toHaveText( | ||||
|       'Aborted' | ||||
|     ); | ||||
|   }); | ||||
| }); | ||||
|   | ||||
| @@ -30,6 +30,11 @@ const examplePlanSmall3 = JSON.parse( | ||||
|     new URL('../../../test-data/examplePlans/ExamplePlan_Small3.json', import.meta.url) | ||||
|   ) | ||||
| ); | ||||
| const examplePlanSmall1 = JSON.parse( | ||||
|   fs.readFileSync( | ||||
|     new URL('../../../test-data/examplePlans/ExamplePlan_Small1.json', import.meta.url) | ||||
|   ) | ||||
| ); | ||||
| // eslint-disable-next-line no-unused-vars | ||||
| const START_TIME_COLUMN = 0; | ||||
| // eslint-disable-next-line no-unused-vars | ||||
| @@ -38,55 +43,10 @@ const TIME_TO_FROM_COLUMN = 2; | ||||
| // eslint-disable-next-line no-unused-vars | ||||
| const ACTIVITY_COLUMN = 3; | ||||
| const HEADER_ROW = 0; | ||||
| const NUM_COLUMNS = 4; | ||||
|  | ||||
| const testPlan = { | ||||
|   TEST_GROUP: [ | ||||
|     { | ||||
|       name: 'Past event 1', | ||||
|       start: 1660320408000, | ||||
|       end: 1660343797000, | ||||
|       type: 'TEST-GROUP', | ||||
|       color: 'orange', | ||||
|       textColor: 'white' | ||||
|     }, | ||||
|     { | ||||
|       name: 'Past event 2', | ||||
|       start: 1660406808000, | ||||
|       end: 1660429160000, | ||||
|       type: 'TEST-GROUP', | ||||
|       color: 'orange', | ||||
|       textColor: 'white' | ||||
|     }, | ||||
|     { | ||||
|       name: 'Past event 3', | ||||
|       start: 1660493208000, | ||||
|       end: 1660503981000, | ||||
|       type: 'TEST-GROUP', | ||||
|       color: 'orange', | ||||
|       textColor: 'white' | ||||
|     }, | ||||
|     { | ||||
|       name: 'Past event 4', | ||||
|       start: 1660579608000, | ||||
|       end: 1660624108000, | ||||
|       type: 'TEST-GROUP', | ||||
|       color: 'orange', | ||||
|       textColor: 'white' | ||||
|     }, | ||||
|     { | ||||
|       name: 'Past event 5', | ||||
|       start: 1660666008000, | ||||
|       end: 1660681529000, | ||||
|       type: 'TEST-GROUP', | ||||
|       color: 'orange', | ||||
|       textColor: 'white' | ||||
|     } | ||||
|   ] | ||||
| }; | ||||
| const NUM_COLUMNS = 5; | ||||
|  | ||||
| test.describe('Time List', () => { | ||||
|   test('Create a Time List, add a single Plan to it and verify all the activities are displayed with no milliseconds', async ({ | ||||
|   test("Create a Time List, add a single Plan to it, verify all the activities are displayed with no milliseconds and selecting an activity shows it's properties", async ({ | ||||
|     page | ||||
|   }) => { | ||||
|     // Goto baseURL | ||||
| @@ -103,12 +63,16 @@ test.describe('Time List', () => { | ||||
|     await test.step('Create a Plan and add it to the timelist', async () => { | ||||
|       await createPlanFromJSON(page, { | ||||
|         name: 'Test Plan', | ||||
|         json: testPlan, | ||||
|         json: examplePlanSmall1, | ||||
|         parent: timelist.uuid | ||||
|       }); | ||||
|  | ||||
|       const startBound = testPlan.TEST_GROUP[0].start; | ||||
|       const endBound = testPlan.TEST_GROUP[testPlan.TEST_GROUP.length - 1].end; | ||||
|       const groups = Object.keys(examplePlanSmall1); | ||||
|       const firstGroupKey = groups[0]; | ||||
|       const firstGroupItems = examplePlanSmall1[firstGroupKey]; | ||||
|       const firstActivity = firstGroupItems[0]; | ||||
|       const lastActivity = firstGroupItems[firstGroupItems.length - 1]; | ||||
|       const startBound = firstActivity.start; | ||||
|       const endBound = lastActivity.end; | ||||
|  | ||||
|       // Switch to fixed time mode with all plan events within the bounds | ||||
|       await page.goto( | ||||
| @@ -118,7 +82,7 @@ test.describe('Time List', () => { | ||||
|       // Verify all events are displayed | ||||
|       const eventCount = await page.getByRole('row').count(); | ||||
|       // subtracting one for the header | ||||
|       await expect(eventCount - 1).toEqual(testPlan.TEST_GROUP.length); | ||||
|       await expect(eventCount - 1).toEqual(firstGroupItems.length); | ||||
|     }); | ||||
|  | ||||
|     await test.step('Does not show milliseconds in times', async () => { | ||||
| @@ -131,6 +95,81 @@ test.describe('Time List', () => { | ||||
|       await expect(row.locator('.--end')).not.toContainText('.'); | ||||
|       await expect(row.locator('.--duration')).not.toContainText('.'); | ||||
|     }); | ||||
|  | ||||
|     await test.step('Shows activity properties when a row is selected', async () => { | ||||
|       await page.getByRole('row').nth(2).click(); | ||||
|  | ||||
|       // Find the activity state section in the inspector | ||||
|       await page.getByRole('tab', { name: 'Activity' }).click(); | ||||
|       // Check that activity state label is displayed in the inspector. | ||||
|       await expect(page.getByLabel('Activity Status').locator("[aria-selected='true']")).toHaveText( | ||||
|         'Not started' | ||||
|       ); | ||||
|     }); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
| test("View a timelist in expanded view, verify all the activities are displayed and selecting an activity shows it's properties", async ({ | ||||
|   page | ||||
| }) => { | ||||
|   // Goto baseURL | ||||
|   await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|  | ||||
|   const timelist = await test.step('Create a Time List', async () => { | ||||
|     const createdTimeList = await createDomainObjectWithDefaults(page, { type: 'Time List' }); | ||||
|     const objectName = await page.locator('.l-browse-bar__object-name').innerText(); | ||||
|     expect(objectName).toBe(createdTimeList.name); | ||||
|  | ||||
|     return createdTimeList; | ||||
|   }); | ||||
|  | ||||
|   await test.step('Create a Plan and add it to the timelist', async () => { | ||||
|     await createPlanFromJSON(page, { | ||||
|       name: 'Test Plan', | ||||
|       json: examplePlanSmall1, | ||||
|       parent: timelist.uuid | ||||
|     }); | ||||
|  | ||||
|     // Ensure that all activities are shown in the expanded view | ||||
|     const groups = Object.keys(examplePlanSmall1); | ||||
|     const firstGroupKey = groups[0]; | ||||
|     const firstGroupItems = examplePlanSmall1[firstGroupKey]; | ||||
|     const firstActivity = firstGroupItems[0]; | ||||
|     const lastActivity = firstGroupItems[firstGroupItems.length - 1]; | ||||
|     const startBound = firstActivity.start; | ||||
|     const endBound = lastActivity.end; | ||||
|  | ||||
|     // Switch to fixed time mode with all plan events within the bounds | ||||
|     await page.goto( | ||||
|       `${timelist.url}?tc.mode=fixed&tc.startBound=${startBound}&tc.endBound=${endBound}&tc.timeSystem=utc&view=timelist.view` | ||||
|     ); | ||||
|  | ||||
|     // Change the object to edit mode | ||||
|     await page.getByRole('button', { name: 'Edit Object' }).click(); | ||||
|  | ||||
|     // Find the display properties section in the inspector | ||||
|     await page.getByRole('tab', { name: 'View Properties' }).click(); | ||||
|     // Switch to expanded view and save the setting | ||||
|     await page.getByLabel('Display Style').selectOption({ label: 'Expanded' }); | ||||
|  | ||||
|     // Click on the "Save" button | ||||
|     await page.getByRole('button', { name: 'Save' }).click(); | ||||
|     await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(); | ||||
|  | ||||
|     // Verify all events are displayed | ||||
|     const eventCount = await page.getByRole('row').count(); | ||||
|     await expect(eventCount).toEqual(firstGroupItems.length); | ||||
|   }); | ||||
|  | ||||
|   await test.step('Shows activity properties when a row is selected', async () => { | ||||
|     await page.getByRole('row').nth(2).click(); | ||||
|  | ||||
|     // Find the activity state section in the inspector | ||||
|     await page.getByRole('tab', { name: 'Activity' }).click(); | ||||
|     // Check that activity state label is displayed in the inspector. | ||||
|     await expect(page.getByLabel('Activity Status').locator("[aria-selected='true']")).toHaveText( | ||||
|       'Not started' | ||||
|     ); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
| @@ -147,8 +186,8 @@ test.describe('Time List', () => { | ||||
| const COUNTDOWN_REGEXP = /(-)?(\d+D\s)?(\d{2}):(\d{2}):(\d{2})/; | ||||
|  | ||||
| /** | ||||
|  * @typedef {Object} CountdownObject | ||||
|  * @property {string} sign - The sign of the countdown ('-' if the countdown is negative, otherwise undefined). | ||||
|  * @typedef {Object} CountdownOrUpObject | ||||
|  * @property {string} sign - The sign of the countdown ('-' if the countdown is negative, '+' otherwise). | ||||
|  * @property {string} days - The number of days in the countdown (undefined if there are no days). | ||||
|  * @property {string} hours - The number of hours in the countdown. | ||||
|  * @property {string} minutes - The number of minutes in the countdown. | ||||
| @@ -220,11 +259,13 @@ test.describe('Time List with controlled clock', () => { | ||||
|       await test.step(`Countdown cell ${i + 1} counts down`, async () => { | ||||
|         const countdownCell = countdownCells[i]; | ||||
|         // Get the initial countdown timestamp object | ||||
|         const beforeCountdown = await getAndAssertCountdownObject(page, i + 3); | ||||
|         const beforeCountdown = await getAndAssertCountdownOrUpObject(page, i + 3); | ||||
|         // should not have a '-' sign | ||||
|         await expect(countdownCell).not.toHaveText('-'); | ||||
|         // Wait until it changes | ||||
|         await expect(countdownCell).not.toHaveText(beforeCountdown.toString()); | ||||
|         // Get the new countdown timestamp object | ||||
|         const afterCountdown = await getAndAssertCountdownObject(page, i + 3); | ||||
|         const afterCountdown = await getAndAssertCountdownOrUpObject(page, i + 3); | ||||
|         // Verify that the new countdown timestamp object is less than the old one | ||||
|         expect(Number(afterCountdown.seconds)).toBeLessThan(Number(beforeCountdown.seconds)); | ||||
|       }); | ||||
| @@ -233,15 +274,17 @@ test.describe('Time List with controlled clock', () => { | ||||
|     // Verify that the count-up cells are counting up | ||||
|     for (let i = 0; i < countUpCells.length; i++) { | ||||
|       await test.step(`Count-up cell ${i + 1} counts up`, async () => { | ||||
|         const countdownCell = countUpCells[i]; | ||||
|         const countUpCell = countUpCells[i]; | ||||
|         // Get the initial count-up timestamp object | ||||
|         const beforeCountdown = await getAndAssertCountdownObject(page, i + 1); | ||||
|         const beforeCountUp = await getAndAssertCountdownOrUpObject(page, i + 1); | ||||
|         // should not have a '+' sign | ||||
|         await expect(countUpCell).not.toHaveText('+'); | ||||
|         // Wait until it changes | ||||
|         await expect(countdownCell).not.toHaveText(beforeCountdown.toString()); | ||||
|         await expect(countUpCell).not.toHaveText(beforeCountUp.toString()); | ||||
|         // Get the new count-up timestamp object | ||||
|         const afterCountdown = await getAndAssertCountdownObject(page, i + 1); | ||||
|         const afterCountUp = await getAndAssertCountdownOrUpObject(page, i + 1); | ||||
|         // Verify that the new count-up timestamp object is greater than the old one | ||||
|         expect(Number(afterCountdown.seconds)).toBeGreaterThan(Number(beforeCountdown.seconds)); | ||||
|         expect(Number(afterCountUp.seconds)).toBeGreaterThan(Number(beforeCountUp.seconds)); | ||||
|       }); | ||||
|     } | ||||
|   }); | ||||
| @@ -271,13 +314,13 @@ async function getCellTextByIndex(page, rowIndex, columnIndex) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get the text from the countdown cell in the given row, assert that it matches the countdown | ||||
|  * Get the text from the countdown (or countup) cell in the given row, assert that it matches the countdown/countup | ||||
|  * regex, and return an object representing the countdown. | ||||
|  * @param {import('@playwright/test').Page} page | ||||
|  * @param {number} rowIndex the row index | ||||
|  * @returns {Promise<CountdownObject>} countdownObject | ||||
|  * @returns {Promise<CountdownOrUpObject>} The countdown (or countup) object | ||||
|  */ | ||||
| async function getAndAssertCountdownObject(page, rowIndex) { | ||||
| async function getAndAssertCountdownOrUpObject(page, rowIndex) { | ||||
|   const timeToFrom = await getCellTextByIndex(page, HEADER_ROW + rowIndex, TIME_TO_FROM_COLUMN); | ||||
|  | ||||
|   expect(timeToFrom).toMatch(COUNTDOWN_REGEXP); | ||||
|   | ||||
| @@ -35,7 +35,7 @@ import { expect, test } from '../../../../pluginFixtures.js'; | ||||
|  | ||||
| let conditionSetUrl; | ||||
|  | ||||
| test.describe.serial('Condition Set CRUD Operations on @localStorage', () => { | ||||
| test.describe.serial('Condition Set CRUD Operations on @localStorage @2p', () => { | ||||
|   test.beforeAll(async ({ browser }) => { | ||||
|     //TODO: This needs to be refactored | ||||
|     const context = await browser.newContext(); | ||||
| @@ -68,30 +68,35 @@ test.describe.serial('Condition Set CRUD Operations on @localStorage', () => { | ||||
|   }); | ||||
|  | ||||
|   //Begin suite of tests again localStorage | ||||
|   test('Condition set object properties persist in main view and inspector @localStorage', async ({ | ||||
|     page | ||||
|   }) => { | ||||
|     //Navigate to baseURL with injected localStorage | ||||
|     await page.goto(conditionSetUrl, { waitUntil: 'networkidle' }); | ||||
|   test.fixme( | ||||
|     'Condition set object properties persist in main view and inspector @localStorage', | ||||
|     async ({ page }) => { | ||||
|       test.info().annotations.push({ | ||||
|         type: 'issue', | ||||
|         description: 'https://github.com/nasa/openmct/issues/7421' | ||||
|       }); | ||||
|       //Navigate to baseURL with injected localStorage | ||||
|       await page.goto(conditionSetUrl, { waitUntil: 'networkidle' }); | ||||
|  | ||||
|     //Assertions on loaded Condition Set in main view. This is a stateful transition step after page.goto() | ||||
|     await expect | ||||
|       .soft(page.locator('.l-browse-bar__object-name')) | ||||
|       .toContainText('Unnamed Condition Set'); | ||||
|       //Assertions on loaded Condition Set in main view. This is a stateful transition step after page.goto() | ||||
|       await expect | ||||
|         .soft(page.locator('.l-browse-bar__object-name')) | ||||
|         .toContainText('Unnamed Condition Set'); | ||||
|  | ||||
|     //Assertions on loaded Condition Set in Inspector | ||||
|     expect.soft(page.locator('_vue=item.name=Unnamed Condition Set')).toBeTruthy(); | ||||
|       //Assertions on loaded Condition Set in Inspector | ||||
|       expect.soft(page.locator('_vue=item.name=Unnamed Condition Set')).toBeTruthy(); | ||||
|  | ||||
|     //Reload Page | ||||
|     await Promise.all([page.reload(), page.waitForLoadState('networkidle')]); | ||||
|       //Reload Page | ||||
|       await Promise.all([page.reload(), page.waitForLoadState('networkidle')]); | ||||
|  | ||||
|     //Re-verify after reload | ||||
|     await expect | ||||
|       .soft(page.locator('.l-browse-bar__object-name')) | ||||
|       .toContainText('Unnamed Condition Set'); | ||||
|     //Assertions on loaded Condition Set in Inspector | ||||
|     expect.soft(page.locator('_vue=item.name=Unnamed Condition Set')).toBeTruthy(); | ||||
|   }); | ||||
|       //Re-verify after reload | ||||
|       await expect | ||||
|         .soft(page.locator('.l-browse-bar__object-name')) | ||||
|         .toContainText('Unnamed Condition Set'); | ||||
|       //Assertions on loaded Condition Set in Inspector | ||||
|       expect.soft(page.locator('_vue=item.name=Unnamed Condition Set')).toBeTruthy(); | ||||
|     } | ||||
|   ); | ||||
|   test('condition set object can be modified on @localStorage', async ({ page, openmctConfig }) => { | ||||
|     const { myItemsFolderName } = openmctConfig; | ||||
|  | ||||
| @@ -293,7 +298,7 @@ test.describe('Basic Condition Set Use', () => { | ||||
|   }) => { | ||||
|     const exampleTelemetry = await createExampleTelemetryObject(page); | ||||
|  | ||||
|     await page.getByTitle('Show selected item in tree').click(); | ||||
|     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(); | ||||
| @@ -373,4 +378,83 @@ test.describe('Basic Condition Set Use', () => { | ||||
|     await page.goto(conditionSet.url); | ||||
|     await expect(outputValue).toHaveText('---'); | ||||
|   }); | ||||
|  | ||||
|   test('ConditionSet has correct outputs when test data is enabled', 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 two conditions | ||||
|     await page.locator('#addCondition').click(); | ||||
|     await page.locator('#addCondition').click(); | ||||
|     await page.locator('#conditionCollection').getByRole('textbox').nth(0).fill('First Condition'); | ||||
|     await page.locator('#conditionCollection').getByRole('textbox').nth(1).fill('Second Condition'); | ||||
|  | ||||
|     // 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); | ||||
|  | ||||
|     // Modify First Criterion | ||||
|     const firstCriterionTelemetry = page.locator( | ||||
|       '[aria-label="Criterion Telemetry Selection"] >> nth=0' | ||||
|     ); | ||||
|     firstCriterionTelemetry.selectOption({ label: exampleTelemetry.name }); | ||||
|     const firstCriterionMetadata = page.locator( | ||||
|       '[aria-label="Criterion Metadata Selection"] >> nth=0' | ||||
|     ); | ||||
|     firstCriterionMetadata.selectOption({ label: 'Sine' }); | ||||
|     const firstCriterionComparison = page.locator( | ||||
|       '[aria-label="Criterion Comparison Selection"] >> nth=0' | ||||
|     ); | ||||
|     firstCriterionComparison.selectOption({ label: 'is greater than or equal to' }); | ||||
|     const firstCriterionInput = page.locator('[aria-label="Criterion Input"] >> nth=0'); | ||||
|     await firstCriterionInput.fill('0'); | ||||
|  | ||||
|     // Modify Second Criterion | ||||
|     const secondCriterionTelemetry = page.locator( | ||||
|       '[aria-label="Criterion Telemetry Selection"] >> nth=1' | ||||
|     ); | ||||
|     await secondCriterionTelemetry.selectOption({ label: exampleTelemetry.name }); | ||||
|  | ||||
|     const secondCriterionMetadata = page.locator( | ||||
|       '[aria-label="Criterion Metadata Selection"] >> nth=1' | ||||
|     ); | ||||
|     await secondCriterionMetadata.selectOption({ label: 'Sine' }); | ||||
|  | ||||
|     const secondCriterionComparison = page.locator( | ||||
|       '[aria-label="Criterion Comparison Selection"] >> nth=1' | ||||
|     ); | ||||
|     await secondCriterionComparison.selectOption({ label: 'is less than' }); | ||||
|  | ||||
|     const secondCriterionInput = page.locator('[aria-label="Criterion Input"] >> nth=1'); | ||||
|     await secondCriterionInput.fill('0'); | ||||
|  | ||||
|     // Enable test data | ||||
|     await page.getByLabel('Apply Test Data').nth(1).click(); | ||||
|     const testDataTelemetry = page.locator('[aria-label="Test Data Telemetry Selection"] >> nth=0'); | ||||
|     await testDataTelemetry.selectOption({ label: exampleTelemetry.name }); | ||||
|  | ||||
|     const testDataMetadata = page.locator('[aria-label="Test Data Metadata Selection"] >> nth=0'); | ||||
|     await testDataMetadata.selectOption({ label: 'Sine' }); | ||||
|  | ||||
|     const testInput = page.locator('[aria-label="Test Data Input"] >> nth=0'); | ||||
|     await testInput.fill('0'); | ||||
|  | ||||
|     // Validate that the condition set is evaluating and outputting | ||||
|     // the correct value when the underlying telemetry subscription is active. | ||||
|     let outputValue = page.locator('[aria-label="Current Output Value"]'); | ||||
|     await expect(outputValue).toHaveText('false'); | ||||
|  | ||||
|     await page.goto(exampleTelemetry.url); | ||||
|   }); | ||||
| }); | ||||
|   | ||||
| @@ -161,6 +161,13 @@ test.describe('Display Layout', () => { | ||||
|     const trimmedDisplayValue = displayLayoutValue.trim(); | ||||
|  | ||||
|     expect(trimmedDisplayValue).toBe(formattedTelemetryValue); | ||||
|  | ||||
|     // ensure we can right click on the alpha-numeric widget and view historical data | ||||
|     await page.getByLabel('Sine', { exact: true }).click({ | ||||
|       button: 'right' | ||||
|     }); | ||||
|     await page.getByLabel('View Historical Data').click(); | ||||
|     await expect(page.getByLabel('Plot Container Style Target')).toBeVisible(); | ||||
|   }); | ||||
|   test('alpha-numeric widget telemetry value exactly matches latest telemetry value received in fixed time', async ({ | ||||
|     page | ||||
|   | ||||
| @@ -136,7 +136,11 @@ test.describe('Gauge', () => { | ||||
|     // TODO: Verify changes in the UI | ||||
|   }); | ||||
|  | ||||
|   test('Gauge does not display NaN when data not available', async ({ page }) => { | ||||
|   test.fixme('Gauge does not display NaN when data not available', async ({ page }) => { | ||||
|     test.info().annotations.push({ | ||||
|       type: 'issue', | ||||
|       description: 'https://github.com/nasa/openmct/issues/7421' | ||||
|     }); | ||||
|     // Create a Gauge | ||||
|     const gauge = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Gauge' | ||||
|   | ||||
| @@ -363,7 +363,7 @@ test.describe('Example Imagery in Display Layout', () => { | ||||
|     await page.locator('li[title="View Large"]').click(); | ||||
|     await expect(pausePlayButton).toHaveClass(/is-paused/); | ||||
|  | ||||
|     await page.locator('[aria-label="Close"]').click(); | ||||
|     await page.getByRole('button', { name: 'Close' }).click(); | ||||
|     await expect.soft(pausePlayButton).not.toHaveClass(/is-paused/); | ||||
|   }); | ||||
|  | ||||
| @@ -386,7 +386,7 @@ test.describe('Example Imagery in Display Layout', () => { | ||||
|     await page.locator('li[title="View Large"]').click(); | ||||
|     await expect(pausePlayButton).toHaveClass(/is-paused/); | ||||
|  | ||||
|     await page.locator('[aria-label="Close"]').click(); | ||||
|     await page.getByRole('button', { name: 'Close' }).click(); | ||||
|     await expect.soft(pausePlayButton).toHaveClass(/is-paused/); | ||||
|   }); | ||||
|  | ||||
| @@ -509,7 +509,7 @@ test.describe('Example Imagery in Flexible layout', () => { | ||||
|     await page.getByRole('button', { name: 'Background Image', state: 'visible' }); | ||||
|  | ||||
|     // Close the large view | ||||
|     await page.getByLabel('Close').click(); | ||||
|     await page.getByRole('button', { name: 'Close' }).click(); | ||||
|   }); | ||||
|  | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|   | ||||
| @@ -24,36 +24,182 @@ | ||||
| This test suite is dedicated to tests which verify the basic operations surrounding exportAsJSON. | ||||
| */ | ||||
|  | ||||
| // FIXME: Remove this eslint exception once tests are implemented | ||||
| // eslint-disable-next-line no-unused-vars | ||||
| import fs from 'fs/promises'; | ||||
|  | ||||
| import { | ||||
|   createDomainObjectWithDefaults, | ||||
|   openObjectTreeContextMenu | ||||
| } from '../../../../appActions.js'; | ||||
| import { expect, test } from '../../../../baseFixtures.js'; | ||||
| import { navigateToFaultManagementWithExample } from '../../../../helper/faultUtils.js'; | ||||
|  | ||||
| test.describe('ExportAsJSON', () => { | ||||
|   test.fixme( | ||||
|     'Create a basic object and verify that it can be exported as JSON from Tree', | ||||
|     async ({ page }) => { | ||||
|       //Create domain object | ||||
|       //Save Domain Object | ||||
|       //Verify that the newly created domain object can be exported as JSON from the Tree | ||||
|     } | ||||
|   ); | ||||
|   test.fixme( | ||||
|     'Create a basic object and verify that it can be exported as JSON from 3 dot menu', | ||||
|     async ({ page }) => { | ||||
|       //Create domain object | ||||
|       //Save Domain Object | ||||
|       //Verify that the newly created domain object can be exported as JSON from the 3 dot menu | ||||
|     } | ||||
|   ); | ||||
|   test.fixme('Verify that a nested Object can be exported as JSON', async ({ page }) => { | ||||
|     // Create 2 objects with hierarchy | ||||
|     // Export as JSON | ||||
|     // Verify Hierarchy | ||||
|   let folder; | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     // Go to baseURL | ||||
|     await page.goto('./'); | ||||
|     // Perform actions to create the domain object | ||||
|     folder = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Folder', | ||||
|       name: 'e2e folder' | ||||
|     }); | ||||
|   }); | ||||
|   test('Create a basic object and verify that it can be exported as JSON from Tree', async ({ | ||||
|     page | ||||
|   }) => { | ||||
|     // Navigate to the page | ||||
|     await page.goto(folder.url); | ||||
|  | ||||
|     // Open context menu and initiate download | ||||
|     await openObjectTreeContextMenu(page, folder.url); | ||||
|     const [download] = await Promise.all([ | ||||
|       page.waitForEvent('download'), // Waits for the download event | ||||
|       page.getByLabel('Export as JSON').click() // Triggers the download | ||||
|     ]); | ||||
|  | ||||
|     // Wait for the download process to complete | ||||
|     const path = await download.path(); | ||||
|  | ||||
|     // Read the contents of the downloaded file using readFile from fs/promises | ||||
|     const fileContents = await fs.readFile(path, 'utf8'); | ||||
|     const jsonData = JSON.parse(fileContents); | ||||
|  | ||||
|     // Use the function to retrieve the key | ||||
|     const key = getFirstKeyFromOpenMctJson(jsonData); | ||||
|  | ||||
|     // Verify the contents of the JSON file | ||||
|     expect(jsonData.openmct[key]).toHaveProperty('name', 'e2e folder'); | ||||
|     expect(jsonData.openmct[key]).toHaveProperty('type', 'folder'); | ||||
|   }); | ||||
|   test('Create a basic object and verify that it can be exported as JSON from 3 dot menu', async ({ | ||||
|     page | ||||
|   }) => { | ||||
|     // Navigate to the page | ||||
|     await page.goto(folder.url); | ||||
|     //3 dot menu | ||||
|     await page.getByLabel('More actions').click(); | ||||
|     // Open context menu and initiate download | ||||
|     const [download] = await Promise.all([ | ||||
|       page.waitForEvent('download'), // Waits for the download event | ||||
|       page.getByLabel('Export as JSON').click() // Triggers the download | ||||
|     ]); | ||||
|  | ||||
|     // Read the contents of the downloaded file using readFile from fs/promises | ||||
|     const fileContents = await fs.readFile(await download.path(), 'utf8'); | ||||
|     const jsonData = JSON.parse(fileContents); | ||||
|  | ||||
|     // Use the function to retrieve the key | ||||
|     const key = getFirstKeyFromOpenMctJson(jsonData); | ||||
|  | ||||
|     // Verify the contents of the JSON file | ||||
|     expect(jsonData.openmct[key]).toHaveProperty('name', 'e2e folder'); | ||||
|     expect(jsonData.openmct[key]).toHaveProperty('type', 'folder'); | ||||
|   }); | ||||
|   test('Verify that a nested Object can be exported as JSON', async ({ page }) => { | ||||
|     const timer = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Timer', | ||||
|       name: 'timer', | ||||
|       parent: folder.uuid | ||||
|     }); | ||||
|     // Navigate to the page | ||||
|     await page.goto(timer.url); | ||||
|  | ||||
|     //do this against parent folder.url, NOT timer.url child | ||||
|     await openObjectTreeContextMenu(page, folder.url); | ||||
|     // Open context menu and initiate download | ||||
|     const [download] = await Promise.all([ | ||||
|       page.waitForEvent('download'), // Waits for the download event | ||||
|       page.getByLabel('Export as JSON').click() // Triggers the download | ||||
|     ]); | ||||
|  | ||||
|     // Read the contents of the downloaded file | ||||
|     const fileContents = await fs.readFile(await download.path(), 'utf8'); | ||||
|     const jsonData = JSON.parse(fileContents); | ||||
|  | ||||
|     // Retrieve the keys for folder and timer | ||||
|     const folderKey = getFirstKeyFromOpenMctJson(jsonData); | ||||
|     const timerKey = jsonData.openmct[folderKey].composition[0].key; | ||||
|  | ||||
|     // Verify the folder properties | ||||
|     expect(jsonData.openmct[folderKey]).toHaveProperty('name', 'e2e folder'); | ||||
|     expect(jsonData.openmct[folderKey]).toHaveProperty('type', 'folder'); | ||||
|  | ||||
|     // Verify the timer properties | ||||
|     expect(jsonData.openmct[timerKey]).toHaveProperty('name', 'timer'); | ||||
|     expect(jsonData.openmct[timerKey]).toHaveProperty('type', 'timer'); | ||||
|  | ||||
|     // Verify the composition of the folder includes the timer | ||||
|     expect(jsonData.openmct[folderKey].composition).toEqual( | ||||
|       expect.arrayContaining([expect.objectContaining({ key: timerKey })]) | ||||
|     ); | ||||
|   }); | ||||
|   test.fixme( | ||||
|     'Verify that the ExportAsJSON dropdown does not appear for the item X', | ||||
|     async ({ page }) => { | ||||
|       // Other than non-persistable objects | ||||
|     } | ||||
|   ); | ||||
| }); | ||||
| test.describe('ExportAsJSON Disabled Actions', () => { | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     //Use a Fault Management Object which is not composable | ||||
|     await navigateToFaultManagementWithExample(page); | ||||
|   }); | ||||
|   test('Verify that the ExportAsJSON dropdown does not appear for the item X', async ({ page }) => { | ||||
|     await page.getByLabel('More actions').click(); | ||||
|     await expect(await page.getByLabel('Export as JSON')).toHaveCount(0); | ||||
|  | ||||
|     await page.getByRole('treeitem', { name: 'Fault Management' }).click({ | ||||
|       button: 'right' | ||||
|     }); | ||||
|     await expect(await page.getByLabel('Export as JSON')).toHaveCount(0); | ||||
|   }); | ||||
| }); | ||||
| test.describe('ExportAsJSON ProgressBar @couchdb', () => { | ||||
|   let folder; | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     await page.goto('./', { waitUntil: 'networkidle' }); | ||||
|     // Perform actions to create the domain object | ||||
|     folder = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Folder' | ||||
|     }); | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Timer', | ||||
|       parent: folder.uuid | ||||
|     }); | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Timer', | ||||
|       parent: folder.uuid | ||||
|     }); | ||||
|   }); | ||||
|   test('Verify that the ExportAsJSON action creates a progressbar', async ({ page }) => { | ||||
|     // Navigate to the page | ||||
|     await page.goto(folder.url); | ||||
|  | ||||
|     //Export My Items to create a large export | ||||
|     await page.getByRole('treeitem', { name: 'My Items' }).click({ button: 'right' }); | ||||
|     // Open context menu and initiate download | ||||
|     await Promise.all([ | ||||
|       page.getByRole('progressbar'), // This is just a check for the progress bar | ||||
|       page.getByText( | ||||
|         'Do not navigate away from this page or close this browser tab while this message' | ||||
|       ), // This is the text associated with the download | ||||
|       page.waitForEvent('download'), // Waits for the download event | ||||
|       page.getByLabel('Export as JSON').click() // Triggers the download | ||||
|     ]); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
| /** | ||||
|  * Retrieves the first key from the 'openmct' property of the provided JSON object. | ||||
|  * | ||||
|  * @param {Object} jsonData - The JSON object containing the 'openmct' property. | ||||
|  * @returns {string} The first key found in the 'openmct' object. | ||||
|  * @throws {Error} If no keys are found in the 'openmct' object. | ||||
|  */ | ||||
| function getFirstKeyFromOpenMctJson(jsonData) { | ||||
|   if (!jsonData.openmct) { | ||||
|     throw new Error("The provided JSON object does not have an 'openmct' property."); | ||||
|   } | ||||
|  | ||||
|   const keys = Object.keys(jsonData.openmct); | ||||
|   if (keys.length === 0) { | ||||
|     throw new Error('No keys found in the openmct object'); | ||||
|   } | ||||
|  | ||||
|   return keys[0]; | ||||
| } | ||||
|   | ||||
| @@ -36,7 +36,7 @@ test.describe('Testing numeric data with inspector data visualization (i.e., dat | ||||
|     await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|   }); | ||||
|  | ||||
|   test('Can click on telemetry and see data in inspector', async ({ page, context }) => { | ||||
|   test('Can click on telemetry and see data in inspector @2p', async ({ page, context }) => { | ||||
|     const exampleDataVisualizationSource = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Example Data Visualization Source' | ||||
|     }); | ||||
|   | ||||
| @@ -53,6 +53,9 @@ test.describe('LAD Table Sets', () => { | ||||
|  | ||||
|     await page.goto(ladTableSet.url); | ||||
|  | ||||
|     // Wait for the initial value to show after mount | ||||
|     await expect(page.getByLabel('lad value').first()).not.toContainText('---'); | ||||
|  | ||||
|     const valueFromFirstSineWave = await page.getByLabel('lad value').first().innerText(); | ||||
|     const firstSineWaveNumber = parseFloat(valueFromFirstSineWave); | ||||
|     // ensure we have a float value in the cell and it's finite | ||||
|   | ||||
| @@ -308,7 +308,7 @@ test.describe('Notebook entry tests', () => { | ||||
|     await page.goto(notebookObject.url); | ||||
|  | ||||
|     // Reveal the notebook in the tree | ||||
|     await page.getByTitle('Show selected item in tree').click(); | ||||
|     await page.getByLabel('Show selected item in tree').click(); | ||||
|  | ||||
|     await page | ||||
|       .getByRole('treeitem', { name: overlayPlot.name }) | ||||
| @@ -332,7 +332,7 @@ test.describe('Notebook entry tests', () => { | ||||
|     await page.goto(notebookObject.url); | ||||
|  | ||||
|     // Reveal the notebook in the tree | ||||
|     await page.getByTitle('Show selected item in tree').click(); | ||||
|     await page.getByLabel('Show selected item in tree').click(); | ||||
|  | ||||
|     await nbUtils.enterTextEntry(page, 'Entry to drop into'); | ||||
|     await page | ||||
| @@ -377,7 +377,7 @@ test.describe('Notebook entry tests', () => { | ||||
|     await page.goto(notebookObject.url); | ||||
|  | ||||
|     // Reveal the notebook in the tree | ||||
|     await page.getByTitle('Show selected item in tree').click(); | ||||
|     await page.getByLabel('Show selected item in tree').click(); | ||||
|  | ||||
|     await nbUtils.enterTextEntry(page, `This should be a link: ${TEST_LINK} is it?`); | ||||
|  | ||||
| @@ -404,7 +404,7 @@ test.describe('Notebook entry tests', () => { | ||||
|     await page.goto(notebookObject.url); | ||||
|  | ||||
|     // Reveal the notebook in the tree | ||||
|     await page.getByTitle('Show selected item in tree').click(); | ||||
|     await page.getByLabel('Show selected item in tree').click(); | ||||
|  | ||||
|     await nbUtils.enterTextEntry(page, `This should NOT be a link: ${TEST_LINK} is it?`); | ||||
|  | ||||
| @@ -421,7 +421,7 @@ test.describe('Notebook entry tests', () => { | ||||
|     await page.goto(notebookObject.url); | ||||
|  | ||||
|     // Reveal the notebook in the tree | ||||
|     await page.getByTitle('Show selected item in tree').click(); | ||||
|     await page.getByLabel('Show selected item in tree').click(); | ||||
|  | ||||
|     await nbUtils.enterTextEntry(page, `This should NOT be a link: ${TEST_LINK} is it?`); | ||||
|  | ||||
| @@ -438,7 +438,7 @@ test.describe('Notebook entry tests', () => { | ||||
|     await page.goto(notebookObject.url); | ||||
|  | ||||
|     // Reveal the notebook in the tree | ||||
|     await page.getByTitle('Show selected item in tree').click(); | ||||
|     await page.getByLabel('Show selected item in tree').click(); | ||||
|  | ||||
|     await nbUtils.enterTextEntry(page, `This should be a link: ${INVALID_TEST_LINK} is it?`); | ||||
|  | ||||
| @@ -455,7 +455,7 @@ test.describe('Notebook entry tests', () => { | ||||
|     await page.goto(notebookObject.url); | ||||
|  | ||||
|     // Reveal the notebook in the tree | ||||
|     await page.getByTitle('Show selected item in tree').click(); | ||||
|     await page.getByLabel('Show selected item in tree').click(); | ||||
|  | ||||
|     await nbUtils.enterTextEntry(page, `This should be a link: ${TEST_LINK} is it?`); | ||||
|  | ||||
| @@ -483,7 +483,7 @@ test.describe('Notebook entry tests', () => { | ||||
|     await page.goto(notebookObject.url); | ||||
|  | ||||
|     // Reveal the notebook in the tree | ||||
|     await page.getByTitle('Show selected item in tree').click(); | ||||
|     await page.getByLabel('Show selected item in tree').click(); | ||||
|  | ||||
|     await nbUtils.enterTextEntry( | ||||
|       page, | ||||
|   | ||||
| @@ -0,0 +1,147 @@ | ||||
| /***************************************************************************** | ||||
|  * 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 Notebooks. | ||||
| */ | ||||
|  | ||||
| import fs from 'fs/promises'; | ||||
| import { fileURLToPath } from 'url'; | ||||
|  | ||||
| import { createDomainObjectWithDefaults } from '../../../../appActions.js'; | ||||
| import { expect, test } from '../../../../pluginFixtures.js'; | ||||
|  | ||||
| const NOTEBOOK_NAME = 'Notebook'; | ||||
|  | ||||
| test.describe('Snapshot image tests', () => { | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     //Navigate to baseURL | ||||
|     await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|  | ||||
|     // Create Notebook | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: NOTEBOOK_NAME | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   test('Can drop an image onto a notebook and create a new entry', async ({ page }) => { | ||||
|     const imageData = await fs.readFile( | ||||
|       fileURLToPath( | ||||
|         new URL('../../../../../src/images/favicons/favicon-96x96.png', import.meta.url) | ||||
|       ) | ||||
|     ); | ||||
|     const imageArray = new Uint8Array(imageData); | ||||
|     const fileData = Array.from(imageArray); | ||||
|  | ||||
|     const dropTransfer = await page.evaluateHandle((data) => { | ||||
|       const dataTransfer = new DataTransfer(); | ||||
|       const file = new File([new Uint8Array(data)], 'favicon-96x96.png', { type: 'image/png' }); | ||||
|       dataTransfer.items.add(file); | ||||
|       return dataTransfer; | ||||
|     }, fileData); | ||||
|  | ||||
|     await page.dispatchEvent('.c-notebook__drag-area', 'drop', { dataTransfer: dropTransfer }); | ||||
|     await page.locator('.c-ne__save-button > button').click(); | ||||
|     // be sure that entry was created | ||||
|     await expect(page.getByText('favicon-96x96.png')).toBeVisible(); | ||||
|  | ||||
|     await page.getByRole('img', { name: 'favicon-96x96.png thumbnail' }).click(); | ||||
|     // expect large image to be displayed | ||||
|     await expect(page.getByRole('dialog').getByText('favicon-96x96.png')).toBeVisible(); | ||||
|  | ||||
|     await page.getByRole('button', { name: 'Close' }).click(); | ||||
|  | ||||
|     // drop another image onto the entry | ||||
|     await page.dispatchEvent('.c-snapshots', 'drop', { dataTransfer: dropTransfer }); | ||||
|  | ||||
|     const secondThumbnail = page.getByRole('img', { name: 'favicon-96x96.png thumbnail' }).nth(1); | ||||
|     await secondThumbnail.waitFor({ state: 'attached' }); | ||||
|     // expect two embedded images now | ||||
|     expect(await page.getByRole('img', { name: 'favicon-96x96.png thumbnail' }).count()).toBe(2); | ||||
|  | ||||
|     await page.locator('.c-snapshot.c-ne__embed').first().getByTitle('More actions').click(); | ||||
|  | ||||
|     await page.getByRole('menuitem', { name: /Remove This Embed/ }).click(); | ||||
|     await page.getByRole('button', { name: 'Ok', exact: true }).click(); | ||||
|     // Ensure that the thumbnail is removed before we assert | ||||
|     await secondThumbnail.waitFor({ state: 'detached' }); | ||||
|  | ||||
|     // expect one embedded image now as we deleted the other | ||||
|     expect(await page.getByRole('img', { name: 'favicon-96x96.png thumbnail' }).count()).toBe(1); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
| test.describe('Snapshot image failure tests', () => { | ||||
|   test.use({ failOnConsoleError: false }); | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     //Navigate to baseURL | ||||
|     await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|  | ||||
|     // Create Notebook | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: NOTEBOOK_NAME | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   test('Get an error notification when dropping unknown file onto notebook entry', async ({ | ||||
|     page | ||||
|   }) => { | ||||
|     // fill Uint8Array array with some garbage data | ||||
|     const garbageData = new Uint8Array(100); | ||||
|     const fileData = Array.from(garbageData); | ||||
|  | ||||
|     const dropTransfer = await page.evaluateHandle((data) => { | ||||
|       const dataTransfer = new DataTransfer(); | ||||
|       const file = new File([new Uint8Array(data)], 'someGarbage.foo', { type: 'unknown/garbage' }); | ||||
|       dataTransfer.items.add(file); | ||||
|       return dataTransfer; | ||||
|     }, fileData); | ||||
|  | ||||
|     await page.dispatchEvent('.c-notebook__drag-area', 'drop', { dataTransfer: dropTransfer }); | ||||
|  | ||||
|     // should have gotten a notification from OpenMCT that we couldn't add it | ||||
|     await expect(page.getByText('Unknown object(s) dropped and cannot embed')).toBeVisible(); | ||||
|   }); | ||||
|  | ||||
|   test('Get an error notification when dropping big files onto notebook entry', async ({ | ||||
|     page | ||||
|   }) => { | ||||
|     const garbageSize = 15 * 1024 * 1024; // 15 megabytes | ||||
|  | ||||
|     await page.addScriptTag({ | ||||
|       // make the garbage client side | ||||
|       content: `window.bigGarbageData = new Uint8Array(${garbageSize})` | ||||
|     }); | ||||
|  | ||||
|     const bigDropTransfer = await page.evaluateHandle(() => { | ||||
|       const dataTransfer = new DataTransfer(); | ||||
|       const file = new File([window.bigGarbageData], 'bigBoy.png', { type: 'image/png' }); | ||||
|       dataTransfer.items.add(file); | ||||
|       return dataTransfer; | ||||
|     }); | ||||
|  | ||||
|     await page.dispatchEvent('.c-notebook__drag-area', 'drop', { dataTransfer: bigDropTransfer }); | ||||
|  | ||||
|     // should have gotten a notification from OpenMCT that we couldn't add it as it's too big | ||||
|     await expect(page.getByText('unable to embed')).toBeVisible(); | ||||
|   }); | ||||
| }); | ||||
| @@ -24,14 +24,8 @@ | ||||
| This test suite is dedicated to tests which verify the basic operations surrounding Notebooks. | ||||
| */ | ||||
|  | ||||
| import fs from 'fs/promises'; | ||||
| import { fileURLToPath } from 'url'; | ||||
|  | ||||
| import { createDomainObjectWithDefaults } from '../../../../appActions.js'; | ||||
| import { expect, test } from '../../../../pluginFixtures.js'; | ||||
|  | ||||
| const NOTEBOOK_NAME = 'Notebook'; | ||||
|  | ||||
| test.describe('Snapshot Menu tests', () => { | ||||
|   test.fixme( | ||||
|     'When no default notebook is selected, Snapshot Menu dropdown should only have a single option', | ||||
| @@ -91,22 +85,13 @@ test.describe('Snapshot Container tests', () => { | ||||
|  | ||||
|     await page.getByLabel('Take a Notebook Snapshot').click(); | ||||
|     await page.getByRole('menuitem', { name: 'Save to Notebook Snapshots' }).click(); | ||||
|     await page.getByRole('button', { name: 'Show' }).click(); | ||||
|     await page.getByLabel('Show Snapshots').click(); | ||||
|   }); | ||||
|   test('A snapshot can be Quick Viewed from Container with 3 dot action menu', async ({ page }) => { | ||||
|     await page.locator('.c-snapshot.c-ne__embed').first().getByTitle('More actions').click(); | ||||
|     await page.getByRole('menuitem', { name: 'Quick View' }).click(); | ||||
|     await expect(page.locator('.c-overlay__outer')).toBeVisible(); | ||||
|   }); | ||||
|   test.fixme('5 Snapshots can be added to a container', async ({ page }) => {}); | ||||
|   test.fixme( | ||||
|     '5 Snapshots can be added to a container and Deleted with Delete All action', | ||||
|     async ({ page }) => {} | ||||
|   ); | ||||
|   test.fixme( | ||||
|     'A snapshot can be Deleted from Container with 3 dot action menu', | ||||
|     async ({ page }) => {} | ||||
|   ); | ||||
|   test.fixme( | ||||
|     'A snapshot can be Viewed, Annotated, display deleted, and saved from Container with 3 dot action menu', | ||||
|     async ({ page }) => { | ||||
| @@ -122,7 +107,15 @@ test.describe('Snapshot Container tests', () => { | ||||
|       //await expect(await page.locator) | ||||
|     } | ||||
|   ); | ||||
|  | ||||
|   test.fixme('5 Snapshots can be added to a container', async ({ page }) => {}); | ||||
|   test.fixme( | ||||
|     '5 Snapshots can be added to a container and Deleted with Delete All action', | ||||
|     async ({ page }) => {} | ||||
|   ); | ||||
|   test.fixme( | ||||
|     'A snapshot can be Deleted from Container with 3 dot action menu', | ||||
|     async ({ page }) => {} | ||||
|   ); | ||||
|   test.fixme( | ||||
|     'A snapshot can be Navigated To from Container with 3 dot action menu', | ||||
|     async ({ page }) => {} | ||||
| @@ -166,117 +159,3 @@ test.describe('Snapshot Container tests', () => { | ||||
|     } | ||||
|   ); | ||||
| }); | ||||
|  | ||||
| test.describe('Snapshot image tests', () => { | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     //Navigate to baseURL | ||||
|     await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|  | ||||
|     // Create Notebook | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: NOTEBOOK_NAME | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   test('Can drop an image onto a notebook and create a new entry', async ({ page }) => { | ||||
|     const imageData = await fs.readFile( | ||||
|       fileURLToPath( | ||||
|         new URL('../../../../../src/images/favicons/favicon-96x96.png', import.meta.url) | ||||
|       ) | ||||
|     ); | ||||
|     const imageArray = new Uint8Array(imageData); | ||||
|     const fileData = Array.from(imageArray); | ||||
|  | ||||
|     const dropTransfer = await page.evaluateHandle((data) => { | ||||
|       const dataTransfer = new DataTransfer(); | ||||
|       const file = new File([new Uint8Array(data)], 'favicon-96x96.png', { type: 'image/png' }); | ||||
|       dataTransfer.items.add(file); | ||||
|       return dataTransfer; | ||||
|     }, fileData); | ||||
|  | ||||
|     await page.dispatchEvent('.c-notebook__drag-area', 'drop', { dataTransfer: dropTransfer }); | ||||
|     await page.locator('.c-ne__save-button > button').click(); | ||||
|     // be sure that entry was created | ||||
|     await expect(page.getByText('favicon-96x96.png')).toBeVisible(); | ||||
|  | ||||
|     await page.getByRole('img', { name: 'favicon-96x96.png thumbnail' }).click(); | ||||
|     // expect large image to be displayed | ||||
|     await expect(page.getByRole('dialog').getByText('favicon-96x96.png')).toBeVisible(); | ||||
|  | ||||
|     await page.getByLabel('Close').click(); | ||||
|  | ||||
|     // drop another image onto the entry | ||||
|     await page.dispatchEvent('.c-snapshots', 'drop', { dataTransfer: dropTransfer }); | ||||
|  | ||||
|     const secondThumbnail = page.getByRole('img', { name: 'favicon-96x96.png thumbnail' }).nth(1); | ||||
|     await secondThumbnail.waitFor({ state: 'attached' }); | ||||
|     // expect two embedded images now | ||||
|     expect(await page.getByRole('img', { name: 'favicon-96x96.png thumbnail' }).count()).toBe(2); | ||||
|  | ||||
|     await page.locator('.c-snapshot.c-ne__embed').first().getByTitle('More actions').click(); | ||||
|  | ||||
|     await page.getByRole('menuitem', { name: /Remove This Embed/ }).click(); | ||||
|     await page.getByRole('button', { name: 'Ok', exact: true }).click(); | ||||
|     // Ensure that the thumbnail is removed before we assert | ||||
|     await secondThumbnail.waitFor({ state: 'detached' }); | ||||
|  | ||||
|     // expect one embedded image now as we deleted the other | ||||
|     expect(await page.getByRole('img', { name: 'favicon-96x96.png thumbnail' }).count()).toBe(1); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
| test.describe('Snapshot image failure tests', () => { | ||||
|   test.use({ failOnConsoleError: false }); | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     //Navigate to baseURL | ||||
|     await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|  | ||||
|     // Create Notebook | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: NOTEBOOK_NAME | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   test('Get an error notification when dropping unknown file onto notebook entry', async ({ | ||||
|     page | ||||
|   }) => { | ||||
|     // fill Uint8Array array with some garbage data | ||||
|     const garbageData = new Uint8Array(100); | ||||
|     const fileData = Array.from(garbageData); | ||||
|  | ||||
|     const dropTransfer = await page.evaluateHandle((data) => { | ||||
|       const dataTransfer = new DataTransfer(); | ||||
|       const file = new File([new Uint8Array(data)], 'someGarbage.foo', { type: 'unknown/garbage' }); | ||||
|       dataTransfer.items.add(file); | ||||
|       return dataTransfer; | ||||
|     }, fileData); | ||||
|  | ||||
|     await page.dispatchEvent('.c-notebook__drag-area', 'drop', { dataTransfer: dropTransfer }); | ||||
|  | ||||
|     // should have gotten a notification from OpenMCT that we couldn't add it | ||||
|     await expect(page.getByText('Unknown object(s) dropped and cannot embed')).toBeVisible(); | ||||
|   }); | ||||
|  | ||||
|   test('Get an error notification when dropping big files onto notebook entry', async ({ | ||||
|     page | ||||
|   }) => { | ||||
|     const garbageSize = 15 * 1024 * 1024; // 15 megabytes | ||||
|  | ||||
|     await page.addScriptTag({ | ||||
|       // make the garbage client side | ||||
|       content: `window.bigGarbageData = new Uint8Array(${garbageSize})` | ||||
|     }); | ||||
|  | ||||
|     const bigDropTransfer = await page.evaluateHandle(() => { | ||||
|       const dataTransfer = new DataTransfer(); | ||||
|       const file = new File([window.bigGarbageData], 'bigBoy.png', { type: 'image/png' }); | ||||
|       dataTransfer.items.add(file); | ||||
|       return dataTransfer; | ||||
|     }); | ||||
|  | ||||
|     await page.dispatchEvent('.c-notebook__drag-area', 'drop', { dataTransfer: bigDropTransfer }); | ||||
|  | ||||
|     // should have gotten a notification from OpenMCT that we couldn't add it as it's too big | ||||
|     await expect(page.getByText('unable to embed')).toBeVisible(); | ||||
|   }); | ||||
| }); | ||||
|   | ||||
| @@ -51,7 +51,7 @@ test.describe('Operator Status', () => { | ||||
|     // Description should be empty https://github.com/nasa/openmct/issues/6978 | ||||
|     await expect(page.locator('.c-message__action-text')).toBeHidden(); | ||||
|     // set role | ||||
|     await page.getByRole('button', { name: 'Select' }).click(); | ||||
|     await page.getByRole('button', { name: 'Select', exact: true }).click(); | ||||
|     // dismiss role confirmation popup | ||||
|     await page.getByRole('button', { name: 'Dismiss' }).click(); | ||||
|   }); | ||||
|   | ||||
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 30 KiB | 
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 39 KiB | 
| @@ -33,15 +33,15 @@ import { | ||||
| import { expect, test } from '../../../../pluginFixtures.js'; | ||||
|  | ||||
| test.describe('Overlay Plot', () => { | ||||
|   let overlayPlot; | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|     overlayPlot = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Overlay Plot' | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   test('Plot legend color is in sync with plot series color', async ({ page }) => { | ||||
|     const overlayPlot = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Overlay Plot' | ||||
|     }); | ||||
|  | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Sine Wave Generator', | ||||
|       parent: overlayPlot.uuid | ||||
| @@ -63,6 +63,63 @@ test.describe('Overlay Plot', () => { | ||||
|     await expect(seriesColorSwatch).toHaveCSS('background-color', 'rgb(255, 166, 61)'); | ||||
|   }); | ||||
|  | ||||
|   test('Plot legend expands by default', async ({ page }) => { | ||||
|     test.info().annotations.push({ | ||||
|       type: 'issue', | ||||
|       description: 'https://github.com/nasa/openmct/issues/7403' | ||||
|     }); | ||||
|  | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Sine Wave Generator', | ||||
|       parent: overlayPlot.uuid | ||||
|     }); | ||||
|  | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Sine Wave Generator', | ||||
|       parent: overlayPlot.uuid | ||||
|     }); | ||||
|  | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Sine Wave Generator', | ||||
|       parent: overlayPlot.uuid | ||||
|     }); | ||||
|  | ||||
|     await page.goto(overlayPlot.url); | ||||
|  | ||||
|     await page.getByRole('tab', { name: 'Config' }).click(); | ||||
|  | ||||
|     // Assert that the legend is collapsed by default | ||||
|     await expect(page.getByLabel('Plot Legend Collapsed')).toBeVisible(); | ||||
|     await expect(page.getByLabel('Plot Legend Expanded')).toBeHidden(); | ||||
|     await expect(page.getByLabel('Expand by Default')).toHaveText('No'); | ||||
|  | ||||
|     expect(await page.getByLabel('Plot Legend Item').count()).toBe(3); | ||||
|  | ||||
|     // Change the legend to expand by default | ||||
|     await page.getByLabel('Edit Object').click(); | ||||
|     await page.getByLabel('Expand By Default').check(); | ||||
|     await page.getByLabel('Save').click(); | ||||
|     await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(); | ||||
|     // Assert that the legend is now open | ||||
|     await expect(page.getByLabel('Plot Legend Collapsed')).toBeHidden(); | ||||
|     await expect(page.getByLabel('Plot Legend Expanded')).toBeVisible(); | ||||
|     await expect(page.getByRole('cell', { name: 'Name' })).toBeVisible(); | ||||
|     await expect(page.getByRole('cell', { name: 'Timestamp' })).toBeVisible(); | ||||
|     await expect(page.getByRole('cell', { name: 'Value' })).toBeVisible(); | ||||
|     await expect(page.getByLabel('Expand by Default')).toHaveText('Yes'); | ||||
|     await expect(page.getByLabel('Plot Legend Item')).toHaveCount(3); | ||||
|  | ||||
|     // Assert that the legend is expanded on page load | ||||
|     await page.reload(); | ||||
|     await expect(page.getByLabel('Plot Legend Collapsed')).toBeHidden(); | ||||
|     await expect(page.getByLabel('Plot Legend Expanded')).toBeVisible(); | ||||
|     await expect(page.getByRole('cell', { name: 'Name' })).toBeVisible(); | ||||
|     await expect(page.getByRole('cell', { name: 'Timestamp' })).toBeVisible(); | ||||
|     await expect(page.getByRole('cell', { name: 'Value' })).toBeVisible(); | ||||
|     await expect(page.getByLabel('Expand by Default')).toHaveText('Yes'); | ||||
|     await expect(page.getByLabel('Plot Legend Item')).toHaveCount(3); | ||||
|   }); | ||||
|  | ||||
|   test('Limit lines persist when series is moved to another Y Axis and on refresh', async ({ | ||||
|     page | ||||
|   }) => { | ||||
| @@ -70,10 +127,6 @@ test.describe('Overlay Plot', () => { | ||||
|       type: 'issue', | ||||
|       description: 'https://github.com/nasa/openmct/issues/6338' | ||||
|     }); | ||||
|     // Create an Overlay Plot with a default SWG | ||||
|     const overlayPlot = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Overlay Plot' | ||||
|     }); | ||||
|  | ||||
|     const swgA = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Sine Wave Generator', | ||||
| @@ -139,10 +192,6 @@ test.describe('Overlay Plot', () => { | ||||
|   test('The elements pool supports dragging series into multiple y-axis buckets', async ({ | ||||
|     page | ||||
|   }) => { | ||||
|     const overlayPlot = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Overlay Plot' | ||||
|     }); | ||||
|  | ||||
|     const swgA = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Sine Wave Generator', | ||||
|       parent: overlayPlot.uuid | ||||
| @@ -224,13 +273,34 @@ test.describe('Overlay Plot', () => { | ||||
|     expect(yAxis3Group.getByRole('listitem').nth(0).getByText(swgB.name)).toBeTruthy(); | ||||
|   }); | ||||
|  | ||||
|   test('Clicking on an item in the elements pool brings up the plot preview with data points', async ({ | ||||
|     page | ||||
|   }) => { | ||||
|     const overlayPlot = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Overlay Plot' | ||||
|     }); | ||||
|   test.fixme( | ||||
|     'Clicking on an item in the elements pool brings up the plot preview with data points', | ||||
|     async ({ page }) => { | ||||
|       test.info().annotations.push({ | ||||
|         type: 'issue', | ||||
|         description: 'https://github.com/nasa/openmct/issues/7421' | ||||
|       }); | ||||
|  | ||||
|       const swgA = await createDomainObjectWithDefaults(page, { | ||||
|         type: 'Sine Wave Generator', | ||||
|         parent: overlayPlot.uuid | ||||
|       }); | ||||
|  | ||||
|       await page.goto(overlayPlot.url); | ||||
|       // Wait for plot series data to load and be drawn | ||||
|       await waitForPlotsToRender(page); | ||||
|       await page.getByLabel('Edit Object').click(); | ||||
|  | ||||
|       await page.getByRole('tab', { name: 'Elements' }).click(); | ||||
|  | ||||
|       await page.locator(`#inspector-elements-tree >> text=${swgA.name}`).click(); | ||||
|       const plotPixels = await getCanvasPixels(page, '.js-overlay canvas'); | ||||
|       const plotPixelSize = plotPixels.length; | ||||
|       expect(plotPixelSize).toBeGreaterThan(0); | ||||
|     } | ||||
|   ); | ||||
|  | ||||
|   test('Can remove an item via the elements pool action menu', async ({ page }) => { | ||||
|     const swgA = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Sine Wave Generator', | ||||
|       parent: overlayPlot.uuid | ||||
| @@ -243,11 +313,12 @@ test.describe('Overlay Plot', () => { | ||||
|  | ||||
|     await page.getByRole('tab', { name: 'Elements' }).click(); | ||||
|  | ||||
|     await page.locator(`#inspector-elements-tree >> text=${swgA.name}`).click(); | ||||
|  | ||||
|     const plotPixels = await getCanvasPixels(page, '.js-overlay canvas'); | ||||
|     const plotPixelSize = plotPixels.length; | ||||
|     expect(plotPixelSize).toBeGreaterThan(0); | ||||
|     const swgAElementsPoolItem = page.getByLabel(`Preview ${swgA.name}`); | ||||
|     await expect(swgAElementsPoolItem).toBeVisible(); | ||||
|     await swgAElementsPoolItem.click({ button: 'right' }); | ||||
|     await page.getByRole('menuitem', { name: 'Remove' }).click(); | ||||
|     await page.getByRole('button', { name: 'OK', exact: true }).click(); | ||||
|     await expect(swgAElementsPoolItem).toBeHidden(); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
| @@ -260,9 +331,9 @@ async function assertLimitLinesExistAndAreVisible(page) { | ||||
|   await waitForPlotsToRender(page); | ||||
|   // Wait for limit lines to be created | ||||
|   await page.waitForSelector('.js-limit-area', { state: 'attached' }); | ||||
|   const limitLineCount = await page.locator('.c-plot-limit-line').count(); | ||||
|   // There should be 10 limit lines created by default | ||||
|   expect(await page.locator('.c-plot-limit-line').count()).toBe(10); | ||||
|   await expect(page.locator('.c-plot-limit-line')).toHaveCount(10); | ||||
|   const limitLineCount = await page.locator('.c-plot-limit-line').count(); | ||||
|   for (let i = 0; i < limitLineCount; i++) { | ||||
|     await expect(page.locator('.c-plot-limit-line').nth(i)).toBeVisible(); | ||||
|   } | ||||
|   | ||||
| @@ -52,7 +52,11 @@ test.describe('Plot Rendering', () => { | ||||
|     expect(createMineFolderRequests.length).toEqual(0); | ||||
|   }); | ||||
|  | ||||
|   test('Plot is rendered when infinity values exist', async ({ page }) => { | ||||
|   test.fixme('Plot is rendered when infinity values exist', async ({ page }) => { | ||||
|     test.info().annotations.push({ | ||||
|       type: 'issue', | ||||
|       description: 'https://github.com/nasa/openmct/issues/7421' | ||||
|     }); | ||||
|     // Edit Plot | ||||
|     await editSineWaveToUseInfinityOption(page, sineWaveGeneratorObject); | ||||
|  | ||||
|   | ||||
							
								
								
									
										88
									
								
								e2e/tests/functional/plugins/plot/previews.e2e.spec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								e2e/tests/functional/plugins/plot/previews.e2e.spec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,88 @@ | ||||
| /***************************************************************************** | ||||
|  * 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 } from '../../../../appActions.js'; | ||||
| import { expect, test } from '../../../../pluginFixtures.js'; | ||||
|  | ||||
| test.describe('Plots work in Previews', () => { | ||||
|   test('We can preview plot in display layouts', async ({ page, openmctConfig }) => { | ||||
|     const { myItemsFolderName } = openmctConfig; | ||||
|     await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|     // Create a Sinewave Generator | ||||
|     const sineWaveObject = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Sine Wave Generator' | ||||
|     }); | ||||
|     // Create a Display Layout | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Display Layout', | ||||
|       name: 'Test Display Layout' | ||||
|     }); | ||||
|     // Edit Display Layout | ||||
|     await page.getByLabel('Edit Object').click(); | ||||
|  | ||||
|     // Expand the 'My Items' folder in the left tree | ||||
|     await page.getByLabel(`Expand ${myItemsFolderName} folder`).click(); | ||||
|     // Add the Sine Wave Generator to the Display Layout and save changes | ||||
|     const treePane = page.getByRole('tree', { | ||||
|       name: 'Main Tree' | ||||
|     }); | ||||
|     const sineWaveGeneratorTreeItem = treePane.getByRole('treeitem', { | ||||
|       name: new RegExp(sineWaveObject.name) | ||||
|     }); | ||||
|     const layoutGridHolder = page.getByLabel('Test Display Layout Layout Grid'); | ||||
|     await sineWaveGeneratorTreeItem.dragTo(layoutGridHolder); | ||||
|     await page.getByLabel('Save').click(); | ||||
|     await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(); | ||||
|  | ||||
|     // right click on the plot and select view large | ||||
|     await page.getByLabel('Sine', { exact: true }).click({ button: 'right' }); | ||||
|     await page.getByLabel('View Historical Data').click(); | ||||
|     await expect(page.getByLabel('Preview Container').getByLabel('Plot Canvas')).toBeVisible(); | ||||
|     await page.getByRole('button', { name: 'Close' }).click(); | ||||
|     await page.getByLabel('Expand Test Display Layout layout').click(); | ||||
|  | ||||
|     // change to a plot and ensure embiggen works | ||||
|     await page.getByLabel('Edit Object').click(); | ||||
|     await page.getByLabel('Move Sub-object Frame').click(); | ||||
|     await page.getByText('View type').click(); | ||||
|     await page.getByText('Overlay Plot').click(); | ||||
|     await page.getByLabel('Save').click(); | ||||
|     await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(); | ||||
|     await expect( | ||||
|       page.getByLabel('Test Display Layout Layout', { exact: true }).getByLabel('Plot Canvas') | ||||
|     ).toBeVisible(); | ||||
|     await expect(page.getByLabel('Preview Container')).toBeHidden(); | ||||
|     await page.getByLabel('Large View').click(); | ||||
|     await expect(page.getByLabel('Preview Container').getByLabel('Plot Canvas')).toBeVisible(); | ||||
|     await page.getByRole('button', { name: 'Close' }).click(); | ||||
|  | ||||
|     // get last sinewave tree item (in the display layout) | ||||
|     await page | ||||
|       .getByRole('treeitem', { name: /Sine Wave Generator/ }) | ||||
|       .locator('a') | ||||
|       .last() | ||||
|       .click({ button: 'right' }); | ||||
|     await page.getByLabel('View', { exact: true }).click(); | ||||
|     await expect(page.getByLabel('Preview Container').getByLabel('Plot Canvas')).toBeVisible(); | ||||
|     await page.getByRole('button', { name: 'Close' }).click(); | ||||
|   }); | ||||
| }); | ||||
| @@ -257,6 +257,56 @@ test.describe('Stacked Plot', () => { | ||||
|  | ||||
|     await assertAggregateLegendIsVisible(page); | ||||
|   }); | ||||
|  | ||||
|   test('can toggle between aggregate and per child legends', async ({ page }) => { | ||||
|     // make some an overlay plot | ||||
|     const overlayPlot = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Overlay Plot', | ||||
|       parent: stackedPlot.uuid | ||||
|     }); | ||||
|  | ||||
|     // make some SWGs for the overlay plot | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Sine Wave Generator', | ||||
|       parent: overlayPlot.uuid | ||||
|     }); | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Sine Wave Generator', | ||||
|       parent: overlayPlot.uuid | ||||
|     }); | ||||
|  | ||||
|     await page.goto(stackedPlot.url); | ||||
|     await page.getByLabel('Edit Object').click(); | ||||
|     await page.getByRole('tab', { name: 'Config' }).click(); | ||||
|     await page.getByLabel('Inspector Views').getByRole('checkbox').uncheck(); | ||||
|     await page.getByLabel('Expand By Default').check(); | ||||
|     await page.getByLabel('Save').click(); | ||||
|     await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(); | ||||
|     await expect(page.getByLabel('Plot Legend Expanded')).toHaveCount(1); | ||||
|     await expect(page.getByLabel('Plot Legend Item')).toHaveCount(5); | ||||
|  | ||||
|     // reload and ensure the legend is still expanded | ||||
|     await page.reload(); | ||||
|     await expect(page.getByLabel('Plot Legend Expanded')).toHaveCount(1); | ||||
|     await expect(page.getByLabel('Plot Legend Item')).toHaveCount(5); | ||||
|  | ||||
|     // change to collapsed by default | ||||
|     await page.getByLabel('Edit Object').click(); | ||||
|     await page.getByLabel('Expand By Default').uncheck(); | ||||
|     await page.getByLabel('Save').click(); | ||||
|     await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(); | ||||
|     await expect(page.getByLabel('Plot Legend Collapsed')).toHaveCount(1); | ||||
|     await expect(page.getByLabel('Plot Legend Item')).toHaveCount(5); | ||||
|  | ||||
|     // change it to individual legends | ||||
|     await page.getByLabel('Edit Object').click(); | ||||
|     await page.getByRole('tab', { name: 'Config' }).click(); | ||||
|     await page.getByLabel('Show Legends For Children').check(); | ||||
|     await page.getByLabel('Save').click(); | ||||
|     await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(); | ||||
|     await expect(page.getByLabel('Plot Legend Collapsed')).toHaveCount(4); | ||||
|     await expect(page.getByLabel('Plot Legend Item')).toHaveCount(5); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
| /** | ||||
|   | ||||
| @@ -0,0 +1,125 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2023, United States Government | ||||
|  * as represented by the Administrator of the National Aeronautics and Space | ||||
|  * Administration. All rights reserved. | ||||
|  * | ||||
|  * Open MCT is licensed under the Apache License, Version 2.0 (the | ||||
|  * "License"); you may not use this file except in compliance with the License. | ||||
|  * You may obtain a copy of the License at | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0. | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  * | ||||
|  * Open MCT includes source code licensed under additional open source | ||||
|  * licenses. See the Open Source Licenses file (LICENSES.md) included with | ||||
|  * this source code distribution or the Licensing information page available | ||||
|  * at runtime from the About dialog for additional information. | ||||
|  *****************************************************************************/ | ||||
| import { createDomainObjectWithDefaults, expandEntireTree } from '../../../../appActions.js'; | ||||
| import { expect, test } from '../../../../pluginFixtures.js'; | ||||
|  | ||||
| test.describe('Reload action', () => { | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|  | ||||
|     const displayLayout = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Display Layout' | ||||
|     }); | ||||
|  | ||||
|     const alphaTable = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Telemetry Table', | ||||
|       name: 'Alpha Table' | ||||
|     }); | ||||
|  | ||||
|     const betaTable = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Telemetry Table', | ||||
|       name: 'Beta Table' | ||||
|     }); | ||||
|  | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Sine Wave Generator', | ||||
|       parent: alphaTable.uuid, | ||||
|       customParameters: { | ||||
|         '[aria-label="Data Rate (hz)"]': '0.001' | ||||
|       } | ||||
|     }); | ||||
|  | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Sine Wave Generator', | ||||
|       parent: betaTable.uuid, | ||||
|       customParameters: { | ||||
|         '[aria-label="Data Rate (hz)"]': '0.001' | ||||
|       } | ||||
|     }); | ||||
|  | ||||
|     await page.goto(displayLayout.url); | ||||
|  | ||||
|     // Expand all folders | ||||
|     await expandEntireTree(page); | ||||
|  | ||||
|     await page.getByLabel('Edit Object', { exact: true }).click(); | ||||
|  | ||||
|     await page.dragAndDrop(`text='Alpha Table'`, '.l-layout__grid-holder', { | ||||
|       targetPosition: { x: 0, y: 0 } | ||||
|     }); | ||||
|  | ||||
|     await page.dragAndDrop(`text='Beta Table'`, '.l-layout__grid-holder', { | ||||
|       targetPosition: { x: 0, y: 250 } | ||||
|     }); | ||||
|  | ||||
|     await page.locator('button[title="Save"]').click(); | ||||
|     await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(); | ||||
|   }); | ||||
|  | ||||
|   test('can reload display layout and its children', async ({ page }) => { | ||||
|     const beforeReloadAlphaTelemetryValue = await page | ||||
|       .getByLabel('Alpha Table table content') | ||||
|       .getByLabel('wavelengths table cell') | ||||
|       .first() | ||||
|       .getAttribute('title'); | ||||
|     const beforeReloadBetaTelemetryValue = await page | ||||
|       .getByLabel('Beta Table table content') | ||||
|       .getByLabel('wavelengths table cell') | ||||
|       .first() | ||||
|       .getAttribute('title'); | ||||
|     // reload alpha | ||||
|     await page.getByTitle('View menu items').first().click(); | ||||
|     await page.getByRole('menuitem', { name: /Reload/ }).click(); | ||||
|  | ||||
|     const afterReloadAlphaTelemetryValue = await page | ||||
|       .getByLabel('Alpha Table table content') | ||||
|       .getByLabel('wavelengths table cell') | ||||
|       .first() | ||||
|       .getAttribute('title'); | ||||
|     const afterReloadBetaTelemetryValue = await page | ||||
|       .getByLabel('Beta Table table content') | ||||
|       .getByLabel('wavelengths table cell') | ||||
|       .first() | ||||
|       .getAttribute('title'); | ||||
|  | ||||
|     expect(beforeReloadAlphaTelemetryValue).not.toEqual(afterReloadAlphaTelemetryValue); | ||||
|     expect(beforeReloadBetaTelemetryValue).toEqual(afterReloadBetaTelemetryValue); | ||||
|  | ||||
|     // now reload parent | ||||
|     await page.getByTitle('More actions').click(); | ||||
|     await page.getByRole('menuitem', { name: /Reload/ }).click(); | ||||
|  | ||||
|     const fullReloadAlphaTelemetryValue = await page | ||||
|       .getByLabel('Alpha Table table content') | ||||
|       .getByLabel('wavelengths table cell') | ||||
|       .first() | ||||
|       .getAttribute('title'); | ||||
|     const fullReloadBetaTelemetryValue = await page | ||||
|       .getByLabel('Beta Table table content') | ||||
|       .getByLabel('wavelengths table cell') | ||||
|       .first() | ||||
|       .getAttribute('title'); | ||||
|  | ||||
|     expect(fullReloadAlphaTelemetryValue).not.toEqual(afterReloadAlphaTelemetryValue); | ||||
|     expect(fullReloadBetaTelemetryValue).not.toEqual(afterReloadBetaTelemetryValue); | ||||
|   }); | ||||
| }); | ||||
| @@ -32,10 +32,10 @@ const setBorderColor = '#ff00ff'; | ||||
| const setBackgroundColor = '#5b0f00'; | ||||
| const setTextColor = '#e6b8af'; | ||||
| const defaultFrameBorderColor = '#e6b8af'; //default border color | ||||
| const defaultBorderTargetColor = '#aaaaaa'; | ||||
| const defaultTextColor = '#aaaaaa'; // default text color | ||||
| const inheritedColor = '#aaaaaa'; // inherited from the body style | ||||
| const pukeGreen = '#6aa84f'; //Ugliest green known to man | ||||
| const defaultBorderTargetColor = '#acacac'; | ||||
| const defaultTextColor = '#acacac'; // default text color | ||||
| const inheritedColor = '#acacac'; // inherited from the body style | ||||
| const pukeGreen = '#6aa84f'; //Ugliest green known to man 🤮 | ||||
| const NO_STYLE_RGBA = 'rgba(0, 0, 0, 0)'; //default background color value | ||||
|  | ||||
| test.describe('Flexible Layout styling', () => { | ||||
| @@ -397,8 +397,8 @@ test.describe('Flexible Layout styling', () => { | ||||
|       page.getByLabel('StackedPlot1 Frame').getByLabel('Stacked Plot Style Target') | ||||
|     ); | ||||
|     // Save Flexible Layout | ||||
|     await page.locator('button[title="Save"]').click(); | ||||
|     await page.locator('text=Save and Finish Editing').click(); | ||||
|     await page.getByRole('button', { name: 'Save' }).click(); | ||||
|     await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(); | ||||
|  | ||||
|     // Reload page and verify that styles persist | ||||
|     await page.reload({ waitUntil: 'domcontentloaded' }); | ||||
| @@ -411,4 +411,39 @@ test.describe('Flexible Layout styling', () => { | ||||
|       page.getByLabel('StackedPlot1 Frame').getByLabel('Stacked Plot Style Target') | ||||
|     ); | ||||
|   }); | ||||
|  | ||||
|   test('Styling, and then canceling reverts to previous style', async ({ page }) => { | ||||
|     test.info().annotations.push({ | ||||
|       type: 'issue', | ||||
|       description: 'https://github.com/nasa/openmct/issues/7233' | ||||
|     }); | ||||
|  | ||||
|     await page.goto(flexibleLayout.url); | ||||
|  | ||||
|     await page.getByLabel('Edit Object').click(); | ||||
|     await page.getByRole('tab', { name: 'Styles' }).click(); | ||||
|     await setStyles( | ||||
|       page, | ||||
|       setBorderColor, | ||||
|       setBackgroundColor, | ||||
|       setTextColor, | ||||
|       page.getByLabel('Flexible Layout Column') | ||||
|     ); | ||||
|     await page.getByLabel('Cancel Editing').click(); | ||||
|     await page.getByRole('button', { name: 'OK', exact: true }).click(); | ||||
|     await checkStyles( | ||||
|       hexToRGB(defaultBorderTargetColor), | ||||
|       NO_STYLE_RGBA, | ||||
|       hexToRGB(inheritedColor), | ||||
|       page.getByLabel('Flexible Layout Column') | ||||
|     ); | ||||
|  | ||||
|     await page.reload(); | ||||
|     await checkStyles( | ||||
|       hexToRGB(defaultBorderTargetColor), | ||||
|       NO_STYLE_RGBA, | ||||
|       hexToRGB(inheritedColor), | ||||
|       page.getByLabel('Flexible Layout Column') | ||||
|     ); | ||||
|   }); | ||||
| }); | ||||
|   | ||||
| @@ -36,9 +36,9 @@ import { test } from '../../../../pluginFixtures.js'; | ||||
| const setBorderColor = '#ff00ff'; | ||||
| const setBackgroundColor = '#5b0f00'; | ||||
| const setTextColor = '#e6b8af'; | ||||
| const defaultTextColor = '#aaaaaa'; // default text color | ||||
| const defaultTextColor = '#acacac'; // default text color | ||||
| const NO_STYLE_RGBA = 'rgba(0, 0, 0, 0)'; //default background color value | ||||
| const DEFAULT_PLOT_VIEW_BORDER_COLOR = '#AAAAAA'; | ||||
| const DEFAULT_PLOT_VIEW_BORDER_COLOR = '#acacac'; | ||||
| const setFontSize = '72px'; | ||||
| const setFontWeight = '700'; //bold for monospace bold | ||||
| const setFontFamily = '"Andale Mono", sans-serif'; | ||||
|   | ||||
| @@ -24,13 +24,18 @@ import { createDomainObjectWithDefaults } from '../../../../appActions.js'; | ||||
| import { expect, test } from '../../../../pluginFixtures.js'; | ||||
|  | ||||
| test.describe('Tabs View', () => { | ||||
|   test('Renders tabbed elements', async ({ page }) => { | ||||
|   let tabsView; | ||||
|   let table; | ||||
|   let notebook; | ||||
|   let sineWaveGenerator; | ||||
|  | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|  | ||||
|     const tabsView = await createDomainObjectWithDefaults(page, { | ||||
|     tabsView = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Tabs View' | ||||
|     }); | ||||
|     const table = await createDomainObjectWithDefaults(page, { | ||||
|     table = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Telemetry Table', | ||||
|       parent: tabsView.uuid | ||||
|     }); | ||||
| @@ -38,36 +43,38 @@ test.describe('Tabs View', () => { | ||||
|       type: 'Event Message Generator', | ||||
|       parent: table.uuid | ||||
|     }); | ||||
|     const notebook = await createDomainObjectWithDefaults(page, { | ||||
|     notebook = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Notebook', | ||||
|       parent: tabsView.uuid | ||||
|     }); | ||||
|     const sineWaveGenerator = await createDomainObjectWithDefaults(page, { | ||||
|     sineWaveGenerator = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Sine Wave Generator', | ||||
|       parent: tabsView.uuid | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|     page.goto(tabsView.url); | ||||
|   test('Renders tabbed elements', async ({ page }) => { | ||||
|     await page.goto(tabsView.url); | ||||
|  | ||||
|     // select first tab | ||||
|     await page.getByLabel(`${table.name} tab`).click(); | ||||
|     await page.getByLabel(`${table.name} tab`, { exact: true }).click(); | ||||
|     // ensure table header visible | ||||
|     await expect(page.getByRole('searchbox', { name: 'message filter input' })).toBeVisible(); | ||||
|  | ||||
|     // no canvas (i.e., sine wave generator) in the document should be visible | ||||
|     await expect(page.locator('canvas')).toBeHidden(); | ||||
|     await expect(page.locator('canvas[id=webglContext]')).toBeHidden(); | ||||
|  | ||||
|     // select second tab | ||||
|     await page.getByLabel(`${notebook.name} tab`).click(); | ||||
|     await page.getByLabel(`${notebook.name} tab`, { exact: true }).click(); | ||||
|  | ||||
|     // ensure notebook visible | ||||
|     await expect(page.locator('.c-notebook__drag-area')).toBeVisible(); | ||||
|  | ||||
|     // no canvas (i.e., sine wave generator) in the document should be visible | ||||
|     await expect(page.locator('canvas')).toBeHidden(); | ||||
|     await expect(page.locator('canvas[id=webglContext]')).toBeHidden(); | ||||
|  | ||||
|     // select third tab | ||||
|     await page.getByLabel(`${sineWaveGenerator.name} tab`).click(); | ||||
|     await page.getByLabel(`${sineWaveGenerator.name} tab`, { exact: true }).click(); | ||||
|  | ||||
|     // expect sine wave generator visible | ||||
|     await expect(page.locator('.c-plot')).toBeVisible(); | ||||
| @@ -78,11 +85,37 @@ test.describe('Tabs View', () => { | ||||
|     await expect(page.locator('canvas').nth(1)).toBeVisible(); | ||||
|  | ||||
|     // now try to select the first tab again | ||||
|     await page.getByLabel(`${table.name} tab`).click(); | ||||
|     await page.getByLabel(`${table.name} tab`, { exact: true }).click(); | ||||
|     // ensure table header visible | ||||
|     await expect(page.getByRole('searchbox', { name: 'message filter input' })).toBeVisible(); | ||||
|  | ||||
|     // no canvas (i.e., sine wave generator) in the document should be visible | ||||
|     await expect(page.locator('canvas')).toBeHidden(); | ||||
|     await expect(page.locator('canvas[id=webglContext]')).toBeHidden(); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
| test.describe('Tabs View CRUD', () => { | ||||
|   let tabsView; | ||||
|  | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|     tabsView = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Tabs View' | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   test('Eager Load Tabs is the default and then can be toggled off', async ({ page }) => { | ||||
|     test.info().annotations.push({ | ||||
|       type: 'issue', | ||||
|       description: 'https://github.com/nasa/openmct/issues/7198' | ||||
|     }); | ||||
|     await page.goto(tabsView.url); | ||||
|  | ||||
|     await page.getByLabel('Edit Object').click(); | ||||
|     await page.getByLabel('More actions').click(); | ||||
|     await page.getByLabel('Edit Properties...').click(); | ||||
|     await expect(await page.getByLabel('Eager Load Tabs')).not.toBeChecked(); | ||||
|     await page.getByLabel('Eager Load Tabs').setChecked(true); | ||||
|     await expect(await page.getByLabel('Eager Load Tabs')).toBeChecked(); | ||||
|   }); | ||||
| }); | ||||
|   | ||||
| @@ -0,0 +1,73 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2024, United States Government | ||||
|  * as represented by the Administrator of the National Aeronautics and Space | ||||
|  * Administration. All rights reserved. | ||||
|  * | ||||
|  * Open MCT is licensed under the Apache License, Version 2.0 (the | ||||
|  * "License"); you may not use this file except in compliance with the License. | ||||
|  * You may obtain a copy of the License at | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0. | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  * | ||||
|  * Open MCT includes source code licensed under additional open source | ||||
|  * licenses. See the Open Source Licenses file (LICENSES.md) included with | ||||
|  * this source code distribution or the Licensing information page available | ||||
|  * at runtime from the About dialog for additional information. | ||||
|  *****************************************************************************/ | ||||
| /* | ||||
|  * This test suite is dedicated to testing the preview plugin. | ||||
|  */ | ||||
|  | ||||
| import { createDomainObjectWithDefaults, expandEntireTree } from '../../../../appActions.js'; | ||||
| import { expect, test } from '../../../../pluginFixtures.js'; | ||||
|  | ||||
| test.describe('Preview mode', () => { | ||||
|   test('all context menu items are available for a telemetry table', async ({ page }) => { | ||||
|     await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|     // Create a Display Layout | ||||
|     const displayLayout = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Display Layout' | ||||
|     }); | ||||
|     // Create a Telemetry Table | ||||
|     const telemetryTable = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Telemetry Table', | ||||
|       parent: displayLayout.uuid | ||||
|     }); | ||||
|     // Create a Sinewave Generator | ||||
|     await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Sine Wave Generator', | ||||
|       parent: telemetryTable.uuid | ||||
|     }); | ||||
|  | ||||
|     await page.goto(displayLayout.url); | ||||
|     await page.getByLabel('View menu items').click(); | ||||
|     await expect(page.getByLabel('Export Marked Rows')).toBeVisible(); | ||||
|  | ||||
|     await page.getByRole('menuitem', { name: 'Large View' }).click(); | ||||
|     await page.getByLabel('Overlay').getByLabel('More actions').click(); | ||||
|     await expect(page.getByLabel('Export Table Data')).toBeVisible(); | ||||
|     await expect(page.getByLabel('Export Marked Rows')).toBeVisible(); | ||||
|     await page.getByRole('menuitem', { name: 'Pause' }).click(); | ||||
|     await page.getByRole('button', { name: 'Close' }).click(); | ||||
|  | ||||
|     await expandEntireTree(page); | ||||
|  | ||||
|     await page.getByLabel('Edit Object').click(); | ||||
|  | ||||
|     const treePane = page.getByRole('tree', { | ||||
|       name: 'Main Tree' | ||||
|     }); | ||||
|     const telemetryTableTreeItem = treePane.getByRole('treeitem', { | ||||
|       name: new RegExp(telemetryTable.name) | ||||
|     }); | ||||
|     await telemetryTableTreeItem.locator('a').click(); | ||||
|     await page.getByLabel('Overlay').getByLabel('More actions').click(); | ||||
|     await expect(page.getByLabel('Export Table Data')).toBeVisible(); | ||||
|     await expect(page.getByLabel('Export Marked Rows')).toBeVisible(); | ||||
|   }); | ||||
| }); | ||||
| @@ -64,10 +64,9 @@ test.describe('Telemetry Table', () => { | ||||
|  | ||||
|     // Get the most recent telemetry date | ||||
|     const latestTelemetryDate = await page | ||||
|       .locator('table.c-telemetry-table__body > tbody > tr') | ||||
|       .getByLabel('table content') | ||||
|       .getByLabel('utc table cell') | ||||
|       .last() | ||||
|       .locator('td') | ||||
|       .nth(1) | ||||
|       .getAttribute('title'); | ||||
|  | ||||
|     // Verify that it is <= our new end bound | ||||
| @@ -91,7 +90,7 @@ test.describe('Telemetry Table', () => { | ||||
|     await page.getByRole('searchbox', { name: 'message filter input' }).click(); | ||||
|     await page.getByRole('searchbox', { name: 'message filter input' }).fill('Roger'); | ||||
|  | ||||
|     let cells = await page.getByRole('cell', { name: /Roger/ }).all(); | ||||
|     let cells = await page.getByRole('cell').getByText(/Roger/).all(); | ||||
|     // ensure we've got more than one cell | ||||
|     expect(cells.length).toBeGreaterThan(1); | ||||
|     // ensure the text content of each cell contains the search term | ||||
| @@ -103,7 +102,10 @@ test.describe('Telemetry Table', () => { | ||||
|     await page.getByRole('searchbox', { name: 'message filter input' }).click(); | ||||
|     await page.getByRole('searchbox', { name: 'message filter input' }).fill('Dodger'); | ||||
|  | ||||
|     cells = await page.getByRole('cell', { name: /Dodger/ }).all(); | ||||
|     cells = await page | ||||
|       .getByRole('cell') | ||||
|       .getByText(/Dodger/) | ||||
|       .all(); | ||||
|     // ensure we've got more than one cell | ||||
|     expect(cells.length).toBe(0); | ||||
|     // ensure the text content of each cell contains the search term | ||||
| @@ -135,7 +137,7 @@ test.describe('Telemetry Table', () => { | ||||
|     await page.getByRole('searchbox', { name: 'message filter input' }).click(); | ||||
|     await page.getByRole('searchbox', { name: 'message filter input' }).fill('/[Rr]oger/'); | ||||
|  | ||||
|     let cells = await page.getByRole('cell', { name: /Roger/ }).all(); | ||||
|     let cells = await page.getByRole('cell').getByText(/Roger/).all(); | ||||
|     // ensure we've got more than one cell | ||||
|     expect(cells.length).toBeGreaterThan(1); | ||||
|     // ensure the text content of each cell contains the search term | ||||
| @@ -147,7 +149,10 @@ test.describe('Telemetry Table', () => { | ||||
|     await page.getByRole('searchbox', { name: 'message filter input' }).click(); | ||||
|     await page.getByRole('searchbox', { name: 'message filter input' }).fill('/[Dd]oger/'); | ||||
|  | ||||
|     cells = await page.getByRole('cell', { name: /Dodger/ }).all(); | ||||
|     cells = await page | ||||
|       .getByRole('cell') | ||||
|       .getByText(/Dodger/) | ||||
|       .all(); | ||||
|     // ensure we've got more than one cell | ||||
|     expect(cells.length).toBe(0); | ||||
|     // ensure the text content of each cell contains the search term | ||||
|   | ||||
| @@ -191,7 +191,7 @@ test.describe('Recent Objects', () => { | ||||
|  | ||||
|     // Navigate to the clock and reveal it in the tree | ||||
|     await page.goto(clock.url); | ||||
|     await page.getByTitle('Show selected item in tree').click(); | ||||
|     await page.getByLabel('Show selected item in tree').click(); | ||||
|  | ||||
|     // Right click the clock and create an alias using the "link" context menu action | ||||
|     const clockTreeItem = page | ||||
| @@ -298,7 +298,7 @@ test.describe('Recent Objects', () => { | ||||
|     // Assert that the list is empty | ||||
|     expect(await recentObjectsList.locator('.c-recentobjects-listitem').count()).toBe(0); | ||||
|   }); | ||||
|   test('Ensure clear recent objects button is active or inactive', async ({ page }) => { | ||||
|   test('Verify functionality of "clear" and "collapse pane" buttons', async ({ page }) => { | ||||
|     // Assert that the list initially contains 3 objects (clock, folder, my items) | ||||
|     expect(await recentObjectsList.locator('.c-recentobjects-listitem').count()).toBe(3); | ||||
|  | ||||
| @@ -331,6 +331,24 @@ test.describe('Recent Objects', () => { | ||||
|     expect(await page.getByRole('button', { name: 'Clear Recently Viewed' }).isEnabled()).toBe( | ||||
|       true | ||||
|     ); | ||||
|  | ||||
|     // Assert initial state of pane and collapse the Recent Objects panel | ||||
|     await expect(page.getByLabel('Expand Recently Viewed Pane')).toBeHidden(); | ||||
|     await expect(page.getByLabel('Collapse Recently Viewed Pane')).toBeVisible(); | ||||
|     await page.getByLabel('Collapse Recently Viewed Pane').click(); | ||||
|  | ||||
|     // Assert that the "Expand Recently Viewed Pane" button is visible | ||||
|     // and that the "Collapse Recently Viewed Pane" button is hidden | ||||
|     await expect(page.getByLabel('Expand Recently Viewed Pane')).toBeVisible(); | ||||
|     await expect(page.getByLabel('Collapse Recently Viewed Pane')).toBeHidden(); | ||||
|  | ||||
|     // Expand the Recent Objects panel by clicking on the "Expand Recently Viewed Pane" button | ||||
|     await page.getByLabel('Expand Recently Viewed Pane').click(); | ||||
|  | ||||
|     // Assert that the "Expand Recently Viewed Pane" button is hidden | ||||
|     // and that the "Collapse Recently Viewed Pane" button is visible | ||||
|     await expect(page.getByLabel('Expand Recently Viewed Pane')).toBeHidden(); | ||||
|     await expect(page.getByLabel('Collapse Recently Viewed Pane')).toBeVisible(); | ||||
|   }); | ||||
|  | ||||
|   function assertInitialRecentObjectsListState() { | ||||
|   | ||||
| @@ -99,7 +99,7 @@ test.describe('Grand Search', () => { | ||||
|       page.waitForNavigation(), | ||||
|       page.getByLabel('OpenMCT Search').getByText('Clock A').click() | ||||
|     ]); | ||||
|     await expect(page.getByRole('status', { name: 'Clock' })).toBeVisible(); | ||||
|     await expect(page.getByRole('status', { name: 'Clock', exact: true })).toBeVisible(); | ||||
|  | ||||
|     await grandSearchInput.fill('Disp'); | ||||
|     await expect(page.getByLabel('Object Search Result').first()).toContainText( | ||||
|   | ||||
| @@ -48,7 +48,7 @@ test('Verify that the create button appears and that the Folder Domain Object is | ||||
|   await expect(page.locator(':nth-match(:text("Folder"), 2)')).toBeEnabled(); | ||||
| }); | ||||
|  | ||||
| test('Verify that My Items Tree appears @ipad', async ({ page, openmctConfig }) => { | ||||
| test('Verify that My Items Tree appears', async ({ page, openmctConfig }) => { | ||||
|   const { myItemsFolderName } = openmctConfig; | ||||
|   //Go to baseURL | ||||
|   await page.goto('./'); | ||||
|   | ||||
| @@ -359,7 +359,11 @@ test.describe('Verify tooltips', () => { | ||||
|     expect(tooltipText).toBe(sineWaveObject3.path); | ||||
|   }); | ||||
|  | ||||
|   test('display tooltip path for telemetry table names', async ({ page }) => { | ||||
|   test.fixme('display tooltip path for telemetry table names', async ({ page }) => { | ||||
|     test.info().annotations.push({ | ||||
|       type: 'issue', | ||||
|       description: 'https://github.com/nasa/openmct/issues/7421' | ||||
|     }); | ||||
|     // set endBound to 10 seconds after start bound | ||||
|     const url = await page.url(); | ||||
|     const parsedUrl = new URL(url.replace('#', '!')); | ||||
|   | ||||
| @@ -40,7 +40,7 @@ test.describe('Main Tree', () => { | ||||
|       type: 'Folder' | ||||
|     }); | ||||
|  | ||||
|     await page.getByTitle('Show selected item in tree').click(); | ||||
|     await page.getByLabel('Show selected item in tree').click(); | ||||
|  | ||||
|     const clock = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Clock', | ||||
|   | ||||
| @@ -34,13 +34,13 @@ test.describe('User Roles', () => { | ||||
|     // we have multiple available roles, so it should prompt the user | ||||
|     await expect(page.getByText('Select Role')).toBeVisible(); | ||||
|     await page.getByRole('combobox').selectOption('driver'); | ||||
|     await page.getByRole('button', { name: 'Select' }).click(); | ||||
|     await page.getByRole('button', { name: 'Select', exact: true }).click(); | ||||
|     await expect(page.getByLabel('User Role')).toContainText('driver'); | ||||
|  | ||||
|     // attempt changing the role to another valid available role | ||||
|     await page.getByRole('button', { name: 'Change Role' }).click(); | ||||
|     await page.getByRole('combobox').selectOption('flight'); | ||||
|     await page.getByRole('button', { name: 'Select' }).click(); | ||||
|     await page.getByRole('button', { name: 'Select', exact: true }).click(); | ||||
|     await expect(page.getByLabel('User Role')).toContainText('flight'); | ||||
|  | ||||
|     // reload page | ||||
| @@ -63,7 +63,7 @@ test.describe('User Roles', () => { | ||||
|  | ||||
|     // select real role of "driver" | ||||
|     await page.getByRole('combobox').selectOption('driver'); | ||||
|     await page.getByRole('button', { name: 'Select' }).click(); | ||||
|     await page.getByRole('button', { name: 'Select', exact: true }).click(); | ||||
|     await expect(page.getByLabel('User Role')).toContainText('driver'); | ||||
|   }); | ||||
| }); | ||||
|   | ||||
							
								
								
									
										59
									
								
								e2e/tests/mobile/smoke.e2e.spec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								e2e/tests/mobile/smoke.e2e.spec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,59 @@ | ||||
| /***************************************************************************** | ||||
|  * 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 can quickly verify that any openmct installation is | ||||
| operable and that any type of testing can proceed. | ||||
|  | ||||
| Ideally, smoke tests should make zero assumptions about how and where they are run. This makes them | ||||
| more resilient to change and therefor a better indicator of failure. Smoke tests will also run quickly | ||||
| as they cover a very "thin surface" of functionality. | ||||
|  | ||||
| When deciding between authoring new smoke tests or functional tests, ask yourself "would I feel | ||||
| comfortable running this test during a live mission?" Avoid creating or deleting Domain Objects. | ||||
| Make no assumptions about the order that elements appear in the DOM. | ||||
| */ | ||||
|  | ||||
| import { expect, test } from '../../pluginFixtures.js'; | ||||
|  | ||||
| test('Verify that My Items Tree appears @mobile', async ({ page, openmctConfig }) => { | ||||
|   const { myItemsFolderName } = openmctConfig; | ||||
|   //Go to baseURL | ||||
|   await page.goto('./'); | ||||
|  | ||||
|   //My Items to be visible | ||||
|   await expect(page.getByRole('treeitem', { name: `${myItemsFolderName}` })).toBeVisible(); | ||||
| }); | ||||
|  | ||||
| test('Verify that user can search @mobile', async ({ page }) => { | ||||
|   //For now, this test is going to be hardcoded against './test-data/display_layout_with_child_layouts.json' | ||||
|   await page.goto('./'); | ||||
|  | ||||
|   await page.getByRole('searchbox', { name: 'Search Input' }).click(); | ||||
|   await page.getByRole('searchbox', { name: 'Search Input' }).fill('Parent Display Layout'); | ||||
|   //Search Results appear in search modal | ||||
|   await expect(page.getByLabel('Object Results').getByText('Parent Display Layout')).toBeVisible(); | ||||
|   //Clicking on the search result takes you to the object | ||||
|   await page.getByLabel('Object Results').getByText('Parent Display Layout').click(); | ||||
|   await page.getByTitle('Collapse Browse Pane').click(); | ||||
|   await expect(page.getByRole('main').getByText('Parent Display Layout')).toBeVisible(); | ||||
| }); | ||||
| @@ -24,7 +24,7 @@ import { createDomainObjectWithDefaults, waitForPlotsToRender } from '../../appA | ||||
| import { expect, test } from '../../pluginFixtures.js'; | ||||
| 
 | ||||
| test.describe('Tabs View', () => { | ||||
|   test('Renders tabbed elements nicely', async ({ page }) => { | ||||
|   test('Renders tabbed elements only when visible', async ({ page }) => { | ||||
|     // Code to hook into the requestAnimationFrame function and log each call
 | ||||
|     let animationCalls = []; | ||||
|     await page.exposeFunction('logCall', (callCount) => { | ||||
| @@ -64,24 +64,24 @@ test.describe('Tabs View', () => { | ||||
|     page.goto(tabsView.url); | ||||
| 
 | ||||
|     // select first tab
 | ||||
|     await page.getByLabel(`${table.name} tab`).click(); | ||||
|     await page.getByLabel(`${table.name} tab`, { exact: true }).click(); | ||||
|     // ensure table header visible
 | ||||
|     await expect(page.getByRole('searchbox', { name: 'message filter input' })).toBeVisible(); | ||||
| 
 | ||||
|     // select second tab
 | ||||
|     await page.getByLabel(`${notebook.name} tab`).click(); | ||||
|     await page.getByLabel(`${notebook.name} tab`, { exact: true }).click(); | ||||
| 
 | ||||
|     // expect notebook visible
 | ||||
|     await expect(page.locator('.c-notebook__drag-area')).toBeVisible(); | ||||
| 
 | ||||
|     // select third tab
 | ||||
|     await page.getByLabel(`${sineWaveGenerator.name} tab`).click(); | ||||
|     await page.getByLabel(`${sineWaveGenerator.name} tab`, { exact: true }).click(); | ||||
| 
 | ||||
|     // ensure sine wave generator visible
 | ||||
|     expect(await page.locator('.c-plot').isVisible()).toBe(true); | ||||
| 
 | ||||
|     // now select notebook and clear animation calls
 | ||||
|     await page.getByLabel(`${notebook.name} tab`).click(); | ||||
|     await page.getByLabel(`${notebook.name} tab`, { exact: true }).click(); | ||||
|     animationCalls = []; | ||||
|     // expect notebook visible
 | ||||
|     await expect(page.locator('.c-notebook__drag-area')).toBeVisible(); | ||||
| @@ -89,7 +89,7 @@ test.describe('Tabs View', () => { | ||||
| 
 | ||||
|     // select sine wave generator and clear animation calls
 | ||||
|     animationCalls = []; | ||||
|     await page.getByLabel(`${sineWaveGenerator.name} tab`).click(); | ||||
|     await page.getByLabel(`${sineWaveGenerator.name} tab`, { exact: true }).click(); | ||||
| 
 | ||||
|     // ensure sine wave generator visible
 | ||||
|     await waitForPlotsToRender(page); | ||||
| @@ -20,14 +20,16 @@ | ||||
|  * at runtime from the About dialog for additional information. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| import { scanForA11yViolations, test } from '../../avpFixtures.js'; | ||||
| import { test } from '../../avpFixtures.js'; | ||||
| import { VISUAL_URL } from '../../constants.js'; | ||||
|  | ||||
| test.describe('a11y - Default @a11y', () => { | ||||
| test.describe('a11y - Default', () => { | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     await page.goto(VISUAL_URL, { waitUntil: 'domcontentloaded' }); | ||||
|   }); | ||||
|   test('main view @a11y', async ({ page }, testInfo) => { | ||||
|     await scanForA11yViolations(page, testInfo.title); | ||||
|   test('main view', async ({ page }, testInfo) => { | ||||
|     await page.goto('./'); | ||||
|     //Skipping for https://github.com/nasa/openmct/issues/7421 | ||||
|     //await scanForA11yViolations(page, testInfo.title); | ||||
|   }); | ||||
| }); | ||||
|   | ||||
| @@ -26,7 +26,7 @@ Tests the branding associated with the default deployment. At least the about mo | ||||
|  | ||||
| import percySnapshot from '@percy/playwright'; | ||||
|  | ||||
| import { scanForA11yViolations, test } from '../../../avpFixtures.js'; | ||||
| import { expect, test } from '../../../avpFixtures.js'; | ||||
| import { VISUAL_URL } from '../../../constants.js'; | ||||
|  | ||||
| //Declare the scope of the visual test | ||||
| @@ -36,6 +36,22 @@ test.describe('Visual - Header @a11y', () => { | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     //Go to baseURL and Hide Tree | ||||
|     await page.goto(VISUAL_URL, { waitUntil: 'domcontentloaded' }); | ||||
|     // Wait for status bar to load | ||||
|     await expect( | ||||
|       page.getByRole('status', { | ||||
|         name: 'Clock Indicator' | ||||
|       }) | ||||
|     ).toBeInViewport(); | ||||
|     await expect( | ||||
|       page.getByRole('status', { | ||||
|         name: 'Global Clear Indicator' | ||||
|       }) | ||||
|     ).toBeInViewport(); | ||||
|     await expect( | ||||
|       page.getByRole('status', { | ||||
|         name: 'Snapshot Indicator' | ||||
|       }) | ||||
|     ).toBeInViewport(); | ||||
|   }); | ||||
|  | ||||
|   test('header sizing', async ({ page, theme }) => { | ||||
| @@ -50,7 +66,19 @@ test.describe('Visual - Header @a11y', () => { | ||||
|       scope: header | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   test('show snapshot button', async ({ page, theme }) => { | ||||
|     await page.getByLabel('Take a Notebook Snapshot').click(); | ||||
|  | ||||
|     await page.getByRole('menuitem', { name: 'Save to Notebook Snapshots' }).click(); | ||||
|  | ||||
|     await percySnapshot(page, `Notebook Snapshot Show button (theme: '${theme}')`, { | ||||
|       scope: header | ||||
|     }); | ||||
|     await expect(await page.getByLabel('Show Snapshots')).toBeVisible(); | ||||
|   }); | ||||
| }); | ||||
| test.afterEach(async ({ page }, testInfo) => { | ||||
|   await scanForA11yViolations(page, testInfo.title); | ||||
| }); | ||||
| // Skipping for https://github.com/nasa/openmct/issues/7421 | ||||
| // test.afterEach(async ({ page }, testInfo) => { | ||||
| //   await scanForA11yViolations(page, testInfo.title); | ||||
| // }); | ||||
|   | ||||
| @@ -22,7 +22,7 @@ | ||||
|  | ||||
| import percySnapshot from '@percy/playwright'; | ||||
|  | ||||
| import { scanForA11yViolations, test } from '../../../avpFixtures.js'; | ||||
| import { test } from '../../../avpFixtures.js'; | ||||
| import { MISSION_TIME, VISUAL_URL } from '../../../constants.js'; | ||||
|  | ||||
| //Declare the scope of the visual test | ||||
| @@ -55,6 +55,7 @@ test.describe('Visual - Inspector @ally', () => { | ||||
|     }); | ||||
|   }); | ||||
| }); | ||||
| test.afterEach(async ({ page }, testInfo) => { | ||||
|   await scanForA11yViolations(page, testInfo.title); | ||||
| }); | ||||
| // Skipping for https://github.com/nasa/openmct/issues/7421 | ||||
| // test.afterEach(async ({ page }, testInfo) => { | ||||
| //   await scanForA11yViolations(page, testInfo.title); | ||||
| // }); | ||||
|   | ||||
| @@ -93,4 +93,14 @@ test.describe('Visual - Display Layout', () => { | ||||
|     await page.getByLabel('Parent Layout Layout', { exact: true }).click(); | ||||
|     await percySnapshot(page, `Parent outer layout selected (theme: '${theme}')`); | ||||
|   }); | ||||
|  | ||||
|   test('Toolbar does not overflow into inspector', async ({ page, theme }) => { | ||||
|     test.info().annotations.push({ | ||||
|       type: 'issue', | ||||
|       description: 'https://github.com/nasa/openmct/issues/7036' | ||||
|     }); | ||||
|     await page.getByLabel('Expand Inspect Pane').click(); | ||||
|     await page.getByLabel('Resize Inspect Pane').dragTo(page.getByLabel('X:')); | ||||
|     await percySnapshot(page, `Toolbar does not overflow into inspector (theme: '${theme}')`); | ||||
|   }); | ||||
| }); | ||||
|   | ||||
| @@ -23,7 +23,7 @@ import percySnapshot from '@percy/playwright'; | ||||
| import { fileURLToPath } from 'url'; | ||||
|  | ||||
| import * as utils from '../../helper/faultUtils.js'; | ||||
| import { test } from '../../pluginFixtures.js'; | ||||
| import { expect, test } from '../../pluginFixtures.js'; | ||||
|  | ||||
| test.describe('Fault Management Visual Tests', () => { | ||||
|   test('icon test', async ({ page, theme }) => { | ||||
| @@ -32,6 +32,23 @@ test.describe('Fault Management Visual Tests', () => { | ||||
|     }); | ||||
|     await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|  | ||||
|     // Wait for status bar to load | ||||
|     await expect( | ||||
|       page.getByRole('status', { | ||||
|         name: 'Clock Indicator' | ||||
|       }) | ||||
|     ).toBeInViewport(); | ||||
|     await expect( | ||||
|       page.getByRole('status', { | ||||
|         name: 'Global Clear Indicator' | ||||
|       }) | ||||
|     ).toBeInViewport(); | ||||
|     await expect( | ||||
|       page.getByRole('status', { | ||||
|         name: 'Snapshot Indicator' | ||||
|       }) | ||||
|     ).toBeInViewport(); | ||||
|  | ||||
|     await percySnapshot(page, `Fault Management icon appears in tree (theme: '${theme}')`); | ||||
|   }); | ||||
|  | ||||
|   | ||||
							
								
								
									
										93
									
								
								e2e/tests/visual-a11y/imagery.visual.spec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								e2e/tests/visual-a11y/imagery.visual.spec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| import percySnapshot from '@percy/playwright'; | ||||
|  | ||||
| import { createDomainObjectWithDefaults, setRealTimeMode } from '../../appActions.js'; | ||||
| import { VISUAL_URL } from '../../constants.js'; | ||||
| import { expect, test } from '../../pluginFixtures.js'; | ||||
|  | ||||
| test.describe('Visual - Example Imagery', () => { | ||||
|   let exampleImagery; | ||||
|   let parentLayout; | ||||
|  | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     await page.goto(VISUAL_URL, { waitUntil: 'domcontentloaded' }); | ||||
|  | ||||
|     parentLayout = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Display Layout', | ||||
|       name: 'Parent Layout' | ||||
|     }); | ||||
|  | ||||
|     exampleImagery = await createDomainObjectWithDefaults(page, { | ||||
|       type: 'Example Imagery', | ||||
|       name: 'Example Imagery Test', | ||||
|       parent: parentLayout.uuid | ||||
|     }); | ||||
|  | ||||
|     // Modify Example Imagery to create a really stable Example Imagery | ||||
|     await page.goto(exampleImagery.url, { waitUntil: 'domcontentloaded' }); | ||||
|     await page.getByRole('button', { name: 'More actions' }).click(); | ||||
|     await page.getByRole('menuitem', { name: 'Edit Properties...' }).click(); | ||||
|     await page | ||||
|       .locator('#imageLocation-textarea') | ||||
|       .fill( | ||||
|         '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-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-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-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-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-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-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-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-18731.jpg' | ||||
|       ); | ||||
|     await page.getByRole('button', { name: 'Save' }).click(); | ||||
|     await page.reload({ waitUntil: 'domcontentloaded' }); | ||||
|     await page.getByTitle('Collapse Browse Pane').click(); | ||||
|     await page.getByTitle('Collapse Inspect Pane').click(); | ||||
|   }); | ||||
|  | ||||
|   test('Example Imagery in Fixed Time', async ({ page, theme }) => { | ||||
|     await page.goto(exampleImagery.url, { waitUntil: 'domcontentloaded' }); | ||||
|  | ||||
|     await expect(page.getByLabel('Image Wrapper')).toBeVisible(); | ||||
|  | ||||
|     await percySnapshot(page, `Example Imagery in Fixed Time (theme: ${theme})`); | ||||
|  | ||||
|     await page.getByLabel('Image Wrapper').hover(); | ||||
|  | ||||
|     await percySnapshot(page, `Example Imagery Hover in Fixed Time (theme: ${theme})`); | ||||
|   }); | ||||
|  | ||||
|   test('Example Imagery in Real Time', async ({ page, theme }) => { | ||||
|     await page.goto(exampleImagery.url, { waitUntil: 'domcontentloaded' }); | ||||
|  | ||||
|     await setRealTimeMode(page, true); | ||||
|     //Temporary to close the dialog | ||||
|     await page.getByLabel('Submit time offsets').click(); | ||||
|  | ||||
|     await expect(page.getByLabel('Image Wrapper')).toBeVisible(); | ||||
|  | ||||
|     await percySnapshot(page, `Example Imagery in Real Time (theme: ${theme})`); | ||||
|   }); | ||||
|  | ||||
|   test('Example Imagery in Display Layout', async ({ page, theme }) => { | ||||
|     await page.goto(parentLayout.url, { waitUntil: 'domcontentloaded' }); | ||||
|  | ||||
|     await expect(page.getByLabel('Image Wrapper')).toBeVisible(); | ||||
|  | ||||
|     await percySnapshot(page, `Example Imagery in Display Layout (theme: ${theme})`); | ||||
|   }); | ||||
| }); | ||||
							
								
								
									
										57
									
								
								e2e/tests/visual-a11y/missionStatus.visual.spec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								e2e/tests/visual-a11y/missionStatus.visual.spec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2024, United States Government | ||||
|  * as represented by the Administrator of the National Aeronautics and Space | ||||
|  * Administration. All rights reserved. | ||||
|  * | ||||
|  * Open MCT is licensed under the Apache License, Version 2.0 (the | ||||
|  * "License"); you may not use this file except in compliance with the License. | ||||
|  * You may obtain a copy of the License at | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0. | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  * | ||||
|  * Open MCT includes source code licensed under additional open source | ||||
|  * licenses. See the Open Source Licenses file (LICENSES.md) included with | ||||
|  * this source code distribution or the Licensing information page available | ||||
|  * at runtime from the About dialog for additional information. | ||||
|  *****************************************************************************/ | ||||
| import percySnapshot from '@percy/playwright'; | ||||
| import { fileURLToPath } from 'url'; | ||||
|  | ||||
| import { expect, scanForA11yViolations, test } from '../../avpFixtures.js'; | ||||
|  | ||||
| test.describe('Mission Status Visual Tests @a11y', () => { | ||||
|   const GO = '1'; | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     await page.addInitScript({ | ||||
|       path: fileURLToPath(new URL('../../helper/addInitExampleUser.js', import.meta.url)) | ||||
|     }); | ||||
|     await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||||
|     await expect(page.getByText('Select Role')).toBeVisible(); | ||||
|     // Description should be empty https://github.com/nasa/openmct/issues/6978 | ||||
|     await expect(page.locator('c-message__action-text')).toBeHidden(); | ||||
|     // set role | ||||
|     await page.getByRole('button', { name: 'Select', exact: true }).click(); | ||||
|     // dismiss role confirmation popup | ||||
|     await page.getByRole('button', { name: 'Dismiss' }).click(); | ||||
|   }); | ||||
|   test('Mission status panel', async ({ page, theme }) => { | ||||
|     await page.getByLabel('Toggle Mission Status Panel').click(); | ||||
|     await expect(page.getByRole('dialog', { name: 'User Control Panel' })).toBeVisible(); | ||||
|     await percySnapshot(page, `Mission status panel w/ default statuses (theme: '${theme}')`); | ||||
|     await page.getByRole('combobox', { name: 'Commanding' }).selectOption(GO); | ||||
|     await expect( | ||||
|       page.getByRole('alert').filter({ hasText: 'Successfully set mission status' }) | ||||
|     ).toBeVisible(); | ||||
|     await page.getByLabel('Dismiss').click(); | ||||
|     await percySnapshot(page, `Mission status panel w/ non-default status (theme: '${theme}')`); | ||||
|   }); | ||||
|  | ||||
|   test.afterEach(async ({ page }, testInfo) => { | ||||
|     await scanForA11yViolations(page, testInfo.title); | ||||
|   }); | ||||
| }); | ||||
| @@ -23,11 +23,11 @@ | ||||
| import percySnapshot from '@percy/playwright'; | ||||
|  | ||||
| import { createDomainObjectWithDefaults, expandTreePaneItemByName } from '../../appActions.js'; | ||||
| import { scanForA11yViolations, test } from '../../avpFixtures.js'; | ||||
| import { test } from '../../avpFixtures.js'; | ||||
| import { VISUAL_URL } from '../../constants.js'; | ||||
| import { enterTextEntry, startAndAddRestrictedNotebookObject } from '../../helper/notebookUtils.js'; | ||||
|  | ||||
| test.describe('Visual - Restricted Notebook', () => { | ||||
| test.describe('Visual - Restricted Notebook @a11y', () => { | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     const restrictedNotebook = await startAndAddRestrictedNotebookObject(page); | ||||
|     await page.goto(restrictedNotebook.url + '?hideTree=true&hideInspector=true'); | ||||
| @@ -39,7 +39,7 @@ test.describe('Visual - Restricted Notebook', () => { | ||||
|   }); | ||||
| }); | ||||
|  | ||||
| test.describe('Visual - Notebook', () => { | ||||
| test.describe('Visual - Notebook @a11y', () => { | ||||
|   let notebook; | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     await page.goto(VISUAL_URL, { waitUntil: 'domcontentloaded' }); | ||||
| @@ -125,7 +125,8 @@ test.describe('Visual - Notebook', () => { | ||||
|     // Take a snapshot | ||||
|     await percySnapshot(page, `Notebook Selected Entry Text Area Active (theme: '${theme}')`); | ||||
|   }); | ||||
|   test.afterEach(async ({ page }, testInfo) => { | ||||
|     await scanForA11yViolations(page, testInfo.title); | ||||
|   }); | ||||
|   // Skipping for https://github.com/nasa/openmct/issues/7421 | ||||
|   // test.afterEach(async ({ page }, testInfo) => { | ||||
|   //   await scanForA11yViolations(page, testInfo.title); | ||||
|   // }); | ||||
| }); | ||||
|   | ||||
| @@ -24,7 +24,7 @@ import percySnapshot from '@percy/playwright'; | ||||
| import fs from 'fs'; | ||||
|  | ||||
| import { createDomainObjectWithDefaults, createPlanFromJSON } from '../../appActions.js'; | ||||
| import { scanForA11yViolations, test } from '../../avpFixtures.js'; | ||||
| import { test } from '../../avpFixtures.js'; | ||||
| import { VISUAL_URL } from '../../constants.js'; | ||||
| import { setBoundsToSpanAllActivities, setDraftStatusForPlan } from '../../helper/planningUtils.js'; | ||||
|  | ||||
| @@ -34,7 +34,7 @@ const examplePlanSmall = JSON.parse( | ||||
|  | ||||
| const snapshotScope = '.l-shell__pane-main .l-pane__contents'; | ||||
|  | ||||
| test.describe('Visual - Planning @a11y', () => { | ||||
| test.describe('Visual - Planning', () => { | ||||
|   test.beforeEach(async ({ page }) => { | ||||
|     await page.goto(VISUAL_URL, { waitUntil: 'domcontentloaded' }); | ||||
|   }); | ||||
| @@ -75,7 +75,25 @@ test.describe('Visual - Planning @a11y', () => { | ||||
|       parent: ganttChart.uuid | ||||
|     }); | ||||
|     await setBoundsToSpanAllActivities(page, examplePlanSmall, ganttChart.url); | ||||
|     await percySnapshot(page, `Gantt Chart View (theme: ${theme})`, { | ||||
|     await percySnapshot(page, `Gantt Chart View (theme: ${theme}) - Clipped Activity Names`, { | ||||
|       scope: snapshotScope | ||||
|     }); | ||||
|  | ||||
|     // Expand the inspect pane and uncheck the 'Clip Activity Names' option | ||||
|     await page.getByRole('button', { name: 'Expand Inspect Pane' }).click(); | ||||
|     await page.getByRole('tab', { name: 'Config' }).click(); | ||||
|     await page.getByLabel('Edit Object').click(); | ||||
|     await page.getByLabel('Clip Activity Names').click(); | ||||
|  | ||||
|     // Close the inspect pane and save the changes | ||||
|     await page.getByRole('button', { name: 'Collapse Inspect Pane' }).click(); | ||||
|     await page.getByLabel('Save').click(); | ||||
|     await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(); | ||||
|  | ||||
|     // Dismiss the notification | ||||
|     await page.getByLabel('Dismiss').click(); | ||||
|  | ||||
|     await percySnapshot(page, `Gantt Chart View (theme: ${theme}) - Unclipped Activity Names`, { | ||||
|       scope: snapshotScope | ||||
|     }); | ||||
|   }); | ||||
| @@ -98,8 +116,31 @@ test.describe('Visual - Planning @a11y', () => { | ||||
|     await percySnapshot(page, `Gantt Chart View w/ draft status (theme: ${theme})`, { | ||||
|       scope: snapshotScope | ||||
|     }); | ||||
|  | ||||
|     // Expand the inspect pane and uncheck the 'Clip Activity Names' option | ||||
|     await page.getByRole('button', { name: 'Expand Inspect Pane' }).click(); | ||||
|     await page.getByRole('tab', { name: 'Config' }).click(); | ||||
|     await page.getByLabel('Edit Object').click(); | ||||
|     await page.getByLabel('Clip Activity Names').click(); | ||||
|  | ||||
|     // Close the inspect pane and save the changes | ||||
|     await page.getByRole('button', { name: 'Collapse Inspect Pane' }).click(); | ||||
|     await page.getByLabel('Save').click(); | ||||
|     await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click(); | ||||
|  | ||||
|     // Dismiss the notification | ||||
|     await page.getByLabel('Dismiss').click(); | ||||
|  | ||||
|     await percySnapshot( | ||||
|       page, | ||||
|       `Gantt Chart View w/ draft status (theme: ${theme}) - Unclipped Activity Names`, | ||||
|       { | ||||
|         scope: snapshotScope | ||||
|       } | ||||
|     ); | ||||
|   }); | ||||
|   test.afterEach(async ({ page }, testInfo) => { | ||||
|     await scanForA11yViolations(page, testInfo.title); | ||||
|   }); | ||||
|   // Skipping for https://github.com/nasa/openmct/issues/7421 | ||||
|   // test.afterEach(async ({ page }, testInfo) => { | ||||
|   //   await scanForA11yViolations(page, testInfo.title); | ||||
|   // }); | ||||
| }); | ||||
|   | ||||
| @@ -60,10 +60,22 @@ const STATUSES = [ | ||||
|     statusFgColor: '#fff' | ||||
|   } | ||||
| ]; | ||||
|  | ||||
| const MISSION_STATUSES = [ | ||||
|   { | ||||
|     key: 0, | ||||
|     label: 'NO GO' | ||||
|   }, | ||||
|   { | ||||
|     key: 1, | ||||
|     label: 'GO' | ||||
|   } | ||||
| ]; | ||||
| /** | ||||
|  * @implements {StatusUserProvider} | ||||
|  */ | ||||
| export default class ExampleUserProvider extends EventEmitter { | ||||
|   #actionToStatusMap; | ||||
|   constructor( | ||||
|     openmct, | ||||
|     { statusRoles } = { | ||||
| @@ -73,6 +85,11 @@ export default class ExampleUserProvider extends EventEmitter { | ||||
|     super(); | ||||
|  | ||||
|     this.openmct = openmct; | ||||
|     this.#actionToStatusMap = { | ||||
|       Imagery: MISSION_STATUSES[0], | ||||
|       Commanding: MISSION_STATUSES[0], | ||||
|       Driving: MISSION_STATUSES[0] | ||||
|     }; | ||||
|     this.user = undefined; | ||||
|     this.loggedIn = false; | ||||
|     this.autoLoginUser = undefined; | ||||
| @@ -110,6 +127,11 @@ export default class ExampleUserProvider extends EventEmitter { | ||||
|   canSetPollQuestion() { | ||||
|     return Promise.resolve(true); | ||||
|   } | ||||
|  | ||||
|   canSetMissionStatus() { | ||||
|     return Promise.resolve(true); | ||||
|   } | ||||
|  | ||||
|   hasRole(roleId) { | ||||
|     if (!this.loggedIn) { | ||||
|       Promise.resolve(undefined); | ||||
| @@ -122,6 +144,28 @@ export default class ExampleUserProvider extends EventEmitter { | ||||
|     return this.user.getRoles(); | ||||
|   } | ||||
|  | ||||
|   getPossibleMissionActions() { | ||||
|     return Promise.resolve(Object.keys(this.#actionToStatusMap)); | ||||
|   } | ||||
|  | ||||
|   getPossibleMissionActionStatuses() { | ||||
|     return Promise.resolve(MISSION_STATUSES); | ||||
|   } | ||||
|  | ||||
|   getStatusForMissionAction(action) { | ||||
|     return Promise.resolve(this.#actionToStatusMap[action]); | ||||
|   } | ||||
|  | ||||
|   setStatusForMissionAction(action, status) { | ||||
|     this.#actionToStatusMap[action] = status; | ||||
|     this.emit('missionStatusChange', { | ||||
|       action, | ||||
|       status | ||||
|     }); | ||||
|  | ||||
|     return true; | ||||
|   } | ||||
|  | ||||
|   getAllStatusRoles() { | ||||
|     return Promise.resolve(this.statusRoles); | ||||
|   } | ||||
|   | ||||
| @@ -92,6 +92,8 @@ GeneratorProvider.prototype.request = function (domainObject, request) { | ||||
|   var workerRequest = this.makeWorkerRequest(domainObject, request); | ||||
|   workerRequest.start = request.start; | ||||
|   workerRequest.end = request.end; | ||||
|   workerRequest.size = request.size; | ||||
|   workerRequest.strategy = request.strategy; | ||||
|  | ||||
|   return this.workerInterface.request(workerRequest); | ||||
| }; | ||||
|   | ||||
| @@ -130,48 +130,37 @@ | ||||
|     var now = Date.now(); | ||||
|     var start = request.start; | ||||
|     var end = request.end > now ? now : request.end; | ||||
|     var amplitude = request.amplitude; | ||||
|     var period = request.period; | ||||
|     var offset = request.offset; | ||||
|     var dataRateInHz = request.dataRateInHz; | ||||
|     var phase = request.phase; | ||||
|     var randomness = request.randomness; | ||||
|     var loadDelay = Math.max(request.loadDelay, 0); | ||||
|     var infinityValues = request.infinityValues; | ||||
|     var exceedFloat32 = request.exceedFloat32; | ||||
|  | ||||
|     var size = request.size; | ||||
|     var duration = end - start; | ||||
|     var step = 1000 / dataRateInHz; | ||||
|     var maxPoints = Math.floor(duration / step); | ||||
|     var nextStep = start - (start % step) + step; | ||||
|  | ||||
|     var data = []; | ||||
|  | ||||
|     for (; nextStep < end && data.length < 5000; nextStep += step) { | ||||
|       data.push({ | ||||
|         utc: nextStep, | ||||
|         yesterday: nextStep - 60 * 60 * 24 * 1000, | ||||
|         sin: sin( | ||||
|           nextStep, | ||||
|           period, | ||||
|           amplitude, | ||||
|           offset, | ||||
|           phase, | ||||
|           randomness, | ||||
|           infinityValues, | ||||
|           exceedFloat32 | ||||
|         ), | ||||
|         wavelengths: wavelengths(), | ||||
|         intensities: intensities(), | ||||
|         cos: cos( | ||||
|           nextStep, | ||||
|           period, | ||||
|           amplitude, | ||||
|           offset, | ||||
|           phase, | ||||
|           randomness, | ||||
|           infinityValues, | ||||
|           exceedFloat32 | ||||
|         ) | ||||
|       }); | ||||
|     if (request.strategy === 'minmax' && size) { | ||||
|       // Calculate the number of cycles to include based on size (2 points per cycle) | ||||
|       var totalCycles = Math.min(Math.floor(size / 2), Math.floor(duration / period)); | ||||
|  | ||||
|       for (let cycle = 0; cycle < totalCycles; cycle++) { | ||||
|         // Distribute cycles evenly across the time range | ||||
|         let cycleStart = start + (duration / totalCycles) * cycle; | ||||
|         let minPointTime = cycleStart; // Assuming min at the start of the cycle | ||||
|         let maxPointTime = cycleStart + period / 2; // Assuming max at the halfway of the cycle | ||||
|  | ||||
|         data.push(createDataPoint(minPointTime, request), createDataPoint(maxPointTime, request)); | ||||
|       } | ||||
|     } else { | ||||
|       for (let i = 0; i < maxPoints && nextStep < end; i++, nextStep += step) { | ||||
|         data.push(createDataPoint(nextStep, request)); | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     if (request.strategy !== 'minmax' && size) { | ||||
|       data = data.slice(-size); | ||||
|     } | ||||
|  | ||||
|     if (loadDelay === 0) { | ||||
| @@ -181,6 +170,35 @@ | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   function createDataPoint(time, request) { | ||||
|     return { | ||||
|       utc: time, | ||||
|       yesterday: time - 60 * 60 * 24 * 1000, | ||||
|       sin: sin( | ||||
|         time, | ||||
|         request.period, | ||||
|         request.amplitude, | ||||
|         request.offset, | ||||
|         request.phase, | ||||
|         request.randomness, | ||||
|         request.infinityValues, | ||||
|         request.exceedFloat32 | ||||
|       ), | ||||
|       wavelengths: wavelengths(), | ||||
|       intensities: intensities(), | ||||
|       cos: cos( | ||||
|         time, | ||||
|         request.period, | ||||
|         request.amplitude, | ||||
|         request.offset, | ||||
|         request.phase, | ||||
|         request.randomness, | ||||
|         request.infinityValues, | ||||
|         request.exceedFloat32 | ||||
|       ) | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   function postOnRequest(message, request, data) { | ||||
|     self.postMessage({ | ||||
|       id: message.id, | ||||
|   | ||||
| @@ -47,7 +47,7 @@ if (document.currentScript) { | ||||
|  * @property {*} inspectorViews | ||||
|  * @property {*} propertyEditors | ||||
|  * @property {*} toolbars | ||||
|  * @property {*} types | ||||
|  * @property {import('./src/api/types/TypeRegistry').default} types | ||||
|  * @property {import('./src/api/objects/ObjectAPI').default} objects | ||||
|  * @property {import('./src/api/telemetry/TelemetryAPI').default} telemetry | ||||
|  * @property {import('./src/api/indicators/IndicatorAPI').default} indicators | ||||
| @@ -67,6 +67,7 @@ if (document.currentScript) { | ||||
|  * @property {import('./src/api/annotation/AnnotationAPI').default} annotation | ||||
|  * @property {{(plugin: OpenMCTPlugin) => void}} install | ||||
|  * @property {{() => string}} getAssetPath | ||||
|  * @property {{(assetPath: string) => void}} setAssetPath | ||||
|  * @property {{(domElement: HTMLElement, isHeadlessMode: boolean) => void}} start | ||||
|  * @property {{() => void}} startHeadless | ||||
|  * @property {{() => void}} destroy | ||||
|   | ||||
							
								
								
									
										21
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								package.json
									
									
									
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "openmct", | ||||
|   "version": "3.3.0-next", | ||||
|   "version": "4.0.0-next", | ||||
|   "description": "The Open MCT core platform", | ||||
|   "type": "module", | ||||
|   "main": "dist/openmct.js", | ||||
| @@ -28,12 +28,12 @@ | ||||
|     "d3-axis": "3.0.0", | ||||
|     "d3-scale": "4.0.2", | ||||
|     "d3-selection": "3.0.0", | ||||
|     "eslint": "8.54.0", | ||||
|     "eslint-config-prettier": "9.0.0", | ||||
|     "eslint": "8.56.0", | ||||
|     "eslint-config-prettier": "9.1.0", | ||||
|     "eslint-plugin-compat": "4.2.0", | ||||
|     "eslint-plugin-no-unsanitized": "4.0.2", | ||||
|     "eslint-plugin-playwright": "0.12.0", | ||||
|     "eslint-plugin-prettier": "4.2.1", | ||||
|     "eslint-plugin-prettier": "5.1.3", | ||||
|     "eslint-plugin-simple-import-sort": "10.0.0", | ||||
|     "eslint-plugin-unicorn": "49.0.0", | ||||
|     "eslint-plugin-vue": "9.18.1", | ||||
| @@ -57,9 +57,9 @@ | ||||
|     "karma-webpack": "5.0.0", | ||||
|     "location-bar": "3.0.1", | ||||
|     "lodash": "4.17.21", | ||||
|     "marked": "11.1.0", | ||||
|     "marked": "11.2.0", | ||||
|     "mini-css-extract-plugin": "2.7.6", | ||||
|     "moment": "2.29.4", | ||||
|     "moment": "2.30.1", | ||||
|     "moment-duration-format": "2.3.2", | ||||
|     "moment-timezone": "0.5.41", | ||||
|     "npm-run-all2": "6.1.1", | ||||
| @@ -67,19 +67,20 @@ | ||||
|     "painterro": "1.2.87", | ||||
|     "plotly.js-basic-dist-min": "2.20.0", | ||||
|     "plotly.js-gl2d-dist-min": "2.20.0", | ||||
|     "prettier": "2.8.7", | ||||
|     "prettier": "3.2.5", | ||||
|     "prettier-eslint": "16.3.0", | ||||
|     "printj": "1.3.1", | ||||
|     "resolve-url-loader": "5.0.0", | ||||
|     "sanitize-html": "2.11.0", | ||||
|     "sass": "1.68.0", | ||||
|     "sass-loader": "13.3.2", | ||||
|     "sass-loader": "14.0.0", | ||||
|     "sinon": "17.0.0", | ||||
|     "style-loader": "3.3.3", | ||||
|     "terser-webpack-plugin": "5.3.9", | ||||
|     "tiny-emitter": "2.1.0", | ||||
|     "typescript": "5.3.3", | ||||
|     "uuid": "9.0.1", | ||||
|     "vue": "3.3.8", | ||||
|     "vue": "3.4.19", | ||||
|     "vue-eslint-parser": "9.3.2", | ||||
|     "vue-loader": "16.8.3", | ||||
|     "webpack": "5.89.0", | ||||
| @@ -106,11 +107,13 @@ | ||||
|     "test:debug": "KARMA_DEBUG=true karma start karma.conf.cjs", | ||||
|     "test:e2e": "npx playwright test", | ||||
|     "test:e2e:a11y": "npx playwright test --config=e2e/playwright-visual-a11y.config.js --project=chrome --grep @a11y", | ||||
|     "test:e2e:mobile": "npx playwright test --config=e2e/playwright-mobile.config.js", | ||||
|     "test:e2e:couchdb": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @couchdb --workers=1", | ||||
|     "test:e2e:stable": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep-invert \"@unstable|@couchdb|@generatedata\"", | ||||
|     "test:e2e:unstable": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @unstable", | ||||
|     "test:e2e:local": "npx playwright test --config=e2e/playwright-local.config.js --project=chrome", | ||||
|     "test:e2e:generatedata": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @generatedata", | ||||
|     "test:e2e:checksnapshots": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @snapshot --retries=0", | ||||
|     "test:e2e:updatesnapshots": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @snapshot --update-snapshots", | ||||
|     "test:e2e:visual:ci": "percy exec --config ./e2e/.percy.ci.yml --partial -- npx playwright test --config=e2e/playwright-visual-a11y.config.js --project=chrome --grep-invert @unstable", | ||||
|     "test:e2e:visual:full": "percy exec --config ./e2e/.percy.nightly.yml -- npx playwright test --config=e2e/playwright-visual-a11y.config.js --grep-invert @unstable", | ||||
|   | ||||
| @@ -251,6 +251,7 @@ export class MCT extends EventEmitter { | ||||
|     this.install(this.plugins.FlexibleLayout()); | ||||
|     this.install(this.plugins.GoToOriginalAction()); | ||||
|     this.install(this.plugins.OpenInNewTabAction()); | ||||
|     this.install(this.plugins.ReloadAction()); | ||||
|     this.install(this.plugins.WebPage()); | ||||
|     this.install(this.plugins.Condition()); | ||||
|     this.install(this.plugins.ConditionWidget()); | ||||
|   | ||||
| @@ -21,7 +21,7 @@ | ||||
|  *****************************************************************************/ | ||||
| import _ from 'lodash'; | ||||
|  | ||||
| import objectUtils from '../objects/object-utils.js'; | ||||
| import { makeKeyString, parseKeyString } from '../objects/object-utils.js'; | ||||
|  | ||||
| /** | ||||
|  * @typedef {import('../objects/ObjectAPI').DomainObject} DomainObject | ||||
| @@ -223,18 +223,18 @@ export default class CompositionProvider { | ||||
|    * @param {DomainObject} oldDomainObject | ||||
|    */ | ||||
|   #onMutation(newDomainObject, oldDomainObject) { | ||||
|     const id = objectUtils.makeKeyString(oldDomainObject.identifier); | ||||
|     const id = makeKeyString(oldDomainObject.identifier); | ||||
|     const listeners = this.#listeningTo[id]; | ||||
|  | ||||
|     if (!listeners) { | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|     const oldComposition = oldDomainObject.composition.map(objectUtils.makeKeyString); | ||||
|     const newComposition = newDomainObject.composition.map(objectUtils.makeKeyString); | ||||
|     const oldComposition = oldDomainObject.composition.map(makeKeyString); | ||||
|     const newComposition = newDomainObject.composition.map(makeKeyString); | ||||
|  | ||||
|     const added = _.difference(newComposition, oldComposition).map(objectUtils.parseKeyString); | ||||
|     const removed = _.difference(oldComposition, newComposition).map(objectUtils.parseKeyString); | ||||
|     const added = _.difference(newComposition, oldComposition).map(parseKeyString); | ||||
|     const removed = _.difference(oldComposition, newComposition).map(parseKeyString); | ||||
|  | ||||
|     function notify(value) { | ||||
|       return function (listener) { | ||||
|   | ||||
| @@ -21,7 +21,7 @@ | ||||
|  *****************************************************************************/ | ||||
| import { toRaw } from 'vue'; | ||||
|  | ||||
| import objectUtils from '../objects/object-utils.js'; | ||||
| import { makeKeyString } from '../objects/object-utils.js'; | ||||
| import CompositionProvider from './CompositionProvider.js'; | ||||
|  | ||||
| /** | ||||
| @@ -91,7 +91,7 @@ export default class DefaultCompositionProvider extends CompositionProvider { | ||||
|     this.establishTopicListener(); | ||||
|  | ||||
|     /** @type {string} */ | ||||
|     const keyString = objectUtils.makeKeyString(domainObject.identifier); | ||||
|     const keyString = makeKeyString(domainObject.identifier); | ||||
|     let objectListeners = this.listeningTo[keyString]; | ||||
|  | ||||
|     if (!objectListeners) { | ||||
| @@ -120,7 +120,7 @@ export default class DefaultCompositionProvider extends CompositionProvider { | ||||
|    */ | ||||
|   off(domainObject, event, callback, context) { | ||||
|     /** @type {string} */ | ||||
|     const keyString = objectUtils.makeKeyString(domainObject.identifier); | ||||
|     const keyString = makeKeyString(domainObject.identifier); | ||||
|     const objectListeners = this.listeningTo[keyString]; | ||||
|  | ||||
|     const index = objectListeners[event].findIndex((l) => { | ||||
| @@ -228,7 +228,7 @@ export default class DefaultCompositionProvider extends CompositionProvider { | ||||
|     this.publicAPI.objects.mutate(domainObject, 'composition', newComposition); | ||||
|  | ||||
|     /** @type {string} */ | ||||
|     let id = objectUtils.makeKeyString(domainObject.identifier); | ||||
|     let id = makeKeyString(domainObject.identifier); | ||||
|     const listeners = this.listeningTo[id]; | ||||
|  | ||||
|     if (!listeners) { | ||||
|   | ||||
| @@ -22,9 +22,12 @@ | ||||
|  | ||||
| import EventEmitter from 'EventEmitter'; | ||||
|  | ||||
| import vueWrapHtmlElement from '../../utils/vueWrapHtmlElement.js'; | ||||
| import SimpleIndicator from './SimpleIndicator.js'; | ||||
|  | ||||
| class IndicatorAPI extends EventEmitter { | ||||
|   /** @type {import('../../../openmct.js').OpenMCT} */ | ||||
|   openmct; | ||||
|   constructor(openmct) { | ||||
|     super(); | ||||
|  | ||||
| @@ -42,6 +45,18 @@ class IndicatorAPI extends EventEmitter { | ||||
|     return new SimpleIndicator(this.openmct); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * @typedef {import('vue').Component} VueComponent | ||||
|    */ | ||||
|  | ||||
|   /** | ||||
|    * @typedef {Object} Indicator | ||||
|    * @property {HTMLElement} [element] | ||||
|    * @property {VueComponent|Promise<VueComponent>} [vueComponent] | ||||
|    * @property {string} key | ||||
|    * @property {number} priority | ||||
|    */ | ||||
|  | ||||
|   /** | ||||
|    * Accepts an indicator object, which is a simple object | ||||
|    * with a two attributes: 'element' which has an HTMLElement | ||||
| @@ -62,11 +77,20 @@ class IndicatorAPI extends EventEmitter { | ||||
|    * myIndicator.text("Hello World!"); | ||||
|    * myIndicator.iconClass("icon-info"); | ||||
|    * | ||||
|    * If you would like to use a Vue component, you can pass it in | ||||
|    * directly as the 'vueComponent' attribute of the indicator object. | ||||
|    * This accepts a Vue component or a promise that resolves to a Vue component (for asynchronous | ||||
|    * rendering). | ||||
|    * | ||||
|    * @param {Indicator} indicator | ||||
|    */ | ||||
|   add(indicator) { | ||||
|     if (!indicator.priority) { | ||||
|       indicator.priority = this.openmct.priority.DEFAULT; | ||||
|     } | ||||
|     if (!indicator.vueComponent) { | ||||
|       indicator.vueComponent = vueWrapHtmlElement(indicator.element); | ||||
|     } | ||||
|  | ||||
|     this.indicatorObjects.push(indicator); | ||||
|  | ||||
|   | ||||
| @@ -19,6 +19,8 @@ | ||||
|  * this source code distribution or the Licensing information page available | ||||
|  * at runtime from the About dialog for additional information. | ||||
|  *****************************************************************************/ | ||||
| import { defineComponent } from 'vue'; | ||||
|  | ||||
| import { createOpenMct, resetApplicationState } from '../../utils/testing.js'; | ||||
| import SimpleIndicator from './SimpleIndicator.js'; | ||||
|  | ||||
| @@ -33,7 +35,7 @@ describe('The Indicator API', () => { | ||||
|     return resetApplicationState(openmct); | ||||
|   }); | ||||
|  | ||||
|   function generateIndicator(className, label, priority) { | ||||
|   function generateHTMLIndicator(className, label, priority) { | ||||
|     const element = document.createElement('div'); | ||||
|     element.classList.add(className); | ||||
|     const textNode = document.createTextNode(label); | ||||
| @@ -46,8 +48,25 @@ describe('The Indicator API', () => { | ||||
|     return testIndicator; | ||||
|   } | ||||
|  | ||||
|   it('can register an indicator', () => { | ||||
|     const testIndicator = generateIndicator('test-indicator', 'This is a test indicator', 2); | ||||
|   function generateVueIndicator(priority) { | ||||
|     return { | ||||
|       vueComponent: defineComponent({ | ||||
|         template: '<div class="test-indicator">This is a test indicator</div>' | ||||
|       }), | ||||
|       priority | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   it('can register an HTML indicator', () => { | ||||
|     const testIndicator = generateHTMLIndicator('test-indicator', 'This is a test indicator', 2); | ||||
|     openmct.indicators.add(testIndicator); | ||||
|     expect(openmct.indicators.indicatorObjects).toBeDefined(); | ||||
|     // notifier indicator is installed by default | ||||
|     expect(openmct.indicators.indicatorObjects.length).toBe(2); | ||||
|   }); | ||||
|  | ||||
|   it('can register a Vue indicator', () => { | ||||
|     const testIndicator = generateVueIndicator(2); | ||||
|     openmct.indicators.add(testIndicator); | ||||
|     expect(openmct.indicators.indicatorObjects).toBeDefined(); | ||||
|     // notifier indicator is installed by default | ||||
| @@ -55,37 +74,40 @@ describe('The Indicator API', () => { | ||||
|   }); | ||||
|  | ||||
|   it('can order indicators based on priority', () => { | ||||
|     const testIndicator1 = generateIndicator( | ||||
|     const testIndicator1 = generateHTMLIndicator( | ||||
|       'test-indicator-1', | ||||
|       'This is a test indicator', | ||||
|       openmct.priority.LOW | ||||
|     ); | ||||
|     openmct.indicators.add(testIndicator1); | ||||
|  | ||||
|     const testIndicator2 = generateIndicator( | ||||
|     const testIndicator2 = generateHTMLIndicator( | ||||
|       'test-indicator-2', | ||||
|       'This is another test indicator', | ||||
|       openmct.priority.DEFAULT | ||||
|     ); | ||||
|     openmct.indicators.add(testIndicator2); | ||||
|  | ||||
|     const testIndicator3 = generateIndicator( | ||||
|     const testIndicator3 = generateHTMLIndicator( | ||||
|       'test-indicator-3', | ||||
|       'This is yet another test indicator', | ||||
|       openmct.priority.LOW | ||||
|     ); | ||||
|     openmct.indicators.add(testIndicator3); | ||||
|  | ||||
|     const testIndicator4 = generateIndicator( | ||||
|     const testIndicator4 = generateHTMLIndicator( | ||||
|       'test-indicator-4', | ||||
|       'This is yet another test indicator', | ||||
|       openmct.priority.HIGH | ||||
|     ); | ||||
|     openmct.indicators.add(testIndicator4); | ||||
|  | ||||
|     expect(openmct.indicators.indicatorObjects.length).toBe(5); | ||||
|     const testIndicator5 = generateVueIndicator(openmct.priority.DEFAULT); | ||||
|     openmct.indicators.add(testIndicator5); | ||||
|  | ||||
|     expect(openmct.indicators.indicatorObjects.length).toBe(6); | ||||
|     const indicatorObjectsByPriority = openmct.indicators.getIndicatorObjectsByPriority(); | ||||
|     expect(indicatorObjectsByPriority.length).toBe(5); | ||||
|     expect(indicatorObjectsByPriority.length).toBe(6); | ||||
|     expect(indicatorObjectsByPriority[2].priority).toBe(openmct.priority.DEFAULT); | ||||
|   }); | ||||
|  | ||||
|   | ||||
| @@ -28,7 +28,8 @@ | ||||
|             v-for="action in actionGroups" | ||||
|             :key="action.name" | ||||
|             role="menuitem" | ||||
|             :class="[action.cssClass, action.isDisabled ? 'disabled' : '']" | ||||
|             :aria-disabled="action.isDisabled" | ||||
|             :class="action.cssClass" | ||||
|             :aria-label="action.name" | ||||
|             :title="action.description" | ||||
|             @click="action.onItemClicked" | ||||
| @@ -51,7 +52,8 @@ | ||||
|         v-for="action in options.actions" | ||||
|         :key="action.name" | ||||
|         role="menuitem" | ||||
|         :class="[action.cssClass, action.isDisabled ? 'disabled' : '']" | ||||
|         :aria-disabled="action.isDisabled" | ||||
|         :class="action.cssClass" | ||||
|         :aria-label="action.name" | ||||
|         :title="action.description" | ||||
|         @click="action.onItemClicked" | ||||
|   | ||||
| @@ -37,7 +37,8 @@ | ||||
|             v-for="action in actionGroups" | ||||
|             :key="action.name" | ||||
|             role="menuitem" | ||||
|             :class="[action.cssClass, action.isDisabled ? 'disabled' : '']" | ||||
|             :aria-disabled="action.isDisabled" | ||||
|             :class="action.cssClass" | ||||
|             :title="action.description" | ||||
|             @click="action.onItemClicked" | ||||
|             @mouseover="toggleItemDescription(action)" | ||||
|   | ||||
| @@ -22,7 +22,7 @@ | ||||
| import EventEmitter from 'EventEmitter'; | ||||
| import _ from 'lodash'; | ||||
|  | ||||
| import utils from './object-utils.js'; | ||||
| import { makeKeyString, refresh } from './object-utils.js'; | ||||
|  | ||||
| const ANY_OBJECT_EVENT = 'mutation'; | ||||
|  | ||||
| @@ -152,7 +152,7 @@ class MutableDomainObject { | ||||
|  | ||||
|     mutable.$observe('$_synchronize_model', (updatedObject) => { | ||||
|       let clone = JSON.parse(JSON.stringify(updatedObject)); | ||||
|       utils.refresh(mutable, clone); | ||||
|       refresh(mutable, clone); | ||||
|     }); | ||||
|  | ||||
|     return mutable; | ||||
| @@ -168,7 +168,7 @@ class MutableDomainObject { | ||||
| } | ||||
|  | ||||
| function qualifiedEventName(object, eventName) { | ||||
|   let keystring = utils.makeKeyString(object.identifier); | ||||
|   let keystring = makeKeyString(object.identifier); | ||||
|  | ||||
|   return [keystring, eventName].join(':'); | ||||
| } | ||||
|   | ||||
| @@ -21,7 +21,7 @@ | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| import EventEmitter from 'EventEmitter'; | ||||
| import utils from 'objectUtils'; | ||||
| import { identifierEquals, makeKeyString, parseKeyString, refresh } from 'objectUtils'; | ||||
|  | ||||
| import ConflictError from './ConflictError.js'; | ||||
| import InMemorySearchProvider from './InMemorySearchProvider.js'; | ||||
| @@ -82,8 +82,19 @@ import Transaction from './Transaction.js'; | ||||
|  * @memberof module:openmct | ||||
|  */ | ||||
| export default class ObjectAPI { | ||||
|   #makeKeyString; | ||||
|   #parseKeyString; | ||||
|   #identifierEquals; | ||||
|   #refresh; | ||||
|   #openmct; | ||||
|  | ||||
|   constructor(typeRegistry, openmct) { | ||||
|     this.openmct = openmct; | ||||
|     this.#makeKeyString = makeKeyString; | ||||
|     this.#parseKeyString = parseKeyString; | ||||
|     this.#identifierEquals = identifierEquals; | ||||
|     this.#refresh = refresh; | ||||
|     this.#openmct = openmct; | ||||
|  | ||||
|     this.typeRegistry = typeRegistry; | ||||
|     this.SEARCH_TYPES = Object.freeze({ | ||||
|       OBJECTS: 'OBJECTS', | ||||
| @@ -99,7 +110,13 @@ export default class ObjectAPI { | ||||
|     this.cache = {}; | ||||
|     this.interceptorRegistry = new InterceptorRegistry(); | ||||
|  | ||||
|     this.SYNCHRONIZED_OBJECT_TYPES = ['notebook', 'restricted-notebook', 'plan', 'annotation']; | ||||
|     this.SYNCHRONIZED_OBJECT_TYPES = [ | ||||
|       'notebook', | ||||
|       'restricted-notebook', | ||||
|       'plan', | ||||
|       'annotation', | ||||
|       'activity-states' | ||||
|     ]; | ||||
|  | ||||
|     this.errors = { | ||||
|       Conflict: ConflictError | ||||
| @@ -200,14 +217,14 @@ export default class ObjectAPI { | ||||
|    *          has been saved, or be rejected if it cannot be saved | ||||
|    */ | ||||
|   get(identifier, abortSignal, forceRemote = false) { | ||||
|     let keystring = this.makeKeyString(identifier); | ||||
|     let keystring = this.#makeKeyString(identifier); | ||||
|  | ||||
|     if (!forceRemote) { | ||||
|       if (this.cache[keystring] !== undefined) { | ||||
|         return this.cache[keystring]; | ||||
|       } | ||||
|  | ||||
|       identifier = utils.parseKeyString(identifier); | ||||
|       identifier = parseKeyString(identifier); | ||||
|  | ||||
|       if (this.isTransactionActive()) { | ||||
|         let dirtyObject = this.transaction.getDirtyObject(identifier); | ||||
| @@ -221,7 +238,7 @@ export default class ObjectAPI { | ||||
|     const provider = this.getProvider(identifier); | ||||
|  | ||||
|     if (!provider) { | ||||
|       throw new Error(`No Provider Matched for keyString "${this.makeKeyString(identifier)}"`); | ||||
|       throw new Error(`No Provider Matched for keyString "${this.#makeKeyString(identifier)}"`); | ||||
|     } | ||||
|  | ||||
|     if (!provider.get) { | ||||
| @@ -319,7 +336,7 @@ export default class ObjectAPI { | ||||
|    */ | ||||
|   getMutable(identifier) { | ||||
|     if (!this.supportsMutation(identifier)) { | ||||
|       throw new Error(`Object "${this.makeKeyString(identifier)}" does not support mutation.`); | ||||
|       throw new Error(`Object "${this.#makeKeyString(identifier)}" does not support mutation.`); | ||||
|     } | ||||
|  | ||||
|     return this.get(identifier).then((object) => { | ||||
| @@ -346,14 +363,17 @@ export default class ObjectAPI { | ||||
|   } | ||||
|  | ||||
|   isPersistable(idOrKeyString) { | ||||
|     let identifier = utils.parseKeyString(idOrKeyString); | ||||
|     let identifier = parseKeyString(idOrKeyString); | ||||
|     let provider = this.getProvider(identifier); | ||||
|     if (provider?.isReadOnly) { | ||||
|       return !provider.isReadOnly(); | ||||
|     } | ||||
|  | ||||
|     return provider !== undefined && provider.create !== undefined && provider.update !== undefined; | ||||
|   } | ||||
|  | ||||
|   isMissing(domainObject) { | ||||
|     let identifier = utils.makeKeyString(domainObject.identifier); | ||||
|     let identifier = makeKeyString(domainObject.identifier); | ||||
|     let missingName = 'Missing: ' + identifier; | ||||
|  | ||||
|     return domainObject.name === missingName; | ||||
| @@ -433,21 +453,21 @@ export default class ObjectAPI { | ||||
|       if (error instanceof this.errors.Conflict) { | ||||
|         // Synchronized objects will resolve their own conflicts | ||||
|         if (this.SYNCHRONIZED_OBJECT_TYPES.includes(domainObject.type)) { | ||||
|           this.openmct.notifications.info( | ||||
|             `Conflict detected while saving "${this.makeKeyString( | ||||
|           this.#openmct.notifications.info( | ||||
|             `Conflict detected while saving "${this.#makeKeyString( | ||||
|               domainObject.name | ||||
|             )}", attempting to resolve` | ||||
|           ); | ||||
|         } else { | ||||
|           this.openmct.notifications.error( | ||||
|             `Conflict detected while saving ${this.makeKeyString(domainObject.identifier)}` | ||||
|           this.#openmct.notifications.error( | ||||
|             `Conflict detected while saving ${this.#makeKeyString(domainObject.identifier)}` | ||||
|           ); | ||||
|  | ||||
|           if (this.isTransactionActive()) { | ||||
|             this.endTransaction(); | ||||
|           } | ||||
|  | ||||
|           await this.refresh(domainObject); | ||||
|           await this.#refresh(domainObject); | ||||
|         } | ||||
|       } | ||||
|  | ||||
| @@ -456,7 +476,7 @@ export default class ObjectAPI { | ||||
|   } | ||||
|  | ||||
|   async #getCurrentUsername() { | ||||
|     const user = await this.openmct.user.getCurrentUser(); | ||||
|     const user = await this.#openmct.user.getCurrentUser(); | ||||
|     let username; | ||||
|  | ||||
|     if (user !== undefined) { | ||||
| @@ -545,7 +565,7 @@ export default class ObjectAPI { | ||||
|    */ | ||||
|   getRelativePath(objectPath) { | ||||
|     return objectPath | ||||
|       .map((p) => this.makeKeyString(p.identifier)) | ||||
|       .map((p) => this.#makeKeyString(p.identifier)) | ||||
|       .reverse() | ||||
|       .join('/'); | ||||
|   } | ||||
| @@ -565,13 +585,13 @@ export default class ObjectAPI { | ||||
|     } | ||||
|  | ||||
|     let sourceTelemetry = null; | ||||
|     if (telemetryIdentifier && utils.identifierEquals(identifier, telemetryIdentifier)) { | ||||
|     if (telemetryIdentifier && this.#identifierEquals(identifier, telemetryIdentifier)) { | ||||
|       sourceTelemetry = identifier; | ||||
|     } else if (objectDetails.composition) { | ||||
|       sourceTelemetry = objectDetails.composition[0]; | ||||
|       if (telemetryIdentifier) { | ||||
|         sourceTelemetry = objectDetails.composition.find((telemetrySource) => | ||||
|           utils.identifierEquals(telemetrySource, telemetryIdentifier) | ||||
|           this.#identifierEquals(telemetrySource, telemetryIdentifier) | ||||
|         ); | ||||
|       } | ||||
|     } | ||||
| @@ -657,7 +677,7 @@ export default class ObjectAPI { | ||||
|       mutableObject = MutableDomainObject.createMutable(domainObject, this.eventEmitter); | ||||
|  | ||||
|       // Check if provider supports realtime updates | ||||
|       let identifier = utils.parseKeyString(mutableObject.identifier); | ||||
|       let identifier = parseKeyString(mutableObject.identifier); | ||||
|       let provider = this.getProvider(identifier); | ||||
|  | ||||
|       if ( | ||||
| @@ -687,15 +707,17 @@ export default class ObjectAPI { | ||||
|   /** | ||||
|    * Updates a domain object based on its latest persisted state. Note that this will mutate the provided object. | ||||
|    * @param {module:openmct.DomainObject} domainObject an object to refresh from its persistence store | ||||
|    * @param {boolean} [forceRemote=false] defaults to false. If true, will skip cached and | ||||
|    *          dirty/in-transaction objects use and the provider.get method | ||||
|    * @returns {Promise} the provided object, updated to reflect the latest persisted state of the object. | ||||
|    */ | ||||
|   async refresh(domainObject) { | ||||
|     const refreshedObject = await this.get(domainObject.identifier); | ||||
|   async refresh(domainObject, forceRemote = false) { | ||||
|     const refreshedObject = await this.get(domainObject.identifier, null, forceRemote); | ||||
|  | ||||
|     if (domainObject.isMutable) { | ||||
|       domainObject.$refresh(refreshedObject); | ||||
|     } else { | ||||
|       utils.refresh(domainObject, refreshedObject); | ||||
|       refresh(domainObject, refreshedObject); | ||||
|     } | ||||
|  | ||||
|     return domainObject; | ||||
| @@ -734,7 +756,7 @@ export default class ObjectAPI { | ||||
|    * @returns {string} A string representation of the given identifier, including namespace and key | ||||
|    */ | ||||
|   makeKeyString(identifier) { | ||||
|     return utils.makeKeyString(identifier); | ||||
|     return makeKeyString(identifier); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
| @@ -742,7 +764,7 @@ export default class ObjectAPI { | ||||
|    * @returns {module:openmct.ObjectAPI~Identifier} An identifier object | ||||
|    */ | ||||
|   parseKeyString(keyString) { | ||||
|     return utils.parseKeyString(keyString); | ||||
|     return parseKeyString(keyString); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
| @@ -750,9 +772,9 @@ export default class ObjectAPI { | ||||
|    * @param {module:openmct.ObjectAPI~Identifier[]} identifiers | ||||
|    */ | ||||
|   areIdsEqual(...identifiers) { | ||||
|     const firstIdentifier = utils.parseKeyString(identifiers[0]); | ||||
|     const firstIdentifier = this.#parseKeyString(identifiers[0]); | ||||
|  | ||||
|     return identifiers.map(utils.parseKeyString).every((identifier) => { | ||||
|     return identifiers.map(this.#parseKeyString).every((identifier) => { | ||||
|       return ( | ||||
|         identifier === firstIdentifier || | ||||
|         (identifier.namespace === firstIdentifier.namespace && | ||||
| @@ -780,7 +802,7 @@ export default class ObjectAPI { | ||||
|     } | ||||
|  | ||||
|     return path.some((pathElement) => { | ||||
|       const identifierToCheck = utils.parseKeyString(keyStringToCheck); | ||||
|       const identifierToCheck = this.#parseKeyString(keyStringToCheck); | ||||
|  | ||||
|       return this.areIdsEqual(identifierToCheck, pathElement.identifier); | ||||
|     }); | ||||
| @@ -803,7 +825,7 @@ export default class ObjectAPI { | ||||
|     if (location && !this.#pathContainsDomainObject(location, path)) { | ||||
|       // if we have a location, and we don't already have this in our constructed path, | ||||
|       // then keep walking up the path | ||||
|       return this.getOriginalPath(utils.parseKeyString(location), path, abortSignal); | ||||
|       return this.getOriginalPath(this.#parseKeyString(location), path, abortSignal); | ||||
|     } else { | ||||
|       return path; | ||||
|     } | ||||
| @@ -842,8 +864,8 @@ export default class ObjectAPI { | ||||
|       await Promise.all( | ||||
|         keyStrings.map((keyString) => | ||||
|           this.supportsMutation(keyString) | ||||
|             ? this.getMutable(utils.parseKeyString(keyString)) | ||||
|             : this.get(utils.parseKeyString(keyString)) | ||||
|             ? this.getMutable(this.#parseKeyString(keyString)) | ||||
|             : this.get(this.#parseKeyString(keyString)) | ||||
|         ) | ||||
|       ) | ||||
|     ).reverse(); | ||||
| @@ -855,7 +877,7 @@ export default class ObjectAPI { | ||||
|     return ( | ||||
|       objectPath !== undefined && | ||||
|       objectPath.length > 1 && | ||||
|       domainObject.location !== this.makeKeyString(objectPath[1].identifier) | ||||
|       domainObject.location !== this.#makeKeyString(objectPath[1].identifier) | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -362,7 +362,7 @@ describe('The Object API', () => { | ||||
|       expect(objectAPI.get).not.toHaveBeenCalled(); | ||||
|  | ||||
|       return objectAPI.refresh(testObject).then(() => { | ||||
|         expect(objectAPI.get).toHaveBeenCalledWith(testObject.identifier); | ||||
|         expect(objectAPI.get).toHaveBeenCalledWith(testObject.identifier, null, false); | ||||
|  | ||||
|         expect(testObject.otherAttribute).toEqual(OTHER_ATTRIBUTE_VALUE); | ||||
|         expect(testObject.newAttribute).toEqual(NEW_ATTRIBUTE_VALUE); | ||||
|   | ||||
| @@ -20,7 +20,7 @@ | ||||
|  * at runtime from the About dialog for additional information. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| import utils from './object-utils.js'; | ||||
| import { isIdentifier } from './object-utils.js'; | ||||
|  | ||||
| export default class RootRegistry { | ||||
|   constructor(openmct) { | ||||
| @@ -47,12 +47,12 @@ export default class RootRegistry { | ||||
|   } | ||||
|  | ||||
|   _isValid(rootItem) { | ||||
|     if (utils.isIdentifier(rootItem) || typeof rootItem === 'function') { | ||||
|     if (isIdentifier(rootItem) || typeof rootItem === 'function') { | ||||
|       return true; | ||||
|     } | ||||
|  | ||||
|     if (Array.isArray(rootItem)) { | ||||
|       return rootItem.every(utils.isIdentifier); | ||||
|       return rootItem.every(isIdentifier); | ||||
|     } | ||||
|  | ||||
|     return false; | ||||
|   | ||||
| @@ -47,9 +47,9 @@ export default class Transaction { | ||||
|     return Promise.all(promiseArray); | ||||
|   } | ||||
|  | ||||
|   createDirtyObjectPromise(object, action) { | ||||
|   createDirtyObjectPromise(object, action, ...args) { | ||||
|     return new Promise((resolve, reject) => { | ||||
|       action(object) | ||||
|       action(object, ...args) | ||||
|         .then((success) => { | ||||
|           const key = this.objectAPI.makeKeyString(object.identifier); | ||||
|  | ||||
| @@ -75,10 +75,10 @@ export default class Transaction { | ||||
|  | ||||
|   _clear() { | ||||
|     const promiseArray = []; | ||||
|     const refresh = this.objectAPI.refresh.bind(this.objectAPI); | ||||
|     const action = (obj) => this.objectAPI.refresh(obj, true); | ||||
|  | ||||
|     Object.values(this.dirtyObjects).forEach((object) => { | ||||
|       promiseArray.push(this.createDirtyObjectPromise(object, refresh)); | ||||
|       promiseArray.push(this.createDirtyObjectPromise(object, action)); | ||||
|     }); | ||||
|  | ||||
|     return Promise.all(promiseArray); | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import utils from 'objectUtils'; | ||||
| import { makeKeyString, parseKeyString } from 'objectUtils'; | ||||
|  | ||||
| import Transaction from './Transaction.js'; | ||||
|  | ||||
| @@ -9,7 +9,7 @@ let transaction; | ||||
| describe('Transaction Class', () => { | ||||
|   beforeEach(() => { | ||||
|     objectAPI = { | ||||
|       makeKeyString: (identifier) => utils.makeKeyString(identifier), | ||||
|       makeKeyString: (identifier) => makeKeyString(identifier), | ||||
|       save: () => Promise.resolve(true), | ||||
|       mutate: (object, prop, value) => { | ||||
|         object[prop] = value; | ||||
| @@ -18,7 +18,7 @@ describe('Transaction Class', () => { | ||||
|       }, | ||||
|       refresh: (object) => Promise.resolve(object), | ||||
|       areIdsEqual: (...identifiers) => { | ||||
|         return identifiers.map(utils.parseKeyString).every((identifier) => { | ||||
|         return identifiers.map(parseKeyString).every((identifier) => { | ||||
|           return ( | ||||
|             identifier === identifiers[0] || | ||||
|             (identifier.namespace === identifiers[0].namespace && | ||||
|   | ||||
| @@ -24,7 +24,7 @@ | ||||
|  * Utility for checking if a thing is an Open MCT Identifier. | ||||
|  * @private | ||||
|  */ | ||||
| function isIdentifier(thing) { | ||||
| export function isIdentifier(thing) { | ||||
|   return ( | ||||
|     typeof thing === 'object' && | ||||
|     Object.prototype.hasOwnProperty.call(thing, 'key') && | ||||
| @@ -36,7 +36,7 @@ function isIdentifier(thing) { | ||||
|  * Utility for checking if a thing is a key string.  Not perfect. | ||||
|  * @private | ||||
|  */ | ||||
| function isKeyString(thing) { | ||||
| export function isKeyString(thing) { | ||||
|   return typeof thing === 'string'; | ||||
| } | ||||
|  | ||||
| @@ -49,7 +49,7 @@ function isKeyString(thing) { | ||||
|  * @param keyString | ||||
|  * @returns identifier | ||||
|  */ | ||||
| function parseKeyString(keyString) { | ||||
| export function parseKeyString(keyString) { | ||||
|   if (isIdentifier(keyString)) { | ||||
|     return keyString; | ||||
|   } | ||||
| @@ -86,7 +86,7 @@ function parseKeyString(keyString) { | ||||
|  * @param identifier | ||||
|  * @returns keyString | ||||
|  */ | ||||
| function makeKeyString(identifier) { | ||||
| export function makeKeyString(identifier) { | ||||
|   if (!identifier) { | ||||
|     throw new Error('Cannot make key string from null identifier'); | ||||
|   } | ||||
| @@ -112,7 +112,7 @@ function makeKeyString(identifier) { | ||||
|  * @param domainObject | ||||
|  * @returns oldFormatModel | ||||
|  */ | ||||
| function toOldFormat(model) { | ||||
| export function toOldFormat(model) { | ||||
|   model = JSON.parse(JSON.stringify(model)); | ||||
|   delete model.identifier; | ||||
|   if (model.composition) { | ||||
| @@ -131,7 +131,7 @@ function toOldFormat(model) { | ||||
|  * @param keyString | ||||
|  * @returns domainObject | ||||
|  */ | ||||
| function toNewFormat(model, keyString) { | ||||
| export function toNewFormat(model, keyString) { | ||||
|   model = JSON.parse(JSON.stringify(model)); | ||||
|   model.identifier = parseKeyString(keyString); | ||||
|   if (model.composition) { | ||||
| @@ -148,7 +148,7 @@ function toNewFormat(model, keyString) { | ||||
|  * @param otherIdentifier | ||||
|  * @returns Boolean true if identifiers are equal. | ||||
|  */ | ||||
| function identifierEquals(a, b) { | ||||
| export function identifierEquals(a, b) { | ||||
|   return a.key === b.key && a.namespace === b.namespace; | ||||
| } | ||||
|  | ||||
| @@ -160,23 +160,12 @@ function identifierEquals(a, b) { | ||||
|  * @param otherDomainOBject | ||||
|  * @returns Boolean true if objects are equal. | ||||
|  */ | ||||
| function objectEquals(a, b) { | ||||
| export function objectEquals(a, b) { | ||||
|   return identifierEquals(a.identifier, b.identifier); | ||||
| } | ||||
|  | ||||
| function refresh(oldObject, newObject) { | ||||
| export function refresh(oldObject, newObject) { | ||||
|   let deleted = _.difference(Object.keys(oldObject), Object.keys(newObject)); | ||||
|   deleted.forEach((propertyName) => delete oldObject[propertyName]); | ||||
|   Object.assign(oldObject, newObject); | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   isIdentifier: isIdentifier, | ||||
|   toOldFormat: toOldFormat, | ||||
|   toNewFormat: toNewFormat, | ||||
|   makeKeyString: makeKeyString, | ||||
|   parseKeyString: parseKeyString, | ||||
|   equals: objectEquals, | ||||
|   identifierEquals: identifierEquals, | ||||
|   refresh: refresh | ||||
| }; | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import objectUtils from 'objectUtils'; | ||||
| import { makeKeyString, parseKeyString, toNewFormat, toOldFormat } from 'objectUtils'; | ||||
|  | ||||
| describe('objectUtils', function () { | ||||
|   describe('keyString util', function () { | ||||
| @@ -31,27 +31,27 @@ describe('objectUtils', function () { | ||||
|  | ||||
|     Object.keys(EXPECTATIONS).forEach(function (keyString) { | ||||
|       it('parses "' + keyString + '".', function () { | ||||
|         expect(objectUtils.parseKeyString(keyString)).toEqual(EXPECTATIONS[keyString]); | ||||
|         expect(parseKeyString(keyString)).toEqual(EXPECTATIONS[keyString]); | ||||
|       }); | ||||
|  | ||||
|       it('parses and re-encodes "' + keyString + '"', function () { | ||||
|         const identifier = objectUtils.parseKeyString(keyString); | ||||
|         expect(objectUtils.makeKeyString(identifier)).toEqual(keyString); | ||||
|         const identifier = parseKeyString(keyString); | ||||
|         expect(makeKeyString(identifier)).toEqual(keyString); | ||||
|       }); | ||||
|  | ||||
|       it('is idempotent for "' + keyString + '".', function () { | ||||
|         const identifier = objectUtils.parseKeyString(keyString); | ||||
|         let again = objectUtils.parseKeyString(identifier); | ||||
|         const identifier = parseKeyString(keyString); | ||||
|         let again = parseKeyString(identifier); | ||||
|         expect(identifier).toEqual(again); | ||||
|         again = objectUtils.parseKeyString(again); | ||||
|         again = objectUtils.parseKeyString(again); | ||||
|         again = parseKeyString(again); | ||||
|         again = parseKeyString(again); | ||||
|         expect(identifier).toEqual(again); | ||||
|  | ||||
|         let againKeyString = objectUtils.makeKeyString(again); | ||||
|         let againKeyString = makeKeyString(again); | ||||
|         expect(againKeyString).toEqual(keyString); | ||||
|         againKeyString = objectUtils.makeKeyString(againKeyString); | ||||
|         againKeyString = objectUtils.makeKeyString(againKeyString); | ||||
|         againKeyString = objectUtils.makeKeyString(againKeyString); | ||||
|         againKeyString = makeKeyString(againKeyString); | ||||
|         againKeyString = makeKeyString(againKeyString); | ||||
|         againKeyString = makeKeyString(againKeyString); | ||||
|         expect(againKeyString).toEqual(keyString); | ||||
|       }); | ||||
|     }); | ||||
| @@ -60,7 +60,7 @@ describe('objectUtils', function () { | ||||
|   describe('old object conversions', function () { | ||||
|     it('translate ids', function () { | ||||
|       expect( | ||||
|         objectUtils.toNewFormat( | ||||
|         toNewFormat( | ||||
|           { | ||||
|             prop: 'someValue' | ||||
|           }, | ||||
| @@ -77,7 +77,7 @@ describe('objectUtils', function () { | ||||
|  | ||||
|     it('translates composition', function () { | ||||
|       expect( | ||||
|         objectUtils.toNewFormat( | ||||
|         toNewFormat( | ||||
|           { | ||||
|             prop: 'someValue', | ||||
|             composition: ['anotherObjectId', 'scratch:anotherObjectId'] | ||||
| @@ -107,7 +107,7 @@ describe('objectUtils', function () { | ||||
|   describe('new object conversions', function () { | ||||
|     it('removes ids', function () { | ||||
|       expect( | ||||
|         objectUtils.toOldFormat({ | ||||
|         toOldFormat({ | ||||
|           prop: 'someValue', | ||||
|           identifier: { | ||||
|             namespace: '', | ||||
| @@ -121,7 +121,7 @@ describe('objectUtils', function () { | ||||
|  | ||||
|     it('translates composition', function () { | ||||
|       expect( | ||||
|         objectUtils.toOldFormat({ | ||||
|         toOldFormat({ | ||||
|           prop: 'someValue', | ||||
|           composition: [ | ||||
|             { | ||||
|   | ||||
| @@ -61,6 +61,7 @@ class Overlay extends EventEmitter { | ||||
|   dismiss() { | ||||
|     this.emit('destroy'); | ||||
|     this.destroy(); | ||||
|     this.container.remove(); | ||||
|   } | ||||
|  | ||||
|   //Ensures that any callers are notified that the overlay is dismissed | ||||
|   | ||||
							
								
								
									
										194
									
								
								src/api/telemetry/BatchingWebSocket.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										194
									
								
								src/api/telemetry/BatchingWebSocket.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,194 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT Web, Copyright (c) 2014-2024, United States Government | ||||
|  * as represented by the Administrator of the National Aeronautics and Space | ||||
|  * Administration. All rights reserved. | ||||
|  * | ||||
|  * Open MCT Web 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 Web 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 installWorker from './WebSocketWorker.js'; | ||||
| const DEFAULT_RATE_MS = 1000; | ||||
| /** | ||||
|  * Describes the strategy to be used when batching WebSocket messages | ||||
|  * | ||||
|  * @typedef BatchingStrategy | ||||
|  * @property {Function} shouldBatchMessage a function that accepts a single | ||||
|  * argument - the raw message received from the websocket. Every message | ||||
|  * 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 | ||||
|  * a lot of boilerplate common to managing WebSocket connections such as: | ||||
|  * - Establishing a WebSocket connection to a server | ||||
|  * - Reconnecting on error, with a fallback strategy | ||||
|  * - Queuing messages so that clients can send messages without concern for the current | ||||
|  * connection state of the WebSocket. | ||||
|  * | ||||
|  * The WebSocket that it manages is based in a dedicated worker so that network | ||||
|  * concerns are not handled on the main event loop. This allows for performant receipt | ||||
|  * and batching of messages without blocking either the UI or server. | ||||
|  * | ||||
|  * @memberof module:openmct.telemetry | ||||
|  */ | ||||
| class BatchingWebSocket extends EventTarget { | ||||
|   #worker; | ||||
|   #openmct; | ||||
|   #showingRateLimitNotification; | ||||
|   #rate; | ||||
|  | ||||
|   constructor(openmct) { | ||||
|     super(); | ||||
|     // Install worker, register listeners etc. | ||||
|     const workerFunction = `(${installWorker.toString()})()`; | ||||
|     const workerBlob = new Blob([workerFunction]); | ||||
|     const workerUrl = URL.createObjectURL(workerBlob, { type: 'application/javascript' }); | ||||
|     this.#worker = new Worker(workerUrl); | ||||
|     this.#openmct = openmct; | ||||
|     this.#showingRateLimitNotification = false; | ||||
|     this.#rate = DEFAULT_RATE_MS; | ||||
|  | ||||
|     const routeMessageToHandler = this.#routeMessageToHandler.bind(this); | ||||
|     this.#worker.addEventListener('message', routeMessageToHandler); | ||||
|     openmct.on( | ||||
|       'destroy', | ||||
|       () => { | ||||
|         this.disconnect(); | ||||
|         URL.revokeObjectURL(workerUrl); | ||||
|       }, | ||||
|       { once: true } | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Will establish a WebSocket connection to the provided url | ||||
|    * @param {string} url The URL to connect to | ||||
|    */ | ||||
|   connect(url) { | ||||
|     this.#worker.postMessage({ | ||||
|       type: 'connect', | ||||
|       url | ||||
|     }); | ||||
|  | ||||
|     this.#readyForNextBatch(); | ||||
|   } | ||||
|  | ||||
|   #readyForNextBatch() { | ||||
|     this.#worker.postMessage({ | ||||
|       type: 'readyForNextBatch' | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Send a message to the WebSocket. | ||||
|    * @param {any} message The message to send. Can be any type supported by WebSockets. | ||||
|    * See https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send#data | ||||
|    */ | ||||
|   sendMessage(message) { | ||||
|     this.#worker.postMessage({ | ||||
|       type: 'message', | ||||
|       message | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Set the strategy used to both decide which raw messages to batch, and how to group | ||||
|    * 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 | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * When using batching, sets the rate at which batches of messages are released. | ||||
|    * @param {Number} rate the amount of time to wait, in ms, between batches. | ||||
|    */ | ||||
|   setRate(rate) { | ||||
|     this.#rate = rate; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * @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 | ||||
|    * 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 | ||||
|    * 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 | ||||
|    * is received at 10Hz for each telemetry point, then a minimal combination of batch | ||||
|    * size and rate is 10 and 1000 respectively. Ideally you would add some margin, so | ||||
|    * 15 would probably be a better batch size. | ||||
|    */ | ||||
|   setMaxBatchSize(maxBatchSize) { | ||||
|     this.#worker.postMessage({ | ||||
|       type: 'setMaxBatchSize', | ||||
|       maxBatchSize | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Disconnect the associated WebSocket. Generally speaking there is no need to call | ||||
|    * this manually. | ||||
|    */ | ||||
|   disconnect() { | ||||
|     this.#worker.postMessage({ | ||||
|       type: 'disconnect' | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   #routeMessageToHandler(message) { | ||||
|     if (message.data.type === 'batch') { | ||||
|       if (message.data.batch.dropped === true && !this.#showingRateLimitNotification) { | ||||
|         const notification = this.#openmct.notifications.alert( | ||||
|           'Telemetry dropped due to client rate limiting.', | ||||
|           { hint: 'Refresh individual telemetry views to retrieve dropped telemetry if needed.' } | ||||
|         ); | ||||
|         this.#showingRateLimitNotification = true; | ||||
|         notification.once('minimized', () => { | ||||
|           this.#showingRateLimitNotification = false; | ||||
|         }); | ||||
|       } | ||||
|       this.dispatchEvent(new CustomEvent('batch', { detail: message.data.batch })); | ||||
|       setTimeout(() => { | ||||
|         this.#readyForNextBatch(); | ||||
|       }, this.#rate); | ||||
|     } else if (message.data.type === 'message') { | ||||
|       this.dispatchEvent(new CustomEvent('message', { detail: message.data.message })); | ||||
|     } else { | ||||
|       throw new Error(`Unknown message type: ${message.data.type}`); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| export default BatchingWebSocket; | ||||
| @@ -20,9 +20,10 @@ | ||||
|  * at runtime from the About dialog for additional information. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| import objectUtils from 'objectUtils'; | ||||
| import { makeKeyString } from 'objectUtils'; | ||||
|  | ||||
| import CustomStringFormatter from '../../plugins/displayLayout/CustomStringFormatter.js'; | ||||
| import BatchingWebSocket from './BatchingWebSocket.js'; | ||||
| import DefaultMetadataProvider from './DefaultMetadataProvider.js'; | ||||
| import TelemetryCollection from './TelemetryCollection.js'; | ||||
| import TelemetryMetadataManager from './TelemetryMetadataManager.js'; | ||||
| @@ -54,6 +55,28 @@ import TelemetryValueFormatter from './TelemetryValueFormatter.js'; | ||||
|  * @memberof module:openmct.TelemetryAPI~ | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * Describes and bounds requests for telemetry data. | ||||
|  * | ||||
|  * @typedef TelemetrySubscriptionOptions | ||||
|  * @property {String} [strategy] symbolic identifier directing providers on how | ||||
|  * to handle telemetry subscriptions. The default behavior is 'latest' which will | ||||
|  * always return a single telemetry value with each callback, and in the event | ||||
|  * of throttling will always prioritize the latest data, meaning intermediate | ||||
|  * data will be skipped. Alternatively, the `batch` strategy can be used, which | ||||
|  * will return all telemetry values since the last callback. This strategy is | ||||
|  * useful for cases where intermediate data is important, such as when | ||||
|  * rendering a telemetry plot or table. If `batch` is specified, the subscription | ||||
|  * callback will be invoked with an Array. | ||||
|  * | ||||
|  * @memberof module:openmct.TelemetryAPI~ | ||||
|  */ | ||||
|  | ||||
| const SUBSCRIBE_STRATEGY = { | ||||
|   LATEST: 'latest', | ||||
|   BATCH: 'batch' | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * Utilities for telemetry | ||||
|  * @interface TelemetryAPI | ||||
| @@ -61,6 +84,11 @@ import TelemetryValueFormatter from './TelemetryValueFormatter.js'; | ||||
|  */ | ||||
| export default class TelemetryAPI { | ||||
|   #isGreedyLAD; | ||||
|   #subscribeCache; | ||||
|  | ||||
|   get SUBSCRIBE_STRATEGY() { | ||||
|     return SUBSCRIBE_STRATEGY; | ||||
|   } | ||||
|  | ||||
|   constructor(openmct) { | ||||
|     this.openmct = openmct; | ||||
| @@ -78,6 +106,8 @@ export default class TelemetryAPI { | ||||
|     this.valueFormatterCache = new WeakMap(); | ||||
|     this.requestInterceptorRegistry = new TelemetryRequestInterceptorRegistry(); | ||||
|     this.#isGreedyLAD = true; | ||||
|     this.BatchingWebSocket = BatchingWebSocket; | ||||
|     this.#subscribeCache = {}; | ||||
|   } | ||||
|  | ||||
|   abortAllRequests() { | ||||
| @@ -378,54 +408,111 @@ export default class TelemetryAPI { | ||||
|    * @memberof module:openmct.TelemetryAPI~TelemetryProvider# | ||||
|    * @param {module:openmct.DomainObject} domainObject the object | ||||
|    *        which has associated telemetry | ||||
|    * @param {TelemetryRequestOptions} options configuration items for subscription | ||||
|    * @param {TelemetrySubscriptionOptions} options configuration items for subscription | ||||
|    * @param {Function} callback the callback to invoke with new data, as | ||||
|    *        it becomes available | ||||
|    * @returns {Function} a function which may be called to terminate | ||||
|    *          the subscription | ||||
|    */ | ||||
|   subscribe(domainObject, callback, options) { | ||||
|   subscribe(domainObject, callback, options = { strategy: SUBSCRIBE_STRATEGY.LATEST }) { | ||||
|     const requestedStrategy = options.strategy || SUBSCRIBE_STRATEGY.LATEST; | ||||
|  | ||||
|     if (domainObject.type === 'unknown') { | ||||
|       return () => {}; | ||||
|     } | ||||
|  | ||||
|     const provider = this.findSubscriptionProvider(domainObject); | ||||
|     const provider = this.findSubscriptionProvider(domainObject, options); | ||||
|     const supportsBatching = | ||||
|       Boolean(provider?.supportsBatching) && provider?.supportsBatching(domainObject, options); | ||||
|  | ||||
|     if (!this.subscribeCache) { | ||||
|       this.subscribeCache = {}; | ||||
|     if (!this.#subscribeCache) { | ||||
|       this.#subscribeCache = {}; | ||||
|     } | ||||
|  | ||||
|     const keyString = objectUtils.makeKeyString(domainObject.identifier); | ||||
|     let subscriber = this.subscribeCache[keyString]; | ||||
|     const keyString = makeKeyString(domainObject.identifier); | ||||
|     const supportedStrategy = supportsBatching ? requestedStrategy : SUBSCRIBE_STRATEGY.LATEST; | ||||
|     // Override the requested strategy with the strategy supported by the provider | ||||
|     const optionsWithSupportedStrategy = { | ||||
|       ...options, | ||||
|       strategy: supportedStrategy | ||||
|     }; | ||||
|     // If batching is supported, we need to cache a subscription for each strategy - | ||||
|     // latest and batched. | ||||
|     const cacheKey = `${keyString}:${supportedStrategy}`; | ||||
|     let subscriber = this.#subscribeCache[cacheKey]; | ||||
|  | ||||
|     if (!subscriber) { | ||||
|       subscriber = this.subscribeCache[keyString] = { | ||||
|         callbacks: [callback] | ||||
|       subscriber = this.#subscribeCache[cacheKey] = { | ||||
|         latestCallbacks: [], | ||||
|         batchCallbacks: [] | ||||
|       }; | ||||
|       if (provider) { | ||||
|         subscriber.unsubscribe = provider.subscribe( | ||||
|           domainObject, | ||||
|           function (value) { | ||||
|             subscriber.callbacks.forEach(function (cb) { | ||||
|               cb(value); | ||||
|             }); | ||||
|           }, | ||||
|           options | ||||
|           invokeCallbackWithRequestedStrategy, | ||||
|           optionsWithSupportedStrategy | ||||
|         ); | ||||
|       } else { | ||||
|         subscriber.unsubscribe = function () {}; | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     if (requestedStrategy === SUBSCRIBE_STRATEGY.BATCH) { | ||||
|       subscriber.batchCallbacks.push(callback); | ||||
|     } else { | ||||
|       subscriber.callbacks.push(callback); | ||||
|       subscriber.latestCallbacks.push(callback); | ||||
|     } | ||||
|  | ||||
|     // Guarantees that view receive telemetry in the expected form | ||||
|     function invokeCallbackWithRequestedStrategy(data) { | ||||
|       invokeCallbacksWithArray(data, subscriber.batchCallbacks); | ||||
|       invokeCallbacksWithSingleValue(data, subscriber.latestCallbacks); | ||||
|     } | ||||
|  | ||||
|     function invokeCallbacksWithArray(data, batchCallbacks) { | ||||
|       // | ||||
|       if (data === undefined || data === null || data.length === 0) { | ||||
|         throw new Error( | ||||
|           'Attempt to invoke telemetry subscription callback with no telemetry datum' | ||||
|         ); | ||||
|       } | ||||
|  | ||||
|       if (!Array.isArray(data)) { | ||||
|         data = [data]; | ||||
|       } | ||||
|  | ||||
|       batchCallbacks.forEach((cb) => { | ||||
|         cb(data); | ||||
|       }); | ||||
|     } | ||||
|  | ||||
|     function invokeCallbacksWithSingleValue(data, latestCallbacks) { | ||||
|       if (Array.isArray(data)) { | ||||
|         data = data[data.length - 1]; | ||||
|       } | ||||
|  | ||||
|       if (data === undefined || data === null) { | ||||
|         throw new Error( | ||||
|           'Attempt to invoke telemetry subscription callback with no telemetry datum' | ||||
|         ); | ||||
|       } | ||||
|  | ||||
|       latestCallbacks.forEach((cb) => { | ||||
|         cb(data); | ||||
|       }); | ||||
|     } | ||||
|  | ||||
|     return function unsubscribe() { | ||||
|       subscriber.callbacks = subscriber.callbacks.filter(function (cb) { | ||||
|       subscriber.latestCallbacks = subscriber.latestCallbacks.filter(function (cb) { | ||||
|         return cb !== callback; | ||||
|       }); | ||||
|       if (subscriber.callbacks.length === 0) { | ||||
|       subscriber.batchCallbacks = subscriber.batchCallbacks.filter(function (cb) { | ||||
|         return cb !== callback; | ||||
|       }); | ||||
|  | ||||
|       if (subscriber.latestCallbacks.length === 0 && subscriber.batchCallbacks.length === 0) { | ||||
|         subscriber.unsubscribe(); | ||||
|         delete this.subscribeCache[keyString]; | ||||
|         delete this.#subscribeCache[cacheKey]; | ||||
|       } | ||||
|     }.bind(this); | ||||
|   } | ||||
| @@ -454,7 +541,7 @@ export default class TelemetryAPI { | ||||
|       this.stalenessSubscriberCache = {}; | ||||
|     } | ||||
|  | ||||
|     const keyString = objectUtils.makeKeyString(domainObject.identifier); | ||||
|     const keyString = makeKeyString(domainObject.identifier); | ||||
|     let stalenessSubscriber = this.stalenessSubscriberCache[keyString]; | ||||
|  | ||||
|     if (!stalenessSubscriber) { | ||||
| @@ -513,7 +600,7 @@ export default class TelemetryAPI { | ||||
|       this.limitsSubscribeCache = {}; | ||||
|     } | ||||
|  | ||||
|     const keyString = objectUtils.makeKeyString(domainObject.identifier); | ||||
|     const keyString = makeKeyString(domainObject.identifier); | ||||
|     let subscriber = this.limitsSubscribeCache[keyString]; | ||||
|  | ||||
|     if (!subscriber) { | ||||
|   | ||||
| @@ -90,7 +90,9 @@ describe('Telemetry API', () => { | ||||
|  | ||||
|       const callback = jasmine.createSpy('callback'); | ||||
|       const unsubscribe = telemetryAPI.subscribe(domainObject, callback); | ||||
|       expect(telemetryProvider.supportsSubscribe).toHaveBeenCalledWith(domainObject); | ||||
|       expect(telemetryProvider.supportsSubscribe).toHaveBeenCalledWith(domainObject, { | ||||
|         strategy: 'latest' | ||||
|       }); | ||||
|       expect(telemetryProvider.subscribe).not.toHaveBeenCalled(); | ||||
|       expect(unsubscribe).toEqual(jasmine.any(Function)); | ||||
|  | ||||
| @@ -111,12 +113,16 @@ describe('Telemetry API', () => { | ||||
|       const callback = jasmine.createSpy('callback'); | ||||
|       const unsubscribe = telemetryAPI.subscribe(domainObject, callback); | ||||
|       expect(telemetryProvider.supportsSubscribe.calls.count()).toBe(1); | ||||
|       expect(telemetryProvider.supportsSubscribe).toHaveBeenCalledWith(domainObject); | ||||
|       expect(telemetryProvider.supportsSubscribe).toHaveBeenCalledWith(domainObject, { | ||||
|         strategy: 'latest' | ||||
|       }); | ||||
|       expect(telemetryProvider.subscribe.calls.count()).toBe(1); | ||||
|       expect(telemetryProvider.subscribe).toHaveBeenCalledWith( | ||||
|         domainObject, | ||||
|         jasmine.any(Function), | ||||
|         undefined | ||||
|         { | ||||
|           strategy: 'latest' | ||||
|         } | ||||
|       ); | ||||
|  | ||||
|       const notify = telemetryProvider.subscribe.calls.mostRecent().args[1]; | ||||
| @@ -321,6 +327,126 @@ describe('Telemetry API', () => { | ||||
|         signal | ||||
|       }); | ||||
|     }); | ||||
|     describe('telemetry batching support', () => { | ||||
|       let callbacks; | ||||
|       let unsubFunc; | ||||
|  | ||||
|       beforeEach(() => { | ||||
|         callbacks = []; | ||||
|         unsubFunc = jasmine.createSpy('unsubscribe'); | ||||
|         telemetryProvider.supportsBatching = jasmine.createSpy('supportsBatching'); | ||||
|         telemetryProvider.supportsBatching.and.returnValue(true); | ||||
|         telemetryProvider.supportsSubscribe.and.returnValue(true); | ||||
|  | ||||
|         telemetryProvider.subscribe.and.callFake(function (obj, cb, options) { | ||||
|           callbacks.push(cb); | ||||
|  | ||||
|           return unsubFunc; | ||||
|         }); | ||||
|  | ||||
|         telemetryAPI.addProvider(telemetryProvider); | ||||
|       }); | ||||
|  | ||||
|       it('caches subscriptions for batched and latest telemetry subscriptions', () => { | ||||
|         const latestCallback1 = jasmine.createSpy('latestCallback1'); | ||||
|         const unsubscribeFromLatest1 = telemetryAPI.subscribe(domainObject, latestCallback1, { | ||||
|           strategy: 'latest' | ||||
|         }); | ||||
|         const latestCallback2 = jasmine.createSpy('latestCallback2'); | ||||
|         const unsubscribeFromLatest2 = telemetryAPI.subscribe(domainObject, latestCallback2, { | ||||
|           strategy: 'latest' | ||||
|         }); | ||||
|  | ||||
|         //Expect a single cached subscription for latest telemetry | ||||
|         expect(telemetryProvider.subscribe.calls.count()).toBe(1); | ||||
|  | ||||
|         const batchedCallback1 = jasmine.createSpy('batchedCallback1'); | ||||
|         const unsubscribeFromBatched1 = telemetryAPI.subscribe(domainObject, batchedCallback1, { | ||||
|           strategy: 'batch' | ||||
|         }); | ||||
|  | ||||
|         const batchedCallback2 = jasmine.createSpy('batchedCallback2'); | ||||
|         const unsubscribeFromBatched2 = telemetryAPI.subscribe(domainObject, batchedCallback2, { | ||||
|           strategy: 'batch' | ||||
|         }); | ||||
|  | ||||
|         //Expect a single cached subscription for each strategy telemetry | ||||
|         expect(telemetryProvider.subscribe.calls.count()).toBe(2); | ||||
|  | ||||
|         unsubscribeFromLatest1(); | ||||
|         unsubscribeFromLatest2(); | ||||
|         unsubscribeFromBatched1(); | ||||
|         unsubscribeFromBatched2(); | ||||
|  | ||||
|         expect(unsubFunc).toHaveBeenCalledTimes(2); | ||||
|       }); | ||||
|       it('subscriptions with the latest strategy are always invoked with a single value', () => { | ||||
|         const latestCallback = jasmine.createSpy('latestCallback1'); | ||||
|         telemetryAPI.subscribe(domainObject, latestCallback, { | ||||
|           strategy: 'latest' | ||||
|         }); | ||||
|  | ||||
|         const batchedValues = [1, 2, 3]; | ||||
|         callbacks.forEach((cb) => { | ||||
|           cb(batchedValues); | ||||
|         }); | ||||
|  | ||||
|         expect(latestCallback).toHaveBeenCalledWith(3); | ||||
|  | ||||
|         const singleValue = 1; | ||||
|         callbacks.forEach((cb) => { | ||||
|           cb(singleValue); | ||||
|         }); | ||||
|  | ||||
|         expect(latestCallback).toHaveBeenCalledWith(1); | ||||
|       }); | ||||
|  | ||||
|       it('subscriptions with the batch strategy are always invoked with an array', () => { | ||||
|         const batchedCallback = jasmine.createSpy('batchedCallback1'); | ||||
|         const latestCallback = jasmine.createSpy('latestCallback1'); | ||||
|         telemetryAPI.subscribe(domainObject, batchedCallback, { | ||||
|           strategy: 'batch' | ||||
|         }); | ||||
|         telemetryAPI.subscribe(domainObject, latestCallback, { | ||||
|           strategy: 'latest' | ||||
|         }); | ||||
|  | ||||
|         const batchedValues = [1, 2, 3]; | ||||
|         callbacks.forEach((cb) => { | ||||
|           cb(batchedValues); | ||||
|         }); | ||||
|  | ||||
|         // Callbacks for the 'batch' strategy are always called with an array of values | ||||
|         expect(batchedCallback).toHaveBeenCalledWith(batchedValues); | ||||
|         // Callbacks for the 'latest' strategy are always called with a single value | ||||
|         expect(latestCallback).toHaveBeenCalledWith(3); | ||||
|  | ||||
|         callbacks.forEach((cb) => { | ||||
|           cb(1); | ||||
|         }); | ||||
|         // Callbacks for the 'batch' strategy are always called with an array of values, even if there is only one value | ||||
|         expect(batchedCallback).toHaveBeenCalledWith([1]); | ||||
|         // Callbacks for the 'latest' strategy are always called with a single value | ||||
|         expect(latestCallback).toHaveBeenCalledWith(1); | ||||
|       }); | ||||
|  | ||||
|       it('legacy providers are left unchanged, with a single subscription', () => { | ||||
|         delete telemetryProvider.supportsBatching; | ||||
|  | ||||
|         const batchCallback = jasmine.createSpy('batchCallback'); | ||||
|         telemetryAPI.subscribe(domainObject, batchCallback, { | ||||
|           strategy: 'batch' | ||||
|         }); | ||||
|         expect(telemetryProvider.subscribe.calls.mostRecent().args[2].strategy).toBe('latest'); | ||||
|  | ||||
|         const latestCallback = jasmine.createSpy('latestCallback'); | ||||
|         telemetryAPI.subscribe(domainObject, latestCallback, { | ||||
|           strategy: 'latest' | ||||
|         }); | ||||
|  | ||||
|         expect(telemetryProvider.subscribe.calls.mostRecent().args[2].strategy).toBe('latest'); | ||||
|       }); | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   describe('metadata', () => { | ||||
|   | ||||
| @@ -180,11 +180,14 @@ export default class TelemetryCollection extends EventEmitter { | ||||
|     if (this.unsubscribe) { | ||||
|       this.unsubscribe(); | ||||
|     } | ||||
|     const options = { ...this.options }; | ||||
|     //We always want to receive all available values in telemetry tables. | ||||
|     options.strategy = this.openmct.telemetry.SUBSCRIBE_STRATEGY.BATCH; | ||||
|  | ||||
|     this.unsubscribe = this.openmct.telemetry.subscribe( | ||||
|       this.domainObject, | ||||
|       (datum) => this._processNewTelemetry(datum), | ||||
|       this.options | ||||
|       options | ||||
|     ); | ||||
|   } | ||||
|  | ||||
| @@ -209,6 +212,8 @@ export default class TelemetryCollection extends EventEmitter { | ||||
|     let added = []; | ||||
|     let addedIndices = []; | ||||
|     let hasDataBeforeStartBound = false; | ||||
|     let size = this.options.size; | ||||
|     let enforceSize = size !== undefined && this.options.enforceSize; | ||||
|  | ||||
|     // loop through, sort and dedupe | ||||
|     for (let datum of data) { | ||||
| @@ -271,6 +276,13 @@ export default class TelemetryCollection extends EventEmitter { | ||||
|         } | ||||
|       } else { | ||||
|         this.emit('add', added, addedIndices); | ||||
|  | ||||
|         if (enforceSize && this.boundedTelemetry.length > size) { | ||||
|           const removeCount = this.boundedTelemetry.length - size; | ||||
|           const removed = this.boundedTelemetry.splice(0, removeCount); | ||||
|  | ||||
|           this.emit('remove', removed); | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   | ||||
							
								
								
									
										366
									
								
								src/api/telemetry/WebSocketWorker.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										366
									
								
								src/api/telemetry/WebSocketWorker.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,366 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT Web, Copyright (c) 2014-2024, United States Government | ||||
|  * as represented by the Administrator of the National Aeronautics and Space | ||||
|  * Administration. All rights reserved. | ||||
|  * | ||||
|  * Open MCT Web 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 Web 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. | ||||
|  *****************************************************************************/ | ||||
| /* eslint-disable max-classes-per-file */ | ||||
| export default function installWorker() { | ||||
|   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. | ||||
|    * On an error or dropout, will automatically reconnect. | ||||
|    * | ||||
|    * Additionally, messages will be queued and sent only when WebSocket is | ||||
|    * connected meaning that client code does not need to check the state of | ||||
|    * the socket before sending. | ||||
|    */ | ||||
|   class ResilientWebSocket extends EventTarget { | ||||
|     #webSocket; | ||||
|     #isConnected = false; | ||||
|     #isConnecting = false; | ||||
|     #messageQueue = []; | ||||
|     #reconnectTimeoutHandle; | ||||
|     #currentWaitIndex = 0; | ||||
|     #messageCallbacks = []; | ||||
|     #wsUrl; | ||||
|  | ||||
|     /** | ||||
|      * Establish a new WebSocket connection to the given URL | ||||
|      * @param {String} url | ||||
|      */ | ||||
|     connect(url) { | ||||
|       this.#wsUrl = url; | ||||
|       if (this.#isConnected) { | ||||
|         throw new Error('WebSocket already connected'); | ||||
|       } | ||||
|  | ||||
|       if (this.#isConnecting) { | ||||
|         throw new Error('WebSocket connection in progress'); | ||||
|       } | ||||
|  | ||||
|       this.#isConnecting = true; | ||||
|  | ||||
|       this.#webSocket = new WebSocket(url); | ||||
|  | ||||
|       const boundConnected = this.#connected.bind(this); | ||||
|       this.#webSocket.addEventListener('open', boundConnected); | ||||
|  | ||||
|       const boundCleanUpAndReconnect = this.#cleanUpAndReconnect.bind(this); | ||||
|       this.#webSocket.addEventListener('error', boundCleanUpAndReconnect); | ||||
|       this.#webSocket.addEventListener('close', boundCleanUpAndReconnect); | ||||
|  | ||||
|       const boundMessage = this.#message.bind(this); | ||||
|       this.#webSocket.addEventListener('message', boundMessage); | ||||
|  | ||||
|       this.addEventListener( | ||||
|         'disconnected', | ||||
|         () => { | ||||
|           this.#webSocket.removeEventListener('open', boundConnected); | ||||
|           this.#webSocket.removeEventListener('error', boundCleanUpAndReconnect); | ||||
|           this.#webSocket.removeEventListener('close', boundCleanUpAndReconnect); | ||||
|         }, | ||||
|         { once: true } | ||||
|       ); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Register a callback to be invoked when a message is received on the WebSocket. | ||||
|      * This paradigm is used instead of the standard EventTarget or EventEmitter approach | ||||
|      * for performance reasons. | ||||
|      * @param {Function} callback The function to be invoked when a message is received | ||||
|      * @returns an unregister function | ||||
|      */ | ||||
|     registerMessageCallback(callback) { | ||||
|       this.#messageCallbacks.push(callback); | ||||
|  | ||||
|       return () => { | ||||
|         this.#messageCallbacks = this.#messageCallbacks.filter((cb) => cb !== callback); | ||||
|       }; | ||||
|     } | ||||
|  | ||||
|     #connected() { | ||||
|       console.debug('Websocket connected.'); | ||||
|       this.#isConnected = true; | ||||
|       this.#isConnecting = false; | ||||
|       this.#currentWaitIndex = 0; | ||||
|  | ||||
|       this.dispatchEvent(new Event('connected')); | ||||
|  | ||||
|       this.#flushQueue(); | ||||
|     } | ||||
|  | ||||
|     #cleanUpAndReconnect() { | ||||
|       console.warn('Websocket closed. Attempting to reconnect...'); | ||||
|       this.disconnect(); | ||||
|       this.#reconnect(); | ||||
|     } | ||||
|  | ||||
|     #message(event) { | ||||
|       this.#messageCallbacks.forEach((callback) => callback(event.data)); | ||||
|     } | ||||
|  | ||||
|     disconnect() { | ||||
|       this.#isConnected = false; | ||||
|       this.#isConnecting = false; | ||||
|  | ||||
|       // On WebSocket error, both error callback and close callback are invoked, resulting in | ||||
|       // this function being called twice, and websocket being destroyed and deallocated. | ||||
|       if (this.#webSocket !== undefined && this.#webSocket !== null) { | ||||
|         this.#webSocket.close(); | ||||
|       } | ||||
|  | ||||
|       this.dispatchEvent(new Event('disconnected')); | ||||
|       this.#webSocket = undefined; | ||||
|     } | ||||
|  | ||||
|     #reconnect() { | ||||
|       if (this.#reconnectTimeoutHandle) { | ||||
|         return; | ||||
|       } | ||||
|  | ||||
|       this.#reconnectTimeoutHandle = setTimeout(() => { | ||||
|         this.connect(this.#wsUrl); | ||||
|  | ||||
|         this.#reconnectTimeoutHandle = undefined; | ||||
|       }, FALLBACK_AND_WAIT_MS[this.#currentWaitIndex]); | ||||
|  | ||||
|       if (this.#currentWaitIndex < FALLBACK_AND_WAIT_MS.length - 1) { | ||||
|         this.#currentWaitIndex++; | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     enqueueMessage(message) { | ||||
|       this.#messageQueue.push(message); | ||||
|       this.#flushQueueIfReady(); | ||||
|     } | ||||
|  | ||||
|     #flushQueueIfReady() { | ||||
|       if (this.#isConnected) { | ||||
|         this.#flushQueue(); | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     #flushQueue() { | ||||
|       while (this.#messageQueue.length > 0) { | ||||
|         if (!this.#isConnected) { | ||||
|           break; | ||||
|         } | ||||
|  | ||||
|         const message = this.#messageQueue.shift(); | ||||
|         this.#webSocket.send(message); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Handles messages over the worker interface, and | ||||
|    * sends corresponding WebSocket messages. | ||||
|    */ | ||||
|   class WorkerToWebSocketMessageBroker { | ||||
|     #websocket; | ||||
|     #messageBatcher; | ||||
|  | ||||
|     constructor(websocket, messageBatcher) { | ||||
|       this.#websocket = websocket; | ||||
|       this.#messageBatcher = messageBatcher; | ||||
|     } | ||||
|  | ||||
|     routeMessageToHandler(message) { | ||||
|       const { type } = message.data; | ||||
|       switch (type) { | ||||
|         case 'connect': | ||||
|           this.connect(message); | ||||
|           break; | ||||
|         case 'disconnect': | ||||
|           this.disconnect(message); | ||||
|           break; | ||||
|         case 'message': | ||||
|           this.#websocket.enqueueMessage(message.data.message); | ||||
|           break; | ||||
|         case 'setBatchingStrategy': | ||||
|           this.setBatchingStrategy(message); | ||||
|           break; | ||||
|         case 'readyForNextBatch': | ||||
|           this.#messageBatcher.readyForNextBatch(); | ||||
|           break; | ||||
|         case 'setMaxBatchSize': | ||||
|           this.#messageBatcher.setMaxBatchSize(message.data.maxBatchSize); | ||||
|           break; | ||||
|         default: | ||||
|           throw new Error(`Unknown message type: ${type}`); | ||||
|       } | ||||
|     } | ||||
|     connect(message) { | ||||
|       const { url } = message.data; | ||||
|       this.#websocket.connect(url); | ||||
|     } | ||||
|     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 | ||||
|    * Worker interface and back to the main thread. | ||||
|    */ | ||||
|   class WebSocketToWorkerMessageBroker { | ||||
|     #worker; | ||||
|     #messageBatcher; | ||||
|  | ||||
|     constructor(messageBatcher, worker) { | ||||
|       this.#messageBatcher = messageBatcher; | ||||
|       this.#worker = worker; | ||||
|     } | ||||
|  | ||||
|     routeMessageToHandler(data) { | ||||
|       //Implement batching here | ||||
|       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; | ||||
|     #worker; | ||||
|  | ||||
|     constructor(worker) { | ||||
|       this.#maxBatchSize = 10; | ||||
|       this.#readyForNextBatch = false; | ||||
|       this.#worker = worker; | ||||
|       this.#resetBatch(); | ||||
|     } | ||||
|     #resetBatch() { | ||||
|       this.#batch = {}; | ||||
|       this.#hasBatch = false; | ||||
|     } | ||||
|     /** | ||||
|      * @param {BatchingStrategy} strategy | ||||
|      */ | ||||
|     setBatchingStrategy(strategy) { | ||||
|       this.#batchingStrategy = strategy; | ||||
|     } | ||||
|     /** | ||||
|      * Applies the `shouldBatchMessage` function from the supplied batching strategy | ||||
|      * to each message to determine if it should be added to a batch. If not batched, | ||||
|      * the message is immediately sent over the worker to the main thread. | ||||
|      * @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 | ||||
|      * @returns | ||||
|      */ | ||||
|     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) { | ||||
|         batch = this.#batch[batchId] = [message]; | ||||
|       } else { | ||||
|         batch.push(message); | ||||
|       } | ||||
|       if (batch.length > this.#maxBatchSize) { | ||||
|         batch.shift(); | ||||
|         this.#batch.dropped = this.#batch.dropped || true; | ||||
|       } | ||||
|       if (this.#readyForNextBatch) { | ||||
|         this.#sendNextBatch(); | ||||
|       } else { | ||||
|         this.#hasBatch = true; | ||||
|       } | ||||
|     } | ||||
|     setMaxBatchSize(maxBatchSize) { | ||||
|       this.#maxBatchSize = maxBatchSize; | ||||
|     } | ||||
|     /** | ||||
|      * Indicates that client code is ready to receive the next batch of | ||||
|      * messages. If a batch is available, it will be immediately sent. | ||||
|      * Otherwise a flag will be set to send the next batch as soon as | ||||
|      * any new data is available. | ||||
|      */ | ||||
|     readyForNextBatch() { | ||||
|       if (this.#hasBatch) { | ||||
|         this.#sendNextBatch(); | ||||
|       } else { | ||||
|         this.#readyForNextBatch = true; | ||||
|       } | ||||
|     } | ||||
|     #sendNextBatch() { | ||||
|       const batch = this.#batch; | ||||
|       this.#resetBatch(); | ||||
|       this.#worker.postMessage({ | ||||
|         type: 'batch', | ||||
|         batch | ||||
|       }); | ||||
|       this.#readyForNextBatch = false; | ||||
|       this.#hasBatch = false; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   const websocket = new ResilientWebSocket(); | ||||
|   const messageBatcher = new MessageBatcher(self); | ||||
|   const workerBroker = new WorkerToWebSocketMessageBroker(websocket, messageBatcher); | ||||
|   const websocketBroker = new WebSocketToWorkerMessageBroker(messageBatcher, self); | ||||
|  | ||||
|   self.addEventListener('message', (message) => { | ||||
|     workerBroker.routeMessageToHandler(message); | ||||
|   }); | ||||
|   websocket.registerMessageCallback((data) => { | ||||
|     websocketBroker.routeMessageToHandler(data); | ||||
|   }); | ||||
| } | ||||
| @@ -32,6 +32,7 @@ export default class StatusAPI extends EventEmitter { | ||||
|  | ||||
|     this.onProviderStatusChange = this.onProviderStatusChange.bind(this); | ||||
|     this.onProviderPollQuestionChange = this.onProviderPollQuestionChange.bind(this); | ||||
|     this.onMissionActionStatusChange = this.onMissionActionStatusChange.bind(this); | ||||
|     this.listenToStatusEvents = this.listenToStatusEvents.bind(this); | ||||
|  | ||||
|     this.#openmct.once('destroy', () => { | ||||
| @@ -40,6 +41,7 @@ export default class StatusAPI extends EventEmitter { | ||||
|       if (typeof provider?.off === 'function') { | ||||
|         provider.off('statusChange', this.onProviderStatusChange); | ||||
|         provider.off('pollQuestionChange', this.onProviderPollQuestionChange); | ||||
|         provider.off('missionActionStatusChange', this.onMissionActionStatusChange); | ||||
|       } | ||||
|     }); | ||||
|  | ||||
| @@ -100,6 +102,67 @@ export default class StatusAPI extends EventEmitter { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Can the currently logged in user set the mission status. | ||||
|    * @returns {Promise<Boolean>} true if the currently logged in user can set the mission status, false otherwise. | ||||
|    */ | ||||
|   canSetMissionStatus() { | ||||
|     const provider = this.#userAPI.getProvider(); | ||||
|  | ||||
|     if (provider.canSetMissionStatus) { | ||||
|       return provider.canSetMissionStatus(); | ||||
|     } else { | ||||
|       return Promise.resolve(false); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Fetch the current status for the given mission action | ||||
|    * @param {MissionAction} action | ||||
|    * @returns {string} | ||||
|    */ | ||||
|   getStatusForMissionAction(action) { | ||||
|     const provider = this.#userAPI.getProvider(); | ||||
|  | ||||
|     if (provider.getStatusForMissionAction) { | ||||
|       return provider.getStatusForMissionAction(action); | ||||
|     } else { | ||||
|       this.#userAPI.error('User provider does not support getting mission action status'); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Fetch the list of possible mission status options (GO, NO-GO, etc.) | ||||
|    * @returns {Promise<MissionStatusOption[]>} the complete list of possible mission statuses | ||||
|    */ | ||||
|   async getPossibleMissionActionStatuses() { | ||||
|     const provider = this.#userAPI.getProvider(); | ||||
|  | ||||
|     if (provider.getPossibleMissionActionStatuses) { | ||||
|       const possibleOptions = await provider.getPossibleMissionActionStatuses(); | ||||
|  | ||||
|       return possibleOptions; | ||||
|     } else { | ||||
|       this.#userAPI.error('User provider does not support mission status options'); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Fetch the list of possible mission actions | ||||
|    * @returns {Promise<string[]>} the list of possible mission actions | ||||
|    */ | ||||
|   async getPossibleMissionActions() { | ||||
|     const provider = this.#userAPI.getProvider(); | ||||
|  | ||||
|     if (provider.getPossibleMissionActions) { | ||||
|       const possibleActions = await provider.getPossibleMissionActions(); | ||||
|  | ||||
|       return possibleActions; | ||||
|     } else { | ||||
|       this.#userAPI.error('User provider does not support mission statuses'); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * @returns {Promise<Array<Status>>} the complete list of possible states that an operator can reply to a poll question with. | ||||
|    */ | ||||
| @@ -166,6 +229,21 @@ export default class StatusAPI extends EventEmitter { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * @param {MissionAction} action | ||||
|    * @param {MissionStatusOption} status | ||||
|    * @returns {Promise<Boolean>} true if operation was successful, otherwise false. | ||||
|    */ | ||||
|   setStatusForMissionAction(action, status) { | ||||
|     const provider = this.#userAPI.getProvider(); | ||||
|  | ||||
|     if (provider.setStatusForMissionAction) { | ||||
|       return provider.setStatusForMissionAction(action, status); | ||||
|     } else { | ||||
|       this.#userAPI.error('User provider does not support setting mission role status'); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Resets the status of the provided role back to its default status. | ||||
|    * @param {import("./UserAPI").Role} role The role to set the status for. | ||||
| @@ -245,6 +323,7 @@ export default class StatusAPI extends EventEmitter { | ||||
|     if (typeof provider.on === 'function') { | ||||
|       provider.on('statusChange', this.onProviderStatusChange); | ||||
|       provider.on('pollQuestionChange', this.onProviderPollQuestionChange); | ||||
|       provider.on('missionActionStatusChange', this.onMissionActionStatusChange); | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @@ -261,14 +340,23 @@ export default class StatusAPI extends EventEmitter { | ||||
|   onProviderPollQuestionChange(pollQuestion) { | ||||
|     this.emit('pollQuestionChange', pollQuestion); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * @private | ||||
|    */ | ||||
|   onMissionActionStatusChange({ action, status }) { | ||||
|     this.emit('missionActionStatusChange', { action, status }); | ||||
|   } | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * @typedef {import('./UserProvider')} UserProvider | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * @typedef {import('./StatusUserProvider')} StatusUserProvider | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * The PollQuestion type | ||||
|  * @typedef {Object} PollQuestion | ||||
| @@ -276,6 +364,19 @@ export default class StatusAPI extends EventEmitter { | ||||
|  * @property {Number} timestamp - The time that the poll question was set. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * The MissionStatus type | ||||
|  * @typedef {Object} MissionStatusOption | ||||
|  * @extends {Status} | ||||
|  * @property {String} color A color to be used when displaying the mission status | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * @typedef {Object} MissionAction | ||||
|  * @property {String} key A unique identifier for this action | ||||
|  * @property {String} label A human readable label for this action | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * The Status type | ||||
|  * @typedef {Object} Status | ||||
|   | ||||
| @@ -23,12 +23,12 @@ import UserProvider from './UserProvider.js'; | ||||
|  | ||||
| export default class StatusUserProvider extends UserProvider { | ||||
|   /** | ||||
|    * @param {('statusChange'|'pollQuestionChange')} event the name of the event to listen to | ||||
|    * @param {('statusChange'|'pollQuestionChange'|'missionActionStatusChange')} event the name of the event to listen to | ||||
|    * @param {Function} callback a function to invoke when this event occurs | ||||
|    */ | ||||
|   on(event, callback) {} | ||||
|   /** | ||||
|    * @param {('statusChange'|'pollQuestionChange')} event the name of the event to stop listen to | ||||
|    * @param {('statusChange'|'pollQuestionChange'|'missionActionStatusChange')} event the name of the event to stop listen to | ||||
|    * @param {Function} callback the callback function used to register the listener | ||||
|    */ | ||||
|   off(event, callback) {} | ||||
|   | ||||
| @@ -24,9 +24,6 @@ import ExampleUserProvider from '../../../example/exampleUser/ExampleUserProvide | ||||
| import { createOpenMct, resetApplicationState } from '../../utils/testing.js'; | ||||
| import { MULTIPLE_PROVIDER_ERROR } from './constants.js'; | ||||
|  | ||||
| const USERNAME = 'Test User'; | ||||
| const EXAMPLE_ROLE = 'flight'; | ||||
|  | ||||
| describe('The User API', () => { | ||||
|   let openmct; | ||||
|  | ||||
| @@ -65,48 +62,4 @@ describe('The User API', () => { | ||||
|       expect(openmct.user.hasProvider()).toBeTrue(); | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   describe('provides the ability', () => { | ||||
|     let provider; | ||||
|  | ||||
|     beforeEach(() => { | ||||
|       provider = new ExampleUserProvider(openmct); | ||||
|       provider.autoLogin(USERNAME); | ||||
|     }); | ||||
|  | ||||
|     it('to check if a user (not specific) is logged in', (done) => { | ||||
|       expect(openmct.user.isLoggedIn()).toBeFalse(); | ||||
|  | ||||
|       openmct.user.on('providerAdded', () => { | ||||
|         expect(openmct.user.isLoggedIn()).toBeTrue(); | ||||
|         done(); | ||||
|       }); | ||||
|  | ||||
|       // this will trigger the user indicator plugin, | ||||
|       // which will in turn login the user | ||||
|       openmct.user.setProvider(provider); | ||||
|     }); | ||||
|  | ||||
|     it('to get the current user', (done) => { | ||||
|       openmct.user.setProvider(provider); | ||||
|       openmct.user | ||||
|         .getCurrentUser() | ||||
|         .then((apiUser) => { | ||||
|           expect(apiUser.name).toEqual(USERNAME); | ||||
|         }) | ||||
|         .finally(done); | ||||
|     }); | ||||
|  | ||||
|     it('to check if a user has a specific role (by id)', (done) => { | ||||
|       openmct.user.setProvider(provider); | ||||
|       let junkIdCheckPromise = openmct.user.hasRole('junk-id').then((hasRole) => { | ||||
|         expect(hasRole).toBeFalse(); | ||||
|       }); | ||||
|       let realIdCheckPromise = openmct.user.hasRole(EXAMPLE_ROLE).then((hasRole) => { | ||||
|         expect(hasRole).toBeTrue(); | ||||
|       }); | ||||
|  | ||||
|       Promise.all([junkIdCheckPromise, realIdCheckPromise]).finally(done); | ||||
|     }); | ||||
|   }); | ||||
| }); | ||||
|   | ||||
| @@ -38,7 +38,6 @@ describe('the plugin', function () { | ||||
|  | ||||
|     let couchPlugin = openmct.plugins.CouchDB(testPath); | ||||
|     openmct.install(couchPlugin); | ||||
|  | ||||
|     openmct.install( | ||||
|       new CouchDBSearchFolderPlugin('CouchDB Documents', couchPlugin, { | ||||
|         selector: { | ||||
|   | ||||
| @@ -46,14 +46,14 @@ describe('DeviceMatchers', function () { | ||||
|     return 'is' + deviceType[0].toUpperCase() + deviceType.slice(1); | ||||
|   } | ||||
|  | ||||
|   ['mobile', 'phone', 'tablet', 'landscape', 'portrait', 'landscape', 'touch'].forEach(function ( | ||||
|     deviceType | ||||
|   ) { | ||||
|     it('detects when a device is a ' + deviceType + ' device', function () { | ||||
|       mockAgent[method(deviceType)].and.returnValue(true); | ||||
|       expect(DeviceMatchers[deviceType](mockAgent)).toBe(true); | ||||
|       mockAgent[method(deviceType)].and.returnValue(false); | ||||
|       expect(DeviceMatchers[deviceType](mockAgent)).toBe(false); | ||||
|     }); | ||||
|   }); | ||||
|   ['mobile', 'phone', 'tablet', 'landscape', 'portrait', 'landscape', 'touch'].forEach( | ||||
|     function (deviceType) { | ||||
|       it('detects when a device is a ' + deviceType + ' device', function () { | ||||
|         mockAgent[method(deviceType)].and.returnValue(true); | ||||
|         expect(DeviceMatchers[deviceType](mockAgent)).toBe(true); | ||||
|         mockAgent[method(deviceType)].and.returnValue(false); | ||||
|         expect(DeviceMatchers[deviceType](mockAgent)).toBe(false); | ||||
|       }); | ||||
|     } | ||||
|   ); | ||||
| }); | ||||
|   | ||||
| @@ -79,5 +79,6 @@ export default class LADTableView { | ||||
|     if (this._destroy) { | ||||
|       this._destroy(); | ||||
|     } | ||||
|     this.component = null; | ||||
|   } | ||||
| } | ||||
|   | ||||
							
								
								
									
										68
									
								
								src/plugins/activityStates/activityStatesInterceptor.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								src/plugins/activityStates/activityStatesInterceptor.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,68 @@ | ||||
| /***************************************************************************** | ||||
|  * 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 { ACTIVITY_STATES_KEY } from './createActivityStatesIdentifier.js'; | ||||
|  | ||||
| /** | ||||
|  * @typedef {object} ActivityStatesInterceptorOptions | ||||
|  * @property {import('../../api/objects/ObjectAPI').Identifier} identifier the {namespace, key} to use for the activity states object. | ||||
|  * @property {string} name The name of the activity states model. | ||||
|  * @property {number} priority the priority of the interceptor. By default, it is low. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * Creates an activity states object in the persistence store. This is used to save plan activity states. | ||||
|  * This will only get invoked when an attempt is made to save the state for an activity and no activity states object exists in the store. | ||||
|  * @param {import('../../../openmct').OpenMCT} openmct | ||||
|  * @param {ActivityStatesInterceptorOptions} options | ||||
|  * @returns {object} | ||||
|  */ | ||||
| const ACTIVITY_STATES_TYPE = 'activity-states'; | ||||
|  | ||||
| function activityStatesInterceptor(openmct, options) { | ||||
|   const { identifier, name, priority = openmct.priority.LOW } = options; | ||||
|   const activityStatesModel = { | ||||
|     identifier, | ||||
|     name, | ||||
|     type: ACTIVITY_STATES_TYPE, | ||||
|     activities: {}, | ||||
|     location: null | ||||
|   }; | ||||
|  | ||||
|   return { | ||||
|     appliesTo: (identifierObject) => { | ||||
|       return identifierObject.key === ACTIVITY_STATES_KEY; | ||||
|     }, | ||||
|     invoke: (identifierObject, object) => { | ||||
|       if (!object || openmct.objects.isMissing(object)) { | ||||
|         openmct.objects.save(activityStatesModel); | ||||
|  | ||||
|         return activityStatesModel; | ||||
|       } | ||||
|  | ||||
|       return object; | ||||
|     }, | ||||
|     priority | ||||
|   }; | ||||
| } | ||||
|  | ||||
| export default activityStatesInterceptor; | ||||
							
								
								
									
										30
									
								
								src/plugins/activityStates/createActivityStatesIdentifier.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/plugins/activityStates/createActivityStatesIdentifier.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| /***************************************************************************** | ||||
|  * 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| export const ACTIVITY_STATES_KEY = 'activity-states'; | ||||
|  | ||||
| export function createActivityStatesIdentifier(namespace = '') { | ||||
|   return { | ||||
|     key: ACTIVITY_STATES_KEY, | ||||
|     namespace | ||||
|   }; | ||||
| } | ||||
							
								
								
									
										89
									
								
								src/plugins/activityStates/pluginSpec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								src/plugins/activityStates/pluginSpec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,89 @@ | ||||
| /***************************************************************************** | ||||
|  * 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 { createOpenMct, resetApplicationState } from 'utils/testing'; | ||||
|  | ||||
| import { | ||||
|   ACTIVITY_STATES_KEY, | ||||
|   createActivityStatesIdentifier | ||||
| } from './createActivityStatesIdentifier.js'; | ||||
|  | ||||
| const MISSING_NAME = `Missing: ${ACTIVITY_STATES_KEY}`; | ||||
| const DEFAULT_NAME = 'Activity States'; | ||||
| const activityStatesIdentifier = createActivityStatesIdentifier(); | ||||
|  | ||||
| describe('the plugin', () => { | ||||
|   let openmct; | ||||
|   let missingObj = { | ||||
|     identifier: activityStatesIdentifier, | ||||
|     type: 'unknown', | ||||
|     name: MISSING_NAME | ||||
|   }; | ||||
|  | ||||
|   describe('with no arguments passed in', () => { | ||||
|     beforeEach((done) => { | ||||
|       openmct = createOpenMct(); | ||||
|       openmct.install(openmct.plugins.PlanLayout()); | ||||
|  | ||||
|       openmct.on('start', done); | ||||
|       openmct.startHeadless(); | ||||
|     }); | ||||
|  | ||||
|     afterEach(() => { | ||||
|       return resetApplicationState(openmct); | ||||
|     }); | ||||
|  | ||||
|     it('when installed, adds "Activity States"', async () => { | ||||
|       const activityStatesObject = await openmct.objects.get(activityStatesIdentifier); | ||||
|       expect(activityStatesObject.name).toBe(DEFAULT_NAME); | ||||
|       expect(activityStatesObject).toBeDefined(); | ||||
|     }); | ||||
|  | ||||
|     describe('adds an interceptor that returns a "Activity States" model for', () => { | ||||
|       let activityStatesObject; | ||||
|       let mockNotFoundProvider; | ||||
|       let activeProvider; | ||||
|  | ||||
|       beforeEach(async () => { | ||||
|         mockNotFoundProvider = { | ||||
|           get: () => Promise.reject(new Error('Not found')), | ||||
|           create: () => Promise.resolve(missingObj), | ||||
|           update: () => Promise.resolve(missingObj) | ||||
|         }; | ||||
|  | ||||
|         activeProvider = mockNotFoundProvider; | ||||
|         spyOn(openmct.objects, 'getProvider').and.returnValue(activeProvider); | ||||
|         activityStatesObject = await openmct.objects.get(activityStatesIdentifier); | ||||
|       }); | ||||
|  | ||||
|       it('missing objects', () => { | ||||
|         let idsMatch = openmct.objects.areIdsEqual( | ||||
|           activityStatesObject.identifier, | ||||
|           activityStatesIdentifier | ||||
|         ); | ||||
|  | ||||
|         expect(activityStatesObject).toBeDefined(); | ||||
|         expect(idsMatch).toBeTrue(); | ||||
|       }); | ||||
|     }); | ||||
|   }); | ||||
| }); | ||||
| @@ -130,11 +130,8 @@ | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import { inject } from 'vue'; | ||||
|  | ||||
| import ColorPalette from '@/ui/color/ColorPalette'; | ||||
|  | ||||
| import { useIsEditing } from '../../../../ui/composables/editing'; | ||||
| import SeriesOptions from './SeriesOptions.vue'; | ||||
|  | ||||
| export default { | ||||
| @@ -142,14 +139,6 @@ export default { | ||||
|     SeriesOptions | ||||
|   }, | ||||
|   inject: ['openmct', 'domainObject'], | ||||
|   setup() { | ||||
|     const openmct = inject('openmct'); | ||||
|     const { isEditing } = useIsEditing(openmct); | ||||
|  | ||||
|     return { | ||||
|       isEditing | ||||
|     }; | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
|       xKey: this.domainObject.configuration.axes.xKey, | ||||
| @@ -159,23 +148,34 @@ export default { | ||||
|       plotSeries: [], | ||||
|       yKeyOptions: [], | ||||
|       xKeyOptions: [], | ||||
|       isEditing: this.openmct.editor.isEditing(), | ||||
|       colorPalette: this.colorPalette, | ||||
|       useInterpolation: this.domainObject.configuration.useInterpolation, | ||||
|       useBar: this.domainObject.configuration.useBar | ||||
|     }; | ||||
|   }, | ||||
|   computed: { | ||||
|     canEdit() { | ||||
|       return this.isEditing && !this.domainObject.locked; | ||||
|     } | ||||
|   }, | ||||
|   beforeMount() { | ||||
|     this.colorPalette = new ColorPalette(); | ||||
|   }, | ||||
|   mounted() { | ||||
|     this.openmct.editor.on('isEditing', this.setEditState); | ||||
|     this.composition = this.openmct.composition.get(this.domainObject); | ||||
|     this.registerListeners(); | ||||
|     this.composition.load(); | ||||
|   }, | ||||
|   beforeUnmount() { | ||||
|     this.openmct.editor.off('isEditing', this.setEditState); | ||||
|     this.stopListening(); | ||||
|   }, | ||||
|   methods: { | ||||
|     setEditState(isEditing) { | ||||
|       this.isEditing = isEditing; | ||||
|     }, | ||||
|     registerListeners() { | ||||
|       this.composition.on('add', this.addSeries); | ||||
|       this.composition.on('remove', this.removeSeries); | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user