Compare commits

..

12 Commits

Author SHA1 Message Date
David Tsay
c08174c31b Merge branch 'test-form-file-input' of github.com:nasa/openmct into test-form-file-input 2023-01-17 12:11:27 -08:00
David Tsay
8b94b99f3c fix dom structure 2023-01-17 12:11:25 -08:00
David Tsay
8a83923d0a Merge branch 'master' into test-form-file-input 2023-01-17 12:08:31 -08:00
Khalid Adil
c54722a520 Merge branch 'master' into test-form-file-input 2023-01-17 12:26:26 -06:00
David Tsay
de2063c85c compress image 2022-12-30 14:01:48 -08:00
David Tsay
585cdad537 add e2e test 2022-12-30 13:56:24 -08:00
David Tsay
618c79a0bc Revert "read file but don't readAsText for images"
This reverts commit 301292ebf4.
2022-12-30 12:32:17 -08:00
David Tsay
301292ebf4 read file but don't readAsText for images 2022-12-30 11:50:06 -08:00
David Tsay
a5320ce1c4 show what file is selected 2022-12-29 12:03:31 -08:00
David Tsay
9698d11716 allow non json raw files upload 2022-12-28 15:59:47 -08:00
David Tsay
a0562c8ee7 accept any filetype 2022-12-27 17:04:35 -08:00
David Tsay
43e648084f debugging: output file to console 2022-12-27 16:31:34 -08:00
1053 changed files with 109307 additions and 131100 deletions

View File

@@ -2,23 +2,19 @@ version: 2.1
executors: executors:
pw-focal-development: pw-focal-development:
docker: docker:
- image: mcr.microsoft.com/playwright:v1.32.3-focal - image: mcr.microsoft.com/playwright:v1.29.0-focal
environment: environment:
NODE_ENV: development # Needed to ensure 'dist' folder created and devDependencies installed NODE_ENV: development # Needed to ensure 'dist' folder created and devDependencies installed
PERCY_POSTINSTALL_BROWSER: 'true' # Needed to store the percy browser in cache deps PERCY_POSTINSTALL_BROWSER: 'true' # Needed to store the percy browser in cache deps
PERCY_LOGLEVEL: 'debug' # Enable DEBUG level logging for Percy (Issue: https://github.com/nasa/openmct/issues/5742) PERCY_LOGLEVEL: 'debug' # Enable DEBUG level logging for Percy (Issue: https://github.com/nasa/openmct/issues/5742)
ubuntu:
machine:
image: ubuntu-2204:current
docker_layer_caching: true
parameters: parameters:
BUST_CACHE: BUST_CACHE:
description: 'Set this with the CircleCI UI Trigger Workflow button (boolean = true) to bust the cache!' description: "Set this with the CircleCI UI Trigger Workflow button (boolean = true) to bust the cache!"
default: false default: false
type: boolean type: boolean
commands: commands:
build_and_install: 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: parameters:
node-version: node-version:
type: string type: string
@@ -27,52 +23,53 @@ commands:
- restore_cache_cmd: - restore_cache_cmd:
node-version: << parameters.node-version >> node-version: << parameters.node-version >>
- node/install: - node/install:
install-npm: true
node-version: << parameters.node-version >> node-version: << parameters.node-version >>
- run: npm install --no-audit --progress=false - run: npm install --prefer-offline --no-audit --progress=false
restore_cache_cmd: 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: parameters:
node-version: node-version:
type: string type: string
steps: steps:
- when: - when:
condition: condition:
equal: [false, << pipeline.parameters.BUST_CACHE >>] equal: [false, << pipeline.parameters.BUST_CACHE >> ]
steps: steps:
- restore_cache: - restore_cache:
key: deps--{{ arch }}--{{ .Branch }}--<< parameters.node-version >>--{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }} key: deps-{{ .Branch }}--<< parameters.node-version >>--{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }}
save_cache_cmd: save_cache_cmd:
description: 'Custom command for saving cache.' description: "Custom command for saving cache."
parameters: parameters:
node-version: node-version:
type: string type: string
steps: steps:
- save_cache: - save_cache:
key: deps--{{ arch }}--{{ .Branch }}--<< parameters.node-version >>--{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }} key: deps-{{ .Branch }}--<< parameters.node-version >>--{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }}
paths: paths:
- ~/.npm - ~/.npm
- node_modules - node_modules
generate_and_store_version_and_filesystem_artifacts: generate_and_store_version_and_filesystem_artifacts:
description: 'Track important packages and files' description: "Track important packages and files"
steps: steps:
- run: | - run: |
[[ $EUID -ne 0 ]] && (sudo mkdir -p /tmp/artifacts && sudo chmod 777 /tmp/artifacts) || (mkdir -p /tmp/artifacts && chmod 777 /tmp/artifacts) mkdir /tmp/artifacts
printenv NODE_ENV >> /tmp/artifacts/NODE_ENV.txt || true printenv NODE_ENV >> /tmp/artifacts/NODE_ENV.txt
npm -v >> /tmp/artifacts/npm-version.txt npm -v >> /tmp/artifacts/npm-version.txt
node -v >> /tmp/artifacts/node-version.txt node -v >> /tmp/artifacts/node-version.txt
ls -latR >> /tmp/artifacts/dir.txt ls -latR >> /tmp/artifacts/dir.txt
- store_artifacts: - store_artifacts:
path: /tmp/artifacts/ path: /tmp/artifacts/
generate_e2e_code_cov_report: generate_e2e_code_cov_report:
description: 'Generate e2e code coverage artifacts and publish to codecov.io. Needed to that we can ignore the exit code status of the npm run test' description: "Generate e2e code coverage artifacts and publish to codecov.io. Needed to that we can ignore the exit code status of the npm run test"
parameters: parameters:
suite: suite:
type: string type: string
steps: steps:
- run: npm run cov:e2e:report || true - run: npm run cov:e2e:report || true
- run: npm run cov:e2e:<<parameters.suite>>:publish - run: npm run cov:e2e:<<parameters.suite>>:publish
orbs: orbs:
node: circleci/node@5.1.0 node: circleci/node@4.9.0
browser-tools: circleci/browser-tools@1.3.0 browser-tools: circleci/browser-tools@1.3.0
jobs: jobs:
npm-audit: npm-audit:
@@ -113,11 +110,7 @@ jobs:
path: dist/reports/tests/ path: dist/reports/tests/
- store_artifacts: - store_artifacts:
path: coverage path: coverage
- when: - generate_and_store_version_and_filesystem_artifacts
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-test: e2e-test:
parameters: parameters:
node-version: node-version:
@@ -131,16 +124,12 @@ jobs:
node-version: <<parameters.node-version>> node-version: <<parameters.node-version>>
- when: #Only install chrome-beta when running the 'full' suite to save $$$ - when: #Only install chrome-beta when running the 'full' suite to save $$$
condition: condition:
equal: ['full', <<parameters.suite>>] equal: [ "full", <<parameters.suite>> ]
steps: steps:
- run: npx playwright install chrome-beta - run: npx playwright install chrome-beta
- run: SHARD="$((${CIRCLE_NODE_INDEX}+1))"; npm run test:e2e:<<parameters.suite>> -- --shard=${SHARD}/${CIRCLE_NODE_TOTAL} - run: SHARD="$((${CIRCLE_NODE_INDEX}+1))"; npm run test:e2e:<<parameters.suite>> -- --shard=${SHARD}/${CIRCLE_NODE_TOTAL}
- when: - generate_e2e_code_cov_report:
condition: suite: <<parameters.suite>>
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: <<parameters.suite>>
- store_test_results: - store_test_results:
path: test-results/results.xml path: test-results/results.xml
- store_artifacts: - store_artifacts:
@@ -149,46 +138,7 @@ jobs:
path: coverage path: coverage
- store_artifacts: - store_artifacts:
path: html-test-results path: html-test-results
- when: - generate_and_store_version_and_filesystem_artifacts
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:
parameters:
node-version:
type: string
executor: ubuntu
steps:
- build_and_install:
node-version: <<parameters.node-version>>
- run: npx playwright@1.32.3 install #Necessary for bare ubuntu machine
- run: |
export $(cat src/plugins/persistence/couch/.env.ci | xargs)
docker-compose -f src/plugins/persistence/couch/couchdb-compose.yaml up --detach
sleep 3
bash src/plugins/persistence/couch/setup-couchdb.sh
- run: sh src/plugins/persistence/couch/replace-localstorage-with-couchdb-indexhtml.sh #Replace LocalStorage Plugin with CouchDB
- run: npm run test:e2e:couchdb
- 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 #add to full suite
- 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
perf-test: perf-test:
parameters: parameters:
node-version: node-version:
@@ -204,11 +154,7 @@ jobs:
path: test-results path: test-results
- store_artifacts: - store_artifacts:
path: html-test-results path: html-test-results
- when: - generate_and_store_version_and_filesystem_artifacts
condition:
equal: [42, 42] # Always run codecov reports regardless of test failure https://discuss.circleci.com/t/make-custom-command-run-always-with-when-always/38957/2
steps:
- generate_and_store_version_and_filesystem_artifacts
visual-test: visual-test:
parameters: parameters:
node-version: node-version:
@@ -224,52 +170,49 @@ jobs:
path: test-results path: test-results
- store_artifacts: - store_artifacts:
path: html-test-results path: html-test-results
- when: - generate_and_store_version_and_filesystem_artifacts
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
workflows: workflows:
overall-circleci-commit-status: #These jobs run on every commit overall-circleci-commit-status: #These jobs run on every commit
jobs: jobs:
- lint: - lint:
name: node16-lint name: node14-lint
node-version: lts/gallium node-version: lts/fermium
- unit-test: - unit-test:
name: node18-chrome name: node18-chrome
node-version: lts/hydrogen node-version: "18"
- e2e-test: - e2e-test:
name: e2e-stable name: e2e-stable
node-version: lts/hydrogen node-version: lts/gallium
suite: stable suite: stable
- perf-test: - perf-test:
node-version: lts/hydrogen node-version: lts/gallium
- visual-test: - visual-test:
node-version: lts/hydrogen node-version: lts/gallium
the-nightly: #These jobs do not run on PRs, but against master at night the-nightly: #These jobs do not run on PRs, but against master at night
jobs: jobs:
- unit-test:
name: node14-chrome-nightly
node-version: lts/fermium
- unit-test: - unit-test:
name: node16-chrome-nightly name: node16-chrome-nightly
node-version: lts/gallium node-version: lts/gallium
- unit-test: - unit-test:
name: node18-chrome name: node18-chrome
node-version: lts/hydrogen node-version: "18"
- npm-audit: - npm-audit:
node-version: lts/hydrogen node-version: lts/gallium
- e2e-test: - e2e-test:
name: e2e-full-nightly name: e2e-full-nightly
node-version: lts/hydrogen node-version: lts/gallium
suite: full suite: full
- perf-test: - perf-test:
node-version: lts/hydrogen node-version: lts/gallium
- visual-test: - visual-test:
node-version: lts/hydrogen node-version: lts/gallium
- e2e-couchdb:
node-version: lts/hydrogen
triggers: triggers:
- schedule: - schedule:
cron: '0 0 * * *' cron: "0 0 * * *"
filters: filters:
branches: branches:
only: only:

View File

@@ -1,170 +1,271 @@
const LEGACY_FILES = ['example/**']; const LEGACY_FILES = ["example/**"];
module.exports = { module.exports = {
env: { "env": {
browser: true, "browser": true,
es6: true, "es6": true,
jasmine: true, "jasmine": true,
amd: true "amd": true
}, },
globals: { "globals": {
_: 'readonly' "_": "readonly"
}, },
plugins: ['prettier'], "extends": [
extends: [ "eslint:recommended",
'eslint:recommended', "plugin:compat/recommended",
'plugin:compat/recommended', "plugin:vue/recommended",
'plugin:vue/vue3-recommended', "plugin:you-dont-need-lodash-underscore/compatible"
'plugin:you-dont-need-lodash-underscore/compatible',
'plugin:prettier/recommended'
],
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@babel/eslint-parser',
requireConfigFile: false,
allowImportExportEverywhere: true,
ecmaVersion: 2015,
ecmaFeatures: {
impliedStrict: true
}
},
rules: {
'vue/no-deprecated-dollar-listeners-api': 'warn',
'vue/no-deprecated-events-api': 'warn',
'vue/no-v-for-template-key': 'off',
'vue/no-v-for-template-key-on-child': 'error',
'prettier/prettier': 'error',
'you-dont-need-lodash-underscore/omit': 'off',
'you-dont-need-lodash-underscore/throttle': 'off',
'you-dont-need-lodash-underscore/flatten': 'off',
'you-dont-need-lodash-underscore/get': 'off',
'no-bitwise': 'error',
curly: 'error',
eqeqeq: 'error',
'guard-for-in': 'error',
'no-extend-native': 'error',
'no-inner-declarations': 'off',
'no-use-before-define': ['error', 'nofunc'],
'no-caller': 'error',
'no-irregular-whitespace': 'error',
'no-new': 'error',
'no-shadow': 'error',
'no-undef': 'error',
'no-unused-vars': [
'error',
{
vars: 'all',
args: 'none'
}
], ],
'no-console': 'off', "parser": "vue-eslint-parser",
'new-cap': [ "parserOptions": {
'error', "parser": "@babel/eslint-parser",
{ "requireConfigFile": false,
capIsNew: false, "allowImportExportEverywhere": true,
properties: false "ecmaVersion": 2015,
} "ecmaFeatures": {
], "impliedStrict": true
'dot-notation': 'error', }
},
// https://eslint.org/docs/rules/no-case-declarations "rules": {
'no-case-declarations': 'error', "you-dont-need-lodash-underscore/omit": "off",
// https://eslint.org/docs/rules/max-classes-per-file "you-dont-need-lodash-underscore/throttle": "off",
'max-classes-per-file': ['error', 1], "you-dont-need-lodash-underscore/flatten": "off",
// https://eslint.org/docs/rules/no-eq-null "you-dont-need-lodash-underscore/get": "off",
'no-eq-null': 'error', "no-bitwise": "error",
// https://eslint.org/docs/rules/no-eval "curly": "error",
'no-eval': 'error', "eqeqeq": "error",
// https://eslint.org/docs/rules/no-implicit-globals "guard-for-in": "error",
'no-implicit-globals': 'error', "no-extend-native": "error",
// https://eslint.org/docs/rules/no-implied-eval "no-inner-declarations": "off",
'no-implied-eval': 'error', "no-use-before-define": ["error", "nofunc"],
// https://eslint.org/docs/rules/no-lone-blocks "no-caller": "error",
'no-lone-blocks': 'error', "no-irregular-whitespace": "error",
// https://eslint.org/docs/rules/no-loop-func "no-new": "error",
'no-loop-func': 'error', "no-shadow": "error",
// https://eslint.org/docs/rules/no-new-func "no-undef": "error",
'no-new-func': 'error', "no-unused-vars": [
// https://eslint.org/docs/rules/no-new-wrappers "error",
'no-new-wrappers': 'error', {
// https://eslint.org/docs/rules/no-octal-escape "vars": "all",
'no-octal-escape': 'error', "args": "none"
// https://eslint.org/docs/rules/no-proto }
'no-proto': 'error',
// https://eslint.org/docs/rules/no-return-await
'no-return-await': 'error',
// https://eslint.org/docs/rules/no-script-url
'no-script-url': 'error',
// https://eslint.org/docs/rules/no-self-compare
'no-self-compare': 'error',
// https://eslint.org/docs/rules/no-sequences
'no-sequences': 'error',
// https://eslint.org/docs/rules/no-unmodified-loop-condition
'no-unmodified-loop-condition': 'error',
// https://eslint.org/docs/rules/no-useless-call
'no-useless-call': 'error',
// https://eslint.org/docs/rules/no-nested-ternary
'no-nested-ternary': 'error',
// https://eslint.org/docs/rules/no-useless-computed-key
'no-useless-computed-key': 'error',
// https://eslint.org/docs/rules/no-var
'no-var': 'error',
// https://eslint.org/docs/rules/one-var
'one-var': ['error', 'never'],
// https://eslint.org/docs/rules/default-case-last
'default-case-last': 'error',
// https://eslint.org/docs/rules/default-param-last
'default-param-last': 'error',
// https://eslint.org/docs/rules/grouped-accessor-pairs
'grouped-accessor-pairs': 'error',
// https://eslint.org/docs/rules/no-constructor-return
'no-constructor-return': 'error',
// https://eslint.org/docs/rules/array-callback-return
'array-callback-return': 'error',
// https://eslint.org/docs/rules/no-invalid-this
'no-invalid-this': 'error', // Believe this one actually surfaces some bugs
// https://eslint.org/docs/rules/func-style
'func-style': ['error', 'declaration'],
// https://eslint.org/docs/rules/no-unused-expressions
'no-unused-expressions': 'error',
// https://eslint.org/docs/rules/no-useless-concat
'no-useless-concat': 'error',
// https://eslint.org/docs/rules/radix
radix: 'error',
// https://eslint.org/docs/rules/require-await
'require-await': 'error',
// https://eslint.org/docs/rules/no-alert
'no-alert': 'error',
// https://eslint.org/docs/rules/no-useless-constructor
'no-useless-constructor': 'error',
// https://eslint.org/docs/rules/no-duplicate-imports
'no-duplicate-imports': 'error',
// https://eslint.org/docs/rules/no-implicit-coercion
'no-implicit-coercion': 'error',
//https://eslint.org/docs/rules/no-unneeded-ternary
'no-unneeded-ternary': 'error',
'vue/first-attribute-linebreak': 'error',
'vue/multiline-html-element-content-newline': 'off',
'vue/singleline-html-element-content-newline': 'off',
'vue/multi-word-component-names': 'off', // TODO enable, align with conventions
'vue/no-mutating-props': 'off'
},
overrides: [
{
files: LEGACY_FILES,
rules: {
'no-unused-vars': [
'warn',
{
vars: 'all',
args: 'none',
varsIgnorePattern: 'controller'
}
], ],
'no-nested-ternary': 'off', "no-console": "off",
'no-var': 'off', "no-trailing-spaces": "error",
'one-var': 'off' "space-before-function-paren": [
} "error",
} {
] "anonymous": "always",
"asyncArrow": "always",
"named": "never"
}
],
"array-bracket-spacing": "error",
"space-in-parens": "error",
"space-before-blocks": "error",
"comma-dangle": "error",
"eol-last": "error",
"new-cap": [
"error",
{
"capIsNew": false,
"properties": false
}
],
"dot-notation": "error",
"indent": ["error", 4],
// https://eslint.org/docs/rules/no-case-declarations
"no-case-declarations": "error",
// https://eslint.org/docs/rules/max-classes-per-file
"max-classes-per-file": ["error", 1],
// https://eslint.org/docs/rules/no-eq-null
"no-eq-null": "error",
// https://eslint.org/docs/rules/no-eval
"no-eval": "error",
// https://eslint.org/docs/rules/no-floating-decimal
"no-floating-decimal": "error",
// https://eslint.org/docs/rules/no-implicit-globals
"no-implicit-globals": "error",
// https://eslint.org/docs/rules/no-implied-eval
"no-implied-eval": "error",
// https://eslint.org/docs/rules/no-lone-blocks
"no-lone-blocks": "error",
// https://eslint.org/docs/rules/no-loop-func
"no-loop-func": "error",
// https://eslint.org/docs/rules/no-new-func
"no-new-func": "error",
// https://eslint.org/docs/rules/no-new-wrappers
"no-new-wrappers": "error",
// https://eslint.org/docs/rules/no-octal-escape
"no-octal-escape": "error",
// https://eslint.org/docs/rules/no-proto
"no-proto": "error",
// https://eslint.org/docs/rules/no-return-await
"no-return-await": "error",
// https://eslint.org/docs/rules/no-script-url
"no-script-url": "error",
// https://eslint.org/docs/rules/no-self-compare
"no-self-compare": "error",
// https://eslint.org/docs/rules/no-sequences
"no-sequences": "error",
// https://eslint.org/docs/rules/no-unmodified-loop-condition
"no-unmodified-loop-condition": "error",
// https://eslint.org/docs/rules/no-useless-call
"no-useless-call": "error",
// https://eslint.org/docs/rules/wrap-iife
"wrap-iife": "error",
// https://eslint.org/docs/rules/no-nested-ternary
"no-nested-ternary": "error",
// https://eslint.org/docs/rules/switch-colon-spacing
"switch-colon-spacing": "error",
// https://eslint.org/docs/rules/no-useless-computed-key
"no-useless-computed-key": "error",
// https://eslint.org/docs/rules/rest-spread-spacing
"rest-spread-spacing": ["error"],
// https://eslint.org/docs/rules/no-var
"no-var": "error",
// https://eslint.org/docs/rules/one-var
"one-var": ["error", "never"],
// https://eslint.org/docs/rules/default-case-last
"default-case-last": "error",
// https://eslint.org/docs/rules/default-param-last
"default-param-last": "error",
// https://eslint.org/docs/rules/grouped-accessor-pairs
"grouped-accessor-pairs": "error",
// https://eslint.org/docs/rules/no-constructor-return
"no-constructor-return": "error",
// https://eslint.org/docs/rules/array-callback-return
"array-callback-return": "error",
// https://eslint.org/docs/rules/no-invalid-this
"no-invalid-this": "error", // Believe this one actually surfaces some bugs
// https://eslint.org/docs/rules/func-style
"func-style": ["error", "declaration"],
// https://eslint.org/docs/rules/no-unused-expressions
"no-unused-expressions": "error",
// https://eslint.org/docs/rules/no-useless-concat
"no-useless-concat": "error",
// https://eslint.org/docs/rules/radix
"radix": "error",
// https://eslint.org/docs/rules/require-await
"require-await": "error",
// https://eslint.org/docs/rules/no-alert
"no-alert": "error",
// https://eslint.org/docs/rules/no-useless-constructor
"no-useless-constructor": "error",
// https://eslint.org/docs/rules/no-duplicate-imports
"no-duplicate-imports": "error",
// https://eslint.org/docs/rules/no-implicit-coercion
"no-implicit-coercion": "error",
//https://eslint.org/docs/rules/no-unneeded-ternary
"no-unneeded-ternary": "error",
// https://eslint.org/docs/rules/semi
"semi": ["error", "always"],
// https://eslint.org/docs/rules/no-multi-spaces
"no-multi-spaces": "error",
// https://eslint.org/docs/rules/key-spacing
"key-spacing": ["error", {
"afterColon": true
}],
// https://eslint.org/docs/rules/keyword-spacing
"keyword-spacing": ["error", {
"before": true,
"after": true
}],
// https://eslint.org/docs/rules/comma-spacing
// Also requires one line code fix
"comma-spacing": ["error", {
"after": true
}],
//https://eslint.org/docs/rules/no-whitespace-before-property
"no-whitespace-before-property": "error",
// https://eslint.org/docs/rules/object-curly-newline
"object-curly-newline": ["error", {
"consistent": true,
"multiline": true
}],
// https://eslint.org/docs/rules/object-property-newline
"object-property-newline": "error",
// https://eslint.org/docs/rules/brace-style
"brace-style": "error",
// https://eslint.org/docs/rules/no-multiple-empty-lines
"no-multiple-empty-lines": ["error", {"max": 1}],
// https://eslint.org/docs/rules/operator-linebreak
"operator-linebreak": ["error", "before", {"overrides": {"=": "after"}}],
// https://eslint.org/docs/rules/padding-line-between-statements
"padding-line-between-statements": ["error", {
"blankLine": "always",
"prev": "multiline-block-like",
"next": "*"
}, {
"blankLine": "always",
"prev": "*",
"next": "return"
}],
// https://eslint.org/docs/rules/space-infix-ops
"space-infix-ops": "error",
// https://eslint.org/docs/rules/space-unary-ops
"space-unary-ops": ["error", {
"words": true,
"nonwords": false
}],
// https://eslint.org/docs/rules/arrow-spacing
"arrow-spacing": "error",
// https://eslint.org/docs/rules/semi-spacing
"semi-spacing": ["error", {
"before": false,
"after": true
}],
"vue/html-indent": [
"error",
4,
{
"attribute": 1,
"baseIndent": 0,
"closeBracket": 0,
"alignAttributesVertically": true,
"ignores": []
}
],
"vue/html-self-closing": ["error",
{
"html": {
"void": "never",
"normal": "never",
"component": "always"
},
"svg": "always",
"math": "always"
}
],
"vue/max-attributes-per-line": ["error", {
"singleline": 1,
"multiline": 1,
}],
"vue/first-attribute-linebreak": "error",
"vue/multiline-html-element-content-newline": "off",
"vue/singleline-html-element-content-newline": "off",
"vue/multi-word-component-names": "off", // TODO enable, align with conventions
"vue/no-mutating-props": "off"
},
"overrides": [
{
"files": LEGACY_FILES,
"rules": {
"no-unused-vars": [
"warn",
{
"vars": "all",
"args": "none",
"varsIgnorePattern": "controller"
}
],
"no-nested-ternary": "off",
"no-var": "off",
"one-var": "off"
}
}
]
}; };

View File

@@ -1,12 +0,0 @@
# git-blame ignored revisions
# To configure, run:
# git config blame.ignoreRevsFile .git-blame-ignore-revs
# Requires Git > 2.23
# See https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt
# Copyright year update 2022
4a9744e916d24122a81092f6b7950054048ba860
# Copyright year update 2023
8040b275fcf2ba71b42cd72d4daa64bb25c19c2d
# Apply `prettier` formatting
caa7bc6faebc204f67aedae3e35fb0d0d3ce27a7

View File

@@ -1,38 +1,35 @@
version: 2 version: 2
updates: updates:
- package-ecosystem: 'npm' - package-ecosystem: "npm"
directory: '/' directory: "/"
schedule: schedule:
interval: 'weekly' interval: "daily"
open-pull-requests-limit: 10 open-pull-requests-limit: 10
labels: labels:
- 'pr:daveit' - "pr:e2e"
- 'pr:e2e' - "type:maintenance"
- 'type:maintenance' - "dependencies"
- 'dependencies' - "pr:daveit"
- 'pr:platform' - "pr:platform"
ignore: ignore:
#We have to source the playwright container which is not detected by Dependabot #We have to source the playwright container which is not detected by Dependabot
- dependency-name: '@playwright/test' - dependency-name: "@playwright/test"
- dependency-name: 'playwright-core' - dependency-name: "playwright-core"
#Lots of noise in these type patch releases. #Lots of noise in these type patch releases.
- dependency-name: '@babel/eslint-parser' - dependency-name: "@babel/eslint-parser"
update-types: ['version-update:semver-patch'] update-types: ["version-update:semver-patch"]
- dependency-name: 'eslint-plugin-vue' - dependency-name: "eslint-plugin-vue"
update-types: ['version-update:semver-patch'] update-types: ["version-update:semver-patch"]
- dependency-name: 'babel-loader' - dependency-name: "babel-loader"
update-types: ['version-update:semver-patch'] update-types: ["version-update:semver-patch"]
- dependency-name: 'sinon' - dependency-name: "sinon"
update-types: ['version-update:semver-patch'] update-types: ["version-update:semver-patch"]
- dependency-name: 'moment-timezone' - package-ecosystem: "github-actions"
update-types: ['version-update:semver-patch'] directory: "/"
- dependency-name: '@types/lodash'
update-types: ['version-update:semver-patch']
- package-ecosystem: 'github-actions'
directory: '/'
schedule: schedule:
interval: 'daily' interval: "daily"
labels: labels:
- 'pr:daveit' - "type:maintenance"
- 'type:maintenance' - "dependencies"
- 'dependencies' - "pr:daveit"

View File

@@ -1,88 +1,38 @@
name: 'e2e-couchdb' name: "e2e-couchdb"
on: on:
push:
branches: master
workflow_dispatch: workflow_dispatch:
pull_request: pull_request:
types: types:
- labeled - labeled
- opened - opened
schedule: env:
- cron: '0 0 * * *' OPENMCT_DATABASE_NAME: openmct
COUCH_ADMIN_USER: admin
COUCH_ADMIN_PASSWORD: password
COUCH_BASE_LOCAL: http://localhost:5984
COUCH_NODE_NAME: nonode@nohost
jobs: jobs:
e2e-couchdb: e2e-couchdb:
if: contains(github.event.pull_request.labels.*.name, 'pr:e2e:couchdb') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event.action == 'opened' if: ${{ github.event.label.name == 'pr:e2e:couchdb' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 60
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run : docker-compose -f src/plugins/persistence/couch/couchdb-compose.yaml up --detach
- run : sleep 3 # wait until CouchDB has started (TODO: there must be a better way)
- run : bash src/plugins/persistence/couch/setup-couchdb.sh
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: 'lts/hydrogen' node-version: '16'
- run: npx playwright@1.29.0 install
- name: Cache NPM dependencies - run: npm install
uses: actions/cache@v3 - run: sh src/plugins/persistence/couch/replace-localstorage-with-couchdb-indexhtml.sh
with: - run: npm run test:e2e:couchdb
path: ~/.npm - run: ls -latr
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm install --cache ~/.npm --prefer-offline --no-audit --progress=false
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- run: npx playwright@1.32.3 install
- name: Start CouchDB Docker Container and Init with Setup Scripts
run: |
export $(cat src/plugins/persistence/couch/.env.ci | xargs)
docker-compose -f src/plugins/persistence/couch/couchdb-compose.yaml up --detach
sleep 3
bash src/plugins/persistence/couch/setup-couchdb.sh
bash src/plugins/persistence/couch/replace-localstorage-with-couchdb-indexhtml.sh
- name: Run CouchDB Tests and publish to deploysentinel
env:
DEPLOYSENTINEL_API_KEY: ${{ secrets.DEPLOYSENTINEL_API_KEY }}
COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha }}
run: npm run test:e2e:couchdb
- name: Publish Results to Codecov.io
env:
SUPER_SECRET: ${{ secrets.CODECOV_TOKEN }}
run: npm run cov:e2e:full:publish
- name: Archive test results - name: Archive test results
if: success() || failure()
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
path: test-results path: test-results
- name: Archive html test results - name: Archive html test results
if: success() || failure()
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
path: html-test-results path: html-test-results
- name: Remove pr:e2e:couchdb label (if present)
if: always()
uses: actions/github-script@v6
with:
script: |
const { owner, repo, number } = context.issue;
const labelToRemove = 'pr:e2e:couchdb';
try {
await github.rest.issues.removeLabel({
owner,
repo,
issue_number: number,
name: labelToRemove
});
} catch (error) {
core.warning(`Failed to remove ' + labelToRemove + ' label: ${error.message}`);
}

View File

@@ -1,68 +1,62 @@
name: 'e2e-pr' name: "e2e-pr"
on: on:
push:
branches: master
workflow_dispatch: workflow_dispatch:
pull_request: pull_request:
types: types:
- labeled - labeled
- opened - opened
schedule:
- cron: '0 0 * * *'
jobs: jobs:
e2e-full: e2e-full:
if: contains(github.event.pull_request.labels.*.name, 'pr:e2e') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' if: ${{ github.event.label.name == 'pr:e2e' }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy: strategy:
matrix: matrix:
os: os:
- ubuntu-latest - ubuntu-latest
- windows-latest - windows-latest
steps: steps:
- uses: actions/checkout@v3 - name: Trigger Success
- uses: actions/setup-node@v3
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.32.3 install
- run: npx playwright install chrome-beta
- run: npm install --cache ~/.npm --prefer-offline --no-audit --progress=false
- run: npm run test:e2e:full -- --max-failures=40
- run: npm run cov:e2e:report || true
- shell: bash
env:
SUPER_SECRET: ${{ secrets.CODECOV_TOKEN }}
run: |
npm run cov:e2e:full:publish
- name: Archive test results
if: success() || failure()
uses: actions/upload-artifact@v3
with:
path: test-results
- name: Remove pr:e2e label (if present)
if: always()
uses: actions/github-script@v6 uses: actions/github-script@v6
with: with:
script: | script: |
const { owner, repo, number } = context.issue; github.rest.issues.createComment({
const labelToRemove = 'pr:e2e'; issue_number: context.issue.number,
try { owner: "nasa",
await github.rest.issues.removeLabel({ repo: "openmct",
owner, body: 'Started e2e Run. Follow along: https://github.com/nasa/openmct/actions/runs/' + context.runId
repo, })
issue_number: number, - uses: actions/checkout@v3
name: labelToRemove - uses: actions/setup-node@v3
}); with:
} catch (error) { node-version: '16'
core.warning(`Failed to remove ' + labelToRemove + ' label: ${error.message}`); - run: npx playwright@1.29.0 install
} - run: npx playwright install chrome-beta
- run: npm install
- run: npm run test:e2e:full
- name: Archive test results
uses: actions/upload-artifact@v3
with:
path: test-results
- name: Test success
if: ${{ success() }}
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: "nasa",
repo: "openmct",
body: 'Success ✅ ! Build artifacts are here: https://github.com/nasa/openmct/actions/runs/' + context.runId
})
- name: Test failure
if: ${{ failure() }}
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: "nasa",
repo: "openmct",
body: 'Failure ❌ ! Build artifacts are here: https://github.com/nasa/openmct/actions/runs/' + context.runId
})

21
.github/workflows/e2e.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: "e2e"
on:
workflow_dispatch:
inputs:
version:
description: 'Which branch do you want to test?' # Limited to branch for now
required: false
default: 'master'
jobs:
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.version }}
- uses: actions/setup-node@v3
with:
node-version: '16'
- run: npm install
- name: Run the e2e tests
run: npm run test:e2e:ci

View File

@@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: lts/hydrogen node-version: 16
- run: npm install - run: npm install
- run: | - run: |
echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
@@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: lts/hydrogen node-version: 16
registry-url: https://registry.npmjs.org/ registry-url: https://registry.npmjs.org/
- run: npm install - run: npm install
- run: npm publish --access=public --tag unstable - run: npm publish --access=public --tag unstable

View File

@@ -1,19 +1,13 @@
name: 'pr-platform' name: "pr-platform"
on: on:
push:
branches: master
workflow_dispatch: workflow_dispatch:
pull_request: pull_request:
types: types: [ labeled ]
- labeled
- opened
schedule:
- cron: '0 0 * * *'
jobs: jobs:
pr-platform: e2e-full:
if: contains(github.event.pull_request.labels.*.name, 'pr:platform') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' if: ${{ github.event.label.name == 'pr:platform' }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@@ -22,49 +16,19 @@ jobs:
- macos-latest - macos-latest
- windows-latest - windows-latest
node_version: node_version:
- lts/gallium - 14
- lts/hydrogen - 16
- 18
architecture: architecture:
- x64 - x64
name: Node ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }} name: Node ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Setup node - name: Setup node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node_version }} node-version: ${{ matrix.node_version }}
architecture: ${{ matrix.architecture }} architecture: ${{ matrix.architecture }}
- run: npm install
- name: Cache NPM dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node_version }}-
- run: npm install --cache ~/.npm --prefer-offline --no-audit --progress=false
- run: npm test - run: npm test
- run: npm run lint -- --quiet - run: npm run lint -- --quiet
- name: Remove pr:platform label (if present)
if: always()
uses: actions/github-script@v6
with:
script: |
const { owner, repo, number } = context.issue;
const labelToRemove = 'pr:platform';
try {
await github.rest.issues.removeLabel({
owner,
repo,
issue_number: number,
name: labelToRemove
});
} catch (error) {
core.warning(`Failed to remove ' + labelToRemove + ' label: ${error.message}`);
}

View File

@@ -22,5 +22,5 @@ jobs:
- name: Linting Pull Request - name: Linting Pull Request
uses: makaroni4/prcop@v1.0.35 uses: makaroni4/prcop@v1.0.35
with: with:
config-file: '.github/workflows/prcop-config.json' config-file: ".github/workflows/prcop-config.json"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,27 +0,0 @@
# Docs
*.md
# Build output
target
dist
# Mac OS X Finder
.DS_Store
# Node dependencies
node_modules
# npm-debug log
npm-debug.log
# karma reports
report.*.json
# e2e test artifacts
test-results
html-test-results
# codecov artifacts
.nyc_output
coverage
codecov

View File

@@ -1,6 +0,0 @@
{
"trailingComma": "none",
"singleQuote": true,
"printWidth": 100,
"endOfLine": "auto"
}

View File

@@ -8,164 +8,168 @@ This is the OpenMCT common webpack file. It is imported by the other three webpa
There are separate npm scripts to use these configurations, though simply running `npm install` There are separate npm scripts to use these configurations, though simply running `npm install`
will use the default production configuration. will use the default production configuration.
*/ */
const path = require('path'); const path = require("path");
const packageDefinition = require('../package.json'); const packageDefinition = require("../package.json");
const CopyWebpackPlugin = require('copy-webpack-plugin'); const CopyWebpackPlugin = require("copy-webpack-plugin");
const webpack = require('webpack'); const webpack = require("webpack");
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { VueLoaderPlugin } = require('vue-loader'); const { VueLoaderPlugin } = require("vue-loader");
let gitRevision = 'error-retrieving-revision'; let gitRevision = "error-retrieving-revision";
let gitBranch = 'error-retrieving-branch'; let gitBranch = "error-retrieving-branch";
try { try {
gitRevision = require('child_process').execSync('git rev-parse HEAD').toString().trim(); gitRevision = require("child_process")
gitBranch = require('child_process') .execSync("git rev-parse HEAD")
.execSync('git rev-parse --abbrev-ref HEAD') .toString()
.toString() .trim();
.trim(); gitBranch = require("child_process")
.execSync("git rev-parse --abbrev-ref HEAD")
.toString()
.trim();
} catch (err) { } catch (err) {
console.warn(err); console.warn(err);
} }
const projectRootDir = path.resolve(__dirname, '..'); const projectRootDir = path.resolve(__dirname, "..");
/** @type {import('webpack').Configuration} */ /** @type {import('webpack').Configuration} */
const config = { const config = {
context: projectRootDir, context: projectRootDir,
entry: { entry: {
openmct: './openmct.js', openmct: "./openmct.js",
generatorWorker: './example/generator/generatorWorker.js', generatorWorker: "./example/generator/generatorWorker.js",
couchDBChangesFeed: './src/plugins/persistence/couch/CouchChangesFeed.js', couchDBChangesFeed:
inMemorySearchWorker: './src/api/objects/InMemorySearchWorker.js', "./src/plugins/persistence/couch/CouchChangesFeed.js",
espressoTheme: './src/plugins/themes/espresso-theme.scss', inMemorySearchWorker: "./src/api/objects/InMemorySearchWorker.js",
snowTheme: './src/plugins/themes/snow-theme.scss' espressoTheme: "./src/plugins/themes/espresso-theme.scss",
}, snowTheme: "./src/plugins/themes/snow-theme.scss"
output: { },
globalObject: 'this', output: {
filename: '[name].js', globalObject: "this",
path: path.resolve(projectRootDir, 'dist'), filename: "[name].js",
library: 'openmct', path: path.resolve(projectRootDir, "dist"),
libraryTarget: 'umd', library: "openmct",
publicPath: '', libraryTarget: "umd",
hashFunction: 'xxhash64', publicPath: "",
clean: true hashFunction: "xxhash64",
}, clean: true
resolve: { },
alias: { resolve: {
'@': path.join(projectRootDir, 'src'), alias: {
legacyRegistry: path.join(projectRootDir, 'src/legacyRegistry'), "@": path.join(projectRootDir, "src"),
saveAs: 'file-saver/src/FileSaver.js', legacyRegistry: path.join(projectRootDir, "src/legacyRegistry"),
csv: 'comma-separated-values', saveAs: "file-saver/src/FileSaver.js",
EventEmitter: 'eventemitter3', csv: "comma-separated-values",
bourbon: 'bourbon.scss', EventEmitter: "eventemitter3",
'plotly-basic': 'plotly.js-basic-dist', bourbon: "bourbon.scss",
'plotly-gl2d': 'plotly.js-gl2d-dist', "plotly-basic": "plotly.js-basic-dist",
'd3-scale': path.join(projectRootDir, 'node_modules/d3-scale/dist/d3-scale.min.js'), "plotly-gl2d": "plotly.js-gl2d-dist",
printj: path.join(projectRootDir, 'node_modules/printj/dist/printj.min.js'), "d3-scale": path.join(
styles: path.join(projectRootDir, 'src/styles'), projectRootDir,
MCT: path.join(projectRootDir, 'src/MCT'), "node_modules/d3-scale/dist/d3-scale.min.js"
testUtils: path.join(projectRootDir, 'src/utils/testUtils.js'), ),
objectUtils: path.join(projectRootDir, 'src/api/objects/object-utils.js'), printj: path.join(
utils: path.join(projectRootDir, 'src/utils'), projectRootDir,
vue: path.join(projectRootDir, 'node_modules/@vue/compat/dist/vue.esm-bundler.js'), "node_modules/printj/dist/printj.min.js"
} ),
}, styles: path.join(projectRootDir, "src/styles"),
plugins: [ MCT: path.join(projectRootDir, "src/MCT"),
new webpack.DefinePlugin({ testUtils: path.join(projectRootDir, "src/utils/testUtils.js"),
__OPENMCT_VERSION__: `'${packageDefinition.version}'`, objectUtils: path.join(
__OPENMCT_BUILD_DATE__: `'${new Date()}'`, projectRootDir,
__OPENMCT_REVISION__: `'${gitRevision}'`, "src/api/objects/object-utils.js"
__OPENMCT_BUILD_BRANCH__: `'${gitBranch}'` ),
}), utils: path.join(projectRootDir, "src/utils")
new VueLoaderPlugin(),
new CopyWebpackPlugin({
patterns: [
{
from: 'src/images/favicons',
to: 'favicons'
},
{
from: './index.html',
transform: function (content) {
return content.toString().replace(/dist\//g, '');
}
},
{
from: 'src/plugins/imagery/layers',
to: 'imagery'
} }
] },
}), plugins: [
new MiniCssExtractPlugin({ new webpack.DefinePlugin({
filename: '[name].css', __OPENMCT_VERSION__: `'${packageDefinition.version}'`,
chunkFilename: '[name].css' __OPENMCT_BUILD_DATE__: `'${new Date()}'`,
}) __OPENMCT_REVISION__: `'${gitRevision}'`,
], __OPENMCT_BUILD_BRANCH__: `'${gitBranch}'`
module: { }),
rules: [ new VueLoaderPlugin(),
{ new CopyWebpackPlugin({
test: /\.(sc|sa|c)ss$/, patterns: [
use: [ {
MiniCssExtractPlugin.loader, from: "src/images/favicons",
{ to: "favicons"
loader: 'css-loader' },
}, {
{ from: "./index.html",
loader: 'resolve-url-loader' transform: function (content) {
}, return content.toString().replace(/dist\//g, "");
{ }
loader: 'sass-loader', },
options: { sourceMap: true } {
} from: "src/plugins/imagery/layers",
] to: "imagery"
}, }
{ ]
test: /\.vue$/, }),
loader: 'vue-loader', new MiniCssExtractPlugin({
options: { filename: "[name].css",
compilerOptions: { chunkFilename: "[name].css"
whitespace: 'preserve', })
compatConfig: { ],
MODE: 2 module: {
rules: [
{
test: /\.(sc|sa|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader"
},
{
loader: "resolve-url-loader"
},
{
loader: "sass-loader",
options: { sourceMap: true }
}
]
},
{
test: /\.vue$/,
use: "vue-loader"
},
{
test: /\.html$/,
type: "asset/source"
},
{
test: /\.(jpg|jpeg|png|svg)$/,
type: "asset/resource",
generator: {
filename: "images/[name][ext]"
}
},
{
test: /\.ico$/,
type: "asset/resource",
generator: {
filename: "icons/[name][ext]"
}
},
{
test: /\.(woff|woff2?|eot|ttf)$/,
type: "asset/resource",
generator: {
filename: "fonts/[name][ext]"
}
} }
} ]
} },
}, stats: "errors-warnings",
{ performance: {
test: /\.html$/, // We should eventually consider chunking to decrease
type: 'asset/source' // these values
}, maxEntrypointSize: 25000000,
{ maxAssetSize: 25000000
test: /\.(jpg|jpeg|png|svg)$/, }
type: 'asset/resource',
generator: {
filename: 'images/[name][ext]'
}
},
{
test: /\.ico$/,
type: 'asset/resource',
generator: {
filename: 'icons/[name][ext]'
}
},
{
test: /\.(woff|woff2?|eot|ttf)$/,
type: 'asset/resource',
generator: {
filename: 'fonts/[name][ext]'
}
}
]
},
stats: 'errors-warnings',
performance: {
// We should eventually consider chunking to decrease
// these values
maxEntrypointSize: 27000000,
maxAssetSize: 27000000
}
}; };
module.exports = config; module.exports = config;

View File

@@ -6,32 +6,32 @@ OpenMCT Continuous Integration servers use this configuration to add code covera
information to pull requests. information to pull requests.
*/ */
const config = require('./webpack.dev'); const config = require("./webpack.dev");
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const CI = process.env.CI === 'true'; const CI = process.env.CI === "true";
config.devtool = CI ? false : undefined; config.devtool = CI ? false : undefined;
config.devServer.hot = false; config.devServer.hot = false;
config.module.rules.push({ config.module.rules.push({
test: /\.js$/, test: /\.js$/,
exclude: /(Spec\.js$)|(node_modules)/, exclude: /(Spec\.js$)|(node_modules)/,
use: { use: {
loader: 'babel-loader', loader: "babel-loader",
options: { options: {
retainLines: true, retainLines: true,
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
plugins: [ plugins: [
[ [
'babel-plugin-istanbul', "babel-plugin-istanbul",
{ {
extension: ['.js', '.vue'] extension: [".js", ".vue"]
} }
] ]
] ]
}
} }
}
}); });
module.exports = config; module.exports = config;

View File

@@ -5,54 +5,55 @@ This configuration should be used for development purposes. It contains full sou
devServer (which be invoked using by `npm start`), and a non-minified Vue.js distribution. devServer (which be invoked using by `npm start`), and a non-minified Vue.js distribution.
If OpenMCT is to be used for a production server, use webpack.prod.js instead. If OpenMCT is to be used for a production server, use webpack.prod.js instead.
*/ */
const path = require('path'); const path = require("path");
const webpack = require('webpack'); const webpack = require("webpack");
const { merge } = require('webpack-merge'); const { merge } = require("webpack-merge");
const common = require('./webpack.common'); const common = require("./webpack.common");
const projectRootDir = path.resolve(__dirname, '..'); const projectRootDir = path.resolve(__dirname, "..");
module.exports = merge(common, { module.exports = merge(common, {
mode: 'development', mode: "development",
watchOptions: { watchOptions: {
// Since we use require.context, webpack is watching the entire directory. // Since we use require.context, webpack is watching the entire directory.
// We need to exclude any files we don't want webpack to watch. // We need to exclude any files we don't want webpack to watch.
// See: https://webpack.js.org/configuration/watch/#watchoptions-exclude // See: https://webpack.js.org/configuration/watch/#watchoptions-exclude
ignored: [ ignored: [
'**/{node_modules,dist,docs,e2e}', // All files in node_modules, dist, docs, e2e, "**/{node_modules,dist,docs,e2e}", // All files in node_modules, dist, docs, e2e,
'**/{*.yml,Procfile,webpack*.js,babel*.js,package*.json,tsconfig.json}', // Config files "**/{*.yml,Procfile,webpack*.js,babel*.js,package*.json,tsconfig.json}", // Config files
'**/*.{sh,md,png,ttf,woff,svg}', // Non source files "**/*.{sh,md,png,ttf,woff,svg}", // Non source files
'**/.*' // dotfiles and dotfolders "**/.*" // dotfiles and dotfolders
] ]
}, },
plugins: [ resolve: {
new webpack.DefinePlugin({ alias: {
__OPENMCT_ROOT_RELATIVE__: '"dist/"' vue: path.join(projectRootDir, "node_modules/vue/dist/vue.js")
}) }
], },
devtool: 'eval-source-map', plugins: [
devServer: { new webpack.DefinePlugin({
devMiddleware: { __OPENMCT_ROOT_RELATIVE__: '"dist/"'
writeToDisk: (filePathString) => { })
const filePath = path.parse(filePathString); ],
const shouldWrite = !filePath.base.includes('hot-update'); devtool: "eval-source-map",
devServer: {
devMiddleware: {
writeToDisk: (filePathString) => {
const filePath = path.parse(filePathString);
const shouldWrite = !filePath.base.includes("hot-update");
return shouldWrite; return shouldWrite;
} }
}, },
watchFiles: ['**/*.css'], watchFiles: ["**/*.css"],
static: { static: {
directory: path.join(__dirname, '..', '/dist'), directory: path.join(__dirname, "..", "/dist"),
publicPath: '/dist', publicPath: "/dist",
watch: false watch: false
}, },
client: { client: {
progress: true, progress: true,
overlay: { overlay: true
// Disable overlay for runtime errors. }
// See: https://github.com/webpack/webpack-dev-server/issues/4771
runtimeErrors: false
}
} }
}
}); });

View File

@@ -4,19 +4,24 @@
This configuration should be used for production installs. This configuration should be used for production installs.
It is the default webpack configuration. It is the default webpack configuration.
*/ */
const path = require('path'); const path = require("path");
const webpack = require('webpack'); const webpack = require("webpack");
const { merge } = require('webpack-merge'); const { merge } = require("webpack-merge");
const common = require('./webpack.common'); const common = require("./webpack.common");
const projectRootDir = path.resolve(__dirname, '..'); const projectRootDir = path.resolve(__dirname, "..");
module.exports = merge(common, { module.exports = merge(common, {
mode: 'production', mode: "production",
plugins: [ resolve: {
new webpack.DefinePlugin({ alias: {
__OPENMCT_ROOT_RELATIVE__: '""' vue: path.join(projectRootDir, "node_modules/vue/dist/vue.min.js")
}) }
], },
devtool: 'source-map' plugins: [
new webpack.DefinePlugin({
__OPENMCT_ROOT_RELATIVE__: '""'
})
],
devtool: "source-map"
}); });

6
API.md
View File

@@ -2,7 +2,7 @@
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** **Table of Contents**
- [Developing Applications With Open MCT](#developing-applications-with-open-mct) - [Building Applications With Open MCT](#developing-applications-with-open-mct)
- [Scope and purpose of this document](#scope-and-purpose-of-this-document) - [Scope and purpose of this document](#scope-and-purpose-of-this-document)
- [Building From Source](#building-from-source) - [Building From Source](#building-from-source)
- [Starting an Open MCT application](#starting-an-open-mct-application) - [Starting an Open MCT application](#starting-an-open-mct-application)
@@ -26,7 +26,7 @@
- [Value Hints](#value-hints) - [Value Hints](#value-hints)
- [The Time Conductor and Telemetry](#the-time-conductor-and-telemetry) - [The Time Conductor and Telemetry](#the-time-conductor-and-telemetry)
- [Telemetry Providers](#telemetry-providers) - [Telemetry Providers](#telemetry-providers)
- [Telemetry Requests and Responses](#telemetry-requests-and-responses) - [Telemetry Requests and Responses.](#telemetry-requests-and-responses)
- [Request Strategies **draft**](#request-strategies-draft) - [Request Strategies **draft**](#request-strategies-draft)
- [`latest` request strategy](#latest-request-strategy) - [`latest` request strategy](#latest-request-strategy)
- [`minmax` request strategy](#minmax-request-strategy) - [`minmax` request strategy](#minmax-request-strategy)
@@ -873,8 +873,6 @@ function without any arguments.
#### Stopping an active clock #### Stopping an active clock
_As of July 2023, this method will be deprecated. Open MCT will always have a ticking clock._
The `stopClock` method can be used to stop an active clock, and to clear it. It The `stopClock` method can be used to stop an active clock, and to clear it. It
will stop the clock from ticking, and set the active clock to `undefined`. will stop the clock from ticking, and set the active clock to `undefined`.

View File

@@ -18,13 +18,13 @@ The short version:
for review.) for review.)
4. Respond to any discussion. When the reviewer decides it's ready, they 4. Respond to any discussion. When the reviewer decides it's ready, they
will merge back `master` and fill out their own check list. will merge back `master` and fill out their own check list.
5. If you are a first-time contributor, please see [this discussion](https://github.com/nasa/openmct/discussions/3821) for further information. 5. If you are a first-time contributor, please see [this discussion](https://github.com/nasa/openmct/discussions/3821) for further information.
## Contribution Process ## Contribution Process
Open MCT uses git for software version control, and for branching and Open MCT uses git for software version control, and for branching and
merging. The central repository is at merging. The central repository is at
<https://github.com/nasa/openmct.git>. https://github.com/nasa/openmct.git.
### Roles ### Roles
@@ -116,7 +116,6 @@ the pull request containing the reviewer checklist (from below) and complete
the merge back to the master branch. the merge back to the master branch.
Additionally: Additionally:
* Every pull request must link to the issue that it addresses. Eg. “Addresses #1234” or “Closes #1234”. This is the responsibility of the pull requests __author__. If no issue exists, [create one](https://github.com/nasa/openmct/issues/new/choose). * Every pull request must link to the issue that it addresses. Eg. “Addresses #1234” or “Closes #1234”. This is the responsibility of the pull requests __author__. If no issue exists, [create one](https://github.com/nasa/openmct/issues/new/choose).
* Every __author__ must include testing instructions. These instructions should identify the areas of code affected, and some minimal test steps. If addressing a bug, reproduction steps should be included, if they were not included in the original issue. If reproduction steps were included on the original issue, and are sufficient, refer to them. * Every __author__ must include testing instructions. These instructions should identify the areas of code affected, and some minimal test steps. If addressing a bug, reproduction steps should be included, if they were not included in the original issue. If reproduction steps were included on the original issue, and are sufficient, refer to them.
* A pull request that closes an issue should say so in the description. Including the text “Closes #1234” will cause the linked issue to be automatically closed when the pull request is merged. This is the responsibility of the pull requests __author__. * A pull request that closes an issue should say so in the description. Including the text “Closes #1234” will cause the linked issue to be automatically closed when the pull request is merged. This is the responsibility of the pull requests __author__.
@@ -133,26 +132,25 @@ changes.
### Code Standards ### Code Standards
JavaScript sources in Open MCT must satisfy the [ESLint](https://eslint.org/) rules defined in JavaScript sources in Open MCT must satisfy the ESLint rules defined in
this repository. [Prettier](https://prettier.io/) is used in conjunction with ESLint to enforce code style this repository. This is verified by the command line build.
via automated formatting. These are verified by the command line build.
#### Code Guidelines #### Code Guidelines
The following guidelines are provided for anyone contributing source code to the Open MCT project: The following guidelines are provided for anyone contributing source code to the Open MCT project:
1. Write clean code. Heres a good summary - <https://github.com/ryanmcdermott/clean-code-javascript>. 1. Write clean code. Heres a good summary - https://github.com/ryanmcdermott/clean-code-javascript.
1. Include JSDoc for any exposed API (e.g. public methods, classes). 1. Include JSDoc for any exposed API (e.g. public methods, classes).
1. Include non-JSDoc comments as-needed for explaining private variables, 1. Include non-JSDoc comments as-needed for explaining private variables,
methods, or algorithms when they are non-obvious. Otherwise code methods, or algorithms when they are non-obvious. Otherwise code
should be self-documenting. should be self-documenting.
1. Classes and Vue components should use camel case, first letter capitalized 1. Classes and Vue components should use camel case, first letter capitalized
(e.g. SomeClassName). (e.g. SomeClassName).
1. Methods, variables, fields, events, and function names should use camelCase, 1. Methods, variables, fields, events, and function names should use camelCase,
first letter lower-case (e.g. someVariableName). first letter lower-case (e.g. someVariableName).
1. Source files that export functions should use camelCase, first letter lower-case (eg. testTools.js) 1. Source files that export functions should use camelCase, first letter lower-case (eg. testTools.js)
1. Constants (variables or fields which are meant to be declared and 1. Constants (variables or fields which are meant to be declared and
initialized statically, and never changed) should use only capital initialized statically, and never changed) should use only capital
letters, with underscores between words (e.g. SOME_CONSTANT). They should always be declared as `const`s letters, with underscores between words (e.g. SOME_CONSTANT). They should always be declared as `const`s
1. File names should be the name of the exported class, plus a .js extension 1. File names should be the name of the exported class, plus a .js extension
(e.g. SomeClassName.js). (e.g. SomeClassName.js).
@@ -161,25 +159,21 @@ The following guidelines are provided for anyone contributing source code to the
(e.g. as arguments to a forEach call). Anonymous functions should always be arrow functions. (e.g. as arguments to a forEach call). Anonymous functions should always be arrow functions.
1. Named functions are preferred over functions assigned to variables. 1. Named functions are preferred over functions assigned to variables.
eg. eg.
```JavaScript ```JavaScript
function renameObject(object, newName) { function renameObject(object, newName) {
Object.name = newName; Object.name = newName;
} }
``` ```
is preferable to is preferable to
```JavaScript ```JavaScript
const rename = (object, newName) => { const rename = (object, newName) => {
Object.name = newName; Object.name = newName;
} }
``` ```
1. Avoid deep nesting (especially of functions), except where necessary 1. Avoid deep nesting (especially of functions), except where necessary
(e.g. due to closure scope). (e.g. due to closure scope).
1. End with a single new-line character. 1. End with a single new-line character.
1. Always use ES6 `Class`es and inheritance rather than the pre-ES6 prototypal 1. Always use ES6 `Class`es and inheritance rather than the pre-ES6 prototypal
pattern. pattern.
1. Within a given function's scope, do not mix declarations and imperative 1. Within a given function's scope, do not mix declarations and imperative
code, and present these in the following order: code, and present these in the following order:
@@ -188,24 +182,19 @@ The following guidelines are provided for anyone contributing source code to the
* Finally, the returned value. A single return statement at the end of the function should be used, except where an early return would improve code clarity. * Finally, the returned value. A single return statement at the end of the function should be used, except where an early return would improve code clarity.
1. Avoid the use of "magic" values. 1. Avoid the use of "magic" values.
eg. eg.
```JavaScript ```JavaScript
const UNAUTHORIZED = 401; const UNAUTHORIZED = 401;
if (responseCode === UNAUTHORIZED) if (responseCode === UNAUTHORIZED)
``` ```
is preferable to is preferable to
```JavaScript ```JavaScript
if (responseCode === 401) if (responseCode === 401)
``` ```
1. Use the ternary operator only for simple cases such as variable assignment. Nested ternaries should be avoided in all cases. 1. Use the ternary operator only for simple cases such as variable assignment. Nested ternaries should be avoided in all cases.
1. Unit Test specs should reside alongside the source code they test, not in a separate directory. 1. Test specs should reside alongside the source code they test, not in a separate directory.
1. Organize code by feature, not by type. 1. Organize code by feature, not by type.
eg. eg.
```
```txt
- telemetryTable - telemetryTable
- row - row
TableRow.js TableRow.js
@@ -217,10 +206,8 @@ The following guidelines are provided for anyone contributing source code to the
plugin.js plugin.js
pluginSpec.js pluginSpec.js
``` ```
is preferable to is preferable to
```
```txt
- telemetryTable - telemetryTable
- components - components
TableRow.vue TableRow.vue
@@ -232,10 +219,47 @@ The following guidelines are provided for anyone contributing source code to the
plugin.js plugin.js
pluginSpec.js pluginSpec.js
``` ```
Deviations from Open MCT code style guidelines require two-party agreement, Deviations from Open MCT code style guidelines require two-party agreement,
typically from the author of the change and its reviewer. typically from the author of the change and its reviewer.
### Test Standards
Automated testing shall occur whenever changes are merged into the main
development branch and must be confirmed alongside any pull request.
Automated tests are tests which exercise plugins, API, and utility classes.
Tests are subject to code review along with the actual implementation, to
ensure that tests are applicable and useful.
Examples of useful tests:
* Tests which replicate bugs (or their root causes) to verify their
resolution.
* Tests which reflect details from software specifications.
* Tests which exercise edge or corner cases among inputs.
* Tests which verify expected interactions with other components in the
system.
#### Guidelines
* 100% statement coverage is achievable and desirable.
* Do blackbox testing. Test external behaviors, not internal details. Write tests that describe what your plugin is supposed to do. How it does this doesn't matter, so don't test it.
* Unit test specs for plugins should be defined at the plugin level. Start with one test spec per plugin named pluginSpec.js, and as this test spec grows too big, break it up into multiple test specs that logically group related tests.
* Unit tests for API or for utility functions and classes may be defined at a per-source file level.
* Wherever possible only use and mock public API, builtin functions, and UI in your test specs. Do not directly invoke any private functions. ie. only call or mock functions and objects exposed by openmct.* (eg. openmct.telemetry, openmct.objectView, etc.), and builtin browser functions (fetch, requestAnimationFrame, setTimeout, etc.).
* Where builtin functions have been mocked, be sure to clear them between tests.
* Test at an appropriate level of isolation. Eg.
* If youre testing a view, you do not need to test the whole application UI, you can just fetch the view provider using the public API and render the view into an element that you have created.
* You do not need to test that the view switcher works, there should be separate tests for that.
* You do not need to test that telemetry providers work, you can mock openmct.telemetry.request() to feed test data to the view.
* Use your best judgement when deciding on appropriate scope.
* Automated tests for plugins should start by actually installing the plugin being tested, and then test that installing the plugin adds the desired features and behavior to Open MCT, observing the above rules.
* All variables used in a test spec, including any instances of the Open MCT API should be declared inside of an appropriate block scope (not at the root level of the source file), and should be initialized in the relevant beforeEach block. `beforeEach` is preferable to `beforeAll` to avoid leaking of state between tests.
* A `afterEach` or `afterAll` should be used to do any clean up necessary to prevent leakage of state between test specs. This can happen when functions on `window` are wrapped, or when the URL is changed. [A convenience function](https://github.com/nasa/openmct/blob/master/src/utils/testing.js#L59) is provided for resetting the URL and clearing builtin spies between tests.
* If writing unit tests for legacy Angular code be sure to follow [best practices in order to avoid memory leaks](https://www.thecodecampus.de/blog/avoid-memory-leaks-angularjs-unit-tests/).
#### Examples
* [Example of an automated test spec for an object view plugin](https://github.com/nasa/openmct/blob/master/src/plugins/telemetryTable/pluginSpec.js)
* [Example of an automated test spec for API](https://github.com/nasa/openmct/blob/master/src/api/time/TimeAPISpec.js)
### Commit Message Standards ### Commit Message Standards
Commit messages should: Commit messages should:
@@ -271,13 +295,13 @@ these standards.
## Issue Reporting ## Issue Reporting
Issues are tracked at <https://github.com/nasa/openmct/issues>. Issues are tracked at https://github.com/nasa/openmct/issues.
Issue severity is categorized as follows (in ascending order): Issue severity is categorized as follows (in ascending order):
* _Trivial_: Minimal impact on the usefulness and functionality of the software; a "nice-to-have." Visual impact without functional impact, * _Trivial_: Minimal impact on the usefulness and functionality of the software; a "nice-to-have." Visual impact without functional impact,
* _Medium_: Some impairment of use, but simple workarounds exist * _Medium_: Some impairment of use, but simple workarounds exist
* _Critical_: Significant loss of functionality or impairment of use. Display of telemetry data is not affected though. Complex workarounds exist. * _Critical_: Significant loss of functionality or impairment of use. Display of telemetry data is not affected though.
* _Blocker_: Major functionality is impaired or lost, threatening mission success. Display of telemetry data is impaired or blocked by the bug, which could lead to loss of situational awareness. * _Blocker_: Major functionality is impaired or lost, threatening mission success. Display of telemetry data is impaired or blocked by the bug, which could lead to loss of situational awareness.
## Check Lists ## Check Lists
@@ -286,4 +310,22 @@ The following check lists should be completed and attached to pull requests
when they are filed (author checklist) and when they are merged (reviewer when they are filed (author checklist) and when they are merged (reviewer
checklist). checklist).
### Author Checklist
[Within PR Template](.github/PULL_REQUEST_TEMPLATE.md) [Within PR Template](.github/PULL_REQUEST_TEMPLATE.md)
### Reviewer Checklist
* [ ] Changes appear to address issue?
* [ ] Changes appear not to be breaking changes?
* [ ] Appropriate unit tests included?
* [ ] Code style and in-line documentation are appropriate?
* [ ] Commit messages meet standards?
* [ ] Has associated issue been labelled `unverified`? (only applicable if this PR closes the issue)
* [ ] Has associated issue been labelled `bug`? (only applicable if this PR is for a bug fix)
* [ ] List of Acceptance Tests Performed.
Write out a small list of tests performed with just enough detail for another developer on the team
to execute.
i.e. ```When Clicking on Add button, new `object` appears in dropdown.```

View File

@@ -1,6 +1,6 @@
# Open MCT License # Open MCT License
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, Copyright (c) 2014-2022, United States Government as represented by the Administrator of the National Aeronautics and Space Administration. All rights reserved.
Open MCT is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. 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.

View File

@@ -1,4 +1,4 @@
# Open MCT [![license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0) [![codecov](https://codecov.io/gh/nasa/openmct/branch/master/graph/badge.svg?token=7DQIipp3ej)](https://codecov.io/gh/nasa/openmct) [![This project is using Percy.io for visual regression testing.](https://percy.io/static/images/percy-badge.svg)](https://percy.io/b2e34b17/openmct) [![npm version](https://img.shields.io/npm/v/openmct.svg)](https://www.npmjs.com/package/openmct) # Open MCT [![license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0) [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/nasa/openmct.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/nasa/openmct/context:javascript) [![codecov](https://codecov.io/gh/nasa/openmct/branch/master/graph/badge.svg?token=7DQIipp3ej)](https://codecov.io/gh/nasa/openmct) [![This project is using Percy.io for visual regression testing.](https://percy.io/static/images/percy-badge.svg)](https://percy.io/b2e34b17/openmct) [![npm version](https://img.shields.io/npm/v/openmct.svg)](https://www.npmjs.com/package/openmct)
Open MCT (Open Mission Control Technologies) is a next-generation mission control framework for visualization of data on desktop and mobile devices. It is developed at NASA's Ames Research Center, and is being used by NASA for data analysis of spacecraft missions, as well as planning and operation of experimental rover systems. As a generalizable and open source framework, Open MCT could be used as the basis for building applications for planning, operation, and analysis of any systems producing telemetry data. Open MCT (Open Mission Control Technologies) is a next-generation mission control framework for visualization of data on desktop and mobile devices. It is developed at NASA's Ames Research Center, and is being used by NASA for data analysis of spacecraft missions, as well as planning and operation of experimental rover systems. As a generalizable and open source framework, Open MCT could be used as the basis for building applications for planning, operation, and analysis of any systems producing telemetry data.
@@ -98,7 +98,7 @@ To run the performance tests:
The test suite is configured to all tests localed in `e2e/tests/` ending in `*.e2e.spec.js`. For more about the e2e test suite, please see the [README](./e2e/README.md) The test suite is configured to all tests localed in `e2e/tests/` ending in `*.e2e.spec.js`. For more about the e2e test suite, please see the [README](./e2e/README.md)
### Security Tests ### Security Tests
Each commit is analyzed for known security vulnerabilities using [CodeQL](https://codeql.github.com/docs/codeql-language-guides/codeql-library-for-javascript/). The list of CWE coverage items is avaiable in the [CodeQL docs](https://codeql.github.com/codeql-query-help/javascript-cwe/). The CodeQL workflow is specified in the [CodeQL analysis file](./.github/workflows/codeql-analysis.yml) and the custom [CodeQL config](./.github/codeql/codeql-config.yml). Each commit is analyzed for known security vulnerabilities using [CodeQL](https://codeql.github.com/docs/codeql-language-guides/codeql-library-for-javascript/) and our overall security report is available on [LGTM](https://lgtm.com/projects/g/nasa/openmct/). The list of CWE coverage items is avaiable in the [CodeQL docs](https://codeql.github.com/codeql-query-help/javascript-cwe/). The CodeQL workflow is specified in the [CodeQL analysis file](./.github/workflows/codeql-analysis.yml) and the custom [CodeQL config](./.github/codeql/codeql-config.yml).
### Test Reporting and Code Coverage ### Test Reporting and Code Coverage

View File

@@ -1,50 +0,0 @@
# Testing
Open MCT Testing is iterating and improving at a rapid pace. This document serves to capture and index existing testing documentation and house documentation which no other obvious location as our testing evolves.
## General Testing Process
Documentation located [here](./docs/src/process/testing/plan.md)
## Unit Testing
Unit testing is essential part of our test strategy and complements our e2e testing strategy.
#### Unit Test Guidelines
* Unit Test specs should reside alongside the source code they test, not in a separate directory.
* Unit test specs for plugins should be defined at the plugin level. Start with one test spec per plugin named pluginSpec.js, and as this test spec grows too big, break it up into multiple test specs that logically group related tests.
* Unit tests for API or for utility functions and classes may be defined at a per-source file level.
* Wherever possible only use and mock public API, builtin functions, and UI in your test specs. Do not directly invoke any private functions. ie. only call or mock functions and objects exposed by openmct.* (eg. openmct.telemetry, openmct.objectView, etc.), and builtin browser functions (fetch, requestAnimationFrame, setTimeout, etc.).
* Where builtin functions have been mocked, be sure to clear them between tests.
* Test at an appropriate level of isolation. Eg.
* If youre testing a view, you do not need to test the whole application UI, you can just fetch the view provider using the public API and render the view into an element that you have created.
* You do not need to test that the view switcher works, there should be separate tests for that.
* You do not need to test that telemetry providers work, you can mock openmct.telemetry.request() to feed test data to the view.
* Use your best judgement when deciding on appropriate scope.
* Automated tests for plugins should start by actually installing the plugin being tested, and then test that installing the plugin adds the desired features and behavior to Open MCT, observing the above rules.
* All variables used in a test spec, including any instances of the Open MCT API should be declared inside of an appropriate block scope (not at the root level of the source file), and should be initialized in the relevant beforeEach block. `beforeEach` is preferable to `beforeAll` to avoid leaking of state between tests.
* A `afterEach` or `afterAll` should be used to do any clean up necessary to prevent leakage of state between test specs. This can happen when functions on `window` are wrapped, or when the URL is changed. [A convenience function](https://github.com/nasa/openmct/blob/master/src/utils/testing.js#L59) is provided for resetting the URL and clearing builtin spies between tests.
#### Unit Test Examples
* [Example of an automated test spec for an object view plugin](https://github.com/nasa/openmct/blob/master/src/plugins/telemetryTable/pluginSpec.js)
* [Example of an automated test spec for API](https://github.com/nasa/openmct/blob/master/src/api/time/TimeAPISpec.js)
#### Unit Testing Execution
The unit tests can be executed in one of two ways:
`npm run test` which runs the entire suite against headless chrome
`npm run test:debug` for debugging the tests in realtime in an active chrome session.
## e2e, performance, and visual testing
Documentation located [here](./e2e/README.md)
## Code Coverage
* 100% statement coverage is achievable and desirable.
Codecov.io will combine each of the above commands with [Codecov.io Flags](https://docs.codecov.com/docs/flags). Effectively, this allows us to combine multiple reports which are run at various stages of our CI Pipeline or run as part of a parallel process.
This e2e coverage is combined with our unit test report to give a comprehensive (if flawed) view of line coverage.
### Limitations in our code coverage reporting
Our code coverage implementation has two known limitations:
- [Variability and accuracy](https://github.com/nasa/openmct/issues/5811)
- [Vue instrumentation](https://github.com/nasa/openmct/issues/4973)

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
#***************************************************************************** #*****************************************************************************
#* Open MCT, Copyright (c) 2014-2023, United States Government #* Open MCT, Copyright (c) 2014-2022, United States Government
#* as represented by the Administrator of the National Aeronautics and Space #* as represented by the Administrator of the National Aeronautics and Space
#* Administration. All rights reserved. #* Administration. All rights reserved.
#* #*

View File

@@ -11,18 +11,18 @@ coverage:
informational: true informational: true
precision: 2 precision: 2
round: down round: down
range: '66...100' range: "66...100"
flags: flags:
unit: unit:
carryforward: false carryforward: true
e2e-stable: e2e-ci:
carryforward: false
e2e-full:
carryforward: true carryforward: true
e2e-full:
carryforward: true
comment: comment:
layout: 'diff,flags,files,footer' layout: "reach,diff,flags,files,footer"
behavior: default behavior: default
require_changes: false require_changes: false
show_carryforward_flags: true show_carryforward_flags: true

View File

@@ -1,5 +1,5 @@
<!-- <!--
Open MCT, Copyright (c) 2014-2023, United States Government Open MCT, Copyright (c) 2014-2022, United States Government
as represented by the Administrator of the National Aeronautics and Space as represented by the Administrator of the National Aeronautics and Space
Administration. All rights reserved. Administration. All rights reserved.

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *

View File

@@ -1,15 +1,15 @@
/* eslint-disable no-undef */ /* eslint-disable no-undef */
module.exports = { module.exports = {
extends: ['plugin:playwright/playwright-test'], "extends": ["plugin:playwright/playwright-test"],
rules: { "rules": {
'playwright/max-nested-describe': ['error', { max: 1 }] "playwright/max-nested-describe": ["error", { "max": 1 }]
}, },
overrides: [ "overrides": [
{ {
files: ['tests/visual/*.spec.js'], "files": ["tests/visual/*.spec.js"],
rules: { "rules": {
'playwright/no-wait-for-timeout': 'off' "playwright/no-wait-for-timeout": "off"
} }
} }
] ]
}; };

View File

@@ -89,37 +89,17 @@ Read more about [Playwright Snapshots](https://playwright.dev/docs/test-snapshot
#### Open MCT's implementation #### Open MCT's implementation
- Our Snapshot tests receive a `@snapshot` tag. - Our Snapshot tests receive a `@snapshot` tag.
- Snapshots need to be executed within the official Playwright container to ensure we're using the exact rendering platform in CI and locally. To do a valid comparison locally: - Snapshots need to be executed within the official Playwright container to ensure we're using the exact rendering platform in CI and locally.
```sh ```sh
// Replace {X.X.X} with the current Playwright version docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:[GET THIS VERSION FROM OUR CIRCLECI CONFIG FILE]-focal /bin/bash
// 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 npm install
npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @snapshot npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @snapshot
``` ```
### Updating Snapshots ### (WIP) Updating Snapshots
When the `@snapshot` tests fail, they will need to be evaluated to determine if the failure is an acceptable and desireable or an unintended regression. When the `@snapshot` tests fail, they will need to be evaluated to see if the failure is an acceptable change or
To compare a snapshot, run a test and open the html report with the 'Expected' vs 'Actual' screenshot. If the actual screenshot is preferred, then the source-controlled 'Expected' snapshots will need to be updated with the following scripts.
MacOS
```
npm run test:e2e:updatesnapshots
```
Linux/CI
```sh
// Replace {X.X.X} with the current Playwright version
// 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
npm run test:e2e:updatesnapshots
```
## Performance Testing ## Performance Testing
@@ -139,18 +119,16 @@ These tests are expected to become blocking and gating with assertions as we ext
Our file structure follows the type of type of testing being excercised at the e2e layer and files containing test suites which matcher application behavior or our `src` and `example` layout. This area is not well refined as we figure out what works best for closed source and downstream projects. This may change altogether if we move `e2e` to it's own npm package. Our file structure follows the type of type of testing being excercised at the e2e layer and files containing test suites which matcher application behavior or our `src` and `example` layout. This area is not well refined as we figure out what works best for closed source and downstream projects. This may change altogether if we move `e2e` to it's own npm package.
|File Path|Description| - `./helper` - contains helper functions or scripts which are leveraged directly within the testsuites. i.e. non-default plugin scripts injected into DOM
|:-:|-| - `./test-data` - contains test data which is leveraged or generated in the functional, performance, or visual test suites. i.e. localStorage data
|`./helper` | Contains helper functions or scripts which are leveraged directly within the test suites (e.g.: non-default plugin scripts injected into the DOM)| - `./tests/functional` - the bulk of the tests are contained within this folder to verify the functionality of open mct
|`./test-data` | Contains test data which is leveraged or generated in the functional, performance, or visual test suites (e.g.: localStorage data).| - `./tests/functional/example/` - tests which specifically verify the example plugins
|`./tests/functional` | The bulk of the tests are contained within this folder to verify the functionality of Open MCT.| - `./tests/functional/plugins/` - tests which loosely test each plugin. This folder is the most likely to change. Note: some @snapshot tests are still contained within this structure
|`./tests/functional/example/` | Tests which specifically verify the example plugins (e.g.: Sine Wave Generator).| - `./tests/framework/` - tests which verify that our testframework functionality and assumptions will continue to work based on further refactoring or playwright version changes
|`./tests/functional/plugins/` | Tests which loosely test each plugin. This folder is the most likely to change. Note: some `@snapshot` tests are still contained within this structure.| - `./tests/performance/` - performance tests
|`./tests/framework/` | Tests which verify that our testing framework's functionality and assumptions will continue to work based on further refactoring or Playwright version changes (e.g.: verifying custom fixtures and appActions).| - `./tests/visual/` - Visual tests
|`./tests/performance/` | Performance tests.| - `./appActions.js` - Contains common fixtures which can be leveraged by testcase authors to quickly move through the application when writing new tests.
|`./tests/visual/` | Visual tests.| - `./baseFixture.js` - Contains base fixtures which only extend default `@playwright/test` functionality. The goal is to remove these fixtures as native Playwright APIs improve.
|`./appActions.js` | Contains common methods which can be leveraged by test case authors to quickly move through the application when writing new tests.|
|`./baseFixture.js` | Contains base fixtures which only extend default `@playwright/test` functionality. The expectation is that these fixtures will be removed as the native Playwright API improves|
Our functional tests end in `*.e2e.spec.js`, visual tests in `*.visual.spec.js` and performance tests in `*.perf.spec.js`. Our functional tests end in `*.e2e.spec.js`, visual tests in `*.visual.spec.js` and performance tests in `*.perf.spec.js`.
@@ -160,12 +138,10 @@ Where possible, we try to run Open MCT without modification or configuration cha
Open MCT is leveraging the [config file](https://playwright.dev/docs/test-configuration) pattern to describe the capabilities of Open MCT e2e _where_ it's run Open MCT is leveraging the [config file](https://playwright.dev/docs/test-configuration) pattern to describe the capabilities of Open MCT e2e _where_ it's run
|Config File|Description| - `./playwright-ci.config.js` - Used when running in CI or to debug CI issues locally
|:-:|-| - `./playwright-local.config.js` - Used when running locally
|`./playwright-ci.config.js` | Used when running in CI or to debug CI issues locally| - `./playwright-performance.config.js` - Used when running performance tests in CI or locally
|`./playwright-local.config.js` | Used when running locally| - `./playwright-visual.config.js` - Used to run the visual tests in CI or locally
|`./playwright-performance.config.js` | Used when running performance tests in CI or locally|
|`./playwright-visual.config.js` | Used to run the visual tests in CI or locally|
#### Test Tags #### Test Tags
@@ -173,15 +149,13 @@ Test tags are a great way of organizing tests outside of a file structure. To le
Current list of test tags: 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).
|:-:|-| - `@gds` - Denotes a GDS Test Case used in the VIPER Mission.
|`@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).| - `@addInit` - Initializes the browser with an injected and artificial state. Useful for loading non-default plugins. Likely will not work outside of `npm start`.
|`@gds` | Denotes a GDS Test Case used in the VIPER Mission.| - `@localStorage` - Captures or generates session storage to manipulate browser state. Useful for excluding in tests which require a persistent backend (i.e. CouchDB).
|`@addInit` | Initializes the browser with an injected and artificial state. Useful for loading non-default plugins. Likely will not work outside of `npm start`.| - `@snapshot` - Uses Playwright's snapshot functionality to record a copy of the DOM for direct comparison. Must be run inside of the playwright container.
|`@localStorage` | Captures or generates session storage to manipulate browser state. Useful for excluding in tests which require a persistent backend (i.e. CouchDB).| - `@unstable` - A new test or test which is known to be flaky.
|`@snapshot` | Uses Playwright's snapshot functionality to record a copy of the DOM for direct comparison. Must be run inside of the playwright container.| - `@2p` - Indicates that multiple users are involved, or multiple tabs/pages are used. Useful for testing multi-user interactivity.
|`@unstable` | A new test or test which is known to be flaky.|
|`@2p` | Indicates that multiple users are involved, or multiple tabs/pages are used. Useful for testing multi-user interactivity.|
### Continuous Integration ### Continuous Integration
@@ -206,7 +180,6 @@ CircleCI
Github Actions / Workflow Github Actions / Workflow
- Full suite against all browsers/projects. Triggered with Github Label Event 'pr:e2e' - Full suite against all browsers/projects. Triggered with Github Label Event 'pr:e2e'
- CouchDB Tests. Triggered on PR Create and again with Github Label Event 'pr:e2e:couchdb'
- Visual Tests. Triggered with Github Label Event 'pr:visual' - Visual Tests. Triggered with Github Label Event 'pr:visual'
#### 3. Scheduled / Batch Testing #### 3. Scheduled / Batch Testing
@@ -238,8 +211,7 @@ At the same time, we don't want to waste CI resources on parallel runs, so we've
In order to maintain fast and reliable feedback, tests go through a promotion process. All new test cases or test suites must be labeled with the `@unstable` annotation. The Open MCT dev team runs these unstable tests in our private repos to ensure they work downstream and are reliable. In order to maintain fast and reliable feedback, tests go through a promotion process. All new test cases or test suites must be labeled with the `@unstable` annotation. The Open MCT dev team runs these unstable tests in our private repos to ensure they work downstream and are reliable.
- To run the stable tests, use the `npm run test:e2e:stable` command. To run the stable tests, use the ```npm run test:e2e:stable``` command. To run the new and flaky tests, use the ```npm run test:e2e:unstable``` command.
- To run the new and flaky tests, use the `npm run test:e2e:unstable` command.
A testcase and testsuite are to be unmarked as @unstable when: A testcase and testsuite are to be unmarked as @unstable when:
@@ -300,24 +272,13 @@ Skipping based on browser version (Rarely used): <https://github.com/microsoft/p
- How to make tests robust to function in other contexts (VISTA, VIPER, etc.) - How to make tests robust to function in other contexts (VISTA, VIPER, etc.)
- Leverage the use of `appActions.js` methods such as `createDomainObjectWithDefaults()` - Leverage the use of `appActions.js` methods such as `createDomainObjectWithDefaults()`
- How to make tests faster and more resilient - How to make tests faster and more resilient
- When possible, navigate directly by URL: - When possible, navigate directly by URL
- Leverage `await page.goto('./', { waitUntil: 'networkidle' });`
```javascript
// You can capture the CreatedObjectInfo returned from this appAction:
const clock = await createDomainObjectWithDefaults(page, { type: 'Clock' });
// ...and use its `url` property to navigate directly to it later in the test:
await page.goto(clock.url);
```
- Leverage `await page.goto('./', { waitUntil: 'domcontentloaded' });`
- Initial navigation should _almost_ always use the `{ waitUntil: 'domcontentloaded' }` option.
- Avoid repeated setup to test to test a single assertion. Write longer tests with multiple soft assertions. - Avoid repeated setup to test to test a single assertion. Write longer tests with multiple soft assertions.
### How to write a great test (WIP) ### How to write a great test (WIP)
- Use our [App Actions](./appActions.js) for performing common actions whenever applicable. - Use our [App Actions](./appActions.js) for performing common actions whenever applicable.
- Use `waitForPlotsToRender()` before asserting against anything that is dependent upon plot series data being loaded and drawn.
- If you create an object outside of using the `createDomainObjectWithDefaults` App Action, make sure to fill in the 'Notes' section of your object with `page.testNotes`: - If you create an object outside of using the `createDomainObjectWithDefaults` App Action, make sure to fill in the 'Notes' section of your object with `page.testNotes`:
```js ```js
@@ -364,16 +325,12 @@ We leverage the following official Playwright reporters:
- Tracefile - Tracefile
- Screenshots - Screenshots
When running the tests locally with the `npm run test:e2e:local` command, the html report will open automatically on failure. Inside this HTML report will be a complete summary of the finished tests. If the tests failed, you'll see embedded links to screenshot failure, execution logs, and the Tracefile. When running the tests locally with the `npm run test:local` command, the html report will open automatically on failure. Inside this HTML report will be a complete summary of the finished tests. If the tests failed, you'll see embedded links to screenshot failure, execution logs, and the Tracefile.
When looking at the reports run in CI, you'll leverage this same HTML Report which is hosted either in CircleCI or Github Actions as a build artifact. When looking at the reports run in CI, you'll leverage this same HTML Report which is hosted either in CircleCI or Github Actions as a build artifact.
### e2e Code Coverage ### e2e Code Coverage
Our e2e code coverage is captured and combined with our unit test coverage. For more information, please see our [code coverage documentation](../TESTING.md)
#### Generating e2e code coverage
Code coverage is collected during test execution using our custom [baseFixture](./baseFixtures.js). The raw coverage files are stored in a `.nyc_report` directory to be converted into a lcov file with the following [nyc](https://github.com/istanbuljs/nyc) command: Code coverage is collected during test execution using our custom [baseFixture](./baseFixtures.js). The raw coverage files are stored in a `.nyc_report` directory to be converted into a lcov file with the following [nyc](https://github.com/istanbuljs/nyc) command:
```npm run cov:e2e:report``` ```npm run cov:e2e:report```
@@ -384,6 +341,10 @@ At this point, the nyc linecov report can be published to [codecov.io](https://a
or or
```npm run cov:e2e:full:publish``` for the full suite running against all available platforms. ```npm run cov:e2e:full:publish``` for the full suite running against all available platforms.
Codecov.io will combine each of the above commands with [Codecov.io Flags](https://docs.codecov.com/docs/flags). Effectively, this allows us to combine multiple reports which are run at various stages of our CI Pipeline or run as part of a parallel process.
This e2e coverage is combined with our unit test report to give a comprehensive (if flawed) view of line coverage.
## Other ## Other
### About e2e testing ### About e2e testing

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -35,7 +35,6 @@
* @property {string} type the type of domain object to create (e.g.: "Sine Wave Generator"). * @property {string} type the type of domain object to create (e.g.: "Sine Wave Generator").
* @property {string} [name] the desired name of the created domain object. * @property {string} [name] the desired name of the created domain object.
* @property {string | import('../src/api/objects/ObjectAPI').Identifier} [parent] the Identifier or uuid of the parent object. * @property {string | import('../src/api/objects/ObjectAPI').Identifier} [parent] the Identifier or uuid of the parent object.
* @property {Object<string, string>} [customParameters] any additional parameters to be passed to the domain object's form. E.g. '[aria-label="Data Rate (hz)"]': {'0.1'}
*/ */
/** /**
@@ -56,7 +55,6 @@
const Buffer = require('buffer').Buffer; const Buffer = require('buffer').Buffer;
const genUuid = require('uuid').v4; const genUuid = require('uuid').v4;
const { expect } = require('@playwright/test');
/** /**
* This common function creates a domain object with the default options. It is the preferred way of creating objects * This common function creates a domain object with the default options. It is the preferred way of creating objects
@@ -66,69 +64,60 @@ const { expect } = require('@playwright/test');
* @param {CreateObjectOptions} options * @param {CreateObjectOptions} options
* @returns {Promise<CreatedObjectInfo>} An object containing information about the newly created domain object. * @returns {Promise<CreatedObjectInfo>} An object containing information about the newly created domain object.
*/ */
async function createDomainObjectWithDefaults( async function createDomainObjectWithDefaults(page, { type, name, parent = 'mine' }) {
page, if (!name) {
{ type, name, parent = 'mine', customParameters = {} } name = `${type}:${genUuid()}`;
) { }
if (!name) {
name = `${type}:${genUuid()}`;
}
const parentUrl = await getHashUrlToDomainObject(page, parent); const parentUrl = await getHashUrlToDomainObject(page, parent);
// Navigate to the parent object. This is necessary to create the object // Navigate to the parent object. This is necessary to create the object
// in the correct location, such as a folder, layout, or plot. // in the correct location, such as a folder, layout, or plot.
await page.goto(`${parentUrl}?hideTree=true`); await page.goto(`${parentUrl}?hideTree=true`);
await page.waitForLoadState('networkidle');
//Click the Create button //Click the Create button
await page.click('button:has-text("Create")'); await page.click('button:has-text("Create")');
// Click the object specified by 'type' // Click the object specified by 'type'
await page.click(`li[role='menuitem']:text("${type}")`); await page.click(`li[role='menuitem']:text("${type}")`);
// Modify the name input field of the domain object to accept 'name' // Modify the name input field of the domain object to accept 'name'
const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]'); const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]');
await nameInput.fill(''); await nameInput.fill("");
await nameInput.fill(name); await nameInput.fill(name);
if (page.testNotes) { if (page.testNotes) {
// Fill the "Notes" section with information about the // Fill the "Notes" section with information about the
// currently running test and its project. // currently running test and its project.
const notesInput = page.locator('form[name="mctForm"] #notes-textarea'); const notesInput = page.locator('form[name="mctForm"] #notes-textarea');
await notesInput.fill(page.testNotes); await notesInput.fill(page.testNotes);
} }
// If there are any further parameters, fill them in // Click OK button and wait for Navigate event
for (const [key, value] of Object.entries(customParameters)) { await Promise.all([
const input = page.locator(`form[name="mctForm"] ${key}`); page.waitForLoadState(),
await input.fill(''); page.click('[aria-label="Save"]'),
await input.fill(value); // Wait for Save Banner to appear
} page.waitForSelector('.c-message-banner__message')
]);
// Click OK button and wait for Navigate event // Wait until the URL is updated
await Promise.all([ await page.waitForURL(`**/${parent}/*`);
page.waitForLoadState(), const uuid = await getFocusedObjectUuid(page);
page.click('[aria-label="Save"]'), const objectUrl = await getHashUrlToDomainObject(page, uuid);
// Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message')
]);
// Wait until the URL is updated if (await _isInEditMode(page, uuid)) {
await page.waitForURL(`**/${parent}/*`); // Save (exit edit mode)
const uuid = await getFocusedObjectUuid(page); await page.locator('button[title="Save"]').click();
const objectUrl = await getHashUrlToDomainObject(page, uuid); await page.locator('li[title="Save and Finish Editing"]').click();
}
if (await _isInEditMode(page, uuid)) { return {
// Save (exit edit mode) name,
await page.locator('button[title="Save"]').click(); uuid,
await page.locator('li[title="Save and Finish Editing"]').click(); url: objectUrl
} };
return {
name,
uuid,
url: objectUrl
};
} }
/** /**
@@ -137,31 +126,28 @@ async function createDomainObjectWithDefaults(
* @param {CreateNotificationOptions} createNotificationOptions * @param {CreateNotificationOptions} createNotificationOptions
*/ */
async function createNotification(page, createNotificationOptions) { async function createNotification(page, createNotificationOptions) {
await page.evaluate((_createNotificationOptions) => { await page.evaluate((_createNotificationOptions) => {
const { message, severity, options } = _createNotificationOptions; const { message, severity, options } = _createNotificationOptions;
const notificationApi = window.openmct.notifications; const notificationApi = window.openmct.notifications;
if (severity === 'info') { if (severity === 'info') {
notificationApi.info(message, options); notificationApi.info(message, options);
} else if (severity === 'alert') { } else if (severity === 'alert') {
notificationApi.alert(message, options); notificationApi.alert(message, options);
} else { } else {
notificationApi.error(message, options); notificationApi.error(message, options);
} }
}, createNotificationOptions); }, createNotificationOptions);
} }
/** /**
* Expand an item in the tree by a given object name.
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
* @param {string} name * @param {string} name
*/ */
async function expandTreePaneItemByName(page, name) { async function expandTreePaneItemByName(page, name) {
const treePane = page.getByRole('tree', { const treePane = page.locator('#tree-pane');
name: 'Main Tree' const treeItem = treePane.locator(`role=treeitem[expanded=false][name=/${name}/]`);
}); const expandTriangle = treeItem.locator('.c-disclosure-triangle');
const treeItem = treePane.locator(`role=treeitem[expanded=false][name=/${name}/]`); await expandTriangle.click();
const expandTriangle = treeItem.locator('.c-disclosure-triangle');
await expandTriangle.click();
} }
/** /**
@@ -171,93 +157,65 @@ async function expandTreePaneItemByName(page, name) {
* @returns {Promise<CreatedObjectInfo>} An object containing information about the newly created domain object. * @returns {Promise<CreatedObjectInfo>} An object containing information about the newly created domain object.
*/ */
async function createPlanFromJSON(page, { name, json, parent = 'mine' }) { async function createPlanFromJSON(page, { name, json, parent = 'mine' }) {
if (!name) { const parentUrl = await getHashUrlToDomainObject(page, parent);
name = `Plan:${genUuid()}`;
}
const parentUrl = await getHashUrlToDomainObject(page, parent); // Navigate to the parent object. This is necessary to create the object
// in the correct location, such as a folder, layout, or plot.
await page.goto(`${parentUrl}?hideTree=true`);
// Navigate to the parent object. This is necessary to create the object //Click the Create button
// in the correct location, such as a folder, layout, or plot. await page.click('button:has-text("Create")');
await page.goto(`${parentUrl}?hideTree=true`);
// Click the Create button // Click 'Plan' menu option
await page.click('button:has-text("Create")'); await page.click(`li:text("Plan")`);
// Click 'Plan' menu option // Modify the name input field of the domain object to accept 'name'
await page.click(`li:text("Plan")`); if (name) {
const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]');
await nameInput.fill("");
await nameInput.fill(name);
}
// Modify the name input field of the domain object to accept 'name' // Upload buffer from memory
const nameInput = page.getByLabel('Title', { exact: true }); await page.locator('input#fileElem').setInputFiles({
await nameInput.fill(''); name: 'plan.txt',
await nameInput.fill(name); mimeType: 'text/plain',
buffer: Buffer.from(JSON.stringify(json))
});
// Upload buffer from memory // Click OK button and wait for Navigate event
await page.locator('input#fileElem').setInputFiles({ await Promise.all([
name: 'plan.txt', page.waitForLoadState(),
mimeType: 'text/plain', page.click('[aria-label="Save"]'),
buffer: Buffer.from(JSON.stringify(json)) // Wait for Save Banner to appear
}); page.waitForSelector('.c-message-banner__message')
]);
// Click OK button and wait for Navigate event // Wait until the URL is updated
await Promise.all([ await page.waitForURL(`**/mine/*`);
page.waitForLoadState(), const uuid = await getFocusedObjectUuid(page);
page.click('[aria-label="Save"]'), const objectUrl = await getHashUrlToDomainObject(page, uuid);
// Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message')
]);
// Wait until the URL is updated return {
await page.waitForURL(`**/${parent}/*`); uuid,
const uuid = await getFocusedObjectUuid(page); name,
const objectUrl = await getHashUrlToDomainObject(page, uuid); url: objectUrl
};
return {
uuid,
name,
url: objectUrl
};
} }
/** /**
* Open the given `domainObject`'s context menu from the object tree. * Open the given `domainObject`'s context menu from the object tree.
* Expands the path to the object and scrolls to it if necessary. * Expands the path to the object and scrolls to it if necessary.
* *
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
* @param {string} url the url to the object * @param {string} url the url to the object
*/ */
async function openObjectTreeContextMenu(page, url) { async function openObjectTreeContextMenu(page, url) {
await page.goto(url); await page.goto(url);
await page.click('button[title="Show selected item in tree"]'); await page.click('button[title="Show selected item in tree"]');
await page.locator('.is-navigated-object').click({ await page.locator('.is-navigated-object').click({
button: 'right' button: 'right'
}); });
}
/**
* Expands the entire object tree (every expandable tree item).
* @param {import('@playwright/test').Page} page
* @param {"Main Tree" | "Create Modal Tree"} [treeName="Main Tree"]
*/
async function expandEntireTree(page, treeName = 'Main Tree') {
const treeLocator = page.getByRole('tree', {
name: treeName
});
const collapsedTreeItems = treeLocator
.getByRole('treeitem', {
expanded: false
})
.locator('span.c-disclosure-triangle.is-enabled');
while ((await collapsedTreeItems.count()) > 0) {
await collapsedTreeItems.nth(0).click();
// FIXME: Replace hard wait with something event-driven.
// Without the wait, this fails periodically due to a race condition
// with Vue rendering (loop exits prematurely).
// eslint-disable-next-line playwright/no-wait-for-timeout
await page.waitForTimeout(200);
}
} }
/** /**
@@ -267,12 +225,12 @@ async function expandEntireTree(page, treeName = 'Main Tree') {
* @returns {Promise<string>} the uuid of the focused object * @returns {Promise<string>} the uuid of the focused object
*/ */
async function getFocusedObjectUuid(page) { async function getFocusedObjectUuid(page) {
const UUIDv4Regexp = /[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/gi; const UUIDv4Regexp = /[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/gi;
const focusedObjectUuid = await page.evaluate((regexp) => { const focusedObjectUuid = await page.evaluate((regexp) => {
return window.location.href.split('?')[0].match(regexp).at(-1); return window.location.href.split('?')[0].match(regexp).at(-1);
}, UUIDv4Regexp); }, UUIDv4Regexp);
return focusedObjectUuid; return focusedObjectUuid;
} }
/** /**
@@ -286,25 +244,21 @@ async function getFocusedObjectUuid(page) {
* @returns {Promise<string>} the url of the object * @returns {Promise<string>} the url of the object
*/ */
async function getHashUrlToDomainObject(page, uuid) { async function getHashUrlToDomainObject(page, uuid) {
await page.waitForLoadState('load'); //Add some determinism const hashUrl = await page.evaluate(async (objectUuid) => {
const hashUrl = await page.evaluate(async (objectUuid) => { const path = await window.openmct.objects.getOriginalPath(objectUuid);
const path = await window.openmct.objects.getOriginalPath(objectUuid); let url = './#/browse/' + [...path].reverse()
let url = .map((object) => window.openmct.objects.makeKeyString(object.identifier))
'./#/browse/' + .join('/');
[...path]
.reverse()
.map((object) => window.openmct.objects.makeKeyString(object.identifier))
.join('/');
// Drop the vestigial '/ROOT' if it exists // Drop the vestigial '/ROOT' if it exists
if (url.includes('/ROOT')) { if (url.includes('/ROOT')) {
url = url.split('/ROOT').join(''); url = url.split('/ROOT').join('');
} }
return url; return url;
}, uuid); }, uuid);
return hashUrl; return hashUrl;
} }
/** /**
@@ -314,8 +268,8 @@ async function getHashUrlToDomainObject(page, uuid) {
* @return {Promise<boolean>} true if the Open MCT is in Edit Mode * @return {Promise<boolean>} true if the Open MCT is in Edit Mode
*/ */
async function _isInEditMode(page, identifier) { async function _isInEditMode(page, identifier) {
// eslint-disable-next-line no-return-await // eslint-disable-next-line no-return-await
return await page.evaluate(() => window.openmct.editor.isEditing()); return await page.evaluate(() => window.openmct.editor.isEditing());
} }
/** /**
@@ -324,15 +278,15 @@ async function _isInEditMode(page, identifier) {
* @param {boolean} [isFixedTimespan=true] true for fixed timespan mode, false for realtime mode; default is true * @param {boolean} [isFixedTimespan=true] true for fixed timespan mode, false for realtime mode; default is true
*/ */
async function setTimeConductorMode(page, isFixedTimespan = true) { async function setTimeConductorMode(page, isFixedTimespan = true) {
// Click 'mode' button // Click 'mode' button
await page.getByRole('button', { name: 'Time Conductor Mode', exact: true }).click(); await page.locator('.c-mode-button').click();
await page.getByRole('button', { name: 'Time Conductor Mode Menu' }).click();
// Switch time conductor mode // Switch time conductor mode
if (isFixedTimespan) { if (isFixedTimespan) {
await page.getByRole('menuitem', { name: /Fixed Timespan/ }).click(); await page.locator('data-testid=conductor-modeOption-fixed').click();
} else { } else {
await page.getByRole('menuitem', { name: /Real-Time/ }).click(); await page.locator('data-testid=conductor-modeOption-realtime').click();
} }
} }
/** /**
@@ -340,7 +294,7 @@ async function setTimeConductorMode(page, isFixedTimespan = true) {
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function setFixedTimeMode(page) { async function setFixedTimeMode(page) {
await setTimeConductorMode(page, true); await setTimeConductorMode(page, true);
} }
/** /**
@@ -348,17 +302,14 @@ async function setFixedTimeMode(page) {
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function setRealTimeMode(page) { async function setRealTimeMode(page) {
await setTimeConductorMode(page, false); await setTimeConductorMode(page, false);
} }
/** /**
* @typedef {Object} OffsetValues * @typedef {Object} OffsetValues
* @property {string | undefined} startHours * @property {string | undefined} hours
* @property {string | undefined} startMins * @property {string | undefined} mins
* @property {string | undefined} startSecs * @property {string | undefined} secs
* @property {string | undefined} endHours
* @property {string | undefined} endMins
* @property {string | undefined} endSecs
*/ */
/** /**
@@ -367,36 +318,23 @@ async function setRealTimeMode(page) {
* @param {OffsetValues} offset * @param {OffsetValues} offset
* @param {import('@playwright/test').Locator} offsetButton * @param {import('@playwright/test').Locator} offsetButton
*/ */
async function setTimeConductorOffset( async function setTimeConductorOffset(page, {hours, mins, secs}, offsetButton) {
page, await offsetButton.click();
{ startHours, startMins, startSecs, endHours, endMins, endSecs }
) {
if (startHours) {
await page.getByRole('spinbutton', { name: 'Start offset hours' }).fill(startHours);
}
if (startMins) { if (hours) {
await page.getByRole('spinbutton', { name: 'Start offset minutes' }).fill(startMins); await page.fill('.pr-time-controls__hrs', hours);
} }
if (startSecs) { if (mins) {
await page.getByRole('spinbutton', { name: 'Start offset seconds' }).fill(startSecs); await page.fill('.pr-time-controls__mins', mins);
} }
if (endHours) { if (secs) {
await page.getByRole('spinbutton', { name: 'End offset hours' }).fill(endHours); await page.fill('.pr-time-controls__secs', secs);
} }
if (endMins) { // Click the check button
await page.getByRole('spinbutton', { name: 'End offset minutes' }).fill(endMins); await page.locator('.pr-time__buttons .icon-check').click();
}
if (endSecs) {
await page.getByRole('spinbutton', { name: 'End offset seconds' }).fill(endSecs);
}
// Click the check button
await page.locator('.pr-time-input--buttons .icon-check').click();
} }
/** /**
@@ -405,9 +343,8 @@ async function setTimeConductorOffset(
* @param {OffsetValues} offset * @param {OffsetValues} offset
*/ */
async function setStartOffset(page, offset) { async function setStartOffset(page, offset) {
// Click 'mode' button const startOffsetButton = page.locator('data-testid=conductor-start-offset-button');
await page.getByRole('button', { name: 'Time Conductor Mode', exact: true }).click(); await setTimeConductorOffset(page, offset, startOffsetButton);
await setTimeConductorOffset(page, offset);
} }
/** /**
@@ -416,204 +353,21 @@ async function setStartOffset(page, offset) {
* @param {OffsetValues} offset * @param {OffsetValues} offset
*/ */
async function setEndOffset(page, offset) { async function setEndOffset(page, offset) {
// Click 'mode' button const endOffsetButton = page.locator('data-testid=conductor-end-offset-button');
await page.getByRole('button', { name: 'Time Conductor Mode', exact: true }).click(); await setTimeConductorOffset(page, offset, endOffsetButton);
await setTimeConductorOffset(page, offset);
}
/**
* Set the time conductor bounds in fixed time mode
*
* NOTE: Unless explicitly testing the Time Conductor itself, it is advised to instead
* navigate directly to the object with the desired time bounds using `navigateToObjectWithFixedTimeBounds()`.
* @param {import('@playwright/test').Page} page
* @param {string} startDate
* @param {string} endDate
*/
async function setTimeConductorBounds(page, startDate, endDate) {
// Bring up the time conductor popup
expect(await page.locator('.l-shell__time-conductor.c-compact-tc').count()).toBe(1);
await page.click('.l-shell__time-conductor.c-compact-tc');
await setTimeBounds(page, startDate, endDate);
await page.keyboard.press('Enter');
}
/**
* Set the independent time conductor bounds in fixed time mode
* @param {import('@playwright/test').Page} page
* @param {string} startDate
* @param {string} endDate
*/
async function setIndependentTimeConductorBounds(page, startDate, endDate) {
// Activate Independent Time Conductor in Fixed Time Mode
await page.getByRole('switch').click();
// Bring up the time conductor popup
await page.click('.c-conductor-holder--compact .c-compact-tc');
await expect(page.locator('.itc-popout')).toBeInViewport();
await setTimeBounds(page, startDate, endDate);
await page.keyboard.press('Enter');
}
/**
* Set the bounds of the visible conductor in fixed time mode
* @param {import('@playwright/test').Page} page
* @param {string} startDate
* @param {string} endDate
*/
async function setTimeBounds(page, startDate, endDate) {
if (startDate) {
// Fill start time
await page
.getByRole('textbox', { name: 'Start date' })
.fill(startDate.toString().substring(0, 10));
await page
.getByRole('textbox', { name: 'Start time' })
.fill(startDate.toString().substring(11, 19));
}
if (endDate) {
// Fill end time
await page.getByRole('textbox', { name: 'End date' }).fill(endDate.toString().substring(0, 10));
await page
.getByRole('textbox', { name: 'End time' })
.fill(endDate.toString().substring(11, 19));
}
}
/**
* Selects an inspector tab based on the provided tab name
*
* @param {import('@playwright/test').Page} page
* @param {String} name the name of the tab
*/
async function selectInspectorTab(page, name) {
const inspectorTabs = page.getByRole('tablist');
const inspectorTab = inspectorTabs.getByTitle(name);
await inspectorTab.click();
}
/**
* Waits and asserts that all plot series data on the page
* is loaded and drawn.
*
* In lieu of a better way to detect when a plot is done rendering,
* we [attach a class to the '.gl-plot' element](https://github.com/nasa/openmct/blob/5924d7ea95a0c2d4141c602a3c7d0665cb91095f/src/plugins/plot/MctPlot.vue#L27)
* once all pending series data has been loaded. The following appAction retrieves
* all plots on the page and waits up to the default timeout for the class to be
* attached to each plot.
* @param {import('@playwright/test').Page} page
*/
async function waitForPlotsToRender(page) {
const plotLocator = page.locator('.gl-plot');
for (const plot of await plotLocator.all()) {
await expect(plot).toHaveClass(/js-series-data-loaded/);
}
}
/**
* @typedef {Object} PlotPixel
* @property {number} r The value of the red channel (0-255)
* @property {number} g The value of the green channel (0-255)
* @property {number} b The value of the blue channel (0-255)
* @property {number} a The value of the alpha channel (0-255)
* @property {string} strValue The rgba string value of the pixel
*/
/**
* Wait for all plots to render and then retrieve and return an array
* of canvas plot pixel data (RGBA values).
* @param {import('@playwright/test').Page} page
* @param {string} canvasSelector The selector for the canvas element
* @return {Promise<PlotPixel[]>}
*/
async function getCanvasPixels(page, canvasSelector) {
const getTelemValuePromise = new Promise((resolve) =>
page.exposeFunction('getCanvasValue', resolve)
);
const canvasHandle = await page.evaluateHandle(
(canvas) => document.querySelector(canvas),
canvasSelector
);
const canvasContextHandle = await page.evaluateHandle(
(canvas) => canvas.getContext('2d'),
canvasHandle
);
await waitForPlotsToRender(page);
await page.evaluate(
([canvas, ctx]) => {
// The document canvas is where the plot points and lines are drawn.
// The only way to access the canvas is using document (using page.evaluate)
/** @type {ImageData} */
const data = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
/** @type {number[]} */
const imageDataValues = Object.values(data);
/** @type {PlotPixel[]} */
const plotPixels = [];
// Each pixel consists of four values within the ImageData.data array. The for loop iterates by multiples of four.
// The values associated with each pixel are R (red), G (green), B (blue), and A (alpha), in that order.
for (let i = 0; i < imageDataValues.length; ) {
if (imageDataValues[i] > 0) {
plotPixels.push({
r: imageDataValues[i],
g: imageDataValues[i + 1],
b: imageDataValues[i + 2],
a: imageDataValues[i + 3],
strValue: `rgb(${imageDataValues[i]}, ${imageDataValues[i + 1]}, ${
imageDataValues[i + 2]
}, ${imageDataValues[i + 3]})`
});
}
i = i + 4;
}
window.getCanvasValue(plotPixels);
},
[canvasHandle, canvasContextHandle]
);
return getTelemValuePromise;
}
/**
* @param {import('@playwright/test').Page} page
* @param {string} myItemsFolderName
* @param {string} url
* @param {string} newName
*/
async function renameObjectFromContextMenu(page, url, newName) {
await openObjectTreeContextMenu(page, url);
await page.click('li:text("Edit Properties")');
const nameInput = page.getByLabel('Title', { exact: true });
await nameInput.fill('');
await nameInput.fill(newName);
await page.click('[aria-label="Save"]');
} }
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
module.exports = { module.exports = {
createDomainObjectWithDefaults, createDomainObjectWithDefaults,
createNotification, createNotification,
createPlanFromJSON, expandTreePaneItemByName,
expandEntireTree, createPlanFromJSON,
expandTreePaneItemByName, openObjectTreeContextMenu,
getCanvasPixels, getHashUrlToDomainObject,
getHashUrlToDomainObject, getFocusedObjectUuid,
getFocusedObjectUuid, setFixedTimeMode,
openObjectTreeContextMenu, setRealTimeMode,
setFixedTimeMode, setStartOffset,
setRealTimeMode, setEndOffset
setStartOffset,
setEndOffset,
setTimeConductorBounds,
setIndependentTimeConductorBounds,
selectInspectorTab,
waitForPlotsToRender,
renameObjectFromContextMenu
}; };

View File

@@ -1,6 +1,6 @@
/* eslint-disable no-undef */ /* eslint-disable no-undef */
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -29,7 +29,7 @@
*/ */
const base = require('@playwright/test'); const base = require('@playwright/test');
const { expect, request } = base; const { expect } = base;
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const { v4: uuid } = require('uuid'); const { v4: uuid } = require('uuid');
@@ -43,9 +43,9 @@ const sinon = require('sinon');
* @returns {String} formatted string with message type, text, url, and line and column numbers * @returns {String} formatted string with message type, text, url, and line and column numbers
*/ */
function _consoleMessageToString(msg) { function _consoleMessageToString(msg) {
const { url, lineNumber, columnNumber } = msg.location(); const { url, lineNumber, columnNumber } = msg.location();
return `[${msg.type()}] ${msg.text()} at (${url} ${lineNumber}:${columnNumber})`; return `[${msg.type()}] ${msg.text()} at (${url} ${lineNumber}:${columnNumber})`;
} }
/** /**
@@ -56,9 +56,12 @@ function _consoleMessageToString(msg) {
* @return {Promise<Animation[]>} * @return {Promise<Animation[]>}
*/ */
function waitForAnimations(locator) { function waitForAnimations(locator) {
return locator.evaluate((element) => return locator
Promise.all(element.getAnimations({ subtree: true }).map((animation) => animation.finished)) .evaluate((element) =>
); Promise.all(
element
.getAnimations({ subtree: true })
.map((animation) => animation.finished)));
} }
/** /**
@@ -69,115 +72,103 @@ function waitForAnimations(locator) {
const istanbulCLIOutput = path.join(process.cwd(), '.nyc_output'); const istanbulCLIOutput = path.join(process.cwd(), '.nyc_output');
exports.test = base.test.extend({ exports.test = base.test.extend({
/** /**
* This allows the test to manipulate the browser clock. This is useful for Visual and Snapshot tests which need * This allows the test to manipulate the browser clock. This is useful for Visual and Snapshot tests which need
* the Time Indicator Clock to be in a specific state. * the Time Indicator Clock to be in a specific state.
* Usage: * Usage:
* ``` * ```
* test.use({ * test.use({
* clockOptions: { * clockOptions: {
* now: 0, * now: 0,
* shouldAdvanceTime: true * shouldAdvanceTime: true
* ``` * ```
* If clockOptions are provided, will override the default clock with fake timers provided by SinonJS. * If clockOptions are provided, will override the default clock with fake timers provided by SinonJS.
* *
* Default: `undefined` * Default: `undefined`
* *
* @see {@link https://github.com/microsoft/playwright/issues/6347 Github RFE} * @see {@link https://github.com/microsoft/playwright/issues/6347 Github RFE}
* @see {@link https://github.com/sinonjs/fake-timers/#var-clock--faketimersinstallconfig SinonJS FakeTimers Config} * @see {@link https://github.com/sinonjs/fake-timers/#var-clock--faketimersinstallconfig SinonJS FakeTimers Config}
*/ */
clockOptions: [undefined, { option: true }], clockOptions: [undefined, { option: true }],
overrideClock: [ overrideClock: [async ({ context, clockOptions }, use) => {
async ({ context, clockOptions }, use) => { if (clockOptions !== undefined) {
if (clockOptions !== undefined) { await context.addInitScript({
await context.addInitScript({ path: path.join(__dirname, '../', './node_modules/sinon/pkg/sinon.js')
path: path.join(__dirname, '../', './node_modules/sinon/pkg/sinon.js') });
}); await context.addInitScript((options) => {
await context.addInitScript((options) => { window.__clock = sinon.useFakeTimers(options);
window.__clock = sinon.useFakeTimers(options); }, clockOptions);
}, clockOptions); }
}
await use(context); await use(context);
}, }, {
{ auto: true,
auto: true, scope: 'test'
scope: 'test' }],
} /**
], * Extends the base context class to add codecoverage shim.
/** * @see {@link https://github.com/mxschmitt/playwright-test-coverage Github Project}
* Extends the base context class to add codecoverage shim. */
* @see {@link https://github.com/mxschmitt/playwright-test-coverage Github Project} context: async ({ context }, use) => {
*/ await context.addInitScript(() =>
context: async ({ context }, use) => { window.addEventListener('beforeunload', () =>
await context.addInitScript(() => (window).collectIstanbulCoverage(JSON.stringify((window).__coverage__))
window.addEventListener('beforeunload', () => )
window.collectIstanbulCoverage(JSON.stringify(window.__coverage__))
)
);
await fs.promises.mkdir(istanbulCLIOutput, { recursive: true });
await context.exposeFunction('collectIstanbulCoverage', (coverageJSON) => {
if (coverageJSON) {
fs.writeFileSync(
path.join(istanbulCLIOutput, `playwright_coverage_${uuid()}.json`),
coverageJSON
); );
} await fs.promises.mkdir(istanbulCLIOutput, { recursive: true });
}); await context.exposeFunction('collectIstanbulCoverage', (coverageJSON) => {
if (coverageJSON) {
fs.writeFileSync(path.join(istanbulCLIOutput, `playwright_coverage_${uuid()}.json`), coverageJSON);
}
});
await use(context); await use(context);
for (const page of context.pages()) { for (const page of context.pages()) {
await page.evaluate(() => await page.evaluate(() => (window).collectIstanbulCoverage(JSON.stringify((window).__coverage__)));
window.collectIstanbulCoverage(JSON.stringify(window.__coverage__)) }
); },
} /**
}, * If true, will assert against any console.error calls that occur during the test. Assertions occur
/** * during test teardown (after the test has completed).
* If true, will assert against any console.error calls that occur during the test. Assertions occur *
* during test teardown (after the test has completed). * Default: `true`
* */
* Default: `true` failOnConsoleError: [true, { option: true }],
*/ /**
failOnConsoleError: [true, { option: true }], * Extends the base page class to enable console log error detection.
/** * @see {@link https://github.com/microsoft/playwright/discussions/11690 Github Discussion}
* Extends the base page class to enable console log error detection. */
* @see {@link https://github.com/microsoft/playwright/discussions/11690 Github Discussion} page: async ({ page, failOnConsoleError }, use) => {
*/ // Capture any console errors during test execution
page: async ({ page, failOnConsoleError }, use) => { const messages = [];
// Capture any console errors during test execution page.on('console', (msg) => messages.push(msg));
const messages = [];
page.on('console', (msg) => messages.push(msg));
await use(page); await use(page);
// Assert against console errors during teardown // Assert against console errors during teardown
if (failOnConsoleError) { if (failOnConsoleError) {
messages.forEach((msg) => messages.forEach(
expect msg => expect.soft(msg.type(), `Console error detected: ${_consoleMessageToString(msg)}`).not.toEqual('error')
.soft(msg.type(), `Console error detected: ${_consoleMessageToString(msg)}`) );
.not.toEqual('error') }
); },
/**
* Extends the base browser class to enable CDP connection definition in playwright.config.js. Once
* that RFE is implemented, this function can be removed.
* @see {@link https://github.com/microsoft/playwright/issues/8379 Github RFE}
*/
browser: async ({ playwright, browser }, use, workerInfo) => {
// Use browserless if configured
if (workerInfo.project.name.match(/browserless/)) {
const vBrowser = await playwright.chromium.connectOverCDP({
endpointURL: 'ws://localhost:3003'
});
await use(vBrowser);
} else {
// Use Local Browser for testing.
await use(browser);
}
} }
},
/**
* Extends the base browser class to enable CDP connection definition in playwright.config.js. Once
* that RFE is implemented, this function can be removed.
* @see {@link https://github.com/microsoft/playwright/issues/8379 Github RFE}
*/
browser: async ({ playwright, browser }, use, workerInfo) => {
// Use browserless if configured
if (workerInfo.project.name.match(/browserless/)) {
const vBrowser = await playwright.chromium.connectOverCDP({
endpointURL: 'ws://localhost:3003'
});
await use(vBrowser);
} else {
// Use Local Browser for testing.
await use(browser);
}
}
}); });
exports.expect = expect; exports.expect = expect;
exports.request = request;
exports.waitForAnimations = waitForAnimations; exports.waitForAnimations = waitForAnimations;

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -23,6 +23,6 @@
// This should be used to install the Example Fault Provider, this will also install the FaultManagementPlugin (neither of which are installed by default). // This should be used to install the Example Fault Provider, this will also install the FaultManagementPlugin (neither of which are installed by default).
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
const openmct = window.openmct; const openmct = window.openmct;
openmct.install(openmct.plugins.example.ExampleFaultSource()); openmct.install(openmct.plugins.example.ExampleFaultSource());
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -23,8 +23,8 @@
// This should be used to install the Example Fault Provider, this will also install the FaultManagementPlugin (neither of which are installed by default). // This should be used to install the Example Fault Provider, this will also install the FaultManagementPlugin (neither of which are installed by default).
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
const openmct = window.openmct; const openmct = window.openmct;
const staticFaults = true; const staticFaults = true;
openmct.install(openmct.plugins.example.ExampleFaultSource(staticFaults)); openmct.install(openmct.plugins.example.ExampleFaultSource(staticFaults));
}); });

View File

@@ -1,27 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
// This should be used to install the Example User
document.addEventListener('DOMContentLoaded', () => {
const openmct = window.openmct;
openmct.install(openmct.plugins.example.ExampleUser());
});

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -23,6 +23,6 @@
// This should be used to install the Example Fault Provider, this will also install the FaultManagementPlugin (neither of which are installed by default). // This should be used to install the Example Fault Provider, this will also install the FaultManagementPlugin (neither of which are installed by default).
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
const openmct = window.openmct; const openmct = window.openmct;
openmct.install(openmct.plugins.FaultManagement()); openmct.install(openmct.plugins.FaultManagement());
}); });

View File

@@ -1,71 +1,76 @@
class DomainObjectViewProvider { class DomainObjectViewProvider {
constructor(openmct) { constructor(openmct) {
this.key = 'doViewProvider'; this.key = 'doViewProvider';
this.name = 'Domain Object View Provider'; this.name = 'Domain Object View Provider';
this.openmct = openmct; this.openmct = openmct;
} }
canView(domainObject) { canView(domainObject) {
return domainObject.type === 'imageFileInput' || domainObject.type === 'jsonFileInput'; return domainObject.type === 'imageFileInput'
} || domainObject.type === 'jsonFileInput';
}
view(domainObject, objectPath) { view(domainObject, objectPath) {
let content; let content;
return { return {
show: function (element) { show: function (element) {
const body = domainObject.selectFile.body; const body = domainObject.selectFile.body;
const type = typeof body; const type = typeof body;
content = document.createElement('div'); content = document.createElement('div');
content.id = 'file-input-type'; content.id = 'file-input-type';
content.textContent = JSON.stringify(type); content.textContent = JSON.stringify(type);
element.appendChild(content); element.appendChild(content);
}, },
destroy: function (element) { destroy: function (element) {
element.removeChild(content); element.removeChild(content);
content = undefined; content = undefined;
} }
}; };
} }
} }
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
const openmct = window.openmct; const openmct = window.openmct;
openmct.types.addType('jsonFileInput', { openmct.types.addType('jsonFileInput', {
key: 'jsonFileInput', key: 'jsonFileInput',
name: 'JSON File Input Object', name: "JSON File Input Object",
creatable: true, creatable: true,
form: [ form: [
{ {
name: 'Upload File', name: 'Upload File',
key: 'selectFile', key: 'selectFile',
control: 'file-input', control: 'file-input',
required: true, required: true,
text: 'Select File...', text: 'Select File...',
type: 'application/json', type: 'application/json',
property: ['selectFile'] property: [
} "selectFile"
] ]
}); }
]
});
openmct.types.addType('imageFileInput', { openmct.types.addType('imageFileInput', {
key: 'imageFileInput', key: 'imageFileInput',
name: 'Image File Input Object', name: "Image File Input Object",
creatable: true, creatable: true,
form: [ form: [
{ {
name: 'Upload File', name: 'Upload File',
key: 'selectFile', key: 'selectFile',
control: 'file-input', control: 'file-input',
required: true, required: true,
text: 'Select File...', text: 'Select File...',
type: 'image/*', type: 'image/*',
property: ['selectFile'] property: [
} "selectFile"
] ]
}); }
]
});
openmct.objectViews.addProvider(new DomainObjectViewProvider(openmct)); openmct.objectViews.addProvider(new DomainObjectViewProvider(openmct));
}); });

View File

@@ -1,32 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
// This should be used to install the re-instal default Notebook plugin with a simple url whitelist.
// e.g.
// await page.addInitScript({ path: path.join(__dirname, 'addInitNotebookWithUrls.js') });
const NOTEBOOK_NAME = 'Notebook';
const URL_WHITELIST = ['google.com'];
document.addEventListener('DOMContentLoaded', () => {
const openmct = window.openmct;
openmct.install(openmct.plugins.Notebook(NOTEBOOK_NAME, URL_WHITELIST));
});

View File

@@ -1,27 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
// This should be used to install the Operator Status
document.addEventListener('DOMContentLoaded', () => {
const openmct = window.openmct;
openmct.install(openmct.plugins.OperatorStatus());
});

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -25,6 +25,6 @@
// await page.addInitScript({ path: path.join(__dirname, 'addInitRestrictedNotebook.js') }); // await page.addInitScript({ path: path.join(__dirname, 'addInitRestrictedNotebook.js') });
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
const openmct = window.openmct; const openmct = window.openmct;
openmct.install(openmct.plugins.RestrictedNotebook('CUSTOM_NAME')); openmct.install(openmct.plugins.RestrictedNotebook('CUSTOM_NAME'));
}); });

View File

@@ -1,27 +1,27 @@
(function () { (function () {
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
const PERSISTENCE_KEY = 'persistence-tests'; const PERSISTENCE_KEY = 'persistence-tests';
const openmct = window.openmct; const openmct = window.openmct;
openmct.objects.addRoot({ openmct.objects.addRoot({
namespace: PERSISTENCE_KEY, namespace: PERSISTENCE_KEY,
key: PERSISTENCE_KEY key: PERSISTENCE_KEY
}); });
openmct.objects.addProvider(PERSISTENCE_KEY, { openmct.objects.addProvider(PERSISTENCE_KEY, {
get(identifier) { get(identifier) {
if (identifier.key !== PERSISTENCE_KEY) { if (identifier.key !== PERSISTENCE_KEY) {
return undefined; return undefined;
} else { } else {
return Promise.resolve({ return Promise.resolve({
identifier, identifier,
type: 'folder', type: 'folder',
name: 'Persistence Testing', name: 'Persistence Testing',
location: 'ROOT', location: 'ROOT',
composition: [] composition: []
}); });
} }
} }
});
}); });
}); }());
})();

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -19,275 +19,259 @@
* this source code distribution or the Licensing information page available * this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
/* global __dirname */
const path = require('path'); const path = require('path');
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function navigateToFaultManagementWithExample(page) { async function navigateToFaultManagementWithExample(page) {
await page.addInitScript({ path: path.join(__dirname, './', 'addInitExampleFaultProvider.js') }); // eslint-disable-next-line no-undef
await page.addInitScript({ path: path.join(__dirname, './', 'addInitExampleFaultProvider.js') });
await navigateToFaultItemInTree(page); await navigateToFaultItemInTree(page);
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function navigateToFaultManagementWithStaticExample(page) { async function navigateToFaultManagementWithStaticExample(page) {
await page.addInitScript({ // eslint-disable-next-line no-undef
path: path.join(__dirname, './', 'addInitExampleFaultProviderStatic.js') await page.addInitScript({ path: path.join(__dirname, './', 'addInitExampleFaultProviderStatic.js') });
});
await navigateToFaultItemInTree(page); await navigateToFaultItemInTree(page);
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function navigateToFaultManagementWithoutExample(page) { async function navigateToFaultManagementWithoutExample(page) {
await page.addInitScript({ path: path.join(__dirname, './', 'addInitFaultManagementPlugin.js') }); // eslint-disable-next-line no-undef
await page.addInitScript({ path: path.join(__dirname, './', 'addInitFaultManagementPlugin.js') });
await navigateToFaultItemInTree(page); await navigateToFaultItemInTree(page);
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function navigateToFaultItemInTree(page) { async function navigateToFaultItemInTree(page) {
await page.goto('./', { waitUntil: 'networkidle' }); await page.goto('./', { waitUntil: 'networkidle' });
const faultManagementTreeItem = page // Click text=Fault Management
.getByRole('tree', { await page.click('text=Fault Management'); // this verifies the plugin has been added
name: 'Main Tree'
})
.getByRole('treeitem', {
name: 'Fault Management'
});
// Navigate to "Fault Management" from the tree
await faultManagementTreeItem.click();
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function acknowledgeFault(page, rowNumber) { async function acknowledgeFault(page, rowNumber) {
await openFaultRowMenu(page, rowNumber); await openFaultRowMenu(page, rowNumber);
await page.locator('.c-menu >> text="Acknowledge"').click(); await page.locator('.c-menu >> text="Acknowledge"').click();
// Click [aria-label="Save"] // Click [aria-label="Save"]
await page.locator('[aria-label="Save"]').click(); await page.locator('[aria-label="Save"]').click();
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function shelveMultipleFaults(page, ...nums) { async function shelveMultipleFaults(page, ...nums) {
const selectRows = nums.map((num) => { const selectRows = nums.map((num) => {
return selectFaultItem(page, num); return selectFaultItem(page, num);
}); });
await Promise.all(selectRows); await Promise.all(selectRows);
await page.locator('button:has-text("Shelve")').click(); await page.locator('button:has-text("Shelve")').click();
await page.locator('[aria-label="Save"]').click(); await page.locator('[aria-label="Save"]').click();
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function acknowledgeMultipleFaults(page, ...nums) { async function acknowledgeMultipleFaults(page, ...nums) {
const selectRows = nums.map((num) => { const selectRows = nums.map((num) => {
return selectFaultItem(page, num); return selectFaultItem(page, num);
}); });
await Promise.all(selectRows); await Promise.all(selectRows);
await page.locator('button:has-text("Acknowledge")').click(); await page.locator('button:has-text("Acknowledge")').click();
await page.locator('[aria-label="Save"]').click(); await page.locator('[aria-label="Save"]').click();
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function shelveFault(page, rowNumber) { async function shelveFault(page, rowNumber) {
await openFaultRowMenu(page, rowNumber); await openFaultRowMenu(page, rowNumber);
await page.locator('.c-menu >> text="Shelve"').click(); await page.locator('.c-menu >> text="Shelve"').click();
// Click [aria-label="Save"] // Click [aria-label="Save"]
await page.locator('[aria-label="Save"]').click(); await page.locator('[aria-label="Save"]').click();
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function changeViewTo(page, view) { async function changeViewTo(page, view) {
await page.locator('.c-fault-mgmt__search-row select').first().selectOption(view); await page.locator('.c-fault-mgmt__search-row select').first().selectOption(view);
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function sortFaultsBy(page, sort) { async function sortFaultsBy(page, sort) {
await page.locator('.c-fault-mgmt__list-header-sortButton select').selectOption(sort); await page.locator('.c-fault-mgmt__list-header-sortButton select').selectOption(sort);
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function enterSearchTerm(page, term) { async function enterSearchTerm(page, term) {
await page.locator('.c-fault-mgmt-search [aria-label="Search Input"]').fill(term); await page.locator('.c-fault-mgmt-search [aria-label="Search Input"]').fill(term);
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function clearSearch(page) { async function clearSearch(page) {
await enterSearchTerm(page, ''); await enterSearchTerm(page, '');
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function selectFaultItem(page, rowNumber) { async function selectFaultItem(page, rowNumber) {
await page.locator(`.c-fault-mgmt-item > input >> nth=${rowNumber - 1}`).check(); // eslint-disable-next-line playwright/no-force-option
await page.check(`.c-fault-mgmt-item > input >> nth=${rowNumber - 1}`, { force: true }); // this will not work without force true, saw this may be a pw bug
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function getHighestSeverity(page) { async function getHighestSeverity(page) {
const criticalCount = await page.locator('[title=CRITICAL]').count(); const criticalCount = await page.locator('[title=CRITICAL]').count();
const warningCount = await page.locator('[title=WARNING]').count(); const warningCount = await page.locator('[title=WARNING]').count();
if (criticalCount > 0) { if (criticalCount > 0) {
return 'CRITICAL'; return 'CRITICAL';
} else if (warningCount > 0) { } else if (warningCount > 0) {
return 'WARNING'; return 'WARNING';
} }
return 'WATCH'; return 'WATCH';
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function getLowestSeverity(page) { async function getLowestSeverity(page) {
const warningCount = await page.locator('[title=WARNING]').count(); const warningCount = await page.locator('[title=WARNING]').count();
const watchCount = await page.locator('[title=WATCH]').count(); const watchCount = await page.locator('[title=WATCH]').count();
if (watchCount > 0) { if (watchCount > 0) {
return 'WATCH'; return 'WATCH';
} else if (warningCount > 0) { } else if (warningCount > 0) {
return 'WARNING'; return 'WARNING';
} }
return 'CRITICAL'; return 'CRITICAL';
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function getFaultResultCount(page) { async function getFaultResultCount(page) {
const count = await page.locator('.c-faults-list-view-item-body > .c-fault-mgmt__list').count(); const count = await page.locator('.c-faults-list-view-item-body > .c-fault-mgmt__list').count();
return count; return count;
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
function getFault(page, rowNumber) { function getFault(page, rowNumber) {
const fault = page.locator( const fault = page.locator(`.c-faults-list-view-item-body > .c-fault-mgmt__list >> nth=${rowNumber - 1}`);
`.c-faults-list-view-item-body > .c-fault-mgmt__list >> nth=${rowNumber - 1}`
);
return fault; return fault;
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
function getFaultByName(page, name) { function getFaultByName(page, name) {
const fault = page.locator(`.c-fault-mgmt__list-faultname:has-text("${name}")`); const fault = page.locator(`.c-fault-mgmt__list-faultname:has-text("${name}")`);
return fault; return fault;
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function getFaultName(page, rowNumber) { async function getFaultName(page, rowNumber) {
const faultName = await page const faultName = await page.locator(`.c-fault-mgmt__list-faultname >> nth=${rowNumber - 1}`).textContent();
.locator(`.c-fault-mgmt__list-faultname >> nth=${rowNumber - 1}`)
.textContent();
return faultName; return faultName;
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function getFaultSeverity(page, rowNumber) { async function getFaultSeverity(page, rowNumber) {
const faultSeverity = await page const faultSeverity = await page.locator(`.c-faults-list-view-item-body .c-fault-mgmt__list-severity >> nth=${rowNumber - 1}`).getAttribute('title');
.locator(`.c-faults-list-view-item-body .c-fault-mgmt__list-severity >> nth=${rowNumber - 1}`)
.getAttribute('title');
return faultSeverity; return faultSeverity;
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function getFaultNamespace(page, rowNumber) { async function getFaultNamespace(page, rowNumber) {
const faultNamespace = await page const faultNamespace = await page.locator(`.c-fault-mgmt__list-path >> nth=${rowNumber - 1}`).textContent();
.locator(`.c-fault-mgmt__list-path >> nth=${rowNumber - 1}`)
.textContent();
return faultNamespace; return faultNamespace;
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function getFaultTriggerTime(page, rowNumber) { async function getFaultTriggerTime(page, rowNumber) {
const faultTriggerTime = await page const faultTriggerTime = await page.locator(`.c-fault-mgmt__list-trigTime >> nth=${rowNumber - 1} >> .c-fault-mgmt-item__value`).textContent();
.locator(`.c-fault-mgmt__list-trigTime >> nth=${rowNumber - 1} >> .c-fault-mgmt-item__value`)
.textContent();
return faultTriggerTime.toString().trim(); return faultTriggerTime.toString().trim();
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function openFaultRowMenu(page, rowNumber) { async function openFaultRowMenu(page, rowNumber) {
// select // select
await page await page.locator(`.c-fault-mgmt-item > .c-fault-mgmt__list-action-button >> nth=${rowNumber - 1}`).click();
.locator(`.c-fault-mgmt-item > .c-fault-mgmt__list-action-button >> nth=${rowNumber - 1}`)
.click();
} }
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
module.exports = { module.exports = {
navigateToFaultManagementWithExample, navigateToFaultManagementWithExample,
navigateToFaultManagementWithStaticExample, navigateToFaultManagementWithStaticExample,
navigateToFaultManagementWithoutExample, navigateToFaultManagementWithoutExample,
navigateToFaultItemInTree, navigateToFaultItemInTree,
acknowledgeFault, acknowledgeFault,
shelveMultipleFaults, shelveMultipleFaults,
acknowledgeMultipleFaults, acknowledgeMultipleFaults,
shelveFault, shelveFault,
changeViewTo, changeViewTo,
sortFaultsBy, sortFaultsBy,
enterSearchTerm, enterSearchTerm,
clearSearch, clearSearch,
selectFaultItem, selectFaultItem,
getHighestSeverity, getHighestSeverity,
getLowestSeverity, getLowestSeverity,
getFaultResultCount, getFaultResultCount,
getFault, getFault,
getFaultByName, getFaultByName,
getFaultName, getFaultName,
getFaultSeverity, getFaultSeverity,
getFaultNamespace, getFaultNamespace,
getFaultTriggerTime, getFaultTriggerTime,
openFaultRowMenu openFaultRowMenu
}; };

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -28,42 +28,33 @@ const NOTEBOOK_DROP_AREA = '.c-notebook__drag-area';
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function enterTextEntry(page, text) { async function enterTextEntry(page, text) {
// Click the 'Add Notebook Entry' area // Click .c-notebook__drag-area
await page.locator(NOTEBOOK_DROP_AREA).click(); await page.locator(NOTEBOOK_DROP_AREA).click();
// enter text // enter text
await page.locator('[aria-label="Notebook Entry"].is-selected div.c-ne__text').fill(text); await page.locator('div.c-ne__text').click();
await commitEntry(page); await page.locator('div.c-ne__text').fill(text);
await page.locator('div.c-ne__text').press('Enter');
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function dragAndDropEmbed(page, notebookObject) { async function dragAndDropEmbed(page, notebookObject) {
// Create example telemetry object // Create example telemetry object
const swg = await createDomainObjectWithDefaults(page, { const swg = await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator' type: "Sine Wave Generator"
}); });
// Navigate to notebook // Navigate to notebook
await page.goto(notebookObject.url); await page.goto(notebookObject.url);
// Expand the tree to reveal the notebook // Expand the tree to reveal the notebook
await page.click('button[title="Show selected item in tree"]'); await page.click('button[title="Show selected item in tree"]');
// Drag and drop the SWG into the notebook // Drag and drop the SWG into the notebook
await page.dragAndDrop(`text=${swg.name}`, NOTEBOOK_DROP_AREA); await page.dragAndDrop(`text=${swg.name}`, NOTEBOOK_DROP_AREA);
await commitEntry(page);
}
/**
* @private
* @param {import('@playwright/test').Page} page
*/
async function commitEntry(page) {
//Click the Commit Entry button
await page.locator('.c-ne__save-button > button').click();
} }
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
module.exports = { module.exports = {
enterTextEntry, enterTextEntry,
dragAndDropEmbed dragAndDropEmbed
}; };

View File

@@ -1,101 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import { expect } from '../pluginFixtures';
/**
* Asserts that the number of activities in the plan view matches the number of
* activities in the plan data within the specified time bounds. Performs an assertion
* for each activity in the plan data per group, using the earliest activity's
* start time as the start bound and the current activity's end time as the end bound.
* @param {import('@playwright/test').Page} page the page
* @param {object} plan The raw plan json to assert against
* @param {string} objectUrl The URL of the object to assert against (plan or gantt chart)
*/
export async function assertPlanActivities(page, plan, objectUrl) {
const groups = Object.keys(plan);
for (const group of groups) {
for (let i = 0; i < plan[group].length; i++) {
// Set the startBound to the start time of the first activity in the group
const startBound = plan[group][0].start;
// Set the endBound to the end time of the current activity
let endBound = plan[group][i].end;
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(
`${objectUrl}?tc.mode=fixed&tc.startBound=${startBound}&tc.endBound=${endBound}&tc.timeSystem=utc&view=plan.view`
);
// Assert that the number of activities in the plan view matches the number of
// activities in the plan data within the specified time bounds
const eventCount = await page.locator('.activity-bounds').count();
expect(eventCount).toEqual(
Object.values(plan)
.flat()
.filter((event) =>
activitiesWithinTimeBounds(event.start, event.end, startBound, endBound)
).length
);
}
}
}
/**
* Returns true if the activities time bounds overlap, false otherwise.
* @param {number} start1 the start time of the first activity
* @param {number} end1 the end time of the first activity
* @param {number} start2 the start time of the second activity
* @param {number} end2 the end time of the second activity
* @returns {boolean} true if the activities overlap, false otherwise
*/
function activitiesWithinTimeBounds(start1, end1, start2, end2) {
return (
(start1 >= start2 && start1 <= end2) ||
(end1 >= start2 && end1 <= end2) ||
(start2 >= start1 && start2 <= end1) ||
(end2 >= start1 && end2 <= end1)
);
}
/**
* Navigate to the plan view, switch to fixed time mode,
* and set the bounds to span all activities.
* @param {import('@playwright/test').Page} page
* @param {object} planJson
* @param {string} planObjectUrl
*/
export async function setBoundsToSpanAllActivities(page, planJson, planObjectUrl) {
const activities = Object.values(planJson).flat();
// Get the earliest start value
const start = Math.min(...activities.map((activity) => activity.start));
// Get the latest end value
const end = Math.max(...activities.map((activity) => activity.end));
// Set the start and end bounds to the earliest start and latest end
await page.goto(
`${planObjectUrl}?tc.mode=fixed&tc.startBound=${start}&tc.endBound=${end}&tc.timeSystem=utc&view=plan.view`
);
}

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -25,6 +25,6 @@
// await page.addInitScript({ path: path.join(__dirname, 'useSnowTheme.js') }); // await page.addInitScript({ path: path.join(__dirname, 'useSnowTheme.js') });
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
const openmct = window.openmct; const openmct = window.openmct;
openmct.install(openmct.plugins.Snow()); openmct.install(openmct.plugins.Snow());
}); });

View File

@@ -9,76 +9,73 @@ const NUM_WORKERS = 2;
/** @type {import('@playwright/test').PlaywrightTestConfig} */ /** @type {import('@playwright/test').PlaywrightTestConfig} */
const config = { 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 retries: 2, //Retries 2 times for a total of 3 runs. When running sharded and with maxFailures = 5, this should ensure that flake is managed without failing the full suite
testDir: 'tests', testDir: 'tests',
testIgnore: '**/*.perf.spec.js', //Ignore performance tests and define in playwright-perfromance.config.js testIgnore: '**/*.perf.spec.js', //Ignore performance tests and define in playwright-perfromance.config.js
timeout: 60 * 1000, timeout: 60 * 1000,
webServer: { webServer: {
command: 'npm run start:coverage', command: 'npm run start:coverage',
url: 'http://localhost:8080/#', url: 'http://localhost:8080/#',
timeout: 200 * 1000, timeout: 200 * 1000,
reuseExistingServer: false reuseExistingServer: false
},
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: 'chrome',
testMatch: '**/*.e2e.spec.js', // only run e2e tests
use: {
browserName: 'chromium'
}
}, },
{ maxFailures: MAX_FAILURES, //Limits failures to 5 to reduce CI Waste
name: 'MMOC', workers: NUM_WORKERS, //Limit to 2 for CircleCI Agent
testMatch: '**/*.e2e.spec.js', // only run e2e tests use: {
grepInvert: /@snapshot/, baseURL: 'http://localhost:8080/',
use: { headless: true,
browserName: 'chromium', ignoreHTTPSErrors: true,
viewport: { screenshot: 'only-on-failure',
width: 2560, trace: 'on-first-retry',
height: 1440 video: 'off'
},
projects: [
{
name: 'chrome',
testMatch: '**/*.e2e.spec.js', // only run e2e tests
use: {
browserName: 'chromium'
}
},
{
name: 'MMOC',
testMatch: '**/*.e2e.spec.js', // only run e2e tests
grepInvert: /@snapshot/,
use: {
browserName: 'chromium',
viewport: {
width: 2560,
height: 1440
}
}
},
{
name: 'firefox',
testMatch: '**/*.e2e.spec.js', // only run e2e tests
grepInvert: /@snapshot/,
use: {
browserName: 'firefox'
}
},
{
name: 'chrome-beta', //Only Chrome Beta is available on ubuntu -- not chrome canary
testMatch: '**/*.e2e.spec.js', // only run e2e tests
grepInvert: /@snapshot/,
use: {
browserName: 'chromium',
channel: 'chrome-beta'
}
} }
}
},
{
name: 'firefox',
testMatch: '**/*.e2e.spec.js', // only run e2e tests
grepInvert: /@snapshot/,
use: {
browserName: 'firefox'
}
},
{
name: 'chrome-beta', //Only Chrome Beta is available on ubuntu -- not chrome canary
testMatch: '**/*.e2e.spec.js', // only run e2e tests
grepInvert: /@snapshot/,
use: {
browserName: 'chromium',
channel: 'chrome-beta'
}
}
],
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' }], reporter: [
['@deploysentinel/playwright'] ['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' }],
['github']
]
}; };
module.exports = config; module.exports = config;

View File

@@ -7,101 +7,98 @@ const { devices } = require('@playwright/test');
/** @type {import('@playwright/test').PlaywrightTestConfig} */ /** @type {import('@playwright/test').PlaywrightTestConfig} */
const config = { const config = {
retries: 0, retries: 0,
testDir: 'tests', testDir: 'tests',
testIgnore: '**/*.perf.spec.js', testIgnore: '**/*.perf.spec.js',
timeout: 30 * 1000, timeout: 30 * 1000,
webServer: { webServer: {
command: 'npm run start:coverage', command: 'npm run start:coverage',
url: 'http://localhost:8080/#', url: 'http://localhost:8080/#',
timeout: 120 * 1000, timeout: 120 * 1000,
reuseExistingServer: true reuseExistingServer: true
},
workers: 1,
use: {
browserName: 'chromium',
baseURL: 'http://localhost:8080/',
headless: false,
ignoreHTTPSErrors: true,
screenshot: 'only-on-failure',
trace: 'retain-on-failure',
video: 'off'
},
projects: [
{
name: 'chrome',
use: {
browserName: 'chromium'
}
}, },
{ workers: 1,
name: 'MMOC', use: {
testMatch: '**/*.e2e.spec.js', // only run e2e tests browserName: "chromium",
grepInvert: /@snapshot/, baseURL: 'http://localhost:8080/',
use: { headless: false,
browserName: 'chromium', ignoreHTTPSErrors: true,
viewport: { screenshot: 'only-on-failure',
width: 2560, trace: 'retain-on-failure',
height: 1440 video: 'off'
},
projects: [
{
name: 'chrome',
use: {
browserName: 'chromium'
}
},
{
name: 'MMOC',
testMatch: '**/*.e2e.spec.js', // only run e2e tests
grepInvert: /@snapshot/,
use: {
browserName: 'chromium',
viewport: {
width: 2560,
height: 1440
}
}
},
{
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'
}
},
{
name: 'firefox',
testMatch: '**/*.e2e.spec.js', // only run e2e tests
grepInvert: /@snapshot/,
use: {
browserName: 'firefox'
}
},
{
name: 'canary',
testMatch: '**/*.e2e.spec.js', // only run e2e tests
grepInvert: /@snapshot/,
use: {
browserName: 'chromium',
channel: 'chrome-canary' //Note this is not available in ubuntu/CircleCI
}
},
{
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: [
{ ['list'],
name: 'safari', ['html', {
testMatch: '**/*.e2e.spec.js', // only run e2e tests open: 'on-failure',
grep: /@ipad/, // only run ipad tests due to this bug https://github.com/microsoft/playwright/issues/8340 outputFolder: '../html-test-results' //Must be in different location due to https://github.com/microsoft/playwright/issues/12840
grepInvert: /@snapshot/, }]
use: {
browserName: 'webkit'
}
},
{
name: 'firefox',
testMatch: '**/*.e2e.spec.js', // only run e2e tests
grepInvert: /@snapshot/,
use: {
browserName: 'firefox'
}
},
{
name: 'canary',
testMatch: '**/*.e2e.spec.js', // only run e2e tests
grepInvert: /@snapshot/,
use: {
browserName: 'chromium',
channel: 'chrome-canary' //Note this is not available in ubuntu/CircleCI
}
},
{
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: [
['list'],
[
'html',
{
open: 'on-failure',
outputFolder: '../html-test-results' //Must be in different location due to https://github.com/microsoft/playwright/issues/12840
}
] ]
]
}; };
module.exports = config; module.exports = config;

View File

@@ -6,38 +6,38 @@ const CI = process.env.CI === 'true';
/** @type {import('@playwright/test').PlaywrightTestConfig} */ /** @type {import('@playwright/test').PlaywrightTestConfig} */
const config = { const config = {
retries: 1, //Only for debugging purposes for trace: 'on-first-retry' retries: 1, //Only for debugging purposes for trace: 'on-first-retry'
testDir: 'tests/performance/', testDir: 'tests/performance/',
timeout: 60 * 1000, timeout: 60 * 1000,
workers: 1, //Only run in serial with 1 worker workers: 1, //Only run in serial with 1 worker
webServer: { webServer: {
command: 'npm run start', //coverage not generated command: 'npm run start', //coverage not generated
url: 'http://localhost:8080/#', url: 'http://localhost:8080/#',
timeout: 200 * 1000, timeout: 200 * 1000,
reuseExistingServer: !CI reuseExistingServer: !CI
}, },
use: { use: {
browserName: 'chromium', browserName: "chromium",
baseURL: 'http://localhost:8080/', baseURL: 'http://localhost:8080/',
headless: CI, //Only if running locally headless: CI, //Only if running locally
ignoreHTTPSErrors: true, ignoreHTTPSErrors: true,
screenshot: 'off', screenshot: 'off',
trace: 'on-first-retry', trace: 'on-first-retry',
video: 'off' video: 'off'
}, },
projects: [ projects: [
{ {
name: 'chrome', name: 'chrome',
use: { use: {
browserName: 'chromium' browserName: 'chromium'
} }
} }
], ],
reporter: [ reporter: [
['list'], ['list'],
['junit', { outputFile: '../test-results/results.xml' }], ['junit', { outputFile: 'test-results/results.xml' }],
['json', { outputFile: '../test-results/results.json' }] ['json', { outputFile: 'test-results/results.json' }]
] ]
}; };
module.exports = config; module.exports = config;

View File

@@ -4,51 +4,48 @@
/** @type {import('@playwright/test').PlaywrightTestConfig<{ theme: string }>} */ /** @type {import('@playwright/test').PlaywrightTestConfig<{ theme: string }>} */
const config = { const config = {
retries: 0, // Visual tests should never retry due to snapshot comparison errors. Leaving as a shim retries: 0, // Visual tests should never retry due to snapshot comparison errors. Leaving as a shim
testDir: 'tests/visual', testDir: 'tests/visual',
testMatch: '**/*.visual.spec.js', // only run visual tests testMatch: '**/*.visual.spec.js', // only run visual tests
timeout: 60 * 1000, timeout: 60 * 1000,
workers: 1, //Lower stress on Circle CI Agent for Visual tests https://github.com/percy/cli/discussions/1067 workers: 1, //Lower stress on Circle CI Agent for Visual tests https://github.com/percy/cli/discussions/1067
webServer: { webServer: {
command: 'npm run start:coverage', command: 'npm run start:coverage',
url: 'http://localhost:8080/#', url: 'http://localhost:8080/#',
timeout: 200 * 1000, timeout: 200 * 1000,
reuseExistingServer: !process.env.CI reuseExistingServer: !process.env.CI
},
use: {
baseURL: 'http://localhost:8080/',
headless: true, // this needs to remain headless to avoid visual changes due to GPU rendering in headed browsers
ignoreHTTPSErrors: true,
screenshot: 'only-on-failure',
trace: 'on-first-retry',
video: 'off'
},
projects: [
{
name: 'chrome',
use: {
browserName: 'chromium'
}
}, },
{ use: {
name: 'chrome-snow-theme', //Runs the same visual tests but with snow-theme enabled baseURL: 'http://localhost:8080/',
use: { headless: true, // this needs to remain headless to avoid visual changes due to GPU rendering in headed browsers
browserName: 'chromium', ignoreHTTPSErrors: true,
theme: 'snow' screenshot: 'only-on-failure',
} trace: 'on-first-retry',
} video: 'off'
], },
reporter: [ projects: [
['list'], {
['junit', { outputFile: '../test-results/results.xml' }], name: 'chrome',
[ use: {
'html', browserName: 'chromium'
{ }
open: 'on-failure', },
outputFolder: '../html-test-results' //Must be in different location due to https://github.com/microsoft/playwright/issues/12840 {
} name: 'chrome-snow-theme', //Runs the same visual tests but with snow-theme enabled
use: {
browserName: 'chromium',
theme: 'snow'
}
}
],
reporter: [
['list'],
['junit', { outputFile: 'test-results/results.xml' }],
['html', {
open: 'on-failure',
outputFolder: '../html-test-results' //Must be in different location due to https://github.com/microsoft/playwright/issues/12840
}]
] ]
]
}; };
module.exports = config; module.exports = config;

View File

@@ -1,6 +1,6 @@
/* eslint-disable no-undef */ /* eslint-disable no-undef */
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -26,7 +26,7 @@
* and appActions. These fixtures should be generalized across all plugins. * and appActions. These fixtures should be generalized across all plugins.
*/ */
const { test, expect, request } = require('./baseFixtures'); const { test, expect } = require('./baseFixtures');
// const { createDomainObjectWithDefaults } = require('./appActions'); // const { createDomainObjectWithDefaults } = require('./appActions');
const path = require('path'); const path = require('path');
@@ -120,45 +120,33 @@ const theme = 'espresso';
* *
* @type {string} * @type {string}
*/ */
const myItemsFolderName = 'My Items'; const myItemsFolderName = "My Items";
exports.test = test.extend({ exports.test = test.extend({
// This should follow in the Project's configuration. Can be set to 'snow' in playwright config.js // This should follow in the Project's configuration. Can be set to 'snow' in playwright config.js
theme: [theme, { option: true }], theme: [theme, { option: true }],
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
page: async ({ page, theme }, use, testInfo) => { page: async ({ page, theme }, use, testInfo) => {
// eslint-disable-next-line playwright/no-conditional-in-test // eslint-disable-next-line playwright/no-conditional-in-test
if (theme === 'snow') { if (theme === 'snow') {
//inject snow theme //inject snow theme
await page.addInitScript({ path: path.join(__dirname, './helper', './useSnowTheme.js') }); await page.addInitScript({ path: path.join(__dirname, './helper', './useSnowTheme.js') });
}
// Attach info about the currently running test and its project.
// This will be used by appActions to fill in the created
// domain object's notes.
page.testNotes = [
`${testInfo.titlePath.join('\n')}`,
`${testInfo.project.name}`
].join('\n');
await use(page);
},
myItemsFolderName: [myItemsFolderName, { option: true }],
// eslint-disable-next-line no-shadow
openmctConfig: async ({ myItemsFolderName }, use) => {
await use({ myItemsFolderName });
} }
// Attach info about the currently running test and its project.
// This will be used by appActions to fill in the created
// domain object's notes.
page.testNotes = [`${testInfo.titlePath.join('\n')}`, `${testInfo.project.name}`].join('\n');
await use(page);
},
myItemsFolderName: [myItemsFolderName, { option: true }],
// eslint-disable-next-line no-shadow
openmctConfig: async ({ myItemsFolderName }, use) => {
await use({ myItemsFolderName });
}
}); });
exports.expect = expect; exports.expect = expect;
exports.request = request;
/**
* Takes a readable stream and returns a string.
* @param {ReadableStream} readable - the readable stream
* @return {Promise<String>} the stringified stream
*/
exports.streamToString = async function (readable) {
let result = '';
for await (const chunk of readable) {
result += chunk;
}
return result;
};

View File

@@ -274,7 +274,10 @@
"id": "ac0d7eb1-b485-458f-bd2a-a63aa87a3a8a" "id": "ac0d7eb1-b485-458f-bd2a-a63aa87a3a8a"
} }
], ],
"layoutGrid": [10, 10], "layoutGrid": [
10,
10
],
"objectStyles": { "objectStyles": {
"ed63cc29-80e2-4e2b-a472-3d6d4adbf310": { "ed63cc29-80e2-4e2b-a472-3d6d4adbf310": {
"staticStyle": { "staticStyle": {
@@ -1452,7 +1455,9 @@
"id": "64e49fe7-5b36-43db-8347-4550b910de4c", "id": "64e49fe7-5b36-43db-8347-4550b910de4c",
"telemetry": "any", "telemetry": "any",
"operation": "greaterThan", "operation": "greaterThan",
"input": ["120"], "input": [
"120"
],
"metadata": "sin" "metadata": "sin"
} }
] ]
@@ -1470,7 +1475,10 @@
"id": "59f1c4bf-5d36-450c-9668-6546955fc066", "id": "59f1c4bf-5d36-450c-9668-6546955fc066",
"telemetry": "any", "telemetry": "any",
"operation": "between", "operation": "between",
"input": ["120", "-20"], "input": [
"120",
"-20"
],
"metadata": "sin" "metadata": "sin"
} }
] ]
@@ -1488,7 +1496,9 @@
"id": "6707be12-6a6e-4535-bb97-ab5c86f99934", "id": "6707be12-6a6e-4535-bb97-ab5c86f99934",
"telemetry": "any", "telemetry": "any",
"operation": "lessThan", "operation": "lessThan",
"input": ["-20"], "input": [
"-20"
],
"metadata": "sin" "metadata": "sin"
} }
] ]
@@ -1540,7 +1550,9 @@
"id": "64e49fe7-5b36-43db-8347-4550b910de4c", "id": "64e49fe7-5b36-43db-8347-4550b910de4c",
"telemetry": "any", "telemetry": "any",
"operation": "greaterThan", "operation": "greaterThan",
"input": ["120"], "input": [
"120"
],
"metadata": "sin" "metadata": "sin"
} }
] ]
@@ -1558,7 +1570,10 @@
"id": "59f1c4bf-5d36-450c-9668-6546955fc066", "id": "59f1c4bf-5d36-450c-9668-6546955fc066",
"telemetry": "any", "telemetry": "any",
"operation": "between", "operation": "between",
"input": ["120", "-20"], "input": [
"120",
"-20"
],
"metadata": "sin" "metadata": "sin"
} }
] ]
@@ -1576,7 +1591,9 @@
"id": "6707be12-6a6e-4535-bb97-ab5c86f99934", "id": "6707be12-6a6e-4535-bb97-ab5c86f99934",
"telemetry": "any", "telemetry": "any",
"operation": "lessThan", "operation": "lessThan",
"input": ["-20"], "input": [
"-20"
],
"metadata": "sin" "metadata": "sin"
} }
] ]
@@ -1628,7 +1645,9 @@
"id": "64e49fe7-5b36-43db-8347-4550b910de4c", "id": "64e49fe7-5b36-43db-8347-4550b910de4c",
"telemetry": "any", "telemetry": "any",
"operation": "greaterThan", "operation": "greaterThan",
"input": ["150"], "input": [
"150"
],
"metadata": "sin" "metadata": "sin"
} }
] ]
@@ -1646,7 +1665,10 @@
"id": "59f1c4bf-5d36-450c-9668-6546955fc066", "id": "59f1c4bf-5d36-450c-9668-6546955fc066",
"telemetry": "any", "telemetry": "any",
"operation": "between", "operation": "between",
"input": ["50", "-50"], "input": [
"50",
"-50"
],
"metadata": "sin" "metadata": "sin"
} }
] ]
@@ -1698,7 +1720,9 @@
"id": "64e49fe7-5b36-43db-8347-4550b910de4c", "id": "64e49fe7-5b36-43db-8347-4550b910de4c",
"telemetry": "any", "telemetry": "any",
"operation": "greaterThan", "operation": "greaterThan",
"input": ["150"], "input": [
"150"
],
"metadata": "sin" "metadata": "sin"
} }
] ]
@@ -1716,7 +1740,10 @@
"id": "59f1c4bf-5d36-450c-9668-6546955fc066", "id": "59f1c4bf-5d36-450c-9668-6546955fc066",
"telemetry": "any", "telemetry": "any",
"operation": "between", "operation": "between",
"input": ["50", "-50"], "input": [
"50",
"-50"
],
"metadata": "sin" "metadata": "sin"
} }
] ]
@@ -2177,4 +2204,4 @@
} }
}, },
"rootId": "45b24009-dfed-4023-a30b-d31f5e3a2d87" "rootId": "45b24009-dfed-4023-a30b-d31f5e3a2d87"
} }

View File

@@ -1,90 +1 @@
{ {"openmct":{"b3cee102-86dd-4c0a-8eec-4d5d276f8691":{"identifier":{"key":"b3cee102-86dd-4c0a-8eec-4d5d276f8691","namespace":""},"name":"Performance Display Layout","type":"layout","composition":[{"key":"9666e7b4-be0c-47a5-94b8-99accad7155e","namespace":""}],"configuration":{"items":[{"width":32,"height":18,"x":12,"y":9,"identifier":{"key":"9666e7b4-be0c-47a5-94b8-99accad7155e","namespace":""},"hasFrame":true,"fontSize":"default","font":"default","type":"subobject-view","id":"23ca351d-a67d-46aa-a762-290eb742d2f1"}],"layoutGrid":[10,10]},"modified":1654299875432,"location":"mine","persisted":1654299878751},"9666e7b4-be0c-47a5-94b8-99accad7155e":{"identifier":{"key":"9666e7b4-be0c-47a5-94b8-99accad7155e","namespace":""},"name":"Performance Example Imagery","type":"example.imagery","configuration":{"imageLocation":"","imageLoadDelayInMilliSeconds":20000,"imageSamples":[],"layers":[{"source":"dist/imagery/example-imagery-layer-16x9.png","name":"16:9","visible":false},{"source":"dist/imagery/example-imagery-layer-safe.png","name":"Safe","visible":false},{"source":"dist/imagery/example-imagery-layer-scale.png","name":"Scale","visible":false}]},"telemetry":{"values":[{"name":"Name","key":"name"},{"name":"Time","key":"utc","format":"utc","hints":{"domain":2}},{"name":"Local Time","key":"local","format":"local-format","hints":{"domain":1}},{"name":"Image","key":"url","format":"image","hints":{"image":1},"layers":[{"source":"dist/imagery/example-imagery-layer-16x9.png","name":"16:9"},{"source":"dist/imagery/example-imagery-layer-safe.png","name":"Safe"},{"source":"dist/imagery/example-imagery-layer-scale.png","name":"Scale"}]},{"name":"Image Download Name","key":"imageDownloadName","format":"imageDownloadName","hints":{"imageDownloadName":1}}]},"modified":1654299840077,"location":"b3cee102-86dd-4c0a-8eec-4d5d276f8691","persisted":1654299840078}},"rootId":"b3cee102-86dd-4c0a-8eec-4d5d276f8691"}
"openmct": {
"b3cee102-86dd-4c0a-8eec-4d5d276f8691": {
"identifier": { "key": "b3cee102-86dd-4c0a-8eec-4d5d276f8691", "namespace": "" },
"name": "Performance Display Layout",
"type": "layout",
"composition": [{ "key": "9666e7b4-be0c-47a5-94b8-99accad7155e", "namespace": "" }],
"configuration": {
"items": [
{
"width": 32,
"height": 18,
"x": 12,
"y": 9,
"identifier": { "key": "9666e7b4-be0c-47a5-94b8-99accad7155e", "namespace": "" },
"hasFrame": true,
"fontSize": "default",
"font": "default",
"type": "subobject-view",
"id": "23ca351d-a67d-46aa-a762-290eb742d2f1"
}
],
"layoutGrid": [10, 10]
},
"modified": 1654299875432,
"location": "mine",
"persisted": 1654299878751
},
"9666e7b4-be0c-47a5-94b8-99accad7155e": {
"identifier": { "key": "9666e7b4-be0c-47a5-94b8-99accad7155e", "namespace": "" },
"name": "Performance Example Imagery",
"type": "example.imagery",
"configuration": {
"imageLocation": "",
"imageLoadDelayInMilliSeconds": 20000,
"imageSamples": [],
"layers": [
{
"source": "dist/imagery/example-imagery-layer-16x9.png",
"name": "16:9",
"visible": false
},
{
"source": "dist/imagery/example-imagery-layer-safe.png",
"name": "Safe",
"visible": false
},
{
"source": "dist/imagery/example-imagery-layer-scale.png",
"name": "Scale",
"visible": false
}
]
},
"telemetry": {
"values": [
{ "name": "Name", "key": "name" },
{ "name": "Time", "key": "utc", "format": "utc", "hints": { "domain": 2 } },
{
"name": "Local Time",
"key": "local",
"format": "local-format",
"hints": { "domain": 1 }
},
{
"name": "Image",
"key": "url",
"format": "image",
"hints": { "image": 1 },
"layers": [
{ "source": "dist/imagery/example-imagery-layer-16x9.png", "name": "16:9" },
{ "source": "dist/imagery/example-imagery-layer-safe.png", "name": "Safe" },
{ "source": "dist/imagery/example-imagery-layer-scale.png", "name": "Scale" }
]
},
{
"name": "Image Download Name",
"key": "imageDownloadName",
"format": "imageDownloadName",
"hints": { "imageDownloadName": 1 }
}
]
},
"modified": 1654299840077,
"location": "b3cee102-86dd-4c0a-8eec-4d5d276f8691",
"persisted": 1654299840078
}
},
"rootId": "b3cee102-86dd-4c0a-8eec-4d5d276f8691"
}

View File

@@ -1,96 +1 @@
{ {"openmct":{"6d2fa9fd-f2aa-461a-a1e1-164ac44bec9d":{"identifier":{"key":"6d2fa9fd-f2aa-461a-a1e1-164ac44bec9d","namespace":""},"name":"Performance Notebook","type":"notebook","configuration":{"defaultSort":"oldest","entries":{"3e31c412-33ba-4757-8ade-e9821f6ba321":{"8c8f6035-631c-45af-8c24-786c60295335":[{"id":"entry-1652815305457","createdOn":1652815305457,"createdBy":"","text":"Existing Entry 1","embeds":[]},{"id":"entry-1652815313465","createdOn":1652815313465,"createdBy":"","text":"Existing Entry 2","embeds":[]},{"id":"entry-1652815399955","createdOn":1652815399955,"createdBy":"","text":"Existing Entry 3","embeds":[]}]}},"imageMigrationVer":"v1","pageTitle":"Page","sections":[{"id":"3e31c412-33ba-4757-8ade-e9821f6ba321","isDefault":false,"isSelected":false,"name":"Section1","pages":[{"id":"8c8f6035-631c-45af-8c24-786c60295335","isDefault":false,"isSelected":false,"name":"Page1","pageTitle":"Page"},{"id":"36555942-c9aa-439c-bbdb-0aaf50db50f5","isDefault":false,"isSelected":false,"name":"Page2","pageTitle":"Page"}],"sectionTitle":"Section"},{"id":"dab0bd1d-2c5a-405c-987f-107123d6189a","isDefault":false,"isSelected":true,"name":"Section2","pages":[{"id":"f625a86a-cb99-4898-8082-80543c8de534","isDefault":false,"isSelected":false,"name":"Page1","pageTitle":"Page"},{"id":"e77ef810-f785-42a7-942e-07e999b79c59","isDefault":false,"isSelected":true,"name":"Page2","pageTitle":"Page"}],"sectionTitle":"Section"}],"sectionTitle":"Section","type":"General","showTime":"0"},"modified":1652815915219,"location":"mine","persisted":1652815915222}},"rootId":"6d2fa9fd-f2aa-461a-a1e1-164ac44bec9d"}
"openmct": {
"6d2fa9fd-f2aa-461a-a1e1-164ac44bec9d": {
"identifier": { "key": "6d2fa9fd-f2aa-461a-a1e1-164ac44bec9d", "namespace": "" },
"name": "Performance Notebook",
"type": "notebook",
"configuration": {
"defaultSort": "oldest",
"entries": {
"3e31c412-33ba-4757-8ade-e9821f6ba321": {
"8c8f6035-631c-45af-8c24-786c60295335": [
{
"id": "entry-1652815305457",
"createdOn": 1652815305457,
"createdBy": "",
"text": "Existing Entry 1",
"embeds": []
},
{
"id": "entry-1652815313465",
"createdOn": 1652815313465,
"createdBy": "",
"text": "Existing Entry 2",
"embeds": []
},
{
"id": "entry-1652815399955",
"createdOn": 1652815399955,
"createdBy": "",
"text": "Existing Entry 3",
"embeds": []
}
]
}
},
"imageMigrationVer": "v1",
"pageTitle": "Page",
"sections": [
{
"id": "3e31c412-33ba-4757-8ade-e9821f6ba321",
"isDefault": false,
"isSelected": false,
"name": "Section1",
"pages": [
{
"id": "8c8f6035-631c-45af-8c24-786c60295335",
"isDefault": false,
"isSelected": false,
"name": "Page1",
"pageTitle": "Page"
},
{
"id": "36555942-c9aa-439c-bbdb-0aaf50db50f5",
"isDefault": false,
"isSelected": false,
"name": "Page2",
"pageTitle": "Page"
}
],
"sectionTitle": "Section"
},
{
"id": "dab0bd1d-2c5a-405c-987f-107123d6189a",
"isDefault": false,
"isSelected": true,
"name": "Section2",
"pages": [
{
"id": "f625a86a-cb99-4898-8082-80543c8de534",
"isDefault": false,
"isSelected": false,
"name": "Page1",
"pageTitle": "Page"
},
{
"id": "e77ef810-f785-42a7-942e-07e999b79c59",
"isDefault": false,
"isSelected": true,
"name": "Page2",
"pageTitle": "Page"
}
],
"sectionTitle": "Section"
}
],
"sectionTitle": "Section",
"type": "General",
"showTime": "0"
},
"modified": 1652815915219,
"location": "mine",
"persisted": 1652815915222
}
},
"rootId": "6d2fa9fd-f2aa-461a-a1e1-164ac44bec9d"
}

View File

@@ -19,4 +19,4 @@
] ]
} }
] ]
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,44 +0,0 @@
{
"Group 1": [
{
"name": "Past event 1",
"start": 1660320408000,
"end": 1660343797000,
"type": "Group 1",
"color": "orange",
"textColor": "white"
},
{
"name": "Past event 2",
"start": 1660406808000,
"end": 1660429160000,
"type": "Group 1",
"color": "orange",
"textColor": "white"
},
{
"name": "Past event 3",
"start": 1660493208000,
"end": 1660503981000,
"type": "Group 1",
"color": "orange",
"textColor": "white"
},
{
"name": "Past event 4",
"start": 1660579608000,
"end": 1660624108000,
"type": "Group 1",
"color": "orange",
"textColor": "white"
},
{
"name": "Past event 5",
"start": 1660666008000,
"end": 1660681529000,
"type": "Group 1",
"color": "orange",
"textColor": "white"
}
]
}

View File

@@ -1,38 +0,0 @@
{
"Group 1": [
{
"name": "Group 1 event 1",
"start": 1650320408000,
"end": 1660343797000,
"type": "Group 1",
"color": "orange",
"textColor": "white"
},
{
"name": "Group 1 event 2",
"start": 1660005808000,
"end": 1660429160000,
"type": "Group 1",
"color": "yellow",
"textColor": "white"
}
],
"Group 2": [
{
"name": "Group 2 event 1",
"start": 1660320408000,
"end": 1660420408000,
"type": "Group 2",
"color": "green",
"textColor": "white"
},
{
"name": "Group 2 event 2",
"start": 1660406808000,
"end": 1690429160000,
"type": "Group 2",
"color": "blue",
"textColor": "white"
}
]
}

View File

@@ -4,21 +4,17 @@
{ {
"origin": "http://localhost:8080", "origin": "http://localhost:8080",
"localStorage": [ "localStorage": [
{
"name": "mct",
"value": "{\"mine\":{\"identifier\":{\"key\":\"mine\",\"namespace\":\"\"},\"name\":\"My Items\",\"type\":\"folder\",\"composition\":[{\"key\":\"f64bea3b-58a7-4586-8c05-8b651e5f0bfd\",\"namespace\":\"\"},{\"key\":\"2d02a680-eb7e-4645-bba2-dd298f76efb8\",\"namespace\":\"\"},{\"key\":\"72a5f66b-39a7-4f62-8c40-4a99a33d6a8e\",\"namespace\":\"\"},{\"key\":\"8e4d20f1-9a04-4de5-8db5-c7e08d27f70d\",\"namespace\":\"\"},{\"key\":\"3e294eae-6124-409b-a870-554d1bdcdd6f\",\"namespace\":\"\"},{\"key\":\"ec24d05d-5df5-4c96-9241-b73636cd19a9\",\"namespace\":\"\"},{\"key\":\"0ec517e8-6c11-4d98-89b5-c300fe61b304\",\"namespace\":\"\"}],\"location\":\"ROOT\",\"persisted\":1689710689554,\"modified\":1689710689554},\"f64bea3b-58a7-4586-8c05-8b651e5f0bfd\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"f64bea3b-58a7-4586-8c05-8b651e5f0bfd\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"73f2d9ae-d1f3-4561-b7fc-ecd5df557249\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1652303755999,\"location\":\"mine\",\"persisted\":1652303756002},\"2d02a680-eb7e-4645-bba2-dd298f76efb8\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"2d02a680-eb7e-4645-bba2-dd298f76efb8\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"4291d80c-303c-4d8d-85e1-10f012b864fb\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1654538965702,\"location\":\"mine\",\"persisted\":1654538965702},\"72a5f66b-39a7-4f62-8c40-4a99a33d6a8e\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"72a5f66b-39a7-4f62-8c40-4a99a33d6a8e\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"2b6bf89f-877b-42b8-acc1-a9a575efdbe1\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1658610682787,\"location\":\"mine\",\"persisted\":1658610682787},\"8e4d20f1-9a04-4de5-8db5-c7e08d27f70d\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"8e4d20f1-9a04-4de5-8db5-c7e08d27f70d\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"b9a9c413-4b94-401d-b0c7-5e404f182616\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1658618261112,\"location\":\"mine\",\"persisted\":1658618261112},\"3e294eae-6124-409b-a870-554d1bdcdd6f\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"3e294eae-6124-409b-a870-554d1bdcdd6f\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"108043b1-9c88-4e1d-8deb-fbf2cdb528f9\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1658618890910,\"location\":\"mine\",\"persisted\":1658618890910},\"ec24d05d-5df5-4c96-9241-b73636cd19a9\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"ec24d05d-5df5-4c96-9241-b73636cd19a9\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"4062bd9b-b788-43dd-ab0a-8fa10a78d4b3\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1658619295363,\"location\":\"mine\",\"persisted\":1658619295363},\"0ec517e8-6c11-4d98-89b5-c300fe61b304\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"0ec517e8-6c11-4d98-89b5-c300fe61b304\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"2f1585da-6f7e-4ccd-8a20-590fdf177b5d\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1689710689550,\"location\":\"mine\",\"created\":1689710689550,\"persisted\":1689710689550}}"
},
{
"name": "mct-tree-expanded",
"value": "[]"
},
{ {
"name": "tcHistory", "name": "tcHistory",
"value": "{\"utc\":[{\"start\":1658617494563,\"end\":1658619294563},{\"start\":1658617090044,\"end\":1658618890044},{\"start\":1658616460484,\"end\":1658618260484},{\"start\":1658608882159,\"end\":1658610682159},{\"start\":1654537164464,\"end\":1654538964464},{\"start\":1652301954635,\"end\":1652303754635}]}" "value": "{\"utc\":[{\"start\":1658617494563,\"end\":1658619294563},{\"start\":1658617090044,\"end\":1658618890044},{\"start\":1658616460484,\"end\":1658618260484},{\"start\":1658608882159,\"end\":1658610682159},{\"start\":1654537164464,\"end\":1654538964464},{\"start\":1652301954635,\"end\":1652303754635}]}"
}, },
{ {
"name": "mct-recent-objects", "name": "mct",
"value": "[{\"objectPath\":[{\"identifier\":{\"key\":\"0ec517e8-6c11-4d98-89b5-c300fe61b304\",\"namespace\":\"\"},\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"2f1585da-6f7e-4ccd-8a20-590fdf177b5d\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1689710689550,\"location\":\"mine\",\"created\":1689710689550,\"persisted\":1689710689550},{\"identifier\":{\"key\":\"mine\",\"namespace\":\"\"},\"name\":\"My Items\",\"type\":\"folder\",\"composition\":[{\"key\":\"f64bea3b-58a7-4586-8c05-8b651e5f0bfd\",\"namespace\":\"\"},{\"key\":\"2d02a680-eb7e-4645-bba2-dd298f76efb8\",\"namespace\":\"\"},{\"key\":\"72a5f66b-39a7-4f62-8c40-4a99a33d6a8e\",\"namespace\":\"\"},{\"key\":\"8e4d20f1-9a04-4de5-8db5-c7e08d27f70d\",\"namespace\":\"\"},{\"key\":\"3e294eae-6124-409b-a870-554d1bdcdd6f\",\"namespace\":\"\"},{\"key\":\"ec24d05d-5df5-4c96-9241-b73636cd19a9\",\"namespace\":\"\"},{\"key\":\"0ec517e8-6c11-4d98-89b5-c300fe61b304\",\"namespace\":\"\"}],\"location\":\"ROOT\",\"persisted\":1689710689554,\"modified\":1689710689554},{\"identifier\":{\"key\":\"ROOT\",\"namespace\":\"\"},\"name\":\"Open MCT\",\"type\":\"root\",\"composition\":[{\"key\":\"mine\",\"namespace\":\"\"}]}],\"navigationPath\":\"/browse/mine/0ec517e8-6c11-4d98-89b5-c300fe61b304\",\"domainObject\":{\"identifier\":{\"key\":\"0ec517e8-6c11-4d98-89b5-c300fe61b304\",\"namespace\":\"\"},\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"2f1585da-6f7e-4ccd-8a20-590fdf177b5d\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1689710689550,\"location\":\"mine\",\"created\":1689710689550,\"persisted\":1689710689550}},{\"objectPath\":[{\"identifier\":{\"key\":\"mine\",\"namespace\":\"\"},\"name\":\"My Items\",\"type\":\"folder\",\"composition\":[{\"key\":\"f64bea3b-58a7-4586-8c05-8b651e5f0bfd\",\"namespace\":\"\"},{\"key\":\"2d02a680-eb7e-4645-bba2-dd298f76efb8\",\"namespace\":\"\"},{\"key\":\"72a5f66b-39a7-4f62-8c40-4a99a33d6a8e\",\"namespace\":\"\"},{\"key\":\"8e4d20f1-9a04-4de5-8db5-c7e08d27f70d\",\"namespace\":\"\"},{\"key\":\"3e294eae-6124-409b-a870-554d1bdcdd6f\",\"namespace\":\"\"},{\"key\":\"ec24d05d-5df5-4c96-9241-b73636cd19a9\",\"namespace\":\"\"},{\"key\":\"0ec517e8-6c11-4d98-89b5-c300fe61b304\",\"namespace\":\"\"}],\"location\":\"ROOT\",\"persisted\":1689710689554,\"modified\":1689710689554},{\"identifier\":{\"key\":\"ROOT\",\"namespace\":\"\"},\"name\":\"Open MCT\",\"type\":\"root\",\"composition\":[{\"key\":\"mine\",\"namespace\":\"\"}]}],\"navigationPath\":\"/browse/mine\",\"domainObject\":{\"identifier\":{\"key\":\"mine\",\"namespace\":\"\"},\"name\":\"My Items\",\"type\":\"folder\",\"composition\":[{\"key\":\"f64bea3b-58a7-4586-8c05-8b651e5f0bfd\",\"namespace\":\"\"},{\"key\":\"2d02a680-eb7e-4645-bba2-dd298f76efb8\",\"namespace\":\"\"},{\"key\":\"72a5f66b-39a7-4f62-8c40-4a99a33d6a8e\",\"namespace\":\"\"},{\"key\":\"8e4d20f1-9a04-4de5-8db5-c7e08d27f70d\",\"namespace\":\"\"},{\"key\":\"3e294eae-6124-409b-a870-554d1bdcdd6f\",\"namespace\":\"\"},{\"key\":\"ec24d05d-5df5-4c96-9241-b73636cd19a9\",\"namespace\":\"\"},{\"key\":\"0ec517e8-6c11-4d98-89b5-c300fe61b304\",\"namespace\":\"\"}],\"location\":\"ROOT\",\"persisted\":1689710689554,\"modified\":1689710689554}}]" "value": "{\"mine\":{\"identifier\":{\"key\":\"mine\",\"namespace\":\"\"},\"name\":\"My Items\",\"type\":\"folder\",\"composition\":[{\"key\":\"f64bea3b-58a7-4586-8c05-8b651e5f0bfd\",\"namespace\":\"\"},{\"key\":\"2d02a680-eb7e-4645-bba2-dd298f76efb8\",\"namespace\":\"\"},{\"key\":\"72a5f66b-39a7-4f62-8c40-4a99a33d6a8e\",\"namespace\":\"\"},{\"key\":\"8e4d20f1-9a04-4de5-8db5-c7e08d27f70d\",\"namespace\":\"\"},{\"key\":\"3e294eae-6124-409b-a870-554d1bdcdd6f\",\"namespace\":\"\"},{\"key\":\"ec24d05d-5df5-4c96-9241-b73636cd19a9\",\"namespace\":\"\"}],\"location\":\"ROOT\",\"persisted\":1658619295366,\"modified\":1658619295366},\"f64bea3b-58a7-4586-8c05-8b651e5f0bfd\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"f64bea3b-58a7-4586-8c05-8b651e5f0bfd\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"73f2d9ae-d1f3-4561-b7fc-ecd5df557249\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1652303755999,\"location\":\"mine\",\"persisted\":1652303756002},\"2d02a680-eb7e-4645-bba2-dd298f76efb8\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"2d02a680-eb7e-4645-bba2-dd298f76efb8\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"4291d80c-303c-4d8d-85e1-10f012b864fb\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1654538965702,\"location\":\"mine\",\"persisted\":1654538965702},\"72a5f66b-39a7-4f62-8c40-4a99a33d6a8e\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"72a5f66b-39a7-4f62-8c40-4a99a33d6a8e\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"2b6bf89f-877b-42b8-acc1-a9a575efdbe1\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1658610682787,\"location\":\"mine\",\"persisted\":1658610682787},\"8e4d20f1-9a04-4de5-8db5-c7e08d27f70d\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"8e4d20f1-9a04-4de5-8db5-c7e08d27f70d\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"b9a9c413-4b94-401d-b0c7-5e404f182616\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1658618261112,\"location\":\"mine\",\"persisted\":1658618261112},\"3e294eae-6124-409b-a870-554d1bdcdd6f\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"3e294eae-6124-409b-a870-554d1bdcdd6f\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"108043b1-9c88-4e1d-8deb-fbf2cdb528f9\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1658618890910,\"location\":\"mine\",\"persisted\":1658618890910},\"ec24d05d-5df5-4c96-9241-b73636cd19a9\":{\"name\":\"Unnamed Condition Set\",\"type\":\"conditionSet\",\"identifier\":{\"key\":\"ec24d05d-5df5-4c96-9241-b73636cd19a9\",\"namespace\":\"\"},\"configuration\":{\"conditionTestData\":[],\"conditionCollection\":[{\"isDefault\":true,\"id\":\"4062bd9b-b788-43dd-ab0a-8fa10a78d4b3\",\"configuration\":{\"name\":\"Default\",\"output\":\"Default\",\"trigger\":\"all\",\"criteria\":[]},\"summary\":\"Default condition\"}]},\"composition\":[],\"telemetry\":{},\"modified\":1658619295363,\"location\":\"mine\",\"persisted\":1658619295363}}"
},
{
"name": "mct-tree-expanded",
"value": "[]"
} }
] ]
} }

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -21,149 +21,92 @@
*****************************************************************************/ *****************************************************************************/
const { test, expect } = require('../../pluginFixtures.js'); const { test, expect } = require('../../pluginFixtures.js');
const { const { createDomainObjectWithDefaults, createNotification } = require('../../appActions.js');
createDomainObjectWithDefaults,
createNotification,
expandEntireTree
} = require('../../appActions.js');
test.describe('AppActions', () => { test.describe('AppActions', () => {
test('createDomainObjectsWithDefaults', async ({ page }) => { test('createDomainObjectsWithDefaults', async ({ page }) => {
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
const e2eFolder = await createDomainObjectWithDefaults(page, { const e2eFolder = await createDomainObjectWithDefaults(page, {
type: 'Folder', type: 'Folder',
name: 'e2e folder' name: 'e2e folder'
}); });
await test.step('Create multiple flat objects in a row', async () => { await test.step('Create multiple flat objects in a row', async () => {
const timer1 = await createDomainObjectWithDefaults(page, { const timer1 = await createDomainObjectWithDefaults(page, {
type: 'Timer', type: 'Timer',
name: 'Timer Foo', name: 'Timer Foo',
parent: e2eFolder.uuid parent: e2eFolder.uuid
}); });
const timer2 = await createDomainObjectWithDefaults(page, { const timer2 = await createDomainObjectWithDefaults(page, {
type: 'Timer', type: 'Timer',
name: 'Timer Bar', name: 'Timer Bar',
parent: e2eFolder.uuid parent: e2eFolder.uuid
}); });
const timer3 = await createDomainObjectWithDefaults(page, { const timer3 = await createDomainObjectWithDefaults(page, {
type: 'Timer', type: 'Timer',
name: 'Timer Baz', name: 'Timer Baz',
parent: e2eFolder.uuid parent: e2eFolder.uuid
}); });
await page.goto(timer1.url); await page.goto(timer1.url, { waitUntil: 'networkidle' });
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer1.name); await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer1.name);
await page.goto(timer2.url); await page.goto(timer2.url, { waitUntil: 'networkidle' });
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer2.name); await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer2.name);
await page.goto(timer3.url); await page.goto(timer3.url, { waitUntil: 'networkidle' });
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer3.name); await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer3.name);
}); });
await test.step('Create multiple nested objects in a row', async () => { await test.step('Create multiple nested objects in a row', async () => {
const folder1 = await createDomainObjectWithDefaults(page, { const folder1 = await createDomainObjectWithDefaults(page, {
type: 'Folder', type: 'Folder',
name: 'Folder Foo', name: 'Folder Foo',
parent: e2eFolder.uuid parent: e2eFolder.uuid
}); });
const folder2 = await createDomainObjectWithDefaults(page, { const folder2 = await createDomainObjectWithDefaults(page, {
type: 'Folder', type: 'Folder',
name: 'Folder Bar', name: 'Folder Bar',
parent: folder1.uuid parent: folder1.uuid
}); });
const folder3 = await createDomainObjectWithDefaults(page, { const folder3 = await createDomainObjectWithDefaults(page, {
type: 'Folder', type: 'Folder',
name: 'Folder Baz', name: 'Folder Baz',
parent: folder2.uuid parent: folder2.uuid
}); });
await page.goto(folder1.url); await page.goto(folder1.url, { waitUntil: 'networkidle' });
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(folder1.name); await expect(page.locator('.l-browse-bar__object-name')).toHaveText(folder1.name);
await page.goto(folder2.url); await page.goto(folder2.url, { waitUntil: 'networkidle' });
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(folder2.name); await expect(page.locator('.l-browse-bar__object-name')).toHaveText(folder2.name);
await page.goto(folder3.url); await page.goto(folder3.url, { waitUntil: 'networkidle' });
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(folder3.name); await expect(page.locator('.l-browse-bar__object-name')).toHaveText(folder3.name);
expect(folder1.url).toBe(`${e2eFolder.url}/${folder1.uuid}`); expect(folder1.url).toBe(`${e2eFolder.url}/${folder1.uuid}`);
expect(folder2.url).toBe(`${e2eFolder.url}/${folder1.uuid}/${folder2.uuid}`); expect(folder2.url).toBe(`${e2eFolder.url}/${folder1.uuid}/${folder2.uuid}`);
expect(folder3.url).toBe(`${e2eFolder.url}/${folder1.uuid}/${folder2.uuid}/${folder3.uuid}`); expect(folder3.url).toBe(`${e2eFolder.url}/${folder1.uuid}/${folder2.uuid}/${folder3.uuid}`);
});
}); });
}); test("createNotification", async ({ page }) => {
test('createNotification', async ({ page }) => { await page.goto('./', { waitUntil: 'networkidle' });
await page.goto('./', { waitUntil: 'domcontentloaded' }); await createNotification(page, {
await createNotification(page, { message: 'Test info notification',
message: 'Test info notification', severity: 'info'
severity: 'info' });
await expect(page.locator('.c-message-banner__message')).toHaveText('Test info notification');
await expect(page.locator('.c-message-banner')).toHaveClass(/info/);
await page.locator('[aria-label="Dismiss"]').click();
await createNotification(page, {
message: 'Test alert notification',
severity: 'alert'
});
await expect(page.locator('.c-message-banner__message')).toHaveText('Test alert notification');
await expect(page.locator('.c-message-banner')).toHaveClass(/alert/);
await page.locator('[aria-label="Dismiss"]').click();
await createNotification(page, {
message: 'Test error notification',
severity: 'error'
});
await expect(page.locator('.c-message-banner__message')).toHaveText('Test error notification');
await expect(page.locator('.c-message-banner')).toHaveClass(/error/);
await page.locator('[aria-label="Dismiss"]').click();
}); });
await expect(page.locator('.c-message-banner__message')).toHaveText('Test info notification');
await expect(page.locator('.c-message-banner')).toHaveClass(/info/);
await page.locator('[aria-label="Dismiss"]').click();
await createNotification(page, {
message: 'Test alert notification',
severity: 'alert'
});
await expect(page.locator('.c-message-banner__message')).toHaveText('Test alert notification');
await expect(page.locator('.c-message-banner')).toHaveClass(/alert/);
await page.locator('[aria-label="Dismiss"]').click();
await createNotification(page, {
message: 'Test error notification',
severity: 'error'
});
await expect(page.locator('.c-message-banner__message')).toHaveText('Test error notification');
await expect(page.locator('.c-message-banner')).toHaveClass(/error/);
await page.locator('[aria-label="Dismiss"]').click();
});
test('expandEntireTree', async ({ page }) => {
await page.goto('./', { waitUntil: 'domcontentloaded' });
const rootFolder = await createDomainObjectWithDefaults(page, {
type: 'Folder'
});
const folder1 = await createDomainObjectWithDefaults(page, {
type: 'Folder',
parent: rootFolder.uuid
});
await createDomainObjectWithDefaults(page, {
type: 'Clock',
parent: folder1.uuid
});
const folder2 = await createDomainObjectWithDefaults(page, {
type: 'Folder',
parent: folder1.uuid
});
await createDomainObjectWithDefaults(page, {
type: 'Folder',
parent: folder1.uuid
});
await createDomainObjectWithDefaults(page, {
type: 'Display Layout',
parent: folder2.uuid
});
await createDomainObjectWithDefaults(page, {
type: 'Folder',
parent: folder2.uuid
});
await page.goto('./#/browse/mine');
await expandEntireTree(page);
const treePane = page.getByRole('tree', {
name: 'Main Tree'
});
const treePaneCollapsedItems = treePane.getByRole('treeitem', { expanded: false });
expect(await treePaneCollapsedItems.count()).toBe(0);
await page.goto('./#/browse/mine');
//Click the Create button
await page.click('button:has-text("Create")');
// Click the object specified by 'type'
await page.click(`li[role='menuitem']:text("Clock")`);
await expandEntireTree(page, 'Create Modal Tree');
const locatorTree = page.getByRole('tree', {
name: 'Create Modal Tree'
});
const locatorTreeCollapsedItems = locatorTree.locator('role=treeitem[expanded=false]');
expect(await locatorTreeCollapsedItems.count()).toBe(0);
});
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -29,26 +29,27 @@ relates to how we've extended it (i.e. ./e2e/baseFixtures.js) and assumptions ma
const { test } = require('../../baseFixtures.js'); const { test } = require('../../baseFixtures.js');
test.describe('baseFixtures tests', () => { test.describe('baseFixtures tests', () => {
//Skip this test for now https://github.com/nasa/openmct/issues/6785 test('Verify that tests fail if console.error is thrown', async ({ page }) => {
test.fixme('Verify that tests fail if console.error is thrown', async ({ page }) => { test.fail();
test.fail(); //Go to baseURL
//Go to baseURL await page.goto('./', { waitUntil: 'networkidle' });
await page.goto('./', { waitUntil: 'domcontentloaded' });
//Verify that ../fixtures.js detects console log errors //Verify that ../fixtures.js detects console log errors
await Promise.all([ await Promise.all([
page.evaluate(() => console.error('This should result in a failure')), page.evaluate(() => console.error('This should result in a failure')),
page.waitForEvent('console') // always wait for the event to happen while triggering it! page.waitForEvent('console') // always wait for the event to happen while triggering it!
]); ]);
});
test('Verify that tests pass if console.warn is thrown', async ({ page }) => {
//Go to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' });
//Verify that ../fixtures.js detects console log errors });
await Promise.all([ test('Verify that tests pass if console.warn is thrown', async ({ page }) => {
page.evaluate(() => console.warn('This should result in a pass')), //Go to baseURL
page.waitForEvent('console') // always wait for the event to happen while triggering it! await page.goto('./', { waitUntil: 'networkidle' });
]);
}); //Verify that ../fixtures.js detects console log errors
await Promise.all([
page.evaluate(() => console.warn('This should result in a pass')),
page.waitForEvent('console') // always wait for the event to happen while triggering it!
]);
});
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -21,28 +21,28 @@
*****************************************************************************/ *****************************************************************************/
/* /*
* This test suite template is to be used when creating new test suites. It will be kept up to date with the latest improvements * This test suite template is to be used when creating new test suites. It will be kept up to date with the latest improvements
* made by the Open MCT team. It will also follow our best pratices as those evolve. Please use this structure as a _reference_ and clear * made by the Open MCT team. It will also follow our best pratices as those evolve. Please use this structure as a _reference_ and clear
* or update any references when creating a new test suite! * or update any references when creating a new test suite!
* *
* To illustrate current best practices, we've included a mocked up test suite for Renaming a Timer domain object. * To illustrate current best practices, we've included a mocked up test suite for Renaming a Timer domain object.
* *
* Demonstrated: * Demonstrated:
* - Using appActions to leverage existing functions * - Using appActions to leverage existing functions
* - Structure * - Structure
* - @unstable annotation * - @unstable annotation
* - await, expect, test, describe syntax * - await, expect, test, describe syntax
* - Writing a custom function for a test suite * - Writing a custom function for a test suite
* - Test stub for unfinished test coverage (test.fixme) * - Test stub for unfinished test coverage (test.fixme)
* *
* The structure should follow * The structure should follow
* 1. imports * 1. imports
* 2. test.describe() * 2. test.describe()
* 3. -> test1 * 3. -> test1
* -> test2 * -> test2
* -> test3(stub) * -> test3(stub)
* 4. Any custom functions * 4. Any custom functions
*/ */
// Structure: Some standard Imports. Please update the required pathing. // Structure: Some standard Imports. Please update the required pathing.
const { test, expect } = require('../../pluginFixtures'); const { test, expect } = require('../../pluginFixtures');
@@ -58,63 +58,63 @@ const { createDomainObjectWithDefaults } = require('../../appActions');
* as a part of our test promotion pipeline. * as a part of our test promotion pipeline.
*/ */
test.describe('Renaming Timer Object', () => { test.describe('Renaming Timer Object', () => {
// Top-level declaration of the Timer object created in beforeEach(). // Top-level declaration of the Timer object created in beforeEach().
// We can then use this throughout the entire test suite. // We can then use this throughout the entire test suite.
let timer; let timer;
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
// Open a browser, navigate to the main page, and wait until all network events to resolve // Open a browser, navigate to the main page, and wait until all network events to resolve
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
// We provide some helper functions in appActions like `createDomainObjectWithDefaults()`. // We provide some helper functions in appActions like `createDomainObjectWithDefaults()`.
// This example will create a Timer object with default properties, under the root folder: // This example will create a Timer object with default properties, under the root folder:
timer = await createDomainObjectWithDefaults(page, { type: 'Timer' }); timer = await createDomainObjectWithDefaults(page, { type: 'Timer' });
// Assert the object to be created and check its name in the title // Assert the object to be created and check its name in the title
await expect(page.locator('.l-browse-bar__object-name')).toContainText(timer.name); await expect(page.locator('.l-browse-bar__object-name')).toContainText(timer.name);
}); });
/** /**
* Make sure to use testcase names which are descriptive and easy to understand. * Make sure to use testcase names which are descriptive and easy to understand.
* A good testcase name concisely describes the test's goal(s) and should give * A good testcase name concisely describes the test's goal(s) and should give
* some hint as to what went wrong if the test fails. * some hint as to what went wrong if the test fails.
*/ */
test('An existing Timer object can be renamed via the 3dot actions menu', async ({ page }) => { test('An existing Timer object can be renamed via the 3dot actions menu', async ({ page }) => {
const newObjectName = 'Renamed Timer'; const newObjectName = "Renamed Timer";
// We've created an example of a shared function which pases the page and newObjectName values // We've created an example of a shared function which pases the page and newObjectName values
await renameTimerFrom3DotMenu(page, timer.url, newObjectName); await renameTimerFrom3DotMenu(page, timer.url, newObjectName);
// Assert that the name has changed in the browser bar to the value we assigned above // Assert that the name has changed in the browser bar to the value we assigned above
await expect(page.locator('.l-browse-bar__object-name')).toContainText(newObjectName); await expect(page.locator('.l-browse-bar__object-name')).toContainText(newObjectName);
}); });
test('An existing Timer object can be renamed twice', async ({ page }) => { test('An existing Timer object can be renamed twice', async ({ page }) => {
const newObjectName = 'Renamed Timer'; const newObjectName = "Renamed Timer";
const newObjectName2 = 'Re-Renamed Timer'; const newObjectName2 = "Re-Renamed Timer";
await renameTimerFrom3DotMenu(page, timer.url, newObjectName); await renameTimerFrom3DotMenu(page, timer.url, newObjectName);
// Assert that the name has changed in the browser bar to the value we assigned above // Assert that the name has changed in the browser bar to the value we assigned above
await expect(page.locator('.l-browse-bar__object-name')).toContainText(newObjectName); await expect(page.locator('.l-browse-bar__object-name')).toContainText(newObjectName);
// Rename the Timer object again // Rename the Timer object again
await renameTimerFrom3DotMenu(page, timer.url, newObjectName2); await renameTimerFrom3DotMenu(page, timer.url, newObjectName2);
// Assert that the name has changed in the browser bar to the second value // Assert that the name has changed in the browser bar to the second value
await expect(page.locator('.l-browse-bar__object-name')).toContainText(newObjectName2); await expect(page.locator('.l-browse-bar__object-name')).toContainText(newObjectName2);
}); });
/** /**
* If you run out of time to write new tests, please stub in the missing tests * If you run out of time to write new tests, please stub in the missing tests
* in-place with a test.fixme and BDD-style test steps. * in-place with a test.fixme and BDD-style test steps.
* Someone will carry the baton! * Someone will carry the baton!
*/ */
test.fixme('Can Rename Timer Object from Tree', async ({ page }) => { test.fixme('Can Rename Timer Object from Tree', async ({ page }) => {
//Create a new object //Create a new object
//Copy this object //Copy this object
//Delete first object //Delete first object
//Expect copied object to persist //Expect copied object to persist
}); });
}); });
/** /**
@@ -131,18 +131,18 @@ test.describe('Renaming Timer Object', () => {
* @param {string} newNameForTimer New name for object * @param {string} newNameForTimer New name for object
*/ */
async function renameTimerFrom3DotMenu(page, timerUrl, newNameForTimer) { async function renameTimerFrom3DotMenu(page, timerUrl, newNameForTimer) {
// Navigate to the timer object // Navigate to the timer object
await page.goto(timerUrl); await page.goto(timerUrl);
// Click on 3 Dot Menu // Click on 3 Dot Menu
await page.locator('button[title="More options"]').click(); await page.locator('button[title="More options"]').click();
// Click text=Edit Properties... // Click text=Edit Properties...
await page.locator('text=Edit Properties...').click(); await page.locator('text=Edit Properties...').click();
// Rename the timer object // Rename the timer object
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(newNameForTimer); await page.locator('text=Properties Title Notes >> input[type="text"]').fill(newNameForTimer);
// Click Ok button to Save // Click Ok button to Save
await page.locator('button:has-text("OK")').click(); await page.locator('button:has-text("OK")').click();
} }

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -35,30 +35,30 @@ const { createDomainObjectWithDefaults } = require('../../appActions.js');
const { test, expect } = require('../../pluginFixtures.js'); const { test, expect } = require('../../pluginFixtures.js');
test('Generate Visual Test Data @localStorage', async ({ page, context }) => { test('Generate Visual Test Data @localStorage', async ({ page, context }) => {
//Go to baseURL //Go to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
const overlayPlot = await createDomainObjectWithDefaults(page, { type: 'Overlay Plot' }); const overlayPlot = await createDomainObjectWithDefaults(page, { type: 'Overlay Plot' });
// click create button // click create button
await page.locator('button:has-text("Create")').click(); await page.locator('button:has-text("Create")').click();
// add sine wave generator with defaults // add sine wave generator with defaults
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click(); await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
//Add a 5000 ms Delay //Add a 5000 ms Delay
await page.locator('[aria-label="Loading Delay \\(ms\\)"]').fill('5000'); await page.locator('[aria-label="Loading Delay \\(ms\\)"]').fill('5000');
await Promise.all([ await Promise.all([
page.waitForNavigation(), page.waitForNavigation(),
page.locator('button:has-text("OK")').click(), page.locator('button:has-text("OK")').click(),
//Wait for Save Banner to appear //Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message') page.waitForSelector('.c-message-banner__message')
]); ]);
// focus the overlay plot // focus the overlay plot
await page.goto(overlayPlot.url); await page.goto(overlayPlot.url);
await expect(page.locator('.l-browse-bar__object-name')).toContainText(overlayPlot.name); await expect(page.locator('.l-browse-bar__object-name')).toContainText(overlayPlot.name);
//Save localStorage for future test execution //Save localStorage for future test execution
await context.storageState({ path: './e2e/test-data/VisualTestData_storage.json' }); await context.storageState({ path: './e2e/test-data/VisualTestData_storage.json' });
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -29,16 +29,18 @@ const { test } = require('../../pluginFixtures.js');
// eslint-disable-next-line playwright/no-skipped-test // eslint-disable-next-line playwright/no-skipped-test
test.describe.skip('pluginFixtures tests', () => { test.describe.skip('pluginFixtures tests', () => {
// test.use({ domainObjectName: 'Timer' }); // test.use({ domainObjectName: 'Timer' });
// let timerUUID; // let timerUUID;
// test('Creates a timer object @framework @unstable', ({ domainObject }) => {
// const { uuid } = domainObject; // test('Creates a timer object @framework @unstable', ({ domainObject }) => {
// const uuidRegexp = /[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/; // const { uuid } = domainObject;
// expect(uuid).toMatch(uuidRegexp); // const uuidRegexp = /[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/;
// timerUUID = uuid; // expect(uuid).toMatch(uuidRegexp);
// }); // timerUUID = uuid;
// test('Provides same uuid for subsequent uses of the same object @framework', ({ domainObject }) => { // });
// const { uuid } = domainObject;
// expect(uuid).toEqual(timerUUID); // test('Provides same uuid for subsequent uses of the same object @framework', ({ domainObject }) => {
// }); // const { uuid } = domainObject;
// expect(uuid).toEqual(timerUUID);
// });
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -21,15 +21,16 @@
*****************************************************************************/ *****************************************************************************/
/* /*
* This test suite template is to be used when verifying Test Data files found in /e2e/test-data/ * This test suite template is to be used when verifying Test Data files found in /e2e/test-data/
*/ */
const { test } = require('../../baseFixtures'); const { test } = require('../../baseFixtures');
test.describe('recycled_local_storage @localStorage', () => { test.describe('recycled_local_storage @localStorage', () => {
//We may want to do some additional level of verification of this file. For now, we just verify that it exists and can be used in a test suite. //We may want to do some additional level of verification of this file. For now, we just verify that it exists and can be used in a test suite.
test.use({ storageState: './e2e/test-data/recycled_local_storage.json' }); test.use({ storageState: './e2e/test-data/recycled_local_storage.json' });
test('Can use recycled_local_storage file', async ({ page }) => { test('Can use recycled_local_storage file', async ({ page }) => {
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
}); });
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -27,39 +27,37 @@ This test suite is dedicated to tests which verify branding related components.
const { test, expect } = require('../../baseFixtures.js'); const { test, expect } = require('../../baseFixtures.js');
test.describe('Branding tests', () => { test.describe('Branding tests', () => {
test('About Modal launches with basic branding properties', async ({ page }) => { test('About Modal launches with basic branding properties', async ({ page }) => {
// Go to baseURL // Go to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
// Click About button // Click About button
await page.click('.l-shell__app-logo'); await page.click('.l-shell__app-logo');
// Verify that the NASA Logo Appears // Verify that the NASA Logo Appears
await expect(page.locator('.c-about__image')).toBeVisible(); await expect(page.locator('.c-about__image')).toBeVisible();
// Modify the Build information in 'about' Modal // Modify the Build information in 'about' Modal
const versionInformationLocator = page.locator('ul.t-info.l-info.s-info').first(); const versionInformationLocator = page.locator('ul.t-info.l-info.s-info').first();
await expect(versionInformationLocator).toBeEnabled(); await expect(versionInformationLocator).toBeEnabled();
await expect.soft(versionInformationLocator).toContainText(/Version: \d/); await expect.soft(versionInformationLocator).toContainText(/Version: \d/);
await expect await expect.soft(versionInformationLocator).toContainText(/Build Date: ((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun))/);
.soft(versionInformationLocator) await expect.soft(versionInformationLocator).toContainText(/Revision: \b[0-9a-f]{5,40}\b/);
.toContainText(/Build Date: ((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun))/); await expect.soft(versionInformationLocator).toContainText(/Branch: ./);
await expect.soft(versionInformationLocator).toContainText(/Revision: \b[0-9a-f]{5,40}\b/); });
await expect.soft(versionInformationLocator).toContainText(/Branch: ./); test('Verify Links in About Modal @2p', async ({ page }) => {
}); // Go to baseURL
test('Verify Links in About Modal @2p', async ({ page }) => { await page.goto('./', { waitUntil: 'networkidle' });
// Go to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' });
// Click About button // Click About button
await page.click('.l-shell__app-logo'); await page.click('.l-shell__app-logo');
// Verify that clicking on the third party licenses information opens up another tab on licenses url // Verify that clicking on the third party licenses information opens up another tab on licenses url
const [page2] = await Promise.all([ const [page2] = await Promise.all([
page.waitForEvent('popup'), page.waitForEvent('popup'),
page.locator('text=click here for third party licensing information').click() page.locator('text=click here for third party licensing information').click()
]); ]);
await page2.waitForLoadState('networkidle'); //Avoids timing issues with juggler/firefox await page2.waitForLoadState('networkidle'); //Avoids timing issues with juggler/firefox
expect(page2.waitForURL('**/licenses**')).toBeTruthy(); expect(page2.waitForURL('**/licenses**')).toBeTruthy();
}); });
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -21,98 +21,91 @@
*****************************************************************************/ *****************************************************************************/
/* /*
* This test suite is meant to be executed against a couchdb container. More doc to come * This test suite is meant to be executed against a couchdb container. More doc to come
* *
*/ */
const { test, expect } = require('../../pluginFixtures'); const { test, expect } = require('../../pluginFixtures');
test.describe('CouchDB Status Indicator with mocked responses @couchdb', () => { test.describe("CouchDB Status Indicator with mocked responses @couchdb", () => {
test.use({ failOnConsoleError: false }); test.use({ failOnConsoleError: false });
//TODO BeforeAll Verify CouchDB Connectivity with APIContext //TODO BeforeAll Verify CouchDB Connectivity with APIContext
test('Shows green if connected', async ({ page }) => { test('Shows green if connected', async ({ page }) => {
await page.route('**/openmct/mine', (route) => { await page.route('**/openmct/mine', route => {
route.fulfill({ route.fulfill({
status: 200, status: 200,
contentType: 'application/json', contentType: 'application/json',
body: JSON.stringify({}) body: JSON.stringify({})
}); });
}); });
//Go to baseURL //Go to baseURL
await page.goto('./#/browse/mine?hideTree=true&hideInspector=true', { await page.goto('./#/browse/mine?hideTree=true&hideInspector=true', { waitUntil: 'networkidle' });
waitUntil: 'networkidle' await expect(page.locator('div:has-text("CouchDB is connected")').nth(3)).toBeVisible();
});
await expect(page.locator('div:has-text("CouchDB is connected")').nth(3)).toBeVisible();
});
test('Shows red if not connected', async ({ page }) => {
await page.route('**/openmct/**', (route) => {
route.fulfill({
status: 503,
contentType: 'application/json',
body: JSON.stringify({})
});
}); });
test('Shows red if not connected', async ({ page }) => {
await page.route('**/openmct/**', route => {
route.fulfill({
status: 503,
contentType: 'application/json',
body: JSON.stringify({})
});
});
//Go to baseURL //Go to baseURL
await page.goto('./#/browse/mine?hideTree=true&hideInspector=true', { await page.goto('./#/browse/mine?hideTree=true&hideInspector=true', { waitUntil: 'networkidle' });
waitUntil: 'networkidle' await expect(page.locator('div:has-text("CouchDB is offline")').nth(3)).toBeVisible();
});
await expect(page.locator('div:has-text("CouchDB is offline")').nth(3)).toBeVisible();
});
test('Shows unknown if it receives an unexpected response code', async ({ page }) => {
await page.route('**/openmct/mine', (route) => {
route.fulfill({
status: 418,
contentType: 'application/json',
body: JSON.stringify({})
});
}); });
test('Shows unknown if it receives an unexpected response code', async ({ page }) => {
await page.route('**/openmct/mine', route => {
route.fulfill({
status: 418,
contentType: 'application/json',
body: JSON.stringify({})
});
});
//Go to baseURL //Go to baseURL
await page.goto('./#/browse/mine?hideTree=true&hideInspector=true', { await page.goto('./#/browse/mine?hideTree=true&hideInspector=true', { waitUntil: 'networkidle' });
waitUntil: 'networkidle' await expect(page.locator('div:has-text("CouchDB connectivity unknown")').nth(3)).toBeVisible();
}); });
await expect(page.locator('div:has-text("CouchDB connectivity unknown")').nth(3)).toBeVisible();
});
}); });
test.describe('CouchDB initialization with mocked responses @couchdb', () => { test.describe("CouchDB initialization with mocked responses @couchdb", () => {
test.use({ failOnConsoleError: false }); test.use({ failOnConsoleError: false });
test("'My Items' folder is created if it doesn't exist", async ({ page }) => { test("'My Items' folder is created if it doesn't exist", async ({ page }) => {
const mockedMissingObjectResponsefromCouchDB = { const mockedMissingObjectResponsefromCouchDB = {
status: 404, status: 404,
contentType: 'application/json', contentType: 'application/json',
body: JSON.stringify({}) body: JSON.stringify({})
}; };
// Override the first request to GET openmct/mine to return a 404. // Override the first request to GET openmct/mine to return a 404.
// This simulates the case of starting Open MCT with a fresh database // This simulates the case of starting Open MCT with a fresh database
// and no "My Items" folder created yet. // and no "My Items" folder created yet.
await page.route( await page.route('**/mine', route => {
'**/mine', route.fulfill(mockedMissingObjectResponsefromCouchDB);
(route) => { }, { times: 1 });
route.fulfill(mockedMissingObjectResponsefromCouchDB);
},
{ times: 1 }
);
// Set up promise to verify that a PUT request to create "My Items" // Set up promise to verify that a PUT request to create "My Items"
// folder was made. // folder was made.
const putMineFolderRequest = page.waitForRequest( const putMineFolderRequest = page.waitForRequest(req =>
(req) => req.url().endsWith('/mine') && req.method() === 'PUT' req.url().endsWith('/mine')
); && req.method() === 'PUT');
// Set up promise to verify that a GET request to retrieve "My Items" // Set up promise to verify that a GET request to retrieve "My Items"
// folder was made. // folder was made.
const getMineFolderRequest = page.waitForRequest( const getMineFolderRequest = page.waitForRequest(req =>
(req) => req.url().endsWith('/mine') && req.method() === 'GET' req.url().endsWith('/mine')
); && req.method() === 'GET');
// Go to baseURL. // Go to baseURL.
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
// Wait for both requests to resolve. // Wait for both requests to resolve.
await Promise.all([putMineFolderRequest, getMineFolderRequest]); await Promise.all([
}); putMineFolderRequest,
getMineFolderRequest
]);
});
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -28,31 +28,32 @@ const { test, expect } = require('../../../pluginFixtures');
const { createDomainObjectWithDefaults } = require('../../../appActions'); const { createDomainObjectWithDefaults } = require('../../../appActions');
test.describe('Example Event Generator CRUD Operations', () => { test.describe('Example Event Generator CRUD Operations', () => {
test('Can create a Test Event Generator and it results in the table View', async ({ page }) => { test('Can create a Test Event Generator and it results in the table View', async ({ page }) => {
//Go to baseURL //Go to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
//Create a name for the object //Create a name for the object
const newObjectName = 'Test Event Generator'; const newObjectName = 'Test Event Generator';
await createDomainObjectWithDefaults(page, { await createDomainObjectWithDefaults(page, {
type: 'Event Message Generator', type: 'Event Message Generator',
name: newObjectName name: newObjectName
});
//Assertions against newly created object which define standard behavior
await expect(page.waitForURL(/.*&view=table/)).toBeTruthy();
await expect(page.locator('.l-browse-bar__object-name')).toContainText(newObjectName);
}); });
//Assertions against newly created object which define standard behavior
await expect(page.waitForURL(/.*&view=table/)).toBeTruthy();
await expect(page.locator('.l-browse-bar__object-name')).toContainText(newObjectName);
});
}); });
test.describe('Example Event Generator Telemetry Event Verficiation', () => { test.describe('Example Event Generator Telemetry Event Verficiation', () => {
test.fixme('telemetry is coming in for test event', async ({ page }) => {
test.fixme('telemetry is coming in for test event', async ({ page }) => {
// Go to object created in step one // Go to object created in step one
// Verify the telemetry table is filled with > 1 row // Verify the telemetry table is filled with > 1 row
}); });
test.fixme('telemetry is sorted by time ascending', async ({ page }) => { test.fixme('telemetry is sorted by time ascending', async ({ page }) => {
// Go to object created in step one // Go to object created in step one
// Verify the telemetry table has a class with "is-sorting asc" // Verify the telemetry table has a class with "is-sorting asc"
}); });
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -27,113 +27,93 @@ This test suite is dedicated to tests which verify the basic operations surround
const { test, expect } = require('../../../../baseFixtures'); const { test, expect } = require('../../../../baseFixtures');
test.describe('Sine Wave Generator', () => { test.describe('Sine Wave Generator', () => {
test('Create new Sine Wave Generator Object and validate create Form Logic', async ({ test('Create new Sine Wave Generator Object and validate create Form Logic', async ({ page, browserName }) => {
page, // eslint-disable-next-line playwright/no-skipped-test
browserName test.skip(browserName === 'firefox', 'This test needs to be updated to work with firefox');
}) => {
// eslint-disable-next-line playwright/no-skipped-test
test.skip(browserName === 'firefox', 'This test needs to be updated to work with firefox');
//Go to baseURL //Go to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
//Click the Create button //Click the Create button
await page.click('button:has-text("Create")'); await page.click('button:has-text("Create")');
// Click Sine Wave Generator // Click Sine Wave Generator
await page.click('text=Sine Wave Generator'); await page.click('text=Sine Wave Generator');
// Verify that the each required field has required indicator // Verify that the each required field has required indicator
// Title // Title
await expect(page.locator('.c-form-row__state-indicator').first()).toHaveClass(/req/); await expect(page.locator('.c-form-row__state-indicator').first()).toHaveClass(/req/);
// Verify that the Notes row does not have a required indicator // Verify that the Notes row does not have a required indicator
await expect( await expect(page.locator('.c-form__section div:nth-child(3) .form-row .c-form-row__state-indicator')).not.toContain('.req');
page.locator('.c-form__section div:nth-child(3) .form-row .c-form-row__state-indicator') await page.locator('textarea[type="text"]').fill('Optional Note Text');
).not.toContain('.req');
await page.locator('textarea[type="text"]').fill('Optional Note Text');
// Period // Period
await expect(page.locator('div:nth-child(4) .c-form-row__state-indicator')).toHaveClass(/req/); await expect(page.locator('div:nth-child(4) .c-form-row__state-indicator')).toHaveClass(/req/);
// Amplitude // Amplitude
await expect(page.locator('div:nth-child(5) .c-form-row__state-indicator')).toHaveClass(/req/); await expect(page.locator('div:nth-child(5) .c-form-row__state-indicator')).toHaveClass(/req/);
// Offset // Offset
await expect(page.locator('div:nth-child(6) .c-form-row__state-indicator')).toHaveClass(/req/); await expect(page.locator('div:nth-child(6) .c-form-row__state-indicator')).toHaveClass(/req/);
// Data Rate // Data Rate
await expect(page.locator('div:nth-child(7) .c-form-row__state-indicator')).toHaveClass(/req/); await expect(page.locator('div:nth-child(7) .c-form-row__state-indicator')).toHaveClass(/req/);
// Phase // Phase
await expect(page.locator('div:nth-child(8) .c-form-row__state-indicator')).toHaveClass(/req/); await expect(page.locator('div:nth-child(8) .c-form-row__state-indicator')).toHaveClass(/req/);
// Randomness // Randomness
await expect(page.locator('div:nth-child(9) .c-form-row__state-indicator')).toHaveClass(/req/); await expect(page.locator('div:nth-child(9) .c-form-row__state-indicator')).toHaveClass(/req/);
// Verify that by removing value from required text field shows invalid indicator // Verify that by removing value from required text field shows invalid indicator
await page await page.locator('text=Properties Title Notes Period Amplitude Offset Data Rate (hz) Phase (radians) Ra >> input[type="text"]').fill('');
.locator( await expect(page.locator('.c-form-row__state-indicator').first()).toHaveClass(/invalid/);
'text=Properties Title Notes Period Amplitude Offset Data Rate (hz) Phase (radians) Ra >> input[type="text"]'
)
.fill('');
await expect(page.locator('.c-form-row__state-indicator').first()).toHaveClass(/invalid/);
// Verify that by adding value to empty required text field changes invalid to valid indicator // Verify that by adding value to empty required text field changes invalid to valid indicator
await page await page.locator('text=Properties Title Notes Period Amplitude Offset Data Rate (hz) Phase (radians) Ra >> input[type="text"]').fill('New Sine Wave Generator');
.locator( await expect(page.locator('.c-form-row__state-indicator').first()).toHaveClass(/valid/);
'text=Properties Title Notes Period Amplitude Offset Data Rate (hz) Phase (radians) Ra >> input[type="text"]'
)
.fill('New Sine Wave Generator');
await expect(page.locator('.c-form-row__state-indicator').first()).toHaveClass(/valid/);
// Verify that by removing value from required number field shows invalid indicator // Verify that by removing value from required number field shows invalid indicator
await page.locator('.field.control.l-input-sm input').first().fill(''); await page.locator('.field.control.l-input-sm input').first().fill('');
await expect(page.locator('div:nth-child(4) .c-form-row__state-indicator')).toHaveClass( await expect(page.locator('div:nth-child(4) .c-form-row__state-indicator')).toHaveClass(/invalid/);
/invalid/
);
// Verify that by adding value to empty required number field changes invalid to valid indicator // Verify that by adding value to empty required number field changes invalid to valid indicator
await page.locator('.field.control.l-input-sm input').first().fill('3'); await page.locator('.field.control.l-input-sm input').first().fill('3');
await expect(page.locator('div:nth-child(4) .c-form-row__state-indicator')).toHaveClass( await expect(page.locator('div:nth-child(4) .c-form-row__state-indicator')).toHaveClass(/valid/);
/valid/
);
// Verify that can change value of number field by up/down arrows keys // Verify that can change value of number field by up/down arrows keys
// Click .field.control.l-input-sm input >> nth=0 // Click .field.control.l-input-sm input >> nth=0
await page.locator('.field.control.l-input-sm input').first().click(); await page.locator('.field.control.l-input-sm input').first().click();
// Press ArrowUp 3 times to change value from 3 to 6 // Press ArrowUp 3 times to change value from 3 to 6
await page.locator('.field.control.l-input-sm input').first().press('ArrowUp'); await page.locator('.field.control.l-input-sm input').first().press('ArrowUp');
await page.locator('.field.control.l-input-sm input').first().press('ArrowUp'); await page.locator('.field.control.l-input-sm input').first().press('ArrowUp');
await page.locator('.field.control.l-input-sm input').first().press('ArrowUp'); await page.locator('.field.control.l-input-sm input').first().press('ArrowUp');
const value = await page.locator('.field.control.l-input-sm input').first().inputValue(); const value = await page.locator('.field.control.l-input-sm input').first().inputValue();
await expect(value).toBe('6'); await expect(value).toBe('6');
//Click text=OK //Click text=OK
await Promise.all([page.waitForNavigation(), page.click('button:has-text("OK")')]); await Promise.all([
page.waitForNavigation(),
page.click('button:has-text("OK")')
]);
// Verify that the Sine Wave Generator is displayed and correct // Verify that the Sine Wave Generator is displayed and correct
// Verify object properties // Verify object properties
await expect(page.locator('.l-browse-bar__object-name')).toContainText( await expect(page.locator('.l-browse-bar__object-name')).toContainText('New Sine Wave Generator');
'New Sine Wave Generator'
);
// Verify canvas rendered and can be interacted with // Verify canvas rendered and can be interacted with
await page await page.locator('canvas').nth(1).click({
.locator('canvas') position: {
.nth(1) x: 341,
.click({ y: 28
position: { }
x: 341, });
y: 28
}
});
// Verify that where we click on canvas shows the number we clicked on // Verify that where we click on canvas shows the number we clicked on
// Note that any number will do, we just care that a number exists // Note that any number will do, we just care that a number exists
await expect(page.locator('.value-to-display-nearestValue')).toContainText( await expect(page.locator('.value-to-display-nearestValue')).toContainText(/[+-]?([0-9]*[.])?[0-9]+/);
/[+-]?([0-9]*[.])?[0-9]+/
); });
});
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -19,7 +19,7 @@
* this source code distribution or the Licensing information page available * this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
/* global __dirname */
/* /*
This test suite is dedicated to tests which verify form functionality in isolation This test suite is dedicated to tests which verify form functionality in isolation
*/ */
@@ -34,269 +34,246 @@ const jsonFilePath = 'e2e/test-data/ExampleLayouts.json';
const imageFilePath = 'e2e/test-data/rick.jpg'; const imageFilePath = 'e2e/test-data/rick.jpg';
test.describe('Form Validation Behavior', () => { test.describe('Form Validation Behavior', () => {
test('Required Field indicators appear if title is empty and can be corrected', async ({ test('Required Field indicators appear if title is empty and can be corrected', async ({ page }) => {
page //Go to baseURL
}) => { await page.goto('./', { waitUntil: 'networkidle' });
//Go to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' });
await page.click('button:has-text("Create")'); await page.click('button:has-text("Create")');
await page.getByRole('menuitem', { name: ' Folder' }).click(); await page.click(':nth-match(:text("Folder"), 2)');
// Fill in empty string into title and trigger validation with 'Tab' // Fill in empty string into title and trigger validation with 'Tab'
await page.click('text=Properties Title Notes >> input[type="text"]'); await page.click('text=Properties Title Notes >> input[type="text"]');
await page.fill('text=Properties Title Notes >> input[type="text"]', ''); await page.fill('text=Properties Title Notes >> input[type="text"]', '');
await page.press('text=Properties Title Notes >> input[type="text"]', 'Tab'); await page.press('text=Properties Title Notes >> input[type="text"]', 'Tab');
//Required Field Form Validation //Required Field Form Validation
await expect(page.locator('button:has-text("OK")')).toBeDisabled(); await expect(page.locator('button:has-text("OK")')).toBeDisabled();
await expect(page.locator('.c-form-row__state-indicator').first()).toHaveClass(/invalid/); await expect(page.locator('.c-form-row__state-indicator').first()).toHaveClass(/invalid/);
//Correct Form Validation for missing title and trigger validation with 'Tab' //Correct Form Validation for missing title and trigger validation with 'Tab'
await page.click('text=Properties Title Notes >> input[type="text"]'); await page.click('text=Properties Title Notes >> input[type="text"]');
await page.fill('text=Properties Title Notes >> input[type="text"]', TEST_FOLDER); await page.fill('text=Properties Title Notes >> input[type="text"]', TEST_FOLDER);
await page.press('text=Properties Title Notes >> input[type="text"]', 'Tab'); await page.press('text=Properties Title Notes >> input[type="text"]', 'Tab');
//Required Field Form Validation is corrected //Required Field Form Validation is corrected
await expect(page.locator('button:has-text("OK")')).toBeEnabled(); await expect(page.locator('button:has-text("OK")')).toBeEnabled();
await expect(page.locator('.c-form-row__state-indicator').first()).not.toHaveClass(/invalid/); await expect(page.locator('.c-form-row__state-indicator').first()).not.toHaveClass(/invalid/);
//Finish Creating Domain Object //Finish Creating Domain Object
await Promise.all([page.waitForNavigation(), page.click('button:has-text("OK")')]); await Promise.all([
page.waitForNavigation(),
page.click('button:has-text("OK")')
]);
//Verify that the Domain Object has been created with the corrected title property //Verify that the Domain Object has been created with the corrected title property
await expect(page.locator('.l-browse-bar__object-name')).toContainText(TEST_FOLDER); await expect(page.locator('.l-browse-bar__object-name')).toContainText(TEST_FOLDER);
}); });
}); });
test.describe('Form File Input Behavior', () => { test.describe('Form File Input Behavior', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
await page.addInitScript({ // eslint-disable-next-line no-undef
path: path.join(__dirname, '../../helper', 'addInitFileInputObject.js') await page.addInitScript({ path: path.join(__dirname, '../../helper', 'addInitFileInputObject.js') });
}); });
});
test('Can select a JSON file type', async ({ page }) => { test('Can select a JSON file type', async ({ page }) => {
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
await page.getByRole('button', { name: ' Create ' }).click(); await page.getByRole('button', { name: ' Create ' }).click();
await page.getByRole('menuitem', { name: 'JSON File Input Object' }).click(); await page.getByRole('menuitem', { name: 'JSON File Input Object' }).click();
await page.setInputFiles('#fileElem', jsonFilePath); await page.setInputFiles('#fileElem', jsonFilePath);
await page.getByRole('button', { name: 'Save' }).click(); await page.getByRole('button', { name: 'Save' }).click();
const type = await page.locator('#file-input-type').textContent(); const type = await page.locator('#file-input-type').textContent();
await expect(type).toBe(`"string"`); await expect(type).toBe(`"string"`);
}); });
test('Can select an image file type', async ({ page }) => { test('Can select an image file type', async ({ page }) => {
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
await page.getByRole('button', { name: ' Create ' }).click(); await page.getByRole('button', { name: ' Create ' }).click();
await page.getByRole('menuitem', { name: 'Image File Input Object' }).click(); await page.getByRole('menuitem', { name: 'Image File Input Object' }).click();
await page.setInputFiles('#fileElem', imageFilePath); await page.setInputFiles('#fileElem', imageFilePath);
await page.getByRole('button', { name: 'Save' }).click(); await page.getByRole('button', { name: 'Save' }).click();
const type = await page.locator('#file-input-type').textContent(); const type = await page.locator('#file-input-type').textContent();
await expect(type).toBe(`"object"`); await expect(type).toBe(`"object"`);
}); });
}); });
test.describe('Persistence operations @addInit', () => { test.describe('Persistence operations @addInit', () => {
// add non persistable root item // add non persistable root item
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
await page.addInitScript({ // eslint-disable-next-line no-undef
path: path.join(__dirname, '../../helper', 'addNoneditableObject.js') await page.addInitScript({ path: path.join(__dirname, '../../helper', 'addNoneditableObject.js') });
}); });
});
test('Persistability should be respected in the create form location field', async ({ page }) => { test('Persistability should be respected in the create form location field', async ({ page }) => {
test.info().annotations.push({ test.info().annotations.push({
type: 'issue', type: 'issue',
description: 'https://github.com/nasa/openmct/issues/4323' description: 'https://github.com/nasa/openmct/issues/4323'
});
await page.goto('./', { waitUntil: 'networkidle' });
await page.click('button:has-text("Create")');
await page.click('text=Condition Set');
await page.locator('form[name="mctForm"] >> text=Persistence Testing').click();
const okButton = page.locator('button:has-text("OK")');
await expect(okButton).toBeDisabled();
}); });
await page.goto('./', { waitUntil: 'domcontentloaded' });
await page.click('button:has-text("Create")');
await page.click('text=Condition Set');
await page.locator('form[name="mctForm"] >> text=Persistence Testing').click();
const okButton = page.locator('button:has-text("OK")');
await expect(okButton).toBeDisabled();
});
}); });
test.describe('Persistence operations @couchdb', () => { test.describe('Persistence operations @couchdb', () => {
test.use({ failOnConsoleError: false }); test.use({ failOnConsoleError: false });
test('Editing object properties should generate a single persistence operation', async ({ test('Editing object properties should generate a single persistence operation', async ({ page }) => {
page test.info().annotations.push({
}) => { type: 'issue',
test.info().annotations.push({ description: 'https://github.com/nasa/openmct/issues/5616'
type: 'issue', });
description: 'https://github.com/nasa/openmct/issues/5616'
await page.goto('./', { waitUntil: 'networkidle' });
// Create a new 'Clock' object with default settings
const clock = await createDomainObjectWithDefaults(page, {
type: 'Clock'
});
// Count all persistence operations (PUT requests) for this specific object
let putRequestCount = 0;
page.on('request', req => {
if (req.method() === 'PUT' && req.url().endsWith(clock.uuid)) {
putRequestCount += 1;
}
});
// Open the edit form for the clock object
await page.click('button[title="More options"]');
await page.click('li[title="Edit properties of this object."]');
// Modify the display format from default 12hr -> 24hr and click 'Save'
await page.locator('select[aria-label="12 or 24 hour clock"]').selectOption({ value: 'clock24' });
await page.click('button[aria-label="Save"]');
await expect.poll(() => putRequestCount, {
message: 'Verify a single PUT request was made to persist the object',
timeout: 1000
}).toEqual(1);
}); });
test('Can create an object after a conflict error @couchdb @2p', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/5982'
});
await page.goto('./', { waitUntil: 'domcontentloaded' }); const page2 = await page.context().newPage();
// Create a new 'Clock' object with default settings // Both pages: Go to baseURL
const clock = await createDomainObjectWithDefaults(page, { await Promise.all([
type: 'Clock' page.goto('./', { waitUntil: 'networkidle' }),
page2.goto('./', { waitUntil: 'networkidle' })
]);
// Both pages: Click the Create button
await Promise.all([
page.click('button:has-text("Create")'),
page2.click('button:has-text("Create")')
]);
// Both pages: Click "Clock" in the Create menu
await Promise.all([
page.click(`li[role='menuitem']:text("Clock")`),
page2.click(`li[role='menuitem']:text("Clock")`)
]);
// Generate unique names for both objects
const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]');
const nameInput2 = page2.locator('form[name="mctForm"] .first input[type="text"]');
// Both pages: Fill in the 'Name' form field.
await Promise.all([
nameInput.fill(""),
nameInput.fill(`Clock:${genUuid()}`),
nameInput2.fill(""),
nameInput2.fill(`Clock:${genUuid()}`)
]);
// Both pages: Fill the "Notes" section with information about the
// currently running test and its project.
const testNotes = page.testNotes;
const notesInput = page.locator('form[name="mctForm"] #notes-textarea');
const notesInput2 = page2.locator('form[name="mctForm"] #notes-textarea');
await Promise.all([
notesInput.fill(testNotes),
notesInput2.fill(testNotes)
]);
// Page 2: Click "OK" to create the domain object and wait for navigation.
// This will update the composition of the parent folder, setting the
// conditions for a conflict error from the first page.
await Promise.all([
page2.waitForLoadState(),
page2.click('[aria-label="Save"]'),
// Wait for Save Banner to appear
page2.waitForSelector('.c-message-banner__message')
]);
// Close Page 2, we're done with it.
await page2.close();
// Page 1: Click "OK" to create the domain object and wait for navigation.
// This will trigger a conflict error upon attempting to update
// the composition of the parent folder.
await Promise.all([
page.waitForLoadState(),
page.click('[aria-label="Save"]'),
// Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message')
]);
// Page 1: Verify that the conflict has occurred and an error notification is displayed.
await expect(page.locator('.c-message-banner__message', {
hasText: "Conflict detected while saving mine"
})).toBeVisible();
// Page 1: Start logging console errors from this point on
let errors = [];
page.on('console', (msg) => {
if (msg.type() === 'error') {
errors.push(msg.text());
}
});
// Page 1: Try to create a clock with the page that received the conflict.
const clockAfterConflict = await createDomainObjectWithDefaults(page, {
type: 'Clock'
});
// Page 1: Wait for save progress dialog to appear/disappear
await page.locator('.c-message-banner__message', {
hasText: 'Do not navigate away from this page or close this browser tab while this message is displayed.',
state: 'visible'
}).waitFor({ state: 'hidden' });
// Page 1: Navigate to 'My Items' and verify that the second clock was created
await page.goto('./#/browse/mine');
await expect(page.locator(`.c-grid-item__name[title="${clockAfterConflict.name}"]`)).toBeVisible();
// Verify no console errors occurred
expect(errors).toHaveLength(0);
}); });
// Count all persistence operations (PUT requests) for this specific object
let putRequestCount = 0;
page.on('request', (req) => {
if (req.method() === 'PUT' && req.url().endsWith(clock.uuid)) {
putRequestCount += 1;
}
});
// Open the edit form for the clock object
await page.click('button[title="More options"]');
await page.click('li[title="Edit properties of this object."]');
// Modify the display format from default 12hr -> 24hr and click 'Save'
await page
.locator('select[aria-label="12 or 24 hour clock"]')
.selectOption({ value: 'clock24' });
await page.click('button[aria-label="Save"]');
await expect
.poll(() => putRequestCount, {
message: 'Verify a single PUT request was made to persist the object',
timeout: 1000
})
.toEqual(1);
});
test('Can create an object after a conflict error @couchdb @2p', async ({
page,
openmctConfig
}) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/5982'
});
const { myItemsFolderName } = openmctConfig;
// Instantiate a second page/tab
const page2 = await page.context().newPage();
// Both pages: Go to baseURL
await Promise.all([
page.goto('./', { waitUntil: 'networkidle' }),
page2.goto('./', { waitUntil: 'networkidle' })
]);
//Slow down the test a bit
await expect(
page.getByRole('button', { name: `Expand ${myItemsFolderName} folder` })
).toBeVisible();
await expect(
page2.getByRole('button', { name: `Expand ${myItemsFolderName} folder` })
).toBeVisible();
// Both pages: Click the Create button
await Promise.all([
page.click('button:has-text("Create")'),
page2.click('button:has-text("Create")')
]);
// Both pages: Click "Clock" in the Create menu
await Promise.all([
page.click(`li[role='menuitem']:text("Clock")`),
page2.click(`li[role='menuitem']:text("Clock")`)
]);
// Generate unique names for both objects
const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]');
const nameInput2 = page2.locator('form[name="mctForm"] .first input[type="text"]');
// Both pages: Fill in the 'Name' form field.
await Promise.all([
nameInput.fill(''),
nameInput.fill(`Clock:${genUuid()}`),
nameInput2.fill(''),
nameInput2.fill(`Clock:${genUuid()}`)
]);
// Both pages: Fill the "Notes" section with information about the
// currently running test and its project.
const testNotes = page.testNotes;
const notesInput = page.locator('form[name="mctForm"] #notes-textarea');
const notesInput2 = page2.locator('form[name="mctForm"] #notes-textarea');
await Promise.all([notesInput.fill(testNotes), notesInput2.fill(testNotes)]);
// Page 2: Click "OK" to create the domain object and wait for navigation.
// This will update the composition of the parent folder, setting the
// conditions for a conflict error from the first page.
await Promise.all([
page2.waitForLoadState(),
page2.click('[aria-label="Save"]'),
// Wait for Save Banner to appear
page2.waitForSelector('.c-message-banner__message')
]);
// Close Page 2, we're done with it.
await page2.close();
// Page 1: Click "OK" to create the domain object and wait for navigation.
// This will trigger a conflict error upon attempting to update
// the composition of the parent folder.
await Promise.all([
page.waitForLoadState(),
page.click('[aria-label="Save"]'),
// Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message')
]);
// Page 1: Verify that the conflict has occurred and an error notification is displayed.
await expect(
page.locator('.c-message-banner__message', {
hasText: 'Conflict detected while saving mine'
})
).toBeVisible();
// Page 1: Start logging console errors from this point on
let errors = [];
page.on('console', (msg) => {
if (msg.type() === 'error') {
errors.push(msg.text());
}
});
// Page 1: Try to create a clock with the page that received the conflict.
const clockAfterConflict = await createDomainObjectWithDefaults(page, {
type: 'Clock'
});
// Page 1: Wait for save progress dialog to appear/disappear
await page
.locator('.c-message-banner__message', {
hasText:
'Do not navigate away from this page or close this browser tab while this message is displayed.',
state: 'visible'
})
.waitFor({ state: 'hidden' });
// Page 1: Navigate to 'My Items' and verify that the second clock was created
await page.goto('./#/browse/mine');
await expect(
page.locator(`.c-grid-item__name[title="${clockAfterConflict.name}"]`)
).toBeVisible();
// Verify no console errors occurred
expect(errors).toHaveLength(0);
});
}); });
test.describe('Form Correctness by Object Type', () => { test.describe('Form Correctness by Object Type', () => {
test.fixme('Verify correct behavior of number object (SWG)', async ({ page }) => {}); test.fixme('Verify correct behavior of number object (SWG)', async ({page}) => {});
test.fixme('Verify correct behavior of number object Timer', async ({ page }) => {}); test.fixme('Verify correct behavior of number object Timer', async ({page}) => {});
test.fixme('Verify correct behavior of number object Plan View', async ({ page }) => {}); test.fixme('Verify correct behavior of number object Plan View', async ({page}) => {});
test.fixme('Verify correct behavior of number object Clock', async ({ page }) => {}); test.fixme('Verify correct behavior of number object Clock', async ({page}) => {});
test.fixme('Verify correct behavior of number object Hyperlink', async ({ page }) => {}); test.fixme('Verify correct behavior of number object Hyperlink', async ({page}) => {});
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -19,7 +19,7 @@
* this source code distribution or the Licensing information page available * this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
/* global __dirname */
/* /*
This test suite is dedicated to tests which verify persistability checks This test suite is dedicated to tests which verify persistability checks
*/ */
@@ -29,31 +29,22 @@ const { test, expect } = require('../../baseFixtures.js');
const path = require('path'); const path = require('path');
test.describe('Persistence operations @addInit', () => { test.describe('Persistence operations @addInit', () => {
// add non persistable root item // add non persistable root item
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
await page.addInitScript({ // eslint-disable-next-line no-undef
path: path.join(__dirname, '../../helper', 'addNoneditableObject.js') await page.addInitScript({ path: path.join(__dirname, '../../helper', 'addNoneditableObject.js') });
});
});
test('Non-persistable objects should not show persistence related actions', async ({ page }) => {
await page.goto('./', { waitUntil: 'domcontentloaded' });
await page.locator('text=Persistence Testing').first().click({
button: 'right'
}); });
const menuOptions = page.locator('.c-menu li'); test('Non-persistable objects should not show persistence related actions', async ({ page }) => {
await page.goto('./', { waitUntil: 'networkidle' });
await expect.soft(menuOptions).toContainText(['Open In New Tab', 'View', 'Create Link']); await page.locator('text=Persistence Testing').first().click({
await expect(menuOptions).not.toContainText([ button: 'right'
'Move', });
'Duplicate',
'Remove', const menuOptions = page.locator('.c-menu li');
'Add New Folder',
'Edit Properties...', await expect.soft(menuOptions).toContainText(['Open In New Tab', 'View', 'Create Link']);
'Export as JSON', await expect(menuOptions).not.toContainText(['Move', 'Duplicate', 'Remove', 'Add New Folder', 'Edit Properties...', 'Export as JSON', 'Import from JSON']);
'Import from JSON' });
]);
});
}); });

View File

@@ -1,303 +1,212 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
* Open MCT is licensed under the Apache License, Version 2.0 (the * 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. * "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0. * http://www.apache.org/licenses/LICENSE-2.0.
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
* *
* Open MCT includes source code licensed under additional open source * Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with * licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available * this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
/* /*
This test suite is dedicated to tests which verify the basic operations surrounding moving & linking objects. This test suite is dedicated to tests which verify the basic operations surrounding moving & linking objects.
*/ */
const { test, expect } = require('../../pluginFixtures'); const { test, expect } = require('../../pluginFixtures');
const { createDomainObjectWithDefaults } = require('../../appActions'); const { createDomainObjectWithDefaults } = require('../../appActions');
test.describe('Move & link item tests', () => { test.describe('Move & link item tests', () => {
test('Create a basic object and verify that it can be moved to another folder', async ({ test('Create a basic object and verify that it can be moved to another folder', async ({ page, openmctConfig }) => {
page, const { myItemsFolderName } = openmctConfig;
openmctConfig
}) => { // Go to Open MCT
const { myItemsFolderName } = openmctConfig; await page.goto('./');
// Go to Open MCT const parentFolder = await createDomainObjectWithDefaults(page, {
await page.goto('./'); type: 'Folder',
name: 'Parent Folder'
const parentFolder = await createDomainObjectWithDefaults(page, { });
type: 'Folder', const childFolder = await createDomainObjectWithDefaults(page, {
name: 'Parent Folder' type: 'Folder',
}); name: 'Child Folder',
const childFolder = await createDomainObjectWithDefaults(page, { parent: parentFolder.uuid
type: 'Folder', });
name: 'Child Folder', await createDomainObjectWithDefaults(page, {
parent: parentFolder.uuid type: 'Folder',
}); name: 'Grandchild Folder',
const grandchildFolder = await createDomainObjectWithDefaults(page, { parent: childFolder.uuid
type: 'Folder', });
name: 'Grandchild Folder',
parent: childFolder.uuid // Attempt to move parent to its own grandparent
}); await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
await page.locator('.c-disclosure-triangle >> nth=0').click();
// Attempt to move parent to its own grandparent
await page.locator('button[title="Show selected item in tree"]').click(); await page.locator(`a:has-text("Parent Folder") >> nth=0`).click({
button: 'right'
const treePane = page.getByRole('tree', { });
name: 'Main Tree'
}); await page.locator('li.icon-move').click();
await treePane await page.locator('form[name="mctForm"] >> .c-disclosure-triangle >> nth=0').click();
.getByRole('treeitem', { await page.locator('form[name="mctForm"] >> text=Parent Folder').click();
name: 'Parent Folder' await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
}) await page.locator('form[name="mctForm"] >> .c-disclosure-triangle >> nth=1').click();
.click({ await page.locator('form[name="mctForm"] >> text=Child Folder').click();
button: 'right' await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
}); await page.locator('form[name="mctForm"] >> .c-disclosure-triangle >> nth=2').click();
await page.locator('form[name="mctForm"] >> text=Grandchild Folder').click();
await page await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
.getByRole('menuitem', { await page.locator('form[name="mctForm"] >> text=Parent Folder').click();
name: /Move/ await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
}) await page.locator('[aria-label="Cancel"]').click();
.click();
// Move Child Folder from Parent Folder to My Items
const createModalTree = page.getByRole('tree', { await page.locator('.c-disclosure-triangle >> nth=0').click();
name: 'Create Modal Tree' await page.locator('.c-disclosure-triangle >> nth=1').click();
});
const myItemsLocatorTreeItem = createModalTree.getByRole('treeitem', { await page.locator(`a:has-text("Child Folder") >> nth=0`).click({
name: myItemsFolderName button: 'right'
}); });
await myItemsLocatorTreeItem.locator('.c-disclosure-triangle').click(); await page.locator('li.icon-move').click();
await myItemsLocatorTreeItem.click(); await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
const parentFolderLocatorTreeItem = createModalTree.getByRole('treeitem', { await page.locator('button:has-text("OK")').click();
name: parentFolder.name
}); // Expect that Child Folder is in My Items, the root folder
await parentFolderLocatorTreeItem.locator('.c-disclosure-triangle').click(); expect(page.locator(`text=${myItemsFolderName} >> nth=0:has(text=Child Folder)`)).toBeTruthy();
await parentFolderLocatorTreeItem.click(); });
await expect(page.locator('[aria-label="Save"]')).toBeDisabled(); test('Create a basic object and verify that it cannot be moved to telemetry object without Composition Provider', async ({ page, openmctConfig }) => {
const { myItemsFolderName } = openmctConfig;
const childFolderLocatorTreeItem = createModalTree.getByRole('treeitem', {
name: new RegExp(childFolder.name) // Go to Open MCT
}); await page.goto('./');
await childFolderLocatorTreeItem.locator('.c-disclosure-triangle').click();
await childFolderLocatorTreeItem.click(); // Create Telemetry Table
await expect(page.locator('[aria-label="Save"]')).toBeDisabled(); let telemetryTable = 'Test Telemetry Table';
await page.locator('button:has-text("Create")').click();
const grandchildFolderLocatorTreeItem = createModalTree.getByRole('treeitem', { await page.locator('li[role="menuitem"]:has-text("Telemetry Table")').click();
name: grandchildFolder.name await page.locator('text=Properties Title Notes >> input[type="text"]').click();
}); await page.locator('text=Properties Title Notes >> input[type="text"]').fill(telemetryTable);
await grandchildFolderLocatorTreeItem.locator('.c-disclosure-triangle').click();
await grandchildFolderLocatorTreeItem.click(); await page.locator('button:has-text("OK")').click();
await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
// Finish editing and save Telemetry Table
await parentFolderLocatorTreeItem.click(); await page.locator('.c-button--menu.c-button--major.icon-save').click();
await expect(page.locator('[aria-label="Save"]')).toBeDisabled(); await page.locator('text=Save and Finish Editing').click();
await page.locator('[aria-label="Cancel"]').click();
// Create New Folder Basic Domain Object
// Move Child Folder from Parent Folder to My Items let folder = 'Test Folder';
await treePane await page.locator('button:has-text("Create")').click();
.getByRole('treeitem', { await page.locator('li[role="menuitem"]:has-text("Folder")').click();
name: new RegExp(childFolder.name) await page.locator('text=Properties Title Notes >> input[type="text"]').click();
}) await page.locator('text=Properties Title Notes >> input[type="text"]').fill(folder);
.click({
button: 'right' // See if it's possible to put the folder in the Telemetry object during creation (Soft Assert)
}); await page.locator(`form[name="mctForm"] >> text=${telemetryTable}`).click();
await page let okButton = await page.locator('button.c-button.c-button--major:has-text("OK")');
.getByRole('menuitem', { let okButtonStateDisabled = await okButton.isDisabled();
name: /Move/ expect.soft(okButtonStateDisabled).toBeTruthy();
})
.click(); // Continue test regardless of assertion and create it in My Items
await myItemsLocatorTreeItem.click(); await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
await page.locator('button:has-text("OK")').click();
await page.locator('[aria-label="Save"]').click();
const myItemsPaneTreeItem = treePane.getByRole('treeitem', { // Open My Items
name: myItemsFolderName await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
});
// Select Folder Object and select Move from context menu
// Expect that Child Folder is in My Items, the root folder await Promise.all([
expect(myItemsPaneTreeItem.locator('nth=0:has(text=Child Folder)')).toBeTruthy(); page.waitForNavigation(),
}); page.locator(`a:has-text("${folder}")`).click()
test('Create a basic object and verify that it cannot be moved to telemetry object without Composition Provider', async ({ ]);
page, await page.locator('.c-tree__item.is-navigated-object .c-tree__item__label .c-tree__item__type-icon').click({
openmctConfig button: 'right'
}) => { });
const { myItemsFolderName } = openmctConfig; await page.locator('li.icon-move').click();
// Go to Open MCT // See if it's possible to put the folder in the Telemetry object after creation
await page.goto('./'); await page.locator(`text=Location Open MCT ${myItemsFolderName} >> span`).nth(3).click();
await page.locator(`form[name="mctForm"] >> text=${telemetryTable}`).click();
// Create Telemetry Table let okButton2 = await page.locator('button.c-button.c-button--major:has-text("OK")');
let telemetryTable = 'Test Telemetry Table'; let okButtonStateDisabled2 = await okButton2.isDisabled();
await page.locator('button:has-text("Create")').click(); expect(okButtonStateDisabled2).toBeTruthy();
await page.locator('li[role="menuitem"]:has-text("Telemetry Table")').click(); });
await page.locator('text=Properties Title Notes >> input[type="text"]').click();
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(telemetryTable); test('Create a basic object and verify that it can be linked to another folder', async ({ page, openmctConfig }) => {
const { myItemsFolderName } = openmctConfig;
await page.locator('button:has-text("OK")').click();
// Go to Open MCT
// Finish editing and save Telemetry Table await page.goto('./');
await page.locator('.c-button--menu.c-button--major.icon-save').click();
await page.locator('text=Save and Finish Editing').click(); const parentFolder = await createDomainObjectWithDefaults(page, {
type: 'Folder',
// Create New Folder Basic Domain Object name: 'Parent Folder'
let folder = 'Test Folder'; });
await page.locator('button:has-text("Create")').click(); const childFolder = await createDomainObjectWithDefaults(page, {
await page.locator('li[role="menuitem"]:has-text("Folder")').click(); type: 'Folder',
await page.locator('text=Properties Title Notes >> input[type="text"]').click(); name: 'Child Folder',
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(folder); parent: parentFolder.uuid
});
// See if it's possible to put the folder in the Telemetry object during creation (Soft Assert) await createDomainObjectWithDefaults(page, {
await page.locator(`form[name="mctForm"] >> text=${telemetryTable}`).click(); type: 'Folder',
let okButton = page.locator('button.c-button.c-button--major:has-text("OK")'); name: 'Grandchild Folder',
let okButtonStateDisabled = await okButton.isDisabled(); parent: childFolder.uuid
expect.soft(okButtonStateDisabled).toBeTruthy(); });
// Continue test regardless of assertion and create it in My Items // Attempt to link parent to its own grandparent
await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click(); await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
await page.locator('button:has-text("OK")').click(); await page.locator('.c-disclosure-triangle >> nth=0').click();
// Open My Items await page.locator(`a:has-text("Parent Folder") >> nth=0`).click({
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click(); button: 'right'
});
// Select Folder Object and select Move from context menu
await Promise.all([page.waitForNavigation(), page.locator(`a:has-text("${folder}")`).click()]); await page.locator('li.icon-link').click();
await page await page.locator('form[name="mctForm"] >> .c-disclosure-triangle >> nth=0').click();
.locator('.c-tree__item.is-navigated-object .c-tree__item__label .c-tree__item__type-icon') await page.locator('form[name="mctForm"] >> text=Parent Folder').click();
.click({ await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
button: 'right' await page.locator('form[name="mctForm"] >> .c-disclosure-triangle >> nth=1').click();
}); await page.locator('form[name="mctForm"] >> text=Child Folder').click();
await page.locator('li.icon-move').click(); await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
await page.locator('form[name="mctForm"] >> .c-disclosure-triangle >> nth=2').click();
// See if it's possible to put the folder in the Telemetry object after creation await page.locator('form[name="mctForm"] >> text=Grandchild Folder').click();
await page.locator(`text=Location Open MCT ${myItemsFolderName} >> span`).nth(3).click(); await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
await page.locator(`form[name="mctForm"] >> text=${telemetryTable}`).click(); await page.locator('form[name="mctForm"] >> text=Parent Folder').click();
let okButton2 = page.locator('button.c-button.c-button--major:has-text("OK")'); await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
let okButtonStateDisabled2 = await okButton2.isDisabled(); await page.locator('[aria-label="Cancel"]').click();
expect(okButtonStateDisabled2).toBeTruthy();
}); // Link Child Folder from Parent Folder to My Items
await page.locator('.c-disclosure-triangle >> nth=0').click();
test('Create a basic object and verify that it can be linked to another folder', async ({ await page.locator('.c-disclosure-triangle >> nth=1').click();
page,
openmctConfig await page.locator(`a:has-text("Child Folder") >> nth=0`).click({
}) => { button: 'right'
const { myItemsFolderName } = openmctConfig; });
await page.locator('li.icon-link').click();
// Go to Open MCT await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
await page.goto('./');
await page.locator('button:has-text("OK")').click();
const parentFolder = await createDomainObjectWithDefaults(page, {
type: 'Folder', // Expect that Child Folder is in My Items, the root folder
name: 'Parent Folder' expect(page.locator(`text=${myItemsFolderName} >> nth=0:has(text=Child Folder)`)).toBeTruthy();
}); });
const childFolder = await createDomainObjectWithDefaults(page, { });
type: 'Folder',
name: 'Child Folder', test.fixme('Cannot move a previously created domain object to non-peristable object in Move Modal', async ({ page }) => {
parent: parentFolder.uuid //Create a domain object
}); //Save Domain object
const grandchildFolder = await createDomainObjectWithDefaults(page, { //Move Object and verify that cannot select non-persistable object
type: 'Folder', //Move Object to My Items
name: 'Grandchild Folder', //Verify successful move
parent: childFolder.uuid });
});
// Attempt to move parent to its own grandparent
await page.locator('button[title="Show selected item in tree"]').click();
const treePane = page.getByRole('tree', {
name: 'Main Tree'
});
await treePane
.getByRole('treeitem', {
name: 'Parent Folder'
})
.click({
button: 'right'
});
await page
.getByRole('menuitem', {
name: /Move/
})
.click();
const createModalTree = page.getByRole('tree', {
name: 'Create Modal Tree'
});
const myItemsLocatorTreeItem = createModalTree.getByRole('treeitem', {
name: myItemsFolderName
});
await myItemsLocatorTreeItem.locator('.c-disclosure-triangle').click();
await myItemsLocatorTreeItem.click();
const parentFolderLocatorTreeItem = createModalTree.getByRole('treeitem', {
name: parentFolder.name
});
await parentFolderLocatorTreeItem.locator('.c-disclosure-triangle').click();
await parentFolderLocatorTreeItem.click();
await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
const childFolderLocatorTreeItem = createModalTree.getByRole('treeitem', {
name: new RegExp(childFolder.name)
});
await childFolderLocatorTreeItem.locator('.c-disclosure-triangle').click();
await childFolderLocatorTreeItem.click();
await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
const grandchildFolderLocatorTreeItem = createModalTree.getByRole('treeitem', {
name: grandchildFolder.name
});
await grandchildFolderLocatorTreeItem.locator('.c-disclosure-triangle').click();
await grandchildFolderLocatorTreeItem.click();
await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
await parentFolderLocatorTreeItem.click();
await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
await page.locator('[aria-label="Cancel"]').click();
// Move Child Folder from Parent Folder to My Items
await treePane
.getByRole('treeitem', {
name: new RegExp(childFolder.name)
})
.click({
button: 'right'
});
await page
.getByRole('menuitem', {
name: /Link/
})
.click();
await myItemsLocatorTreeItem.click();
await page.locator('[aria-label="Save"]').click();
const myItemsPaneTreeItem = treePane.getByRole('treeitem', {
name: myItemsFolderName
});
// Expect that Child Folder is in My Items, the root folder
expect(myItemsPaneTreeItem.locator('nth=0:has(text=Child Folder)')).toBeTruthy();
});
});
test.fixme(
'Cannot move a previously created domain object to non-peristable object in Move Modal',
async ({ page }) => {
//Create a domain object
//Save Domain object
//Move Object and verify that cannot select non-persistable object
//Move Object to My Items
//Verify successful move
}
);

View File

@@ -24,95 +24,16 @@
This test suite is dedicated to tests which verify Open MCT's Notification functionality This test suite is dedicated to tests which verify Open MCT's Notification functionality
*/ */
const { createDomainObjectWithDefaults, createNotification } = require('../../appActions'); // FIXME: Remove this eslint exception once tests are implemented
// eslint-disable-next-line no-unused-vars
const { test, expect } = require('../../pluginFixtures'); const { test, expect } = require('../../pluginFixtures');
test.describe('Notifications List', () => { test.describe('Notifications List', () => {
test.fixme('Notifications can be dismissed individually', async ({ page }) => { test.fixme('Notifications can be dismissed individually', async ({ page }) => {
test.info().annotations.push({ // Create some persistent notifications
type: 'issue', // Verify that they are present in the notifications list
description: 'https://github.com/nasa/openmct/issues/6820' // Dismiss one of the notifications
// Verify that it is no longer present in the notifications list
// Verify that the other notifications are still present in the notifications list
}); });
// Go to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' });
// Create an error notification with the message "Error message"
await createNotification(page, {
severity: 'error',
message: 'Error message'
});
// Create an alert notification with the message "Alert message"
await createNotification(page, {
severity: 'alert',
message: 'Alert message'
});
// Verify that there is a button with aria-label "Review 2 Notifications"
expect(await page.locator('button[aria-label="Review 2 Notifications"]').count()).toBe(1);
// Click on button with aria-label "Review 2 Notifications"
await page.click('button[aria-label="Review 2 Notifications"]');
// Click on button with aria-label="Dismiss notification of Error message"
await page.click('button[aria-label="Dismiss notification of Error message"]');
// Verify there is no a notification (listitem) with the text "Error message" since it was dismissed
expect(await page.locator('div[role="dialog"] div[role="listitem"]').innerText()).not.toContain(
'Error message'
);
// Verify there is still a notification (listitem) with the text "Alert message"
expect(await page.locator('div[role="dialog"] div[role="listitem"]').innerText()).toContain(
'Alert message'
);
// Click on button with aria-label="Dismiss notification of Alert message"
await page.click('button[aria-label="Dismiss notification of Alert message"]');
// Verify that there is no dialog since the notification overlay was closed automatically after all notifications were dismissed
expect(await page.locator('div[role="dialog"]').count()).toBe(0);
});
});
test.describe('Notification Overlay', () => {
test('Closing notification list after notification banner disappeared does not cause it to open automatically', async ({
page
}) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/6130'
});
// Go to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' });
// Create a new Display Layout object
await createDomainObjectWithDefaults(page, { type: 'Display Layout' });
// Click on the button "Review 1 Notification"
await page.click('button[aria-label="Review 1 Notification"]');
// Verify that Notification List is open
expect(await page.locator('div[role="dialog"]').isVisible()).toBe(true);
// Wait until there is no Notification Banner
await page.waitForSelector('div[role="alert"]', { state: 'detached' });
// Click on the "Close" button of the Notification List
await page.click('button[aria-label="Close"]');
// On the Display Layout object, click on the "Edit" button
await page.click('button[title="Edit"]');
// Click on the "Save" button
await page.click('button[title="Save"]');
// Click on the "Save and Finish Editing" option
await page.click('li[title="Save and Finish Editing"]');
// Verify that Notification List is NOT open
expect(await page.locator('div[role="dialog"]').isVisible()).toBe(false);
});
}); });

View File

@@ -1,127 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
const { test, expect } = require('../../../pluginFixtures');
const {
createPlanFromJSON,
createDomainObjectWithDefaults,
selectInspectorTab
} = require('../../../appActions');
const testPlan1 = require('../../../test-data/examplePlans/ExamplePlan_Small1.json');
const testPlan2 = require('../../../test-data/examplePlans/ExamplePlan_Small2.json');
const {
assertPlanActivities,
setBoundsToSpanAllActivities
} = require('../../../helper/planningUtils');
const { getPreciseDuration } = require('../../../../src/utils/duration');
test.describe('Gantt Chart', () => {
let ganttChart;
let plan;
test.beforeEach(async ({ page }) => {
await page.goto('./', { waitUntil: 'domcontentloaded' });
ganttChart = await createDomainObjectWithDefaults(page, {
type: 'Gantt Chart'
});
plan = await createPlanFromJSON(page, {
json: testPlan1,
parent: ganttChart.uuid
});
});
test('Displays all plan events', async ({ page }) => {
await page.goto(ganttChart.url);
await assertPlanActivities(page, testPlan1, ganttChart.url);
});
test('Replaces a plan with a new plan', async ({ page }) => {
await assertPlanActivities(page, testPlan1, ganttChart.url);
await createPlanFromJSON(page, {
json: testPlan2,
parent: ganttChart.uuid
});
const replaceModal = page
.getByRole('dialog')
.filter({ hasText: 'This action will replace the current Plan. Do you want to continue?' });
await expect(replaceModal).toBeVisible();
await page.getByRole('button', { name: 'OK' }).click();
await assertPlanActivities(page, testPlan2, ganttChart.url);
});
test('Can select a single activity and display its details in the inspector', async ({
page
}) => {
test.slow();
await page.goto(ganttChart.url);
await setBoundsToSpanAllActivities(page, testPlan1, ganttChart.url);
const activities = Object.values(testPlan1).flat();
const activity = activities[0];
await page
.locator('g')
.filter({ hasText: new RegExp(activity.name) })
.click();
await selectInspectorTab(page, 'Activity');
const startDateTime = await page
.locator(
'.c-inspect-properties__label:has-text("Start DateTime")+.c-inspect-properties__value'
)
.innerText();
const endDateTime = await page
.locator('.c-inspect-properties__label:has-text("End DateTime")+.c-inspect-properties__value')
.innerText();
const duration = await page
.locator('.c-inspect-properties__label:has-text("duration")+.c-inspect-properties__value')
.innerText();
const expectedStartDate = new Date(activity.start).toISOString();
const actualStartDate = new Date(startDateTime).toISOString();
const expectedEndDate = new Date(activity.end).toISOString();
const actualEndDate = new Date(endDateTime).toISOString();
const expectedDuration = getPreciseDuration(activity.end - activity.start);
const actualDuration = duration;
expect(expectedStartDate).toEqual(actualStartDate);
expect(expectedEndDate).toEqual(actualEndDate);
expect(expectedDuration).toEqual(actualDuration);
});
test("Displays a Plan's draft status", async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/6641'
});
// Mark the Plan's status as draft in the OpenMCT API
await page.evaluate(async (planObject) => {
await window.openmct.status.set(planObject.uuid, 'draft');
}, plan);
// Navigate to the Gantt Chart
await page.goto(ganttChart.url);
// Assert that the Plan's status is displayed as draft
expect(await page.locator('.u-contents.c-swimlane.is-status--draft').count()).toBe(
Object.keys(testPlan1).length
);
});
});

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -19,21 +19,69 @@
* this source code distribution or the Licensing information page available * this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
const { test } = require('../../../pluginFixtures'); const { test, expect } = require('../../../pluginFixtures');
const { createPlanFromJSON } = require('../../../appActions'); const { createPlanFromJSON } = require('../../../appActions');
const testPlan1 = require('../../../test-data/examplePlans/ExamplePlan_Small1.json');
const { assertPlanActivities } = require('../../../helper/planningUtils');
test.describe('Plan', () => { const testPlan = {
let plan; "TEST_GROUP": [
test.beforeEach(async ({ page }) => { {
await page.goto('./', { waitUntil: 'domcontentloaded' }); "name": "Past event 1",
plan = await createPlanFromJSON(page, { "start": 1660320408000,
json: testPlan1 "end": 1660343797000,
"type": "TEST-GROUP",
"color": "orange",
"textColor": "white"
},
{
"name": "Past event 2",
"start": 1660406808000,
"end": 1660429160000,
"type": "TEST-GROUP",
"color": "orange",
"textColor": "white"
},
{
"name": "Past event 3",
"start": 1660493208000,
"end": 1660503981000,
"type": "TEST-GROUP",
"color": "orange",
"textColor": "white"
},
{
"name": "Past event 4",
"start": 1660579608000,
"end": 1660624108000,
"type": "TEST-GROUP",
"color": "orange",
"textColor": "white"
},
{
"name": "Past event 5",
"start": 1660666008000,
"end": 1660681529000,
"type": "TEST-GROUP",
"color": "orange",
"textColor": "white"
}
]
};
test.describe("Plan", () => {
test("Create a Plan and display all plan events @unstable", async ({ page }) => {
await page.goto('./', { waitUntil: 'networkidle' });
const plan = await createPlanFromJSON(page, {
name: 'Test Plan',
json: testPlan
});
const startBound = testPlan.TEST_GROUP[0].start;
const endBound = testPlan.TEST_GROUP[testPlan.TEST_GROUP.length - 1].end;
// Switch to fixed time mode with all plan events within the bounds
await page.goto(`${plan.url}?tc.mode=fixed&tc.startBound=${startBound}&tc.endBound=${endBound}&tc.timeSystem=utc&view=plan.view`);
const eventCount = await page.locator('.activity-bounds').count();
expect(eventCount).toEqual(testPlan.TEST_GROUP.length);
}); });
});
test('Displays all plan events', async ({ page }) => {
await assertPlanActivities(page, testPlan1, plan.url);
});
}); });

View File

@@ -1,124 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
const { test, expect } = require('../../../pluginFixtures');
const { createDomainObjectWithDefaults, createPlanFromJSON } = require('../../../appActions');
const testPlan = {
TEST_GROUP: [
{
name: 'Past event 1',
start: 1660320408000,
end: 1660343797000,
type: 'TEST-GROUP',
color: 'orange',
textColor: 'white'
},
{
name: 'Past event 2',
start: 1660406808000,
end: 1660429160000,
type: 'TEST-GROUP',
color: 'orange',
textColor: 'white'
},
{
name: 'Past event 3',
start: 1660493208000,
end: 1660503981000,
type: 'TEST-GROUP',
color: 'orange',
textColor: 'white'
},
{
name: 'Past event 4',
start: 1660579608000,
end: 1660624108000,
type: 'TEST-GROUP',
color: 'orange',
textColor: 'white'
},
{
name: 'Past event 5',
start: 1660666008000,
end: 1660681529000,
type: 'TEST-GROUP',
color: 'orange',
textColor: 'white'
}
]
};
test.describe('Time List', () => {
test('Create a Time List, add a single Plan to it and verify all the activities are displayed with no milliseconds', 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 () => {
const createdPlan = await createPlanFromJSON(page, {
name: 'Test Plan',
json: testPlan
});
await page.goto(timelist.url);
// Expand the tree to show the plan
await page.click("button[title='Show selected item in tree']");
await page.dragAndDrop(`role=treeitem[name=/${createdPlan.name}/]`, '.c-object-view');
await page.click("button[title='Save']");
await page.click("li[title='Save and Finish Editing']");
const startBound = testPlan.TEST_GROUP[0].start;
const endBound = testPlan.TEST_GROUP[testPlan.TEST_GROUP.length - 1].end;
await page.goto(timelist.url);
// 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`
);
// Verify all events are displayed
const eventCount = await page.locator('.js-list-item').count();
expect(eventCount).toEqual(testPlan.TEST_GROUP.length);
});
await test.step('Does not show milliseconds in times', async () => {
// Get the first activity
const row = page.locator('.js-list-item').first();
// Verify that none fo the times have milliseconds displayed.
// Example: 2024-11-17T16:00:00Z is correct and 2024-11-17T16:00:00.000Z is wrong
await expect(row.locator('.--start')).not.toContainText('.');
await expect(row.locator('.--end')).not.toContainText('.');
await expect(row.locator('.--duration')).not.toContainText('.');
});
});
});

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -21,153 +21,161 @@
*****************************************************************************/ *****************************************************************************/
const { test, expect } = require('../../../pluginFixtures'); const { test, expect } = require('../../../pluginFixtures');
const { const { createDomainObjectWithDefaults, createPlanFromJSON } = require('../../../appActions');
createDomainObjectWithDefaults,
createPlanFromJSON,
setIndependentTimeConductorBounds
} = require('../../../appActions');
const testPlan = { const testPlan = {
TEST_GROUP: [ "TEST_GROUP": [
{ {
name: 'Past event 1', "name": "Past event 1",
start: 1660320408000, "start": 1660320408000,
end: 1660343797000, "end": 1660343797000,
type: 'TEST-GROUP', "type": "TEST-GROUP",
color: 'orange', "color": "orange",
textColor: 'white' "textColor": "white"
}, },
{ {
name: 'Past event 2', "name": "Past event 2",
start: 1660406808000, "start": 1660406808000,
end: 1660429160000, "end": 1660429160000,
type: 'TEST-GROUP', "type": "TEST-GROUP",
color: 'orange', "color": "orange",
textColor: 'white' "textColor": "white"
}, },
{ {
name: 'Past event 3', "name": "Past event 3",
start: 1660493208000, "start": 1660493208000,
end: 1660503981000, "end": 1660503981000,
type: 'TEST-GROUP', "type": "TEST-GROUP",
color: 'orange', "color": "orange",
textColor: 'white' "textColor": "white"
}, },
{ {
name: 'Past event 4', "name": "Past event 4",
start: 1660579608000, "start": 1660579608000,
end: 1660624108000, "end": 1660624108000,
type: 'TEST-GROUP', "type": "TEST-GROUP",
color: 'orange', "color": "orange",
textColor: 'white' "textColor": "white"
}, },
{ {
name: 'Past event 5', "name": "Past event 5",
start: 1660666008000, "start": 1660666008000,
end: 1660681529000, "end": 1660681529000,
type: 'TEST-GROUP', "type": "TEST-GROUP",
color: 'orange', "color": "orange",
textColor: 'white' "textColor": "white"
} }
] ]
}; };
test.describe('Time Strip', () => { test.describe("Time Strip", () => {
test('Create two Time Strips, add a single Plan to both, and verify they can have separate Indepdenent Time Contexts @unstable', async ({ test("Create two Time Strips, add a single Plan to both, and verify they can have separate Indepdenent Time Contexts @unstable", async ({ page }) => {
page test.info().annotations.push({
}) => { type: 'issue',
test.info().annotations.push({ description: 'https://github.com/nasa/openmct/issues/5627'
type: 'issue', });
description: 'https://github.com/nasa/openmct/issues/5627'
// Constant locators
const independentTimeConductorInputs = page.locator('.l-shell__main-independent-time-conductor .c-input--datetime');
const activityBounds = page.locator('.activity-bounds');
// Goto baseURL
await page.goto('./', { waitUntil: 'networkidle' });
const timestrip = await test.step("Create a Time Strip", async () => {
const createdTimeStrip = await createDomainObjectWithDefaults(page, { type: 'Time Strip' });
const objectName = await page.locator('.l-browse-bar__object-name').innerText();
expect(objectName).toBe(createdTimeStrip.name);
return createdTimeStrip;
});
const plan = await test.step("Create a Plan and add it to the timestrip", async () => {
const createdPlan = await createPlanFromJSON(page, {
name: 'Test Plan',
json: testPlan
});
await page.goto(timestrip.url);
// Expand the tree to show the plan
await page.click("button[title='Show selected item in tree']");
await page.dragAndDrop(`role=treeitem[name=/${createdPlan.name}/]`, '.c-object-view');
await page.click("button[title='Save']");
await page.click("li[title='Save and Finish Editing']");
const startBound = testPlan.TEST_GROUP[0].start;
const endBound = testPlan.TEST_GROUP[testPlan.TEST_GROUP.length - 1].end;
// Switch to fixed time mode with all plan events within the bounds
await page.goto(`${timestrip.url}?tc.mode=fixed&tc.startBound=${startBound}&tc.endBound=${endBound}&tc.timeSystem=utc&view=time-strip.view`);
// Verify all events are displayed
const eventCount = await page.locator('.activity-bounds').count();
expect(eventCount).toEqual(testPlan.TEST_GROUP.length);
return createdPlan;
});
await test.step("TimeStrip can use the Independent Time Conductor", async () => {
// Activate Independent Time Conductor in Fixed Time Mode
await page.click('.c-toggle-switch__slider');
expect(await activityBounds.count()).toEqual(0);
// Set the independent time bounds so that only one event is shown
const startBound = testPlan.TEST_GROUP[0].start;
const endBound = testPlan.TEST_GROUP[0].end;
const startBoundString = new Date(startBound).toISOString().replace('T', ' ');
const endBoundString = new Date(endBound).toISOString().replace('T', ' ');
await independentTimeConductorInputs.nth(0).fill('');
await independentTimeConductorInputs.nth(0).fill(startBoundString);
await page.keyboard.press('Enter');
await independentTimeConductorInputs.nth(1).fill('');
await independentTimeConductorInputs.nth(1).fill(endBoundString);
await page.keyboard.press('Enter');
expect(await activityBounds.count()).toEqual(1);
});
await test.step("Can have multiple TimeStrips with the same plan linked and different Independent Time Contexts", async () => {
// Create another Time Strip and verify that it has been created
const createdTimeStrip = await createDomainObjectWithDefaults(page, {
type: 'Time Strip',
name: "Another Time Strip"
});
const objectName = await page.locator('.l-browse-bar__object-name').innerText();
expect(objectName).toBe(createdTimeStrip.name);
// Drag the existing Plan onto the newly created Time Strip, and save.
await page.dragAndDrop(`role=treeitem[name=/${plan.name}/]`, '.c-object-view');
await page.click("button[title='Save']");
await page.click("li[title='Save and Finish Editing']");
// Activate Independent Time Conductor in Fixed Time Mode
await page.click('.c-toggle-switch__slider');
// All events should be displayed at this point because the
// initial independent context bounds will match the global bounds
expect(await activityBounds.count()).toEqual(5);
// Set the independent time bounds so that two events are shown
const startBound = testPlan.TEST_GROUP[0].start;
const endBound = testPlan.TEST_GROUP[1].end;
const startBoundString = new Date(startBound).toISOString().replace('T', ' ');
const endBoundString = new Date(endBound).toISOString().replace('T', ' ');
await independentTimeConductorInputs.nth(0).fill('');
await independentTimeConductorInputs.nth(0).fill(startBoundString);
await page.keyboard.press('Enter');
await independentTimeConductorInputs.nth(1).fill('');
await independentTimeConductorInputs.nth(1).fill(endBoundString);
await page.keyboard.press('Enter');
// Verify that two events are displayed
expect(await activityBounds.count()).toEqual(2);
// Switch to the previous Time Strip and verify that only one event is displayed
await page.goto(timestrip.url);
expect(await activityBounds.count()).toEqual(1);
});
}); });
// Constant locators
const activityBounds = page.locator('.activity-bounds');
// Goto baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' });
const timestrip = await test.step('Create a Time Strip', async () => {
const createdTimeStrip = await createDomainObjectWithDefaults(page, { type: 'Time Strip' });
const objectName = await page.locator('.l-browse-bar__object-name').innerText();
expect(objectName).toBe(createdTimeStrip.name);
return createdTimeStrip;
});
const plan = await test.step('Create a Plan and add it to the timestrip', async () => {
const createdPlan = await createPlanFromJSON(page, {
name: 'Test Plan',
json: testPlan
});
await page.goto(timestrip.url);
// Expand the tree to show the plan
await page.click("button[title='Show selected item in tree']");
await page.dragAndDrop(`role=treeitem[name=/${createdPlan.name}/]`, '.c-object-view');
await page.click("button[title='Save']");
await page.click("li[title='Save and Finish Editing']");
const startBound = testPlan.TEST_GROUP[0].start;
const endBound = testPlan.TEST_GROUP[testPlan.TEST_GROUP.length - 1].end;
// Switch to fixed time mode with all plan events within the bounds
await page.goto(
`${timestrip.url}?tc.mode=fixed&tc.startBound=${startBound}&tc.endBound=${endBound}&tc.timeSystem=utc&view=time-strip.view`
);
// Verify all events are displayed
const eventCount = await page.locator('.activity-bounds').count();
expect(eventCount).toEqual(testPlan.TEST_GROUP.length);
return createdPlan;
});
await test.step('TimeStrip can use the Independent Time Conductor', async () => {
expect(await activityBounds.count()).toEqual(5);
// Set the independent time bounds so that only one event is shown
const startBound = testPlan.TEST_GROUP[0].start;
const endBound = testPlan.TEST_GROUP[0].end;
const startBoundString = new Date(startBound).toISOString().replace('T', ' ');
const endBoundString = new Date(endBound).toISOString().replace('T', ' ');
await setIndependentTimeConductorBounds(page, startBoundString, endBoundString);
expect(await activityBounds.count()).toEqual(1);
});
await test.step('Can have multiple TimeStrips with the same plan linked and different Independent Time Contexts', async () => {
// Create another Time Strip and verify that it has been created
const createdTimeStrip = await createDomainObjectWithDefaults(page, {
type: 'Time Strip',
name: 'Another Time Strip'
});
const objectName = await page.locator('.l-browse-bar__object-name').innerText();
expect(objectName).toBe(createdTimeStrip.name);
// Drag the existing Plan onto the newly created Time Strip, and save.
await page.dragAndDrop(`role=treeitem[name=/${plan.name}/]`, '.c-object-view');
await page.click("button[title='Save']");
await page.click("li[title='Save and Finish Editing']");
// All events should be displayed at this point because the
// initial independent context bounds will match the global bounds
expect(await activityBounds.count()).toEqual(5);
// Set the independent time bounds so that two events are shown
const startBound = testPlan.TEST_GROUP[0].start;
const endBound = testPlan.TEST_GROUP[1].end;
const startBoundString = new Date(startBound).toISOString().replace('T', ' ');
const endBoundString = new Date(endBound).toISOString().replace('T', ' ');
await setIndependentTimeConductorBounds(page, startBoundString, endBoundString);
// Verify that two events are displayed
expect(await activityBounds.count()).toEqual(2);
// Switch to the previous Time Strip and verify that only one event is displayed
await page.goto(timestrip.url);
expect(await activityBounds.count()).toEqual(1);
});
});
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -27,40 +27,40 @@ This test suite is dedicated to tests which verify the basic operations surround
const { test, expect } = require('../../../../baseFixtures'); const { test, expect } = require('../../../../baseFixtures');
test.describe('Clock Generator CRUD Operations', () => { test.describe('Clock Generator CRUD Operations', () => {
test('Timezone dropdown will collapse when clicked outside or on dropdown icon again', async ({
page test('Timezone dropdown will collapse when clicked outside or on dropdown icon again', async ({ page }) => {
}) => { test.info().annotations.push({
test.info().annotations.push({ type: 'issue',
type: 'issue', description: 'https://github.com/nasa/openmct/issues/4878'
description: 'https://github.com/nasa/openmct/issues/4878' });
//Go to baseURL
await page.goto('./', { waitUntil: 'networkidle' });
//Click the Create button
await page.click('button:has-text("Create")');
// Click Clock
await page.click('text=Clock');
// Click .icon-arrow-down
await page.locator('.icon-arrow-down').click();
//verify if the autocomplete dropdown is visible
await expect(page.locator(".c-input--autocomplete__options")).toBeVisible();
// Click .icon-arrow-down
await page.locator('.icon-arrow-down').click();
// Verify clicking on the autocomplete arrow collapses the dropdown
await expect(page.locator(".c-input--autocomplete__options")).toBeHidden();
// Click timezone input to open dropdown
await page.locator('.c-input--autocomplete__input').click();
//verify if the autocomplete dropdown is visible
await expect(page.locator(".c-input--autocomplete__options")).toBeVisible();
// Verify clicking outside the autocomplete dropdown collapses it
await page.locator('text=Timezone').click();
// Verify clicking on the autocomplete arrow collapses the dropdown
await expect(page.locator(".c-input--autocomplete__options")).toBeHidden();
}); });
//Go to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' });
//Click the Create button
await page.click('button:has-text("Create")');
// Click Clock
await page.getByRole('menuitem').first().click();
// Click .icon-arrow-down
await page.locator('.icon-arrow-down').click();
//verify if the autocomplete dropdown is visible
await expect(page.locator('.c-input--autocomplete__options')).toBeVisible();
// Click .icon-arrow-down
await page.locator('.icon-arrow-down').click();
// Verify clicking on the autocomplete arrow collapses the dropdown
await expect(page.locator('.c-input--autocomplete__options')).toBeHidden();
// Click timezone input to open dropdown
await page.locator('.c-input--autocomplete__input').click();
//verify if the autocomplete dropdown is visible
await expect(page.locator('.c-input--autocomplete__options')).toBeVisible();
// Verify clicking outside the autocomplete dropdown collapses it
await page.locator('text=Timezone').click();
// Verify clicking on the autocomplete arrow collapses the dropdown
await expect(page.locator('.c-input--autocomplete__options')).toBeHidden();
});
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -25,17 +25,17 @@
const { test, expect } = require('../../../../baseFixtures'); const { test, expect } = require('../../../../baseFixtures');
test.describe('Remote Clock', () => { test.describe('Remote Clock', () => {
// eslint-disable-next-line require-await // eslint-disable-next-line require-await
test.fixme('blocks historical requests until first tick is received', async ({ page }) => { test.fixme('blocks historical requests until first tick is received', async ({ page }) => {
test.info().annotations.push({ test.info().annotations.push({
type: 'issue', type: 'issue',
description: 'https://github.com/nasa/openmct/issues/5221' description: 'https://github.com/nasa/openmct/issues/5221'
});
// addInitScript to with remote clock
// Switch time conductor mode to 'remote clock'
// Navigate to telemetry
// Verify that the plot renders historical data within the correct bounds
// Refresh the page
// Verify again that the plot renders historical data within the correct bounds
}); });
// addInitScript to with remote clock
// Switch time conductor mode to 'remote clock'
// Navigate to telemetry
// Verify that the plot renders historical data within the correct bounds
// Refresh the page
// Verify again that the plot renders historical data within the correct bounds
});
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -33,336 +33,170 @@ let conditionSetUrl;
let getConditionSetIdentifierFromUrl; let getConditionSetIdentifierFromUrl;
test.describe.serial('Condition Set CRUD Operations on @localStorage', () => { test.describe.serial('Condition Set CRUD Operations on @localStorage', () => {
test.beforeAll(async ({ browser }) => { test.beforeAll(async ({ browser}) => {
//TODO: This needs to be refactored //TODO: This needs to be refactored
const context = await browser.newContext(); const context = await browser.newContext();
const page = await context.newPage(); const page = await context.newPage();
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
await page.click('button:has-text("Create")'); await page.click('button:has-text("Create")');
await page.locator('li[role="menuitem"]:has-text("Condition Set")').click(); await page.locator('li[role="menuitem"]:has-text("Condition Set")').click();
await Promise.all([page.waitForNavigation(), page.click('button:has-text("OK")')]); await Promise.all([
page.waitForNavigation(),
page.click('button:has-text("OK")')
]);
//Save localStorage for future test execution //Save localStorage for future test execution
await context.storageState({ path: './e2e/test-data/recycled_local_storage.json' }); await context.storageState({ path: './e2e/test-data/recycled_local_storage.json' });
//Set object identifier from url //Set object identifier from url
conditionSetUrl = page.url(); conditionSetUrl = page.url();
console.log('conditionSetUrl ' + conditionSetUrl);
getConditionSetIdentifierFromUrl = conditionSetUrl.split('/').pop().split('?')[0]; getConditionSetIdentifierFromUrl = conditionSetUrl.split('/').pop().split('?')[0];
console.debug(`getConditionSetIdentifierFromUrl: ${getConditionSetIdentifierFromUrl}`); console.debug('getConditionSetIdentifierFromUrl ' + getConditionSetIdentifierFromUrl);
await page.close(); await page.close();
}); });
//Load localStorage for subsequent tests //Load localStorage for subsequent tests
test.use({ storageState: './e2e/test-data/recycled_local_storage.json' }); test.use({ storageState: './e2e/test-data/recycled_local_storage.json' });
//Begin suite of tests again localStorage //Begin suite of tests again localStorage
test('Condition set object properties persist in main view and inspector @localStorage', async ({ test('Condition set object properties persist in main view and inspector @localStorage', async ({ page }) => {
page //Navigate to baseURL with injected localStorage
}) => { await page.goto(conditionSetUrl, { waitUntil: 'networkidle' });
//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() //Assertions on loaded Condition Set in main view. This is a stateful transition step after page.goto()
await expect await expect.soft(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Condition Set');
.soft(page.locator('.l-browse-bar__object-name'))
.toContainText('Unnamed Condition Set');
//Assertions on loaded Condition Set in Inspector //Assertions on loaded Condition Set in Inspector
expect.soft(page.locator('_vue=item.name=Unnamed Condition Set')).toBeTruthy(); expect.soft(page.locator('_vue=item.name=Unnamed Condition Set')).toBeTruthy();
//Reload Page //Reload Page
await Promise.all([page.reload(), page.waitForLoadState('networkidle')]); await Promise.all([
page.reload(),
page.waitForLoadState('networkidle')
]);
//Re-verify after reload //Re-verify after reload
await expect await expect.soft(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Condition Set');
.soft(page.locator('.l-browse-bar__object-name')) //Assertions on loaded Condition Set in Inspector
.toContainText('Unnamed Condition Set'); 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();
});
test('condition set object can be modified on @localStorage', async ({ page, openmctConfig }) => {
const { myItemsFolderName } = openmctConfig;
await page.goto(conditionSetUrl, { waitUntil: 'networkidle' }); });
test('condition set object can be modified on @localStorage', async ({ page, openmctConfig }) => {
const { myItemsFolderName } = openmctConfig;
//Assertions on loaded Condition Set in main view. This is a stateful transition step after page.goto() await page.goto(conditionSetUrl, { waitUntil: 'networkidle' });
await expect
.soft(page.locator('.l-browse-bar__object-name'))
.toContainText('Unnamed Condition Set');
//Update the Condition Set properties //Assertions on loaded Condition Set in main view. This is a stateful transition step after page.goto()
// Click Edit Button await expect.soft(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Condition Set');
await page.locator('text=Conditions View Snapshot >> button').nth(3).click();
//Edit Condition Set Name from main view //Update the Condition Set properties
await page // Click Edit Button
.locator('.l-browse-bar__object-name') await page.locator('text=Conditions View Snapshot >> button').nth(3).click();
.filter({ hasText: 'Unnamed Condition Set' })
.first()
.fill('Renamed Condition Set');
await page
.locator('.l-browse-bar__object-name')
.filter({ hasText: 'Renamed Condition Set' })
.first()
.press('Enter');
// Click Save Button
await page
.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button')
.nth(1)
.click();
// Click Save and Finish Editing Option
await page.locator('text=Save and Finish Editing').click();
//Verify Main section reflects updated Name Property //Edit Condition Set Name from main view
await expect await page.locator('text=Unnamed Condition Set').first().fill('Renamed Condition Set');
.soft(page.locator('.l-browse-bar__object-name')) await page.locator('text=Renamed Condition Set').first().press('Enter');
.toContainText('Renamed Condition Set'); // Click Save Button
await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1).click();
// Click Save and Finish Editing Option
await page.locator('text=Save and Finish Editing').click();
// Verify Inspector properties //Verify Main section reflects updated Name Property
// Verify Inspector has updated Name property await expect.soft(page.locator('.l-browse-bar__object-name')).toContainText('Renamed Condition Set');
expect.soft(page.locator('text=Renamed Condition Set').nth(1)).toBeTruthy();
// Verify Inspector Details has updated Name property
expect.soft(page.locator('text=Renamed Condition Set').nth(2)).toBeTruthy();
// Verify Tree reflects updated Name proprety // Verify Inspector properties
// Expand Tree // Verify Inspector has updated Name property
await page.locator(`text=Open MCT ${myItemsFolderName} >> span >> nth=3`).click(); expect.soft(page.locator('text=Renamed Condition Set').nth(1)).toBeTruthy();
// Verify Condition Set Object is renamed in Tree // Verify Inspector Details has updated Name property
expect(page.locator('a:has-text("Renamed Condition Set")')).toBeTruthy(); expect.soft(page.locator('text=Renamed Condition Set').nth(2)).toBeTruthy();
// Verify Search Tree reflects renamed Name property
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Renamed');
expect(page.locator('a:has-text("Renamed Condition Set")')).toBeTruthy();
//Reload Page // Verify Tree reflects updated Name proprety
await Promise.all([page.reload(), page.waitForLoadState('networkidle')]); // Expand Tree
await page.locator(`text=Open MCT ${myItemsFolderName} >> span >> nth=3`).click();
// Verify Condition Set Object is renamed in Tree
expect(page.locator('a:has-text("Renamed Condition Set")')).toBeTruthy();
// Verify Search Tree reflects renamed Name property
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Renamed');
expect(page.locator('a:has-text("Renamed Condition Set")')).toBeTruthy();
//Verify Main section reflects updated Name Property //Reload Page
await expect await Promise.all([
.soft(page.locator('.l-browse-bar__object-name')) page.reload(),
.toContainText('Renamed Condition Set'); page.waitForLoadState('networkidle')
]);
// Verify Inspector properties //Verify Main section reflects updated Name Property
// Verify Inspector has updated Name property await expect.soft(page.locator('.l-browse-bar__object-name')).toContainText('Renamed Condition Set');
expect.soft(page.locator('text=Renamed Condition Set').nth(1)).toBeTruthy();
// Verify Inspector Details has updated Name property
expect.soft(page.locator('text=Renamed Condition Set').nth(2)).toBeTruthy();
// Verify Tree reflects updated Name proprety // Verify Inspector properties
// Expand Tree // Verify Inspector has updated Name property
await page.locator(`text=Open MCT ${myItemsFolderName} >> span >> nth=3`).click(); expect.soft(page.locator('text=Renamed Condition Set').nth(1)).toBeTruthy();
// Verify Condition Set Object is renamed in Tree // Verify Inspector Details has updated Name property
expect(page.locator('a:has-text("Renamed Condition Set")')).toBeTruthy(); expect.soft(page.locator('text=Renamed Condition Set').nth(2)).toBeTruthy();
// Verify Search Tree reflects renamed Name property
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Renamed');
expect(page.locator('a:has-text("Renamed Condition Set")')).toBeTruthy();
});
test('condition set object can be deleted by Search Tree Actions menu on @localStorage', async ({
page
}) => {
//Navigate to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' });
//Assertions on loaded Condition Set in main view. This is a stateful transition step after page.goto() // Verify Tree reflects updated Name proprety
await expect( // Expand Tree
page.locator('a:has-text("Unnamed Condition Set Condition Set") >> nth=0') await page.locator(`text=Open MCT ${myItemsFolderName} >> span >> nth=3`).click();
).toBeVisible(); // Verify Condition Set Object is renamed in Tree
expect(page.locator('a:has-text("Renamed Condition Set")')).toBeTruthy();
// Verify Search Tree reflects renamed Name property
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Renamed');
expect(page.locator('a:has-text("Renamed Condition Set")')).toBeTruthy();
});
test('condition set object can be deleted by Search Tree Actions menu on @localStorage', async ({ page }) => {
//Navigate to baseURL
await page.goto('./', { waitUntil: 'networkidle' });
const numberOfConditionSetsToStart = await page //Assertions on loaded Condition Set in main view. This is a stateful transition step after page.goto()
.locator('a:has-text("Unnamed Condition Set Condition Set")') await expect(page.locator('a:has-text("Unnamed Condition Set Condition Set") >> nth=0')).toBeVisible();
.count();
// Search for Unnamed Condition Set const numberOfConditionSetsToStart = await page.locator('a:has-text("Unnamed Condition Set Condition Set")').count();
await page
.locator('[aria-label="OpenMCT Search"] input[type="search"]')
.fill('Unnamed Condition Set');
// Click Search Result
await page
.locator('[aria-label="OpenMCT Search"] >> text=Unnamed Condition Set')
.first()
.click();
// Click hamburger button
await page.locator('[title="More options"]').click();
// Click 'Remove' and press OK // Search for Unnamed Condition Set
await page.locator('li[role="menuitem"]:has-text("Remove")').click(); await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Unnamed Condition Set');
await page.locator('button:has-text("OK")').click(); // Click Search Result
await page.locator('[aria-label="OpenMCT Search"] >> text=Unnamed Condition Set').first().click();
// Click hamburger button
await page.locator('[title="More options"]').click();
//Expect Unnamed Condition Set to be removed in Main View // Click 'Remove' and press OK
const numberOfConditionSetsAtEnd = await page await page.locator('li[role="menuitem"]:has-text("Remove")').click();
.locator('a:has-text("Unnamed Condition Set Condition Set")') await page.locator('button:has-text("OK")').click();
.count();
expect(numberOfConditionSetsAtEnd).toEqual(numberOfConditionSetsToStart - 1); //Expect Unnamed Condition Set to be removed in Main View
const numberOfConditionSetsAtEnd = await page.locator('a:has-text("Unnamed Condition Set Condition Set")').count();
//Feature? expect(numberOfConditionSetsAtEnd).toEqual(numberOfConditionSetsToStart - 1);
//Domain Object is still available by direct URL after delete
await page.goto(conditionSetUrl, { waitUntil: 'networkidle' }); //Feature?
await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Condition Set'); //Domain Object is still available by direct URL after delete
}); await page.goto(conditionSetUrl, { waitUntil: 'networkidle' });
await expect(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Condition Set');
});
}); });
test.describe('Basic Condition Set Use', () => { test.describe('Basic Condition Set Use', () => {
test.beforeEach(async ({ page }) => { test('Can add a condition', async ({ page }) => {
// Open a browser, navigate to the main page, and wait until all network events to resolve //Navigate to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
});
test('Can add a condition', async ({ page }) => { // Create a new condition set
// Create a new condition set await createDomainObjectWithDefaults(page, {
await createDomainObjectWithDefaults(page, { type: 'Condition Set',
type: 'Condition Set', name: "Test Condition Set"
name: 'Test Condition Set' });
// Change the object to edit mode
await page.locator('[title="Edit"]').click();
// Click Add Condition button
await page.locator('#addCondition').click();
// Check that the new Unnamed Condition section appears
const numOfUnnamedConditions = await page.locator('text=Unnamed Condition').count();
expect(numOfUnnamedConditions).toEqual(1);
}); });
// Change the object to edit mode
await page.locator('[title="Edit"]').click();
// Click Add Condition button
await page.locator('#addCondition').click();
// Check that the new Unnamed Condition section appears
const numOfUnnamedConditions = await page.locator('text=Unnamed Condition').count();
expect(numOfUnnamedConditions).toEqual(1);
});
test('ConditionSet should display appropriate view options', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/5924'
});
await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
name: 'Alpha Sine Wave Generator'
});
await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
name: 'Beta Sine Wave Generator'
});
const conditionSet1 = await createDomainObjectWithDefaults(page, {
type: 'Condition Set',
name: 'Test Condition Set'
});
// Change the object to edit mode
await page.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree
await page.goto(conditionSet1.url);
page.click('button[title="Show selected item in tree"]');
// Add the Alpha & Beta Sine Wave Generator to the Condition Set and save changes
const treePane = page.getByRole('tree', {
name: 'Main Tree'
});
const alphaGeneratorTreeItem = treePane.getByRole('treeitem', {
name: 'Alpha Sine Wave Generator'
});
const betaGeneratorTreeItem = treePane.getByRole('treeitem', {
name: 'Beta Sine Wave Generator'
});
const conditionCollection = page.locator('#conditionCollection');
await alphaGeneratorTreeItem.dragTo(conditionCollection);
await betaGeneratorTreeItem.dragTo(conditionCollection);
const saveButtonLocator = page.locator('button[title="Save"]');
await saveButtonLocator.click();
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
await page.click('button[title="Change the current view"]');
await expect(page.getByRole('menuitem', { name: /Lad Table/ })).toBeHidden();
await expect(page.getByRole('menuitem', { name: /Conditions View/ })).toBeVisible();
await expect(page.getByRole('menuitem', { name: /Plot/ })).toBeVisible();
await expect(page.getByRole('menuitem', { name: /Telemetry Table/ })).toBeVisible();
});
test('ConditionSet should output blank instead of the default value', async ({ page }) => {
//Navigate to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' });
//Click the Create button
await page.click('button:has-text("Create")');
// Click the object specified by 'type'
await page.click(`li[role='menuitem']:text("Sine Wave Generator")`);
await page.getByRole('spinbutton', { name: 'Loading Delay (ms)' }).fill('8000');
const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]');
await nameInput.fill('Delayed Sine Wave Generator');
// Click OK button and wait for Navigate event
await Promise.all([
page.waitForLoadState(),
page.click('[aria-label="Save"]'),
// Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message')
]);
// Create a new condition set
await createDomainObjectWithDefaults(page, {
type: 'Condition Set',
name: 'Test Blank Output of Condition Set'
});
// Change the object to edit mode
await page.locator('[title="Edit"]').click();
// Click Add Condition button twice
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');
// Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').first().click();
// Add the Sine Wave Generator to the Condition Set and save changes
const treePane = page.getByRole('tree', {
name: 'Main Tree'
});
const sineWaveGeneratorTreeItem = treePane.getByRole('treeitem', {
name: 'Delayed Sine Wave Generator'
});
const conditionCollection = await page.locator('#conditionCollection');
await sineWaveGeneratorTreeItem.dragTo(conditionCollection);
const firstCriterionTelemetry = await page.locator(
'[aria-label="Criterion Telemetry Selection"] >> nth=0'
);
firstCriterionTelemetry.selectOption({ label: 'Delayed Sine Wave Generator' });
const secondCriterionTelemetry = await page.locator(
'[aria-label="Criterion Telemetry Selection"] >> nth=1'
);
secondCriterionTelemetry.selectOption({ label: 'Delayed Sine Wave Generator' });
const firstCriterionMetadata = await page.locator(
'[aria-label="Criterion Metadata Selection"] >> nth=0'
);
firstCriterionMetadata.selectOption({ label: 'Sine' });
const secondCriterionMetadata = await page.locator(
'[aria-label="Criterion Metadata Selection"] >> nth=1'
);
secondCriterionMetadata.selectOption({ label: 'Sine' });
const firstCriterionComparison = await page.locator(
'[aria-label="Criterion Comparison Selection"] >> nth=0'
);
firstCriterionComparison.selectOption({ label: 'is greater than or equal to' });
const secondCriterionComparison = await page.locator(
'[aria-label="Criterion Comparison Selection"] >> nth=1'
);
secondCriterionComparison.selectOption({ label: 'is less than' });
const firstCriterionInput = await page.locator('[aria-label="Criterion Input"] >> nth=0');
await firstCriterionInput.fill('0');
const secondCriterionInput = await page.locator('[aria-label="Criterion Input"] >> nth=1');
await secondCriterionInput.fill('0');
const saveButtonLocator = page.locator('button[title="Save"]');
await saveButtonLocator.click();
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
const outputValue = await page.locator('[aria-label="Current Output Value"]');
await expect(outputValue).toHaveText('---');
});
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -21,317 +21,146 @@
*****************************************************************************/ *****************************************************************************/
const { test, expect } = require('../../../../pluginFixtures'); const { test, expect } = require('../../../../pluginFixtures');
const { const { createDomainObjectWithDefaults, setStartOffset, setFixedTimeMode, setRealTimeMode } = require('../../../../appActions');
createDomainObjectWithDefaults,
setStartOffset,
setFixedTimeMode,
setRealTimeMode,
setIndependentTimeConductorBounds
} = require('../../../../appActions');
test.describe('Display Layout', () => { test.describe('Display Layout', () => {
/** @type {import('../../../../appActions').CreatedObjectInfo} */ let sineWaveObject;
let sineWaveObject; test.beforeEach(async ({ page }) => {
test.beforeEach(async ({ page }) => { await page.goto('./', { waitUntil: 'networkidle' });
await page.goto('./', { waitUntil: 'domcontentloaded' }); await setRealTimeMode(page);
await setRealTimeMode(page);
// Create Sine Wave Generator // Create Sine Wave Generator
sineWaveObject = await createDomainObjectWithDefaults(page, { sineWaveObject = await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator' type: 'Sine Wave Generator',
name: "Test Sine Wave Generator"
});
}); });
}); test('alpha-numeric widget telemetry value exactly matches latest telemetry value received in real time', async ({ page }) => {
test('alpha-numeric widget telemetry value exactly matches latest telemetry value received in real time', async ({ // Create a Display Layout
page await createDomainObjectWithDefaults(page, {
}) => { type: 'Display Layout',
// Create a Display Layout name: "Test Display Layout"
await createDomainObjectWithDefaults(page, { });
type: 'Display Layout', // Edit Display Layout
name: 'Test Display Layout' await page.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
// Add the Sine Wave Generator to the Display Layout and save changes
await page.dragAndDrop('text=Test Sine Wave Generator', '.l-layout__grid-holder');
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
// Subscribe to the Sine Wave Generator data
// On getting data, check if the value found in the Display Layout is the most recent value
// from the Sine Wave Generator
const getTelemValuePromise = await subscribeToTelemetry(page, sineWaveObject.uuid);
const formattedTelemetryValue = getTelemValuePromise;
const displayLayoutValuePromise = await page.waitForSelector(`text="${formattedTelemetryValue}"`);
const displayLayoutValue = await displayLayoutValuePromise.textContent();
const trimmedDisplayValue = displayLayoutValue.trim();
expect(trimmedDisplayValue).toBe(formattedTelemetryValue);
}); });
// Edit Display Layout test('alpha-numeric widget telemetry value exactly matches latest telemetry value received in fixed time', async ({ page }) => {
await page.locator('[title="Edit"]').click(); // Create a Display Layout
await createDomainObjectWithDefaults(page, {
type: 'Display Layout',
name: "Test Display Layout"
});
// Edit Display Layout
await page.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree // Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click(); await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
// Add the Sine Wave Generator to the Display Layout and save changes // Add the Sine Wave Generator to the Display Layout and save changes
const treePane = page.getByRole('tree', { await page.dragAndDrop('text=Test Sine Wave Generator', '.l-layout__grid-holder');
name: 'Main Tree' await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
// Subscribe to the Sine Wave Generator data
const getTelemValuePromise = await subscribeToTelemetry(page, sineWaveObject.uuid);
// Set an offset of 1 minute and then change the time mode to fixed to set a 1 minute historical window
await setStartOffset(page, { mins: '1' });
await setFixedTimeMode(page);
// On getting data, check if the value found in the Display Layout is the most recent value
// from the Sine Wave Generator
const formattedTelemetryValue = getTelemValuePromise;
const displayLayoutValuePromise = await page.waitForSelector(`text="${formattedTelemetryValue}"`);
const displayLayoutValue = await displayLayoutValuePromise.textContent();
const trimmedDisplayValue = displayLayoutValue.trim();
expect(trimmedDisplayValue).toBe(formattedTelemetryValue);
}); });
const sineWaveGeneratorTreeItem = treePane.getByRole('treeitem', { test('items in a display layout can be removed with object tree context menu when viewing the display layout', async ({ page }) => {
name: new RegExp(sineWaveObject.name) // Create a Display Layout
await createDomainObjectWithDefaults(page, {
type: 'Display Layout',
name: "Test Display Layout"
});
// Edit Display Layout
await page.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
// Add the Sine Wave Generator to the Display Layout and save changes
await page.dragAndDrop('text=Test Sine Wave Generator', '.l-layout__grid-holder');
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
expect.soft(await page.locator('.l-layout .l-layout__frame').count()).toEqual(1);
// Expand the Display Layout so we can remove the sine wave generator
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
// Bring up context menu and remove
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').first().click({ button: 'right' });
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
await page.locator('button:has-text("OK")').click();
// delete
expect(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0);
}); });
const layoutGridHolder = page.locator('.l-layout__grid-holder'); test('items in a display layout can be removed with object tree context menu when viewing another item', async ({ page }) => {
await sineWaveGeneratorTreeItem.dragTo(layoutGridHolder); test.info().annotations.push({
await page.locator('button[title="Save"]').click(); type: 'issue',
await page.locator('text=Save and Finish Editing').click(); description: 'https://github.com/nasa/openmct/issues/3117'
});
// Create a Display Layout
const displayLayout = await createDomainObjectWithDefaults(page, {
type: 'Display Layout',
name: "Test Display Layout"
});
// Edit Display Layout
await page.locator('[title="Edit"]').click();
// Subscribe to the Sine Wave Generator data // Expand the 'My Items' folder in the left tree
// On getting data, check if the value found in the Display Layout is the most recent value await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
// from the Sine Wave Generator // Add the Sine Wave Generator to the Display Layout and save changes
const getTelemValuePromise = await subscribeToTelemetry(page, sineWaveObject.uuid); await page.dragAndDrop('text=Test Sine Wave Generator', '.l-layout__grid-holder');
const formattedTelemetryValue = getTelemValuePromise; await page.locator('button[title="Save"]').click();
const displayLayoutValuePromise = await page.waitForSelector( await page.locator('text=Save and Finish Editing').click();
`text="${formattedTelemetryValue}"`
);
const displayLayoutValue = await displayLayoutValuePromise.textContent();
const trimmedDisplayValue = displayLayoutValue.trim();
expect(trimmedDisplayValue).toBe(formattedTelemetryValue); expect.soft(await page.locator('.l-layout .l-layout__frame').count()).toEqual(1);
});
test('alpha-numeric widget telemetry value exactly matches latest telemetry value received in fixed time', async ({ // Expand the Display Layout so we can remove the sine wave generator
page await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
}) => {
// Create a Display Layout // Go to the original Sine Wave Generator to navigate away from the Display Layout
await createDomainObjectWithDefaults(page, { await page.goto(sineWaveObject.url);
type: 'Display Layout',
name: 'Test Display Layout' // Bring up context menu and remove
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').click({ button: 'right' });
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
await page.locator('button:has-text("OK")').click();
// navigate back to the display layout to confirm it has been removed
await page.goto(displayLayout.url);
expect(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0);
}); });
// Edit Display Layout
await page.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
// Add the Sine Wave Generator to the 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.locator('.l-layout__grid-holder');
await sineWaveGeneratorTreeItem.dragTo(layoutGridHolder);
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
// Subscribe to the Sine Wave Generator data
const getTelemValuePromise = await subscribeToTelemetry(page, sineWaveObject.uuid);
// Set an offset of 1 minute and then change the time mode to fixed to set a 1 minute historical window
await setStartOffset(page, { mins: '1' });
await setFixedTimeMode(page);
// On getting data, check if the value found in the Display Layout is the most recent value
// from the Sine Wave Generator
const formattedTelemetryValue = getTelemValuePromise;
const displayLayoutValuePromise = await page.waitForSelector(
`text="${formattedTelemetryValue}"`
);
const displayLayoutValue = await displayLayoutValuePromise.textContent();
const trimmedDisplayValue = displayLayoutValue.trim();
expect(trimmedDisplayValue).toBe(formattedTelemetryValue);
});
test('items in a display layout can be removed with object tree context menu when viewing the display layout', async ({
page
}) => {
// Create a Display Layout
await createDomainObjectWithDefaults(page, {
type: 'Display Layout',
name: 'Test Display Layout'
});
// Edit Display Layout
await page.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
// Add the Sine Wave Generator to the 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.locator('.l-layout__grid-holder');
await sineWaveGeneratorTreeItem.dragTo(layoutGridHolder);
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
expect.soft(await page.locator('.l-layout .l-layout__frame').count()).toEqual(1);
// Expand the Display Layout so we can remove the sine wave generator
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
// Bring up context menu and remove
await sineWaveGeneratorTreeItem.nth(1).click({ button: 'right' });
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
await page.locator('button:has-text("OK")').click();
// delete
expect(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0);
});
test('items in a display layout can be removed with object tree context menu when viewing another item', async ({
page
}) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/3117'
});
// Create a Display Layout
const displayLayout = await createDomainObjectWithDefaults(page, {
type: 'Display Layout'
});
// Edit Display Layout
await page.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
// Add the Sine Wave Generator to the 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.locator('.l-layout__grid-holder');
await sineWaveGeneratorTreeItem.dragTo(layoutGridHolder);
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
expect.soft(await page.locator('.l-layout .l-layout__frame').count()).toEqual(1);
// Expand the Display Layout so we can remove the sine wave generator
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
// Go to the original Sine Wave Generator to navigate away from the Display Layout
await page.goto(sineWaveObject.url);
// Bring up context menu and remove
await sineWaveGeneratorTreeItem.first().click({ button: 'right' });
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
await page.locator('button:has-text("OK")').click();
// navigate back to the display layout to confirm it has been removed
await page.goto(displayLayout.url);
expect(await page.locator('.l-layout .l-layout__frame').count()).toEqual(0);
});
test('independent time works with display layouts and its children', async ({ page }) => {
await setFixedTimeMode(page);
// Create Example Imagery
const exampleImageryObject = await createDomainObjectWithDefaults(page, {
type: 'Example Imagery'
});
// Create a Display Layout
await createDomainObjectWithDefaults(page, {
type: 'Display Layout'
});
// Edit Display Layout
await page.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
// Add the Sine Wave Generator to the Display Layout and save changes
const treePane = page.getByRole('tree', {
name: 'Main Tree'
});
const exampleImageryTreeItem = treePane.getByRole('treeitem', {
name: new RegExp(exampleImageryObject.name)
});
let layoutGridHolder = page.locator('.l-layout__grid-holder');
await exampleImageryTreeItem.dragTo(layoutGridHolder);
//adjust so that we can see the independent time conductor toggle
// Adjust object height
await page.locator('div[title="Resize object height"] > input').click();
await page.locator('div[title="Resize object height"] > input').fill('70');
// Adjust object width
await page.locator('div[title="Resize object width"] > input').click();
await page.locator('div[title="Resize object width"] > input').fill('70');
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
const startDate = '2021-12-30 01:01:00.000Z';
const endDate = '2021-12-30 01:11:00.000Z';
await setIndependentTimeConductorBounds(page, startDate, endDate);
// check image date
await expect(page.getByText('2021-12-30 01:11:00.000Z').first()).toBeVisible();
// flip it off
await page.getByRole('switch').click();
// timestamp shouldn't be in the past anymore
await expect(page.getByText('2021-12-30 01:11:00.000Z')).toBeHidden();
});
test('When multiple plots are contained in a layout, we only ask for annotations once @couchdb', async ({
page
}) => {
await setFixedTimeMode(page);
// Create another Sine Wave Generator
const anotherSineWaveObject = 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.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
// Add the Sine Wave Generator to the Display Layout and save changes
const treePane = page.getByRole('tree', {
name: 'Main Tree'
});
const sineWaveGeneratorTreeItem = treePane.getByRole('treeitem', {
name: new RegExp(sineWaveObject.name)
});
let layoutGridHolder = page.locator('.l-layout__grid-holder');
// eslint-disable-next-line playwright/no-force-option
await sineWaveGeneratorTreeItem.dragTo(layoutGridHolder, { force: true });
await page.getByText('View type').click();
await page.getByText('Overlay Plot').click();
const anotherSineWaveGeneratorTreeItem = treePane.getByRole('treeitem', {
name: new RegExp(anotherSineWaveObject.name)
});
layoutGridHolder = page.locator('.l-layout__grid-holder');
// eslint-disable-next-line playwright/no-force-option
await anotherSineWaveGeneratorTreeItem.dragTo(layoutGridHolder, { force: true });
await page.getByText('View type').click();
await page.getByText('Overlay Plot').click();
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
// Time to inspect some network traffic
let networkRequests = [];
page.on('request', (request) => {
const searchRequest = request.url().endsWith('_find');
const fetchRequest = request.resourceType() === 'fetch';
if (searchRequest && fetchRequest) {
networkRequests.push(request);
}
});
await page.reload();
// wait for annotations requests to be batched and requested
await page.waitForLoadState('networkidle');
// Network requests for the composite telemetry with multiple items should be:
// 1. a single batched request for annotations
expect(networkRequests.length).toBe(1);
await setRealTimeMode(page);
networkRequests = [];
await page.reload();
// wait for annotations to not load (if we have any, we've got a problem)
await page.waitForLoadState('networkidle');
// In real time mode, we don't fetch annotations at all
expect(networkRequests.length).toBe(0);
});
}); });
/** /**
@@ -344,20 +173,18 @@ test.describe('Display Layout', () => {
* @returns {Promise<string>} the formatted sin telemetry value * @returns {Promise<string>} the formatted sin telemetry value
*/ */
async function subscribeToTelemetry(page, objectIdentifier) { async function subscribeToTelemetry(page, objectIdentifier) {
const getTelemValuePromise = new Promise((resolve) => const getTelemValuePromise = new Promise(resolve => page.exposeFunction('getTelemValue', resolve));
page.exposeFunction('getTelemValue', resolve)
);
await page.evaluate(async (telemetryIdentifier) => { await page.evaluate(async (telemetryIdentifier) => {
const telemetryObject = await window.openmct.objects.get(telemetryIdentifier); const telemetryObject = await window.openmct.objects.get(telemetryIdentifier);
const metadata = window.openmct.telemetry.getMetadata(telemetryObject); const metadata = window.openmct.telemetry.getMetadata(telemetryObject);
const formats = await window.openmct.telemetry.getFormatMap(metadata); const formats = await window.openmct.telemetry.getFormatMap(metadata);
window.openmct.telemetry.subscribe(telemetryObject, (obj) => { window.openmct.telemetry.subscribe(telemetryObject, (obj) => {
const sinVal = obj.sin; const sinVal = obj.sin;
const formattedSinVal = formats.sin.format(sinVal); const formattedSinVal = formats.sin.format(sinVal);
window.getTelemValue(formattedSinVal); window.getTelemValue(formattedSinVal);
}); });
}, objectIdentifier); }, objectIdentifier);
return getTelemValuePromise; return getTelemValuePromise;
} }

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -22,234 +22,216 @@
const { test, expect } = require('../../../../pluginFixtures'); const { test, expect } = require('../../../../pluginFixtures');
const utils = require('../../../../helper/faultUtils'); const utils = require('../../../../helper/faultUtils');
const { selectInspectorTab } = require('../../../../appActions');
test.describe('The Fault Management Plugin using example faults', () => { test.describe('The Fault Management Plugin using example faults', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
await utils.navigateToFaultManagementWithExample(page); await utils.navigateToFaultManagementWithExample(page);
}); });
test('Shows a criticality icon for every fault @unstable', async ({ page }) => { test('Shows a criticality icon for every fault @unstable', async ({ page }) => {
const faultCount = await page.locator('c-fault-mgmt__list').count(); const faultCount = await page.locator('c-fault-mgmt__list').count();
const criticalityIconCount = await page.locator('c-fault-mgmt__list-severity').count(); const criticalityIconCount = await page.locator('c-fault-mgmt__list-severity').count();
expect.soft(faultCount).toEqual(criticalityIconCount); expect.soft(faultCount).toEqual(criticalityIconCount);
}); });
test('When selecting a fault, it has an "is-selected" class and it\'s information shows in the inspector @unstable', async ({ test('When selecting a fault, it has an "is-selected" class and it\'s information shows in the inspector @unstable', async ({ page }) => {
page await utils.selectFaultItem(page, 1);
}) => {
await utils.selectFaultItem(page, 1);
await selectInspectorTab(page, 'Fault Management Configuration'); const selectedFaultName = await page.locator('.c-fault-mgmt__list.is-selected .c-fault-mgmt__list-faultname').textContent();
const selectedFaultName = await page const inspectorFaultNameCount = await page.locator(`.c-inspector__properties >> :text("${selectedFaultName}")`).count();
.locator('.c-fault-mgmt__list.is-selected .c-fault-mgmt__list-faultname')
.textContent();
const inspectorFaultNameCount = await page
.locator(`.c-inspector__properties >> :text("${selectedFaultName}")`)
.count();
await expect await expect.soft(page.locator('.c-faults-list-view-item-body > .c-fault-mgmt__list').first()).toHaveClass(/is-selected/);
.soft(page.locator('.c-faults-list-view-item-body > .c-fault-mgmt__list').first()) expect.soft(inspectorFaultNameCount).toEqual(1);
.toHaveClass(/is-selected/); });
expect.soft(inspectorFaultNameCount).toEqual(1);
});
test('When selecting multiple faults, no specific fault information is shown in the inspector @unstable', async ({ test('When selecting multiple faults, no specific fault information is shown in the inspector @unstable', async ({ page }) => {
page await utils.selectFaultItem(page, 1);
}) => { await utils.selectFaultItem(page, 2);
await utils.selectFaultItem(page, 1);
await utils.selectFaultItem(page, 2);
const selectedRows = page.locator( const selectedRows = page.locator('.c-fault-mgmt__list.is-selected .c-fault-mgmt__list-faultname');
'.c-fault-mgmt__list.is-selected .c-fault-mgmt__list-faultname' expect.soft(await selectedRows.count()).toEqual(2);
);
expect.soft(await selectedRows.count()).toEqual(2);
await selectInspectorTab(page, 'Fault Management Configuration'); const firstSelectedFaultName = await selectedRows.nth(0).textContent();
const firstSelectedFaultName = await selectedRows.nth(0).textContent(); const secondSelectedFaultName = await selectedRows.nth(1).textContent();
const secondSelectedFaultName = await selectedRows.nth(1).textContent(); const firstNameInInspectorCount = await page.locator(`.c-inspector__properties >> :text("${firstSelectedFaultName}")`).count();
const firstNameInInspectorCount = await page const secondNameInInspectorCount = await page.locator(`.c-inspector__properties >> :text("${secondSelectedFaultName}")`).count();
.locator(`.c-inspector__properties >> :text("${firstSelectedFaultName}")`)
.count();
const secondNameInInspectorCount = await page
.locator(`.c-inspector__properties >> :text("${secondSelectedFaultName}")`)
.count();
expect.soft(firstNameInInspectorCount).toEqual(0); expect.soft(firstNameInInspectorCount).toEqual(0);
expect.soft(secondNameInInspectorCount).toEqual(0); expect.soft(secondNameInInspectorCount).toEqual(0);
}); });
test('Allows you to shelve a fault @unstable', async ({ page }) => { test('Allows you to shelve a fault @unstable', async ({ page }) => {
const shelvedFaultName = await utils.getFaultName(page, 2); const shelvedFaultName = await utils.getFaultName(page, 2);
const beforeShelvedFault = utils.getFaultByName(page, shelvedFaultName); const beforeShelvedFault = utils.getFaultByName(page, shelvedFaultName);
expect.soft(await beforeShelvedFault.count()).toBe(1); expect.soft(await beforeShelvedFault.count()).toBe(1);
await utils.shelveFault(page, 2); await utils.shelveFault(page, 2);
// check it is removed from standard view // check it is removed from standard view
const afterShelvedFault = utils.getFaultByName(page, shelvedFaultName); const afterShelvedFault = utils.getFaultByName(page, shelvedFaultName);
expect.soft(await afterShelvedFault.count()).toBe(0); expect.soft(await afterShelvedFault.count()).toBe(0);
await utils.changeViewTo(page, 'shelved'); await utils.changeViewTo(page, 'shelved');
const shelvedViewFault = utils.getFaultByName(page, shelvedFaultName); const shelvedViewFault = utils.getFaultByName(page, shelvedFaultName);
expect.soft(await shelvedViewFault.count()).toBe(1); expect.soft(await shelvedViewFault.count()).toBe(1);
}); });
test('Allows you to acknowledge a fault @unstable', async ({ page }) => { test('Allows you to acknowledge a fault @unstable', async ({ page }) => {
const acknowledgedFaultName = await utils.getFaultName(page, 3); const acknowledgedFaultName = await utils.getFaultName(page, 3);
await utils.acknowledgeFault(page, 3); await utils.acknowledgeFault(page, 3);
const fault = utils.getFault(page, 3); const fault = utils.getFault(page, 3);
await expect.soft(fault).toHaveClass(/is-acknowledged/); await expect.soft(fault).toHaveClass(/is-acknowledged/);
await utils.changeViewTo(page, 'acknowledged'); await utils.changeViewTo(page, 'acknowledged');
const acknowledgedViewFaultName = await utils.getFaultName(page, 1); const acknowledgedViewFaultName = await utils.getFaultName(page, 1);
expect.soft(acknowledgedFaultName).toEqual(acknowledgedViewFaultName); expect.soft(acknowledgedFaultName).toEqual(acknowledgedViewFaultName);
}); });
test('Allows you to shelve multiple faults @unstable', async ({ page }) => { test('Allows you to shelve multiple faults @unstable', async ({ page }) => {
const shelvedFaultNameOne = await utils.getFaultName(page, 1); const shelvedFaultNameOne = await utils.getFaultName(page, 1);
const shelvedFaultNameFour = await utils.getFaultName(page, 4); const shelvedFaultNameFour = await utils.getFaultName(page, 4);
const beforeShelvedFaultOne = utils.getFaultByName(page, shelvedFaultNameOne); const beforeShelvedFaultOne = utils.getFaultByName(page, shelvedFaultNameOne);
const beforeShelvedFaultFour = utils.getFaultByName(page, shelvedFaultNameFour); const beforeShelvedFaultFour = utils.getFaultByName(page, shelvedFaultNameFour);
expect.soft(await beforeShelvedFaultOne.count()).toBe(1); expect.soft(await beforeShelvedFaultOne.count()).toBe(1);
expect.soft(await beforeShelvedFaultFour.count()).toBe(1); expect.soft(await beforeShelvedFaultFour.count()).toBe(1);
await utils.shelveMultipleFaults(page, 1, 4); await utils.shelveMultipleFaults(page, 1, 4);
// check it is removed from standard view // check it is removed from standard view
const afterShelvedFaultOne = utils.getFaultByName(page, shelvedFaultNameOne); const afterShelvedFaultOne = utils.getFaultByName(page, shelvedFaultNameOne);
const afterShelvedFaultFour = utils.getFaultByName(page, shelvedFaultNameFour); const afterShelvedFaultFour = utils.getFaultByName(page, shelvedFaultNameFour);
expect.soft(await afterShelvedFaultOne.count()).toBe(0); expect.soft(await afterShelvedFaultOne.count()).toBe(0);
expect.soft(await afterShelvedFaultFour.count()).toBe(0); expect.soft(await afterShelvedFaultFour.count()).toBe(0);
await utils.changeViewTo(page, 'shelved'); await utils.changeViewTo(page, 'shelved');
const shelvedViewFaultOne = utils.getFaultByName(page, shelvedFaultNameOne); const shelvedViewFaultOne = utils.getFaultByName(page, shelvedFaultNameOne);
const shelvedViewFaultFour = utils.getFaultByName(page, shelvedFaultNameFour); const shelvedViewFaultFour = utils.getFaultByName(page, shelvedFaultNameFour);
expect.soft(await shelvedViewFaultOne.count()).toBe(1); expect.soft(await shelvedViewFaultOne.count()).toBe(1);
expect.soft(await shelvedViewFaultFour.count()).toBe(1); expect.soft(await shelvedViewFaultFour.count()).toBe(1);
}); });
test('Allows you to acknowledge multiple faults @unstable', async ({ page }) => { test('Allows you to acknowledge multiple faults @unstable', async ({ page }) => {
const acknowledgedFaultNameTwo = await utils.getFaultName(page, 2); const acknowledgedFaultNameTwo = await utils.getFaultName(page, 2);
const acknowledgedFaultNameFive = await utils.getFaultName(page, 5); const acknowledgedFaultNameFive = await utils.getFaultName(page, 5);
await utils.acknowledgeMultipleFaults(page, 2, 5); await utils.acknowledgeMultipleFaults(page, 2, 5);
const faultTwo = utils.getFault(page, 2); const faultTwo = utils.getFault(page, 2);
const faultFive = utils.getFault(page, 5); const faultFive = utils.getFault(page, 5);
// check they have been acknowledged // check they have been acknowledged
await expect.soft(faultTwo).toHaveClass(/is-acknowledged/); await expect.soft(faultTwo).toHaveClass(/is-acknowledged/);
await expect.soft(faultFive).toHaveClass(/is-acknowledged/); await expect.soft(faultFive).toHaveClass(/is-acknowledged/);
await utils.changeViewTo(page, 'acknowledged'); await utils.changeViewTo(page, 'acknowledged');
const acknowledgedViewFaultTwo = utils.getFaultByName(page, acknowledgedFaultNameTwo); const acknowledgedViewFaultTwo = utils.getFaultByName(page, acknowledgedFaultNameTwo);
const acknowledgedViewFaultFive = utils.getFaultByName(page, acknowledgedFaultNameFive); const acknowledgedViewFaultFive = utils.getFaultByName(page, acknowledgedFaultNameFive);
expect.soft(await acknowledgedViewFaultTwo.count()).toBe(1); expect.soft(await acknowledgedViewFaultTwo.count()).toBe(1);
expect.soft(await acknowledgedViewFaultFive.count()).toBe(1); expect.soft(await acknowledgedViewFaultFive.count()).toBe(1);
}); });
test('Allows you to search faults @unstable', async ({ page }) => { test('Allows you to search faults @unstable', async ({ page }) => {
const faultThreeNamespace = await utils.getFaultNamespace(page, 3); const faultThreeNamespace = await utils.getFaultNamespace(page, 3);
const faultTwoName = await utils.getFaultName(page, 2); const faultTwoName = await utils.getFaultName(page, 2);
const faultFiveTriggerTime = await utils.getFaultTriggerTime(page, 5); const faultFiveTriggerTime = await utils.getFaultTriggerTime(page, 5);
// should be all faults (5) // should be all faults (5)
let faultResultCount = await utils.getFaultResultCount(page); let faultResultCount = await utils.getFaultResultCount(page);
expect.soft(faultResultCount).toEqual(5); expect.soft(faultResultCount).toEqual(5);
// search namespace // search namespace
await utils.enterSearchTerm(page, faultThreeNamespace); await utils.enterSearchTerm(page, faultThreeNamespace);
faultResultCount = await utils.getFaultResultCount(page); faultResultCount = await utils.getFaultResultCount(page);
expect.soft(faultResultCount).toEqual(1); expect.soft(faultResultCount).toEqual(1);
expect.soft(await utils.getFaultNamespace(page, 1)).toEqual(faultThreeNamespace); expect.soft(await utils.getFaultNamespace(page, 1)).toEqual(faultThreeNamespace);
// all faults // all faults
await utils.clearSearch(page); await utils.clearSearch(page);
faultResultCount = await utils.getFaultResultCount(page); faultResultCount = await utils.getFaultResultCount(page);
expect.soft(faultResultCount).toEqual(5); expect.soft(faultResultCount).toEqual(5);
// search name // search name
await utils.enterSearchTerm(page, faultTwoName); await utils.enterSearchTerm(page, faultTwoName);
faultResultCount = await utils.getFaultResultCount(page); faultResultCount = await utils.getFaultResultCount(page);
expect.soft(faultResultCount).toEqual(1); expect.soft(faultResultCount).toEqual(1);
expect.soft(await utils.getFaultName(page, 1)).toEqual(faultTwoName); expect.soft(await utils.getFaultName(page, 1)).toEqual(faultTwoName);
// all faults // all faults
await utils.clearSearch(page); await utils.clearSearch(page);
faultResultCount = await utils.getFaultResultCount(page); faultResultCount = await utils.getFaultResultCount(page);
expect.soft(faultResultCount).toEqual(5); expect.soft(faultResultCount).toEqual(5);
// search triggerTime // search triggerTime
await utils.enterSearchTerm(page, faultFiveTriggerTime); await utils.enterSearchTerm(page, faultFiveTriggerTime);
faultResultCount = await utils.getFaultResultCount(page); faultResultCount = await utils.getFaultResultCount(page);
expect.soft(faultResultCount).toEqual(1); expect.soft(faultResultCount).toEqual(1);
expect.soft(await utils.getFaultTriggerTime(page, 1)).toEqual(faultFiveTriggerTime); expect.soft(await utils.getFaultTriggerTime(page, 1)).toEqual(faultFiveTriggerTime);
}); });
test('Allows you to sort faults @unstable', async ({ page }) => { test('Allows you to sort faults @unstable', async ({ page }) => {
const highestSeverity = await utils.getHighestSeverity(page); const highestSeverity = await utils.getHighestSeverity(page);
const lowestSeverity = await utils.getLowestSeverity(page); const lowestSeverity = await utils.getLowestSeverity(page);
const faultOneName = 'Example Fault 1'; const faultOneName = 'Example Fault 1';
const faultFiveName = 'Example Fault 5'; const faultFiveName = 'Example Fault 5';
let firstFaultName = await utils.getFaultName(page, 1); let firstFaultName = await utils.getFaultName(page, 1);
expect.soft(firstFaultName).toEqual(faultOneName); expect.soft(firstFaultName).toEqual(faultOneName);
await utils.sortFaultsBy(page, 'oldest-first'); await utils.sortFaultsBy(page, 'oldest-first');
firstFaultName = await utils.getFaultName(page, 1); firstFaultName = await utils.getFaultName(page, 1);
expect.soft(firstFaultName).toEqual(faultFiveName); expect.soft(firstFaultName).toEqual(faultFiveName);
await utils.sortFaultsBy(page, 'severity'); await utils.sortFaultsBy(page, 'severity');
const sortedHighestSeverity = await utils.getFaultSeverity(page, 1);
const sortedLowestSeverity = await utils.getFaultSeverity(page, 5);
expect.soft(sortedHighestSeverity).toEqual(highestSeverity);
expect.soft(sortedLowestSeverity).toEqual(lowestSeverity);
});
const sortedHighestSeverity = await utils.getFaultSeverity(page, 1);
const sortedLowestSeverity = await utils.getFaultSeverity(page, 5);
expect.soft(sortedHighestSeverity).toEqual(highestSeverity);
expect.soft(sortedLowestSeverity).toEqual(lowestSeverity);
});
}); });
test.describe('The Fault Management Plugin without using example faults', () => { test.describe('The Fault Management Plugin without using example faults', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
await utils.navigateToFaultManagementWithoutExample(page); await utils.navigateToFaultManagementWithoutExample(page);
}); });
test('Shows no faults when no faults are provided @unstable', async ({ page }) => { test('Shows no faults when no faults are provided @unstable', async ({ page }) => {
const faultCount = await page.locator('c-fault-mgmt__list').count(); const faultCount = await page.locator('c-fault-mgmt__list').count();
expect.soft(faultCount).toEqual(0); expect.soft(faultCount).toEqual(0);
await utils.changeViewTo(page, 'acknowledged'); await utils.changeViewTo(page, 'acknowledged');
const acknowledgedCount = await page.locator('c-fault-mgmt__list').count(); const acknowledgedCount = await page.locator('c-fault-mgmt__list').count();
expect.soft(acknowledgedCount).toEqual(0); expect.soft(acknowledgedCount).toEqual(0);
await utils.changeViewTo(page, 'shelved'); await utils.changeViewTo(page, 'shelved');
const shelvedCount = await page.locator('c-fault-mgmt__list').count(); const shelvedCount = await page.locator('c-fault-mgmt__list').count();
expect.soft(shelvedCount).toEqual(0); expect.soft(shelvedCount).toEqual(0);
}); });
test('Will return no faults when searching @unstable', async ({ page }) => { test('Will return no faults when searching @unstable', async ({ page }) => {
await utils.enterSearchTerm(page, 'fault'); await utils.enterSearchTerm(page, 'fault');
const faultCount = await page.locator('c-fault-mgmt__list').count(); const faultCount = await page.locator('c-fault-mgmt__list').count();
expect.soft(faultCount).toEqual(0); expect.soft(faultCount).toEqual(0);
}); });
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -21,239 +21,115 @@
*****************************************************************************/ *****************************************************************************/
const { test, expect } = require('../../../../pluginFixtures'); const { test, expect } = require('../../../../pluginFixtures');
const { const { createDomainObjectWithDefaults } = require('../../../../appActions');
createDomainObjectWithDefaults,
setIndependentTimeConductorBounds
} = require('../../../../appActions');
test.describe('Flexible Layout', () => { test.describe('Flexible Layout', () => {
let sineWaveObject; let sineWaveObject;
let clockObject; test.beforeEach(async ({ page }) => {
let treePane; await page.goto('./', { waitUntil: 'networkidle' });
let sineWaveGeneratorTreeItem;
let clockTreeItem;
let flexibleLayout;
test.beforeEach(async ({ page }) => {
await page.goto('./', { waitUntil: 'domcontentloaded' });
// Create Sine Wave Generator // Create Sine Wave Generator
sineWaveObject = await createDomainObjectWithDefaults(page, { sineWaveObject = await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator' type: 'Sine Wave Generator',
name: "Test Sine Wave Generator"
});
// Create Clock Object
await createDomainObjectWithDefaults(page, {
type: 'Clock',
name: "Test Clock"
});
}); });
test('panes have the appropriate draggable attribute while in Edit and Browse modes', async ({ page }) => {
// Create a Flexible Layout
await createDomainObjectWithDefaults(page, {
type: 'Flexible Layout',
name: "Test Flexible Layout"
});
// Edit Flexible Layout
await page.locator('[title="Edit"]').click();
// Create Clock Object // Expand the 'My Items' folder in the left tree
clockObject = await createDomainObjectWithDefaults(page, { await page.locator('.c-tree__item__view-control.c-disclosure-triangle').first().click();
type: 'Clock' // Add the Sine Wave Generator and Clock to the Flexible Layout
await page.dragAndDrop('text=Test Sine Wave Generator', '.c-fl__container.is-empty');
await page.dragAndDrop('text=Test Clock', '.c-fl__container.is-empty');
// Check that panes can be dragged while Flexible Layout is in Edit mode
let dragWrapper = page.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper').first();
await expect(dragWrapper).toHaveAttribute('draggable', 'true');
// Save Flexible Layout
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
// Check that panes are not draggable while Flexible Layout is in Browse mode
dragWrapper = page.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper').first();
await expect(dragWrapper).toHaveAttribute('draggable', 'false');
}); });
test('items in a flexible layout can be removed with object tree context menu when viewing the flexible layout', async ({ page }) => {
// Create a Display Layout
await createDomainObjectWithDefaults(page, {
type: 'Flexible Layout',
name: "Test Flexible Layout"
});
// Edit Flexible Layout
await page.locator('[title="Edit"]').click();
// Create a Flexible Layout // Expand the 'My Items' folder in the left tree
flexibleLayout = await createDomainObjectWithDefaults(page, { await page.locator('.c-tree__item__view-control.c-disclosure-triangle').first().click();
type: 'Flexible Layout' // Add the Sine Wave Generator to the Flexible Layout and save changes
await page.dragAndDrop('text=Test Sine Wave Generator', '.c-fl__container.is-empty');
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
expect.soft(await page.locator('.c-fl-container__frame').count()).toEqual(1);
// Expand the Flexible Layout so we can remove the sine wave generator
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
// Bring up context menu and remove
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').first().click({ button: 'right' });
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
await page.locator('button:has-text("OK")').click();
// Verify that the item has been removed from the layout
expect(await page.locator('.c-fl-container__frame').count()).toEqual(0);
}); });
test('items in a flexible layout can be removed with object tree context menu when viewing another item', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/3117'
});
// Create a Flexible Layout
const flexibleLayout = await createDomainObjectWithDefaults(page, {
type: 'Flexible Layout',
name: "Test Flexible Layout"
});
// Edit Flexible Layout
await page.locator('[title="Edit"]').click();
// Define the Sine Wave Generator and Clock tree items // Expand the 'My Items' folder in the left tree
treePane = page.getByRole('tree', { await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
name: 'Main Tree' // Add the Sine Wave Generator to the Flexible Layout and save changes
await page.dragAndDrop('text=Test Sine Wave Generator', '.c-fl__container.is-empty');
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
expect.soft(await page.locator('.c-fl-container__frame').count()).toEqual(1);
// Expand the Flexible Layout so we can remove the sine wave generator
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
// Go to the original Sine Wave Generator to navigate away from the Flexible Layout
await page.goto(sineWaveObject.url);
// Bring up context menu and remove
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').click({ button: 'right' });
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
await page.locator('button:has-text("OK")').click();
// navigate back to the display layout to confirm it has been removed
await page.goto(flexibleLayout.url);
// Verify that the item has been removed from the layout
expect(await page.locator('.c-fl-container__frame').count()).toEqual(0);
}); });
sineWaveGeneratorTreeItem = treePane.getByRole('treeitem', {
name: new RegExp(sineWaveObject.name)
});
clockTreeItem = treePane.getByRole('treeitem', {
name: new RegExp(clockObject.name)
});
});
test('panes have the appropriate draggable attribute while in Edit and Browse modes', async ({
page
}) => {
await page.goto(flexibleLayout.url);
// Edit Flexible Layout
await page.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').first().click();
// Add the Sine Wave Generator and Clock to the Flexible Layout
await sineWaveGeneratorTreeItem.dragTo(page.locator('.c-fl__container.is-empty').first());
await clockTreeItem.dragTo(page.locator('.c-fl__container.is-empty'));
// Check that panes can be dragged while Flexible Layout is in Edit mode
let dragWrapper = page
.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper')
.first();
await expect(dragWrapper).toHaveAttribute('draggable', 'true');
// Save Flexible Layout
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
// Check that panes are not draggable while Flexible Layout is in Browse mode
dragWrapper = page.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper').first();
await expect(dragWrapper).toHaveAttribute('draggable', 'false');
});
test('changing toolbar settings in edit mode is immediately reflected and persists upon save', async ({
page
}) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/6942'
});
await page.goto(flexibleLayout.url);
// Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').first().click();
// Add the Sine Wave Generator and Clock to the Flexible Layout
await sineWaveGeneratorTreeItem.dragTo(page.locator('.c-fl__container.is-empty').first());
await clockTreeItem.dragTo(page.locator('.c-fl__container.is-empty'));
// Click on the first frame to select it
await page.locator('.c-fl-container__frame').first().click();
await expect(page.locator('.c-fl-container__frame > .c-frame').first()).toHaveAttribute(
's-selected',
''
);
// Assert the toolbar is visible
await expect(page.locator('.c-toolbar')).toBeInViewport();
// Assert the layout is in columns orientation
expect(await page.locator('.c-fl--rows').count()).toEqual(0);
// Change the layout to rows orientation
await page.getByTitle('Columns layout').click();
// Assert the layout is in rows orientation
expect(await page.locator('.c-fl--rows').count()).toBeGreaterThan(0);
// Assert the frame of the first item is visible
await expect(page.locator('.c-so-view').first()).not.toHaveClass(/c-so-view--no-frame/);
// Hide the frame of the first item
await page.getByTitle('Frame visible').click();
// Assert the frame is hidden
await expect(page.locator('.c-so-view').first()).toHaveClass(/c-so-view--no-frame/);
// Assert there are 2 containers
expect(await page.locator('.c-fl-container').count()).toEqual(2);
// Add a container
await page.getByTitle('Add Container').click();
// Assert there are 3 containers
expect(await page.locator('.c-fl-container').count()).toEqual(3);
// Save Flexible Layout
await page.locator('button[title="Save"]').click();
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
// Nav away and back
await page.goto(sineWaveObject.url);
await page.goto(flexibleLayout.url);
// Wait for the first frame to be visible so we know the layout has loaded
await expect(page.locator('.c-fl-container').nth(0)).toBeInViewport();
// Assert the settings have persisted
expect(await page.locator('.c-fl-container').count()).toEqual(3);
expect(await page.locator('.c-fl--rows').count()).toBeGreaterThan(0);
await expect(page.locator('.c-so-view').first()).toHaveClass(/c-so-view--no-frame/);
});
test('items in a flexible layout can be removed with object tree context menu when viewing the flexible layout', async ({
page
}) => {
await page.goto(flexibleLayout.url);
// Edit Flexible Layout
await page.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').first().click();
// Add the Sine Wave Generator to the Flexible Layout and save changes
await sineWaveGeneratorTreeItem.dragTo(page.locator('.c-fl__container.is-empty').first());
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
expect.soft(await page.locator('.c-fl-container__frame').count()).toEqual(1);
// Expand the Flexible Layout so we can remove the sine wave generator
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
// Bring up context menu and remove
await sineWaveGeneratorTreeItem.first().click({ button: 'right' });
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
await page.locator('button:has-text("OK")').click();
// Verify that the item has been removed from the layout
expect(await page.locator('.c-fl-container__frame').count()).toEqual(0);
});
test('items in a flexible layout can be removed with object tree context menu when viewing another item', async ({
page
}) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/3117'
});
await page.goto(flexibleLayout.url);
// Edit Flexible Layout
await page.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
// Add the Sine Wave Generator to the Flexible Layout and save changes
await sineWaveGeneratorTreeItem.dragTo(page.locator('.c-fl__container.is-empty').first());
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
expect.soft(await page.locator('.c-fl-container__frame').count()).toEqual(1);
// Expand the Flexible Layout so we can remove the sine wave generator
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
// Go to the original Sine Wave Generator to navigate away from the Flexible Layout
await page.goto(sineWaveObject.url);
// Bring up context menu and remove
await sineWaveGeneratorTreeItem.first().click({ button: 'right' });
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
await page.locator('button:has-text("OK")').click();
// navigate back to the display layout to confirm it has been removed
await page.goto(flexibleLayout.url);
// Verify that the item has been removed from the layout
expect(await page.locator('.c-fl-container__frame').count()).toEqual(0);
});
test('independent time works with flexible layouts and its children', async ({ page }) => {
// Create Example Imagery
const exampleImageryObject = await createDomainObjectWithDefaults(page, {
type: 'Example Imagery'
});
await page.goto(flexibleLayout.url);
// Edit Flexible Layout
await page.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
const exampleImageryTreeItem = treePane.getByRole('treeitem', {
name: new RegExp(exampleImageryObject.name)
});
// Add the Sine Wave Generator to the Flexible Layout and save changes
await exampleImageryTreeItem.dragTo(page.locator('.c-fl__container.is-empty').first());
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
// flip on independent time conductor
await setIndependentTimeConductorBounds(
page,
'2021-12-30 01:01:00.000Z',
'2021-12-30 01:11:00.000Z'
);
// check image date
await expect(page.getByText('2021-12-30 01:11:00.000Z').first()).toBeVisible();
// flip it off
await page.getByRole('switch').click();
// timestamp shouldn't be in the past anymore
await expect(page.getByText('2021-12-30 01:11:00.000Z')).toBeHidden();
});
}); });

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -21,116 +21,104 @@
*****************************************************************************/ *****************************************************************************/
/* /*
* This test suite is dedicated to testing the Gauge component. * This test suite is dedicated to testing the Gauge component.
*/ */
const { test, expect } = require('../../../../pluginFixtures'); const { test, expect } = require('../../../../pluginFixtures');
const { createDomainObjectWithDefaults } = require('../../../../appActions'); const { createDomainObjectWithDefaults } = require('../../../../appActions');
const uuid = require('uuid').v4; const uuid = require('uuid').v4;
test.describe('Gauge', () => { test.describe('Gauge', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
// Open a browser, navigate to the main page, and wait until all networkevents to resolve // Open a browser, navigate to the main page, and wait until all networkevents to resolve
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
});
test('Can add and remove telemetry sources @unstable', async ({ page }) => {
// Create the gauge with defaults
const gauge = await createDomainObjectWithDefaults(page, { type: 'Gauge' });
const editButtonLocator = page.locator('button[title="Edit"]');
const saveButtonLocator = page.locator('button[title="Save"]');
// Create a sine wave generator within the gauge
const swg1 = await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
name: `swg-${uuid()}`,
parent: gauge.uuid
}); });
// Navigate to the gauge and verify that test('Can add and remove telemetry sources @unstable', async ({ page }) => {
// the SWG appears in the elements pool // Create the gauge with defaults
await page.goto(gauge.url); const gauge = await createDomainObjectWithDefaults(page, { type: 'Gauge' });
await editButtonLocator.click(); const editButtonLocator = page.locator('button[title="Edit"]');
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeVisible(); const saveButtonLocator = page.locator('button[title="Save"]');
await saveButtonLocator.click();
await page.locator('li[title="Save and Finish Editing"]').click();
// Create another sine wave generator within the gauge // Create a sine wave generator within the gauge
const swg2 = await createDomainObjectWithDefaults(page, { const swg1 = await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator', type: 'Sine Wave Generator',
name: `swg-${uuid()}`, name: `swg-${uuid()}`,
parent: gauge.uuid parent: gauge.uuid
});
// Navigate to the gauge and verify that
// the SWG appears in the elements pool
await page.goto(gauge.url);
await editButtonLocator.click();
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeVisible();
await saveButtonLocator.click();
await page.locator('li[title="Save and Finish Editing"]').click();
// Create another sine wave generator within the gauge
const swg2 = await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
name: `swg-${uuid()}`,
parent: gauge.uuid
});
// Verify that the 'Replace telemetry source' modal appears and accept it
await expect.soft(page.locator('text=This action will replace the current telemetry source. Do you want to continue?')).toBeVisible();
await page.click('text=Ok');
// Navigate to the gauge and verify that the new SWG
// appears in the elements pool and the old one is gone
await page.goto(gauge.url);
await editButtonLocator.click();
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeHidden();
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg2.name}`)).toBeVisible();
await saveButtonLocator.click();
// Right click on the new SWG in the elements pool and delete it
await page.locator(`#inspector-elements-tree >> text=${swg2.name}`).click({
button: 'right'
});
await page.locator('li[title="Remove this object from its containing object."]').click();
// Verify that the 'Remove object' confirmation modal appears and accept it
await expect.soft(page.locator('text=Warning! This action will remove this object. Are you sure you want to continue?')).toBeVisible();
await page.click('text=Ok');
// Verify that the elements pool shows no elements
await expect(page.locator('text="No contained elements"')).toBeVisible();
}); });
test('Can create a non-default Gauge', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/5356'
});
//Click the Create button
await page.click('button:has-text("Create")');
// Verify that the 'Replace telemetry source' modal appears and accept it // Click the object specified by 'type'
await expect await page.click(`li[role='menuitem']:text("Gauge")`);
.soft( // FIXME: We need better selectors for these custom form controls
page.locator( const displayCurrentValueSwitch = page.locator('.c-toggle-switch__slider >> nth=0');
'text=This action will replace the current telemetry source. Do you want to continue?' await displayCurrentValueSwitch.setChecked(false);
) await page.click('button[aria-label="Save"]');
)
.toBeVisible();
await page.click('text=Ok');
// Navigate to the gauge and verify that the new SWG // TODO: Verify changes in the UI
// appears in the elements pool and the old one is gone
await page.goto(gauge.url);
await editButtonLocator.click();
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg1.name}`)).toBeHidden();
await expect.soft(page.locator(`#inspector-elements-tree >> text=${swg2.name}`)).toBeVisible();
await saveButtonLocator.click();
// Right click on the new SWG in the elements pool and delete it
await page.locator(`#inspector-elements-tree >> text=${swg2.name}`).click({
button: 'right'
}); });
await page.locator('li[title="Remove this object from its containing object."]').click(); test('Can edit a single Gauge-specific property', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/5985'
});
// Verify that the 'Remove object' confirmation modal appears and accept it // Create the gauge with defaults
await expect await createDomainObjectWithDefaults(page, { type: 'Gauge' });
.soft( await page.click('button[title="More options"]');
page.locator( await page.click('li[role="menuitem"]:has-text("Edit Properties")');
'text=Warning! This action will remove this object. Are you sure you want to continue?' // FIXME: We need better selectors for these custom form controls
) const displayCurrentValueSwitch = page.locator('.c-toggle-switch__slider >> nth=0');
) await displayCurrentValueSwitch.setChecked(false);
.toBeVisible(); await page.click('button[aria-label="Save"]');
await page.click('text=Ok');
// Verify that the elements pool shows no elements // TODO: Verify changes in the UI
await expect(page.locator('text="No contained elements"')).toBeVisible();
});
test('Can create a non-default Gauge', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/5356'
}); });
//Click the Create button
await page.click('button:has-text("Create")');
// Click the object specified by 'type'
await page.click(`li[role='menuitem']:text("Gauge")`);
// FIXME: We need better selectors for these custom form controls
const displayCurrentValueSwitch = page.locator('.c-toggle-switch__slider >> nth=0');
await displayCurrentValueSwitch.setChecked(false);
await page.click('button[aria-label="Save"]');
// TODO: Verify changes in the UI
});
test('Can edit a single Gauge-specific property', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/5985'
});
// Create the gauge with defaults
await createDomainObjectWithDefaults(page, { type: 'Gauge' });
await page.click('button[title="More options"]');
await page.click('li[role="menuitem"]:has-text("Edit Properties")');
// FIXME: We need better selectors for these custom form controls
const displayCurrentValueSwitch = page.locator('.c-toggle-switch__slider >> nth=0');
await displayCurrentValueSwitch.setChecked(false);
await page.click('button[aria-label="Save"]');
// TODO: Verify changes in the UI
});
}); });

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -29,31 +29,22 @@ This test suite is dedicated to tests which verify the basic operations surround
const { test, expect } = require('../../../../baseFixtures'); const { test, expect } = require('../../../../baseFixtures');
test.describe('ExportAsJSON', () => { test.describe('ExportAsJSON', () => {
test.fixme( test.fixme('Create a basic object and verify that it can be exported as JSON from Tree', async ({ page }) => {
'Create a basic object and verify that it can be exported as JSON from Tree', //Create domain object
async ({ page }) => { //Save Domain Object
//Create domain object //Verify that the newly created domain object can be exported as JSON from the Tree
//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
test.fixme( //Verify that the newly created domain object can be exported as JSON from the 3 dot menu
'Create a basic object and verify that it can be exported as JSON from 3 dot menu', });
async ({ page }) => { test.fixme('Verify that a nested Object can be exported as JSON', async ({ page }) => {
//Create domain object // Create 2 objects with hierarchy
//Save Domain Object // Export as JSON
//Verify that the newly created domain object can be exported as JSON from the 3 dot menu // Verify Hiearchy
} });
); test.fixme('Verify that the ExportAsJSON dropdown does not appear for the item X', async ({ page }) => {
test.fixme('Verify that a nested Object can be exported as JSON', async ({ page }) => { // Other than non-persistible objects
// Create 2 objects with hierarchy });
// Export as JSON
// Verify Hiearchy
});
test.fixme(
'Verify that the ExportAsJSON dropdown does not appear for the item X',
async ({ page }) => {
// Other than non-persistible objects
}
);
}); });

View File

@@ -1,54 +1,48 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
* Open MCT is licensed under the Apache License, Version 2.0 (the * 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. * "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0. * http://www.apache.org/licenses/LICENSE-2.0.
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
* *
* Open MCT includes source code licensed under additional open source * Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with * licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available * this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
/* /*
This test suite is dedicated to tests which verify the basic operations surrounding importAsJSON. This test suite is dedicated to tests which verify the basic operations surrounding importAsJSON.
*/ */
// FIXME: Remove this eslint exception once tests are implemented // FIXME: Remove this eslint exception once tests are implemented
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { test, expect } = require('../../../../baseFixtures'); const { test, expect } = require('../../../../baseFixtures');
test.describe('ExportAsJSON', () => { test.describe('ExportAsJSON', () => {
test.fixme('Verify that domain object can be importAsJSON from Tree', async ({ page }) => { test.fixme('Verify that domain object can be importAsJSON from Tree', async ({ page }) => {
//Verify that an testdata JSON file can be imported from Tree //Verify that an testdata JSON file can be imported from Tree
//Verify correctness of imported domain object //Verify correctness of imported domain object
}); });
test.fixme( test.fixme('Verify that domain object can be importAsJSON from 3 dot menu on folder', async ({ page }) => {
'Verify that domain object can be importAsJSON from 3 dot menu on folder', //Verify that an testdata JSON file can be imported from 3 dot menu on folder domain object
async ({ page }) => { //Verify correctness of imported domain object
//Verify that an testdata JSON file can be imported from 3 dot menu on folder domain object });
//Verify correctness of imported domain object test.fixme('Verify that a nested Objects can be importAsJSON', async ({ page }) => {
} // Testdata with hierarchy
); // ImportAsJSON on Tree
test.fixme('Verify that a nested Objects can be importAsJSON', async ({ page }) => { // Verify Hierarchy
// Testdata with hierarchy });
// ImportAsJSON on Tree test.fixme('Verify that the ImportAsJSON dropdown does not appear for the item X', async ({ page }) => {
// Verify Hierarchy // Other than non-persistible objects
}); });
test.fixme( });
'Verify that the ImportAsJSON dropdown does not appear for the item X',
async ({ page }) => {
// Other than non-persistible objects
}
);
});

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -21,201 +21,76 @@
*****************************************************************************/ *****************************************************************************/
const { test, expect } = require('../../../../pluginFixtures'); const { test, expect } = require('../../../../pluginFixtures');
const { const { createDomainObjectWithDefaults, setStartOffset, setFixedTimeMode, setRealTimeMode } = require('../../../../appActions');
createDomainObjectWithDefaults,
setStartOffset,
setFixedTimeMode,
setRealTimeMode,
selectInspectorTab
} = require('../../../../appActions');
test.describe('Testing LAD table configuration', () => {
test.beforeEach(async ({ page }) => {
await page.goto('./', { waitUntil: 'domcontentloaded' });
// Create LAD table
const ladTable = await createDomainObjectWithDefaults(page, {
type: 'LAD Table',
name: 'Test LAD Table'
});
// Create Sine Wave Generator
await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
name: 'Test Sine Wave Generator',
parent: ladTable.uuid
});
await page.goto(ladTable.url);
});
test('in edit mode, LAD Tables provide ability to hide columns', async ({ page }) => {
// Edit LAD table
await page.locator('[title="Edit"]').click();
// // Expand the 'My Items' folder in the left tree
// await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
// // Add the Sine Wave Generator to the LAD table and save changes
// await page.dragAndDrop('role=treeitem[name=/Test Sine Wave Generator/]', '.c-lad-table-wrapper');
// select configuration tab in inspector
await selectInspectorTab(page, 'LAD Table Configuration');
// make sure headers are visible initially
await expect(page.getByRole('cell', { name: 'Timestamp' })).toBeVisible();
await expect(page.getByRole('cell', { name: 'Units' })).toBeVisible();
await expect(page.getByRole('cell', { name: 'Type' })).toBeVisible();
// hide timestamp column
await page.getByLabel('Timestamp').uncheck();
await expect(page.getByRole('cell', { name: 'Timestamp' })).toBeHidden();
await expect(page.getByRole('cell', { name: 'Units' })).toBeVisible();
await expect(page.getByRole('cell', { name: 'Type' })).toBeVisible();
// hide units & type column
await page.getByLabel('Units').uncheck();
await page.getByLabel('Type').uncheck();
await expect(page.getByRole('cell', { name: 'Timestamp' })).toBeHidden();
await expect(page.getByRole('cell', { name: 'Units' })).toBeHidden();
await expect(page.getByRole('cell', { name: 'Type' })).toBeHidden();
// save and reload and verify they columns are still hidden
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
await page.reload();
await expect(page.getByRole('cell', { name: 'Timestamp' })).toBeHidden();
await expect(page.getByRole('cell', { name: 'Units' })).toBeHidden();
await expect(page.getByRole('cell', { name: 'Type' })).toBeHidden();
// Edit LAD table
await page.locator('[title="Edit"]').click();
await selectInspectorTab(page, 'LAD Table Configuration');
// show timestamp column
await page.getByLabel('Timestamp').check();
await expect(page.getByRole('cell', { name: 'Units' })).toBeHidden();
await expect(page.getByRole('cell', { name: 'Type' })).toBeHidden();
await expect(page.getByRole('cell', { name: 'Timestamp' })).toBeVisible();
// save and reload and make sure only timestamp is still visible
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
await page.reload();
await expect(page.getByRole('cell', { name: 'Units' })).toBeHidden();
await expect(page.getByRole('cell', { name: 'Type' })).toBeHidden();
await expect(page.getByRole('cell', { name: 'Timestamp' })).toBeVisible();
// Edit LAD table
await page.locator('[title="Edit"]').click();
await selectInspectorTab(page, 'LAD Table Configuration');
// show units and type columns
await page.getByLabel('Units').check();
await page.getByLabel('Type').check();
await expect(page.getByRole('cell', { name: 'Timestamp' })).toBeVisible();
await expect(page.getByRole('cell', { name: 'Units' })).toBeVisible();
await expect(page.getByRole('cell', { name: 'Type' })).toBeVisible();
// save and reload and make sure all columns are still visible
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
await page.reload();
await expect(page.getByRole('cell', { name: 'Timestamp' })).toBeVisible();
await expect(page.getByRole('cell', { name: 'Units' })).toBeVisible();
await expect(page.getByRole('cell', { name: 'Type' })).toBeVisible();
});
test("LAD Tables don't allow selection of rows but does show context click menus", async ({
page
}) => {
const cell = await page.locator('.js-first-data');
const userSelectable = await cell.evaluate((el) => {
return window.getComputedStyle(el).getPropertyValue('user-select');
});
expect(userSelectable).toBe('none');
// Right-click on the LAD table row
await cell.click({
button: 'right'
});
const menuOptions = page.locator('.c-menu ul');
await expect.soft(menuOptions).toContainText('View Full Datum');
await expect.soft(menuOptions).toContainText('View Historical Data');
await expect.soft(menuOptions).toContainText('Remove');
// await page.locator('li[title="Remove this object from its containing object."]').click();
});
});
test.describe('Testing LAD table @unstable', () => { test.describe('Testing LAD table @unstable', () => {
let sineWaveObject; let sineWaveObject;
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
await setRealTimeMode(page); await setRealTimeMode(page);
// Create Sine Wave Generator // Create Sine Wave Generator
sineWaveObject = await createDomainObjectWithDefaults(page, { sineWaveObject = await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator', type: 'Sine Wave Generator',
name: 'Test Sine Wave Generator' name: "Test Sine Wave Generator"
});
}); });
}); test('telemetry value exactly matches latest telemetry value received in real time', async ({ page }) => {
test('telemetry value exactly matches latest telemetry value received in real time', async ({ // Create LAD table
page await createDomainObjectWithDefaults(page, {
}) => { type: 'LAD Table',
// Create LAD table name: "Test LAD Table"
await createDomainObjectWithDefaults(page, { });
type: 'LAD Table', // Edit LAD table
name: 'Test LAD Table' await page.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
// Add the Sine Wave Generator to the LAD table and save changes
await page.dragAndDrop('text=Test Sine Wave Generator', '.c-lad-table-wrapper');
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
// Subscribe to the Sine Wave Generator data
// On getting data, check if the value found in the LAD table is the most recent value
// from the Sine Wave Generator
const getTelemValuePromise = await subscribeToTelemetry(page, sineWaveObject.uuid);
const subscribeTelemValue = await getTelemValuePromise;
const ladTableValuePromise = await page.waitForSelector(`text="${subscribeTelemValue}"`);
const ladTableValue = await ladTableValuePromise.textContent();
expect(ladTableValue).toBe(subscribeTelemValue);
}); });
// Edit LAD table test('telemetry value exactly matches latest telemetry value received in fixed time', async ({ page }) => {
await page.locator('[title="Edit"]').click(); // Create LAD table
await createDomainObjectWithDefaults(page, {
type: 'LAD Table',
name: "Test LAD Table"
});
// Edit LAD table
await page.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree // Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click(); await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
// Add the Sine Wave Generator to the LAD table and save changes // Add the Sine Wave Generator to the LAD table and save changes
await page.dragAndDrop('text=Test Sine Wave Generator', '.c-lad-table-wrapper'); await page.dragAndDrop('text=Test Sine Wave Generator', '.c-lad-table-wrapper');
await page.locator('button[title="Save"]').click(); await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click(); await page.locator('text=Save and Finish Editing').click();
// Subscribe to the Sine Wave Generator data // Subscribe to the Sine Wave Generator data
// On getting data, check if the value found in the LAD table is the most recent value const getTelemValuePromise = await subscribeToTelemetry(page, sineWaveObject.uuid);
// from the Sine Wave Generator // Set an offset of 1 minute and then change the time mode to fixed to set a 1 minute historical window
const getTelemValuePromise = await subscribeToTelemetry(page, sineWaveObject.uuid); await setStartOffset(page, { mins: '1' });
const subscribeTelemValue = await getTelemValuePromise; await setFixedTimeMode(page);
const ladTableValuePromise = await page.waitForSelector(`text="${subscribeTelemValue}"`);
const ladTableValue = await ladTableValuePromise.textContent();
expect(ladTableValue).toBe(subscribeTelemValue); // On getting data, check if the value found in the LAD table is the most recent value
}); // from the Sine Wave Generator
test('telemetry value exactly matches latest telemetry value received in fixed time', async ({ const subscribeTelemValue = await getTelemValuePromise;
page const ladTableValuePromise = await page.waitForSelector(`text="${subscribeTelemValue}"`);
}) => { const ladTableValue = await ladTableValuePromise.textContent();
// Create LAD table
await createDomainObjectWithDefaults(page, { expect(ladTableValue).toBe(subscribeTelemValue);
type: 'LAD Table',
name: 'Test LAD Table'
}); });
// Edit LAD table
await page.locator('[title="Edit"]').click();
// Expand the 'My Items' folder in the left tree
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').click();
// Add the Sine Wave Generator to the LAD table and save changes
await page.dragAndDrop('text=Test Sine Wave Generator', '.c-lad-table-wrapper');
await page.locator('button[title="Save"]').click();
await page.locator('text=Save and Finish Editing').click();
// Subscribe to the Sine Wave Generator data
const getTelemValuePromise = await subscribeToTelemetry(page, sineWaveObject.uuid);
// Set an offset of 1 minute and then change the time mode to fixed to set a 1 minute historical window
await setStartOffset(page, { mins: '1' });
await setFixedTimeMode(page);
// On getting data, check if the value found in the LAD table is the most recent value
// from the Sine Wave Generator
const subscribeTelemValue = await getTelemValuePromise;
const ladTableValuePromise = await page.waitForSelector(`text="${subscribeTelemValue}"`);
const ladTableValue = await ladTableValuePromise.textContent();
expect(ladTableValue).toBe(subscribeTelemValue);
});
}); });
/** /**
@@ -228,20 +103,18 @@ test.describe('Testing LAD table @unstable', () => {
* @returns {Promise<string>} the formatted sin telemetry value * @returns {Promise<string>} the formatted sin telemetry value
*/ */
async function subscribeToTelemetry(page, objectIdentifier) { async function subscribeToTelemetry(page, objectIdentifier) {
const getTelemValuePromise = new Promise((resolve) => const getTelemValuePromise = new Promise(resolve => page.exposeFunction('getTelemValue', resolve));
page.exposeFunction('getTelemValue', resolve)
);
await page.evaluate(async (telemetryIdentifier) => { await page.evaluate(async (telemetryIdentifier) => {
const telemetryObject = await window.openmct.objects.get(telemetryIdentifier); const telemetryObject = await window.openmct.objects.get(telemetryIdentifier);
const metadata = window.openmct.telemetry.getMetadata(telemetryObject); const metadata = window.openmct.telemetry.getMetadata(telemetryObject);
const formats = await window.openmct.telemetry.getFormatMap(metadata); const formats = await window.openmct.telemetry.getFormatMap(metadata);
window.openmct.telemetry.subscribe(telemetryObject, (obj) => { window.openmct.telemetry.subscribe(telemetryObject, (obj) => {
const sinVal = obj.sin; const sinVal = obj.sin;
const formattedSinVal = formats.sin.format(sinVal); const formattedSinVal = formats.sin.format(sinVal);
window.getTelemValue(formattedSinVal); window.getTelemValue(formattedSinVal);
}); });
}, objectIdentifier); }, objectIdentifier);
return getTelemValuePromise; return getTelemValuePromise;
} }

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -19,467 +19,317 @@
* this source code distribution or the Licensing information page available * this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
/* global __dirname */
/* /*
This test suite is dedicated to tests which verify the basic operations surrounding Notebooks. This test suite is dedicated to tests which verify the basic operations surrounding Notebooks.
*/ */
const { test, expect, streamToString } = require('../../../../pluginFixtures'); // FIXME: Remove this eslint exception once tests are implemented
const { createDomainObjectWithDefaults } = require('../../../../appActions'); // eslint-disable-next-line no-unused-vars
const { test, expect } = require('../../../../pluginFixtures');
const { expandTreePaneItemByName, createDomainObjectWithDefaults } = require('../../../../appActions');
const nbUtils = require('../../../../helper/notebookUtils'); const nbUtils = require('../../../../helper/notebookUtils');
const path = require('path');
const NOTEBOOK_NAME = 'Notebook';
test.describe('Notebook CRUD Operations', () => { test.describe('Notebook CRUD Operations', () => {
test.fixme('Can create a Notebook Object', async ({ page }) => { test.fixme('Can create a Notebook Object', async ({ page }) => {
//Create domain object //Create domain object
//Newly created notebook should have one Section and one page, 'Unnamed Section'/'Unnamed Page' //Newly created notebook should have one Section and one page, 'Unnamed Section'/'Unnamed Page'
}); });
test.fixme('Can update a Notebook Object', async ({ page }) => {}); test.fixme('Can update a Notebook Object', async ({ page }) => {});
test.fixme('Can view a perviously created Notebook Object', async ({ page }) => {}); test.fixme('Can view a perviously created Notebook Object', async ({ page }) => {});
test.fixme('Can Delete a Notebook Object', async ({ page }) => { test.fixme('Can Delete a Notebook Object', async ({ page }) => {
// Other than non-persistible objects // Other than non-persistible objects
}); });
}); });
test.describe('Default Notebook', () => { test.describe('Default Notebook', () => {
// General Default Notebook statements // General Default Notebook statements
// ## Useful commands: // ## Useful commands:
// 1. - To check default notebook: // 1. - To check default notebook:
// `JSON.parse(localStorage.getItem('notebook-storage'));` // `JSON.parse(localStorage.getItem('notebook-storage'));`
// 1. - Clear default notebook: // 1. - Clear default notebook:
// `localStorage.setItem('notebook-storage', null);` // `localStorage.setItem('notebook-storage', null);`
test.fixme( test.fixme('A newly created Notebook is automatically set as the default notebook if no other notebooks exist', async ({ page }) => {
'A newly created Notebook is automatically set as the default notebook if no other notebooks exist', //Create new notebook
async ({ page }) => { //Verify Default Notebook Characteristics
//Create new notebook });
//Verify Default Notebook Characteristics test.fixme('A newly created Notebook is automatically set as the default notebook if at least one other notebook exists', async ({ page }) => {
} //Create new notebook A
); //Create second notebook B
test.fixme( //Verify Non-Default Notebook A Characteristics
'A newly created Notebook is automatically set as the default notebook if at least one other notebook exists', //Verify Default Notebook B Characteristics
async ({ page }) => { });
//Create new notebook A test.fixme('If a default notebook is deleted, the second most recent notebook becomes the default', async ({ page }) => {
//Create second notebook B //Create new notebook A
//Verify Non-Default Notebook A Characteristics //Create second notebook B
//Verify Default Notebook B Characteristics //Delete Notebook B
} //Verify Default Notebook A Characteristics
); });
test.fixme(
'If a default notebook is deleted, the second most recent notebook becomes the default',
async ({ page }) => {
//Create new notebook A
//Create second notebook B
//Delete Notebook B
//Verify Default Notebook A Characteristics
}
);
}); });
test.describe('Notebook section tests', () => { test.describe('Notebook section tests', () => {
//The following test cases are associated with Notebook Sections //The following test cases are associated with Notebook Sections
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
//Navigate to baseURL //Navigate to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
// Create Notebook // Create Notebook
await createDomainObjectWithDefaults(page, { await createDomainObjectWithDefaults(page, {
type: NOTEBOOK_NAME type: 'Notebook',
name: "Test Notebook"
});
}); });
}); test('Default and new sections are automatically named Unnamed Section with Unnamed Page', async ({ page }) => {
test('Default and new sections are automatically named Unnamed Section with Unnamed Page', async ({ // Check that the default section and page are created and the name matches the defaults
page const defaultSectionName = await page.locator('.c-notebook__sections .c-list__item__name').textContent();
}) => { expect(defaultSectionName).toBe('Unnamed Section');
const notebookSectionNames = page.locator('.c-notebook__sections .c-list__item__name'); const defaultPageName = await page.locator('.c-notebook__pages .c-list__item__name').textContent();
const notebookPageNames = page.locator('.c-notebook__pages .c-list__item__name'); expect(defaultPageName).toBe('Unnamed Page');
await expect(notebookSectionNames).toBeHidden();
await expect(notebookPageNames).toBeHidden();
// Expand sidebar
await page.locator('.c-notebook__toggle-nav-button').click();
// Check that the default section and page are created and the name matches the defaults
const defaultSectionName = await notebookSectionNames.innerText();
await expect(notebookSectionNames).toBeVisible();
expect(defaultSectionName).toBe('Unnamed Section');
const defaultPageName = await notebookPageNames.innerText();
await expect(notebookPageNames).toBeVisible();
expect(defaultPageName).toBe('Unnamed Page');
// Add a section // Expand sidebar and add a section
await page.locator('.js-sidebar-sections .c-icon-button.icon-plus').click(); await page.locator('.c-notebook__toggle-nav-button').click();
await page.locator('.js-sidebar-sections .c-icon-button.icon-plus').click();
// Check that new section and page within the new section match the defaults // Check that new section and page within the new section match the defaults
const newSectionName = await notebookSectionNames.nth(1).innerText(); const newSectionName = await page.locator('.c-notebook__sections .c-list__item__name').nth(1).textContent();
await expect(notebookSectionNames.nth(1)).toBeVisible(); expect(newSectionName).toBe('Unnamed Section');
expect(newSectionName).toBe('Unnamed Section'); const newPageName = await page.locator('.c-notebook__pages .c-list__item__name').textContent();
const newPageName = await notebookPageNames.innerText(); expect(newPageName).toBe('Unnamed Page');
await expect(notebookPageNames).toBeVisible(); });
expect(newPageName).toBe('Unnamed Page'); test.fixme('Section selection operations and associated behavior', async ({ page }) => {
}); //Create new notebook A
test.fixme('Section selection operations and associated behavior', async ({ page }) => { //Add Sections until 6 total with no default section/page
//Create new notebook A //Select 3rd section
//Add Sections until 6 total with no default section/page //Delete 4th section
//Select 3rd section //3rd section is still selected
//Delete 4th section //Delete 3rd section
//3rd section is still selected //1st section is selected
//Delete 3rd section //Set 3rd section as default
//1st section is selected //Delete 2nd section
//Set 3rd section as default //3rd section is still default
//Delete 2nd section //Delete 3rd section
//3rd section is still default //1st is selected and there is no default notebook
//Delete 3rd section });
//1st is selected and there is no default notebook test.fixme('Section rename operations', async ({ page }) => {
}); // Create a new notebook
test.fixme('Section rename operations', async ({ page }) => { // Add a section
// Create a new notebook // Rename the section but do not confirm
// Add a section // Keyboard press 'Escape'
// Rename the section but do not confirm // Verify that the section name reverts to the default name
// Keyboard press 'Escape' // Rename the section but do not confirm
// Verify that the section name reverts to the default name // Keyboard press 'Enter'
// Rename the section but do not confirm // Verify that the section name is updated
// Keyboard press 'Enter' // Rename the section to "" (empty string)
// Verify that the section name is updated // Keyboard press 'Enter' to confirm
// Rename the section to "" (empty string) // Verify that the section name reverts to the default name
// Keyboard press 'Enter' to confirm // Rename the section to something long that overflows the text box
// Verify that the section name reverts to the default name // Verify that the section name is not truncated while input is active
// Rename the section to something long that overflows the text box // Confirm the section name edit
// Verify that the section name is not truncated while input is active // Verify that the section name is truncated now that input is not active
// Confirm the section name edit });
// Verify that the section name is truncated now that input is not active
});
}); });
test.describe('Notebook page tests', () => { test.describe('Notebook page tests', () => {
//The following test cases are associated with Notebook Pages //The following test cases are associated with Notebook Pages
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
//Navigate to baseURL //Navigate to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
// Create Notebook // Create Notebook
await createDomainObjectWithDefaults(page, { await createDomainObjectWithDefaults(page, {
type: NOTEBOOK_NAME type: 'Notebook',
name: "Test Notebook"
});
}); });
}); //Test will need to be implemented after a refactor in #5713
//Test will need to be implemented after a refactor in #5713 // eslint-disable-next-line playwright/no-skipped-test
// eslint-disable-next-line playwright/no-skipped-test test.skip('Delete page popup is removed properly on clicking dropdown again', async ({ page }) => {
test.skip('Delete page popup is removed properly on clicking dropdown again', async ({ test.info().annotations.push({
page type: 'issue',
}) => { description: 'https://github.com/nasa/openmct/issues/5713'
test.info().annotations.push({ });
type: 'issue', // Expand sidebar and add a second page
description: 'https://github.com/nasa/openmct/issues/5713' await page.locator('.c-notebook__toggle-nav-button').click();
await page.locator('text=Page Add >> button').click();
// Click on the 2nd page dropdown button and expect the Delete Page option to appear
await page.locator('button[title="Open context menu"]').nth(2).click();
await expect(page.locator('text=Delete Page')).toBeEnabled();
// Clicking on the same page a second time causes the same Delete Page option to recreate
await page.locator('button[title="Open context menu"]').nth(2).click();
await expect(page.locator('text=Delete Page')).toBeEnabled();
// Clicking on the first page causes the first delete button to detach and recreate on the first page
await page.locator('button[title="Open context menu"]').nth(1).click();
const numOfDeletePagePopups = await page.locator('li[title="Delete Page"]').count();
expect(numOfDeletePagePopups).toBe(1);
}); });
// Expand sidebar and add a second page test.fixme('Page selection operations and associated behavior', async ({ page }) => {
await page.locator('.c-notebook__toggle-nav-button').click(); //Create new notebook A
await page.locator('text=Page Add >> button').click(); //Delete existing Page
//New 'Unnamed Page' automatically created
// Click on the 2nd page dropdown button and expect the Delete Page option to appear //Create 6 total Pages without a default page
await page.locator('button[title="Open context menu"]').nth(2).click(); //Select 3rd
await expect(page.locator('text=Delete Page')).toBeEnabled(); //Delete 3rd
// Clicking on the same page a second time causes the same Delete Page option to recreate //First is now selected
await page.locator('button[title="Open context menu"]').nth(2).click(); //Set 3rd as default
await expect(page.locator('text=Delete Page')).toBeEnabled(); //Select 2nd page
// Clicking on the first page causes the first delete button to detach and recreate on the first page //Delete 2nd page
await page.locator('button[title="Open context menu"]').nth(1).click(); //3rd (default) is now selected
const numOfDeletePagePopups = await page.locator('li[title="Delete Page"]').count(); //Set 3rd as default page
expect(numOfDeletePagePopups).toBe(1); //Select 3rd (default) page
}); //Delete 3rd page
test.fixme('Page selection operations and associated behavior', async ({ page }) => { //First is now selected and there is no default notebook
//Create new notebook A });
//Delete existing Page test.fixme('Page rename operations', async ({ page }) => {
//New 'Unnamed Page' automatically created // Create a new notebook
//Create 6 total Pages without a default page // Add a page
//Select 3rd // Rename the page but do not confirm
//Delete 3rd // Keyboard press 'Escape'
//First is now selected // Verify that the page name reverts to the default name
//Set 3rd as default // Rename the page but do not confirm
//Select 2nd page // Keyboard press 'Enter'
//Delete 2nd page // Verify that the page name is updated
//3rd (default) is now selected // Rename the page to "" (empty string)
//Set 3rd as default page // Keyboard press 'Enter' to confirm
//Select 3rd (default) page // Verify that the page name reverts to the default name
//Delete 3rd page // Rename the page to something long that overflows the text box
//First is now selected and there is no default notebook // Verify that the page name is not truncated while input is active
}); // Confirm the page name edit
test.fixme('Page rename operations', async ({ page }) => { // Verify that the page name is truncated now that input is not active
// Create a new notebook
// Add a page
// Rename the page but do not confirm
// Keyboard press 'Escape'
// Verify that the page name reverts to the default name
// Rename the page but do not confirm
// Keyboard press 'Enter'
// Verify that the page name is updated
// Rename the page to "" (empty string)
// Keyboard press 'Enter' to confirm
// Verify that the page name reverts to the default name
// Rename the page to something long that overflows the text box
// Verify that the page name is not truncated while input is active
// Confirm the page name edit
// Verify that the page name is truncated now that input is not active
});
});
test.describe('Notebook export tests', () => {
test.beforeEach(async ({ page }) => {
//Navigate to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' });
// Create Notebook
await createDomainObjectWithDefaults(page, {
type: NOTEBOOK_NAME
}); });
});
test('can export notebook as text', async ({ page }) => {
await nbUtils.enterTextEntry(page, `Foo bar entry`);
// Click on 3 Dot Menu
await page.locator('button[title="More options"]').click();
const downloadPromise = page.waitForEvent('download');
await page.getByRole('menuitem', { name: /Export Notebook as Text/ }).click();
await page.getByRole('button', { name: 'Save' }).click();
const download = await downloadPromise;
const readStream = await download.createReadStream();
const exportedText = await streamToString(readStream);
expect(exportedText).toContain('Foo bar entry');
});
test.fixme('can export multiple notebook entries as text ', async ({ page }) => {});
test.fixme('can export all notebook entry metdata', async ({ page }) => {});
test.fixme('can export all notebook tags', async ({ page }) => {});
test.fixme('can export all notebook snapshots', async ({ page }) => {});
}); });
test.describe('Notebook search tests', () => { test.describe('Notebook search tests', () => {
test.fixme('Can search for a single result', async ({ page }) => {}); test.fixme('Can search for a single result', async ({ page }) => {});
test.fixme('Can search for many results', async ({ page }) => {}); test.fixme('Can search for many results', async ({ page }) => {});
test.fixme('Can search for new and recently modified entries', async ({ page }) => {}); test.fixme('Can search for new and recently modified entries', async ({ page }) => {});
test.fixme('Can search for section text', async ({ page }) => {}); test.fixme('Can search for section text', async ({ page }) => {});
test.fixme('Can search for page text', async ({ page }) => {}); test.fixme('Can search for page text', async ({ page }) => {});
test.fixme('Can search for entry text', async ({ page }) => {}); test.fixme('Can search for entry text', async ({ page }) => {});
}); });
test.describe('Notebook entry tests', () => { test.describe('Notebook entry tests', () => {
// Create Notebook with URL Whitelist test.fixme('When a new entry is created, it should be focused', async ({ page }) => {});
let notebookObject; test('When an object is dropped into a notebook, a new entry is created and it should be focused @unstable', async ({ page }) => {
test.beforeEach(async ({ page }) => { await page.goto('./#/browse/mine', { waitUntil: 'networkidle' });
// eslint-disable-next-line no-undef
await page.addInitScript({ // Create Notebook
path: path.join(__dirname, '../../../../helper/', 'addInitNotebookWithUrls.js') const notebook = await createDomainObjectWithDefaults(page, {
type: 'Notebook',
name: "Embed Test Notebook"
});
// Create Overlay Plot
await createDomainObjectWithDefaults(page, {
type: 'Overlay Plot',
name: "Dropped Overlay Plot"
});
await expandTreePaneItemByName(page, 'My Items');
await page.goto(notebook.url);
await page.dragAndDrop('role=treeitem[name=/Dropped Overlay Plot/]', '.c-notebook__drag-area');
const embed = page.locator('.c-ne__embed__link');
const embedName = await embed.textContent();
await expect(embed).toHaveClass(/icon-plot-overlay/);
expect(embedName).toBe('Dropped Overlay Plot');
}); });
await page.goto('./', { waitUntil: 'domcontentloaded' }); test('When an object is dropped into a notebooks existing entry, it should be focused @unstable', async ({ page }) => {
await page.goto('./#/browse/mine', { waitUntil: 'networkidle' });
notebookObject = await createDomainObjectWithDefaults(page, { // Create Notebook
type: NOTEBOOK_NAME const notebook = await createDomainObjectWithDefaults(page, {
type: 'Notebook',
name: "Embed Test Notebook"
});
// Create Overlay Plot
await createDomainObjectWithDefaults(page, {
type: 'Overlay Plot',
name: "Dropped Overlay Plot"
});
await expandTreePaneItemByName(page, 'My Items');
await page.goto(notebook.url);
await nbUtils.enterTextEntry(page, 'Entry to drop into');
await page.dragAndDrop('role=treeitem[name=/Dropped Overlay Plot/]', 'text=Entry to drop into');
const existingEntry = page.locator('.c-ne__content', { has: page.locator('text="Entry to drop into"') });
const embed = existingEntry.locator('.c-ne__embed__link');
const embedName = await embed.textContent();
await expect(embed).toHaveClass(/icon-plot-overlay/);
expect(embedName).toBe('Dropped Overlay Plot');
});
test.fixme('new entries persist through navigation events without save', async ({ page }) => {});
test.fixme('previous and new entries can be deleted', async ({ page }) => {});
});
test.describe('Snapshot Menu tests', () => {
test.fixme('When no default notebook is selected, Snapshot Menu dropdown should only have a single option', async ({ page }) => {
// There should be no default notebook
// Clear default notebook if exists using `localStorage.setItem('notebook-storage', null);`
// refresh page
// Click on 'Notebook Snaphot Menu'
// 'save to Notebook Snapshots' should be only option there
});
test.fixme('When default notebook is updated selected, Snapshot Menu dropdown should list it as the newest option', async ({ page }) => {
// Create 2a notebooks
// Set Notebook A as Default
// Open Snapshot Menu and note that Notebook A is listed
// Close Snapshot Menu
// Set Default Notebook to Notebook B
// Open Snapshot Notebook and note that Notebook B is listed
// Select Default Notebook Option and verify that Snapshot is added to Notebook B
});
test.fixme('Can add Snapshots via Snapshot Menu and details are correct', async ({ page }) => {
//Note this should be a visual test, too
// Create Telemetry object
// Create A notebook with many pages and sections.
// Set page and section defaults to be between first and last of many. i.e. 3 of 5
// Navigate to Telemetry object
// Select Default Notebook Option and verify that Snapshot is added to Notebook A
// Verify Snapshot Details appear correctly
});
test.fixme('Snapshots adjust time conductor', async ({ page }) => {
// Create Telemetry object
// Set Telemetry object's timeconductor to Fixed time with Start and Endtimes are recorded
// Embed Telemetry object into notebook
// Set Time Conductor to Local clock
// Click into embedded telemetry object and verify object appears with same fixed time from record
});
});
test.describe('Snapshot Container tests', () => {
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', async ({ page }) => {});
test.fixme('A snapshot can be Previewed from Container', async ({ page }) => {});
test.fixme('A snapshot Container can be open and closed', async ({ page }) => {});
test.fixme('Can add object to Snapshot container and pull into notebook and create a new entry', async ({ page }) => {
//Create Notebook
//Create Telemetry Object
//From Telemetry Object, use 'save to Notebook Snapshots'
//Snapshots indicator should blink, click on it to view snapshots
//Navigate to Notebook
//Drag and Drop onto droppable area for new entry
//New Entry created with given snapshot added
//Snapshot removed from container?
});
test.fixme('Can add object to Snapshot container and pull into notebook and existing entry', async ({ page }) => {
//Create Notebook
//Create Telemetry Object
//From Telemetry Object, use 'save to Notebook Snapshots'
//Snapshots indicator should blink, click on it to view snapshots
//Navigate to Notebook
//Drag and Drop into exiting entry
//Existing Entry updated with given snapshot
//Snapshot removed from container?
});
test.fixme('Verify Embedded options for PNG, JPG, and Annotate work correctly', async ({ page }) => {
//Add snapshot to container
//Verify PNG, JPG, and Annotate buttons work correctly
}); });
});
test('When a new entry is created, it should be focused and selected', async ({ page }) => {
// Navigate to the notebook object
await page.goto(notebookObject.url);
// Click .c-notebook__drag-area
await page.locator('.c-notebook__drag-area').click();
await expect(page.locator('[aria-label="Notebook Entry Input"]')).toBeVisible();
await expect(page.locator('[aria-label="Notebook Entry"]')).toHaveClass(/is-selected/);
});
test('When an object is dropped into a notebook, a new entry is created and it should be focused @unstable', async ({
page
}) => {
// Create Overlay Plot
const overlayPlot = await createDomainObjectWithDefaults(page, {
type: 'Overlay Plot'
});
// Navigate to the notebook object
await page.goto(notebookObject.url);
// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await page
.getByRole('treeitem', { name: overlayPlot.name })
.dragTo(page.locator('.c-notebook__drag-area'));
const embed = page.locator('.c-ne__embed__link');
const embedName = await embed.innerText();
await expect(embed).toHaveClass(/icon-plot-overlay/);
expect(embedName).toBe(overlayPlot.name);
});
test('When an object is dropped into a notebooks existing entry, it should be focused @unstable', async ({
page
}) => {
// Create Overlay Plot
const overlayPlot = await createDomainObjectWithDefaults(page, {
type: 'Overlay Plot'
});
// Navigate to the notebook object
await page.goto(notebookObject.url);
// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await nbUtils.enterTextEntry(page, 'Entry to drop into');
await page
.getByRole('treeitem', { name: overlayPlot.name })
.dragTo(page.locator('text=Entry to drop into'));
const existingEntry = page.locator('.c-ne__content', {
has: page.locator('text="Entry to drop into"')
});
const embed = existingEntry.locator('.c-ne__embed__link');
const embedName = await embed.innerText();
await expect(embed).toHaveClass(/icon-plot-overlay/);
expect(embedName).toBe(overlayPlot.name);
});
test.fixme('new entries persist through navigation events without save', async ({ page }) => {});
test('previous and new entries can be deleted', async ({ page }) => {
// Navigate to the notebook object
await page.goto(notebookObject.url);
await nbUtils.enterTextEntry(page, 'First Entry');
await page.hover('text="First Entry"');
await page.click('button[title="Delete this entry"]');
await page.getByRole('button', { name: 'Ok' }).filter({ hasText: 'Ok' }).click();
await expect(page.locator('text="First Entry"')).toBeHidden();
await nbUtils.enterTextEntry(page, 'Another First Entry');
await nbUtils.enterTextEntry(page, 'Second Entry');
await nbUtils.enterTextEntry(page, 'Third Entry');
await page.hover('[aria-label="Notebook Entry"] >> nth=2');
await page.click('button[title="Delete this entry"] >> nth=2');
await page.getByRole('button', { name: 'Ok' }).filter({ hasText: 'Ok' }).click();
await expect(page.locator('text="Third Entry"')).toBeHidden();
await expect(page.locator('text="Another First Entry"')).toBeVisible();
await expect(page.locator('text="Second Entry"')).toBeVisible();
});
test('when a valid link is entered into a notebook entry, it becomes clickable when viewing', async ({
page
}) => {
const TEST_LINK = 'http://www.google.com';
// Navigate to the notebook object
await page.goto(notebookObject.url);
// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await nbUtils.enterTextEntry(page, `This should be a link: ${TEST_LINK} is it?`);
const validLink = page.locator(`a[href="${TEST_LINK}"]`);
// Start waiting for popup before clicking. Note no await.
const popupPromise = page.waitForEvent('popup');
await validLink.click();
const popup = await popupPromise;
// Wait for the popup to load.
await popup.waitForLoadState();
expect.soft(popup.url()).toContain('www.google.com');
expect(await validLink.count()).toBe(1);
});
test('when an invalid link is entered into a notebook entry, it does not become clickable when viewing', async ({
page
}) => {
const TEST_LINK = 'www.google.com';
// Navigate to the notebook object
await page.goto(notebookObject.url);
// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await nbUtils.enterTextEntry(page, `This should NOT be a link: ${TEST_LINK} is it?`);
const invalidLink = page.locator(`a[href="${TEST_LINK}"]`);
expect(await invalidLink.count()).toBe(0);
});
test('when a link is entered, but it is not in the whitelisted urls, it does not become clickable when viewing', async ({
page
}) => {
const TEST_LINK = 'http://www.bing.com';
// Navigate to the notebook object
await page.goto(notebookObject.url);
// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await nbUtils.enterTextEntry(page, `This should NOT be a link: ${TEST_LINK} is it?`);
const invalidLink = page.locator(`a[href="${TEST_LINK}"]`);
expect(await invalidLink.count()).toBe(0);
});
test('when a valid link with a subdomain and a valid domain in the whitelisted urls is entered into a notebook entry, it becomes clickable when viewing', async ({
page
}) => {
const INVALID_TEST_LINK = 'http://bing.google.com';
// Navigate to the notebook object
await page.goto(notebookObject.url);
// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await nbUtils.enterTextEntry(page, `This should be a link: ${INVALID_TEST_LINK} is it?`);
const validLink = page.locator(`a[href="${INVALID_TEST_LINK}"]`);
expect(await validLink.count()).toBe(1);
});
test('when a valid secure link is entered into a notebook entry, it becomes clickable when viewing', async ({
page
}) => {
const TEST_LINK = 'https://www.google.com';
// Navigate to the notebook object
await page.goto(notebookObject.url);
// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await nbUtils.enterTextEntry(page, `This should be a link: ${TEST_LINK} is it?`);
const validLink = page.locator(`a[href="${TEST_LINK}"]`);
// Start waiting for popup before clicking. Note no await.
const popupPromise = page.waitForEvent('popup');
await validLink.click();
const popup = await popupPromise;
// Wait for the popup to load.
await popup.waitForLoadState();
expect.soft(popup.url()).toContain('www.google.com');
expect(await validLink.count()).toBe(1);
});
test('when a nefarious link is entered into a notebook entry, it is sanitized when viewing', async ({
page
}) => {
const TEST_LINK = 'http://www.google.com?bad=';
const TEST_LINK_BAD = `http://www.google.com?bad=<script>alert('gimme your cookies')</script>`;
// Navigate to the notebook object
await page.goto(notebookObject.url);
// Reveal the notebook in the tree
await page.getByTitle('Show selected item in tree').click();
await nbUtils.enterTextEntry(
page,
`This should be a link, BUT not a bad link: ${TEST_LINK_BAD} is it?`
);
const sanitizedLink = page.locator(`a[href="${TEST_LINK}"]`);
const unsanitizedLink = page.locator(`a[href="${TEST_LINK_BAD}"]`);
expect.soft(await sanitizedLink.count()).toBe(1);
expect(await unsanitizedLink.count()).toBe(0);
});
}); });

View File

@@ -1,163 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*
This test suite is dedicated to tests which verify the basic operations surrounding Notebooks.
*/
const { test, expect } = require('../../../../pluginFixtures');
// const { expandTreePaneItemByName, createDomainObjectWithDefaults } = require('../../../../appActions');
// const nbUtils = require('../../../../helper/notebookUtils');
test.describe('Snapshot Menu tests', () => {
test.fixme(
'When no default notebook is selected, Snapshot Menu dropdown should only have a single option',
async ({ page }) => {
// There should be no default notebook
// Clear default notebook if exists using `localStorage.setItem('notebook-storage', null);`
// refresh page
// Click on 'Notebook Snaphot Menu'
// 'save to Notebook Snapshots' should be only option there
}
);
test.fixme(
'When default notebook is updated selected, Snapshot Menu dropdown should list it as the newest option',
async ({ page }) => {
// Create 2a notebooks
// Set Notebook A as Default
// Open Snapshot Menu and note that Notebook A is listed
// Close Snapshot Menu
// Set Default Notebook to Notebook B
// Open Snapshot Notebook and note that Notebook B is listed
// Select Default Notebook Option and verify that Snapshot is added to Notebook B
}
);
test.fixme('Can add Snapshots via Snapshot Menu and details are correct', async ({ page }) => {
//Note this should be a visual test, too
// Create Telemetry object
// Create A notebook with many pages and sections.
// Set page and section defaults to be between first and last of many. i.e. 3 of 5
// Navigate to Telemetry object
// Select Default Notebook Option and verify that Snapshot is added to Notebook A
// Verify Snapshot Details appear correctly
});
test.fixme('Snapshots adjust time conductor', async ({ page }) => {
// Create Telemetry object
// Set Telemetry object's timeconductor to Fixed time with Start and Endtimes are recorded
// Embed Telemetry object into notebook
// Set Time Conductor to Local clock
// Click into embedded telemetry object and verify object appears with same fixed time from record
});
});
test.describe('Snapshot Container tests', () => {
test.beforeEach(async ({ page }) => {
//Navigate to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' });
// Create Notebook
// const notebook = await createDomainObjectWithDefaults(page, {
// type: 'Notebook',
// name: "Test Notebook"
// });
// // Create Overlay Plot
// const snapShotObject = await createDomainObjectWithDefaults(page, {
// type: 'Overlay Plot',
// name: "Dropped Overlay Plot"
// });
await page.getByRole('button', { name: ' Snapshot ' }).click();
await page.getByRole('menuitem', { name: ' Save to Notebook Snapshots' }).click();
await page.getByRole('button', { name: 'Show' }).click();
});
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 }) => {
await page.locator('.c-snapshot.c-ne__embed').first().getByTitle('More options').click();
await page.getByRole('menuitem', { name: ' View Snapshot' }).click();
await expect(page.locator('.c-overlay__outer')).toBeVisible();
await page.getByTitle('Annotate').click();
await expect(page.locator('#snap-annotation-canvas')).toBeVisible();
await page.getByRole('button', { name: '' }).click();
// await expect(page.locator('#snap-annotation-canvas')).not.toBeVisible();
await page.getByRole('button', { name: 'Save' }).click();
await page.getByRole('button', { name: 'Done' }).click();
//await expect(await page.locator)
}
);
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 options').click();
await page.getByRole('menuitem', { name: 'Quick View' }).click();
await expect(page.locator('.c-overlay__outer')).toBeVisible();
});
test.fixme(
'A snapshot can be Navigated To from Container with 3 dot action menu',
async ({ page }) => {}
);
test.fixme(
'A snapshot can be Navigated To Item in Time from Container with 3 dot action menu',
async ({ page }) => {}
);
test.fixme('A snapshot Container can be open and closed', async ({ page }) => {});
test.fixme(
'Can add object to Snapshot container and pull into notebook and create a new entry',
async ({ page }) => {
//Create Notebook
//Create Telemetry Object
//From Telemetry Object, use 'save to Notebook Snapshots'
//Snapshots indicator should blink, click on it to view snapshots
//Navigate to Notebook
//Drag and Drop onto droppable area for new entry
//New Entry created with given snapshot added
//Snapshot removed from container?
}
);
test.fixme(
'Can add object to Snapshot container and pull into notebook and existing entry',
async ({ page }) => {
//Create Notebook
//Create Telemetry Object
//From Telemetry Object, use 'save to Notebook Snapshots'
//Snapshots indicator should blink, click on it to view snapshots
//Navigate to Notebook
//Drag and Drop into exiting entry
//Existing Entry updated with given snapshot
//Snapshot removed from container?
}
);
test.fixme(
'Verify Embedded options for PNG, JPG, and Annotate work correctly',
async ({ page }) => {
//Add snapshot to container
//Verify PNG, JPG, and Annotate buttons work correctly
}
);
});

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -26,221 +26,246 @@ This test suite is dedicated to tests which verify the basic operations surround
const { test, expect } = require('../../../../pluginFixtures'); const { test, expect } = require('../../../../pluginFixtures');
const { createDomainObjectWithDefaults } = require('../../../../appActions'); const { createDomainObjectWithDefaults } = require('../../../../appActions');
const nbUtils = require('../../../../helper/notebookUtils');
test.describe('Notebook Tests with CouchDB @couchdb', () => { test.describe('Notebook Tests with CouchDB @couchdb', () => {
let testNotebook; let testNotebook;
test.beforeEach(async ({ page }) => {
//Navigate to baseURL
await page.goto('./', { waitUntil: 'networkidle' });
test.beforeEach(async ({ page }) => { // Create Notebook
//Navigate to baseURL testNotebook = await createDomainObjectWithDefaults(page, {
await page.goto('./', { waitUntil: 'domcontentloaded' }); type: 'Notebook',
name: "TestNotebook"
// Create Notebook });
testNotebook = await createDomainObjectWithDefaults(page, { type: 'Notebook' });
await page.goto(testNotebook.url, { waitUntil: 'networkidle' });
});
test('Inspect Notebook Entry Network Requests', async ({ page }) => {
//Ensure we're on the annotations Tab in the inspector
await page.getByText('Annotations').click();
// Expand sidebar
await page.locator('.c-notebook__toggle-nav-button').click();
// Collect all request events to count and assert after notebook action
let notebookElementsRequests = [];
page.on('request', (request) => notebookElementsRequests.push(request));
//Clicking Add Page generates
let [notebookUrlRequest] = await Promise.all([
// Waits for the next request with the specified url
page.waitForRequest(`**/openmct/${testNotebook.uuid}`),
// Triggers the request
page.click('[aria-label="Add Page"]')
]);
// Ensures that there are no other network requests
await page.waitForLoadState('networkidle');
// Assert that only two requests are made
// Network Requests are:
// 1) The actual POST to create the page
expect(notebookElementsRequests.length).toBe(1);
// Assert on request object
expect(notebookUrlRequest.postDataJSON().metadata.name).toBe(testNotebook.name);
expect(notebookUrlRequest.postDataJSON().model.persisted).toBeGreaterThanOrEqual(
notebookUrlRequest.postDataJSON().model.modified
);
// Add an entry
// Network Requests are:
// 1) The actual POST to create the entry
// 2) The shared worker event from 👆 POST request
notebookElementsRequests = [];
await nbUtils.enterTextEntry(page, 'First Entry');
await page.waitForLoadState('networkidle');
expect(notebookElementsRequests.length).toBeLessThanOrEqual(2);
// Add some tags
// Network Requests are for each tag creation are:
// 1) Getting the original path of the parent object
// 2) Getting the original path of the grandparent object (recursive call)
// 3) Creating the annotation/tag object
// 4) The shared worker event from 👆 POST request
// 5) Mutate notebook domain object's annotationModified property
// 6) The shared worker event from 👆 POST request
// 7) Notebooks fetching new annotations due to annotationModified changed
// 8) The update of the notebook domain's object's modified property
// 9) The shared worker event from 👆 POST request
// 10) Entry is timestamped
// 11) The shared worker event from 👆 POST request
notebookElementsRequests = [];
await addTagAndAwaitNetwork(page, 'Driving');
expect(filterNonFetchRequests(notebookElementsRequests).length).toBeLessThanOrEqual(11);
notebookElementsRequests = [];
await addTagAndAwaitNetwork(page, 'Drilling');
expect(filterNonFetchRequests(notebookElementsRequests).length).toBeLessThanOrEqual(11);
notebookElementsRequests = [];
await addTagAndAwaitNetwork(page, 'Science');
expect(filterNonFetchRequests(notebookElementsRequests).length).toBeLessThanOrEqual(11);
// Delete all the tags
// Network requests are:
// 1) Send POST to mutate _delete property to true on annotation with tag
// 2) The shared worker event from 👆 POST request
// 3) Timestamp update on entry
// 4) The shared worker event from 👆 POST request
// This happens for 3 tags so 12 requests
notebookElementsRequests = [];
await removeTagAndAwaitNetwork(page, 'Driving');
await removeTagAndAwaitNetwork(page, 'Drilling');
await removeTagAndAwaitNetwork(page, 'Science');
expect(filterNonFetchRequests(notebookElementsRequests).length).toBeLessThanOrEqual(12);
// Add two more pages
await page.click('[aria-label="Add Page"]');
await page.click('[aria-label="Add Page"]');
// Add three entries
await nbUtils.enterTextEntry(page, 'First Entry');
await nbUtils.enterTextEntry(page, 'Second Entry');
await nbUtils.enterTextEntry(page, 'Third Entry');
// Add three tags
await addTagAndAwaitNetwork(page, 'Science');
await addTagAndAwaitNetwork(page, 'Drilling');
await addTagAndAwaitNetwork(page, 'Driving');
// Add a fourth entry
// Network requests are:
// 1) Send POST to add new entry
// 2) The shared worker event from 👆 POST request
// 3) Timestamp update on entry
// 4) The shared worker event from 👆 POST request
notebookElementsRequests = [];
await nbUtils.enterTextEntry(page, 'Fourth Entry');
page.waitForLoadState('networkidle');
expect(filterNonFetchRequests(notebookElementsRequests).length).toBeLessThanOrEqual(4);
// Add a fifth entry
// Network requests are:
// 1) Send POST to add new entry
// 2) The shared worker event from 👆 POST request
// 3) Timestamp update on entry
// 4) The shared worker event from 👆 POST request
notebookElementsRequests = [];
await nbUtils.enterTextEntry(page, 'Fifth Entry');
page.waitForLoadState('networkidle');
expect(filterNonFetchRequests(notebookElementsRequests).length).toBeLessThanOrEqual(4);
// Add a sixth entry
// 1) Send POST to add new entry
// 2) The shared worker event from 👆 POST request
// 3) Timestamp update on entry
// 4) The shared worker event from 👆 POST request
notebookElementsRequests = [];
await nbUtils.enterTextEntry(page, 'Sixth Entry');
page.waitForLoadState('networkidle');
expect(filterNonFetchRequests(notebookElementsRequests).length).toBeLessThanOrEqual(4);
});
test('Search tests', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/akhenry/openmct-yamcs/issues/69'
}); });
await page.getByText('Annotations').click();
await nbUtils.enterTextEntry(page, 'First Entry');
// Add three tags test('Inspect Notebook Entry Network Requests', async ({ page }) => {
await addTagAndAwaitNetwork(page, 'Science'); // Expand sidebar
await addTagAndAwaitNetwork(page, 'Drilling'); await page.locator('.c-notebook__toggle-nav-button').click();
await addTagAndAwaitNetwork(page, 'Driving');
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click(); // Collect all request events to count and assert after notebook action
//Partial match for "Science" should only return Science let addingNotebookElementsRequests = [];
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Sc'); page.on('request', (request) => addingNotebookElementsRequests.push(request));
await expect(page.locator('[aria-label="Search Result"]').first()).toContainText('Science');
await expect(page.locator('[aria-label="Search Result"]').first()).not.toContainText('Driving');
await expect(page.locator('[aria-label="Search Result"]').first()).not.toContainText(
'Drilling'
);
//Searching for a tag which does not exist should return an empty result let [notebookUrlRequest, allDocsRequest] = await Promise.all([
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click(); // Waits for the next request with the specified url
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Xq'); page.waitForRequest(`**/openmct/${testNotebook.uuid}`),
await expect(page.locator('text=No results found')).toBeVisible(); page.waitForRequest('**/openmct/_all_docs?include_docs=true'),
}); // Triggers the request
page.click('[aria-label="Add Page"]'),
// Ensures that there are no other network requests
page.waitForLoadState('networkidle')
]);
// Assert that only two requests are made
// Network Requests are:
// 1) The actual POST to create the page
// 2) The shared worker event from 👆 request
expect(addingNotebookElementsRequests.length).toBe(2);
// Assert on request object
expect(notebookUrlRequest.postDataJSON().metadata.name).toBe('TestNotebook');
expect(notebookUrlRequest.postDataJSON().model.persisted).toBeGreaterThanOrEqual(notebookUrlRequest.postDataJSON().model.modified);
expect(allDocsRequest.postDataJSON().keys).toContain(testNotebook.uuid);
// Add an entry
// Network Requests are:
// 1) The actual POST to create the entry
// 2) The shared worker event from 👆 POST request
addingNotebookElementsRequests = [];
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
await page.locator('[aria-label="Notebook Entry Input"]').click();
await page.locator('[aria-label="Notebook Entry Input"]').fill(`First Entry`);
await page.waitForLoadState('networkidle');
expect(addingNotebookElementsRequests.length).toBeLessThanOrEqual(2);
// Add some tags
// Network Requests are for each tag creation are:
// 1) Getting the original path of the parent object
// 2) Getting the original path of the grandparent object (recursive call)
// 3) Creating the annotation/tag object
// 4) The shared worker event from 👆 POST request
// 5) Mutate notebook domain object's annotationModified property
// 6) The shared worker event from 👆 POST request
// 7) Notebooks fetching new annotations due to annotationModified changed
// 8) The update of the notebook domain's object's modified property
// 9) The shared worker event from 👆 POST request
// 10) Entry is timestamped
// 11) The shared worker event from 👆 POST request
addingNotebookElementsRequests = [];
await page.hover(`button:has-text("Add Tag")`);
await page.locator(`button:has-text("Add Tag")`).click();
await page.locator('[placeholder="Type to select tag"]').click();
await page.locator('[aria-label="Autocomplete Options"] >> text=Driving').click();
await page.waitForSelector('[aria-label="Tag"]:has-text("Driving")');
page.waitForLoadState('networkidle');
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(11);
addingNotebookElementsRequests = [];
await page.hover(`button:has-text("Add Tag")`);
await page.locator(`button:has-text("Add Tag")`).click();
await page.locator('[placeholder="Type to select tag"]').click();
await page.locator('[aria-label="Autocomplete Options"] >> text=Drilling').click();
await page.waitForSelector('[aria-label="Tag"]:has-text("Drilling")');
page.waitForLoadState('networkidle');
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(11);
addingNotebookElementsRequests = [];
await page.hover(`button:has-text("Add Tag")`);
await page.locator(`button:has-text("Add Tag")`).click();
await page.locator('[placeholder="Type to select tag"]').click();
await page.locator('[aria-label="Autocomplete Options"] >> text=Science').click();
await page.waitForSelector('[aria-label="Tag"]:has-text("Science")');
page.waitForLoadState('networkidle');
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(11);
// Delete all the tags
// Network requests are:
// 1) Send POST to mutate _delete property to true on annotation with tag
// 2) The shared worker event from 👆 POST request
// 3) Timestamp update on entry
// 4) The shared worker event from 👆 POST request
// This happens for 3 tags so 12 requests
addingNotebookElementsRequests = [];
await page.hover('[aria-label="Tag"]:has-text("Driving")');
await page.locator('[aria-label="Tag"]:has-text("Driving") ~ .c-completed-tag-deletion').click();
await page.waitForSelector('[aria-label="Tag"]:has-text("Driving")', {state: 'hidden'});
await page.hover('[aria-label="Tag"]:has-text("Drilling")');
await page.locator('[aria-label="Tag"]:has-text("Drilling") ~ .c-completed-tag-deletion').click();
await page.waitForSelector('[aria-label="Tag"]:has-text("Drilling")', {state: 'hidden'});
page.hover('[aria-label="Tag"]:has-text("Science")');
await page.locator('[aria-label="Tag"]:has-text("Science") ~ .c-completed-tag-deletion').click();
await page.waitForSelector('[aria-label="Tag"]:has-text("Science")', {state: 'hidden'});
page.waitForLoadState('networkidle');
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(12);
// Add two more pages
await page.click('[aria-label="Add Page"]');
await page.click('[aria-label="Add Page"]');
// Add three entries
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
await page.locator('[aria-label="Notebook Entry Input"]').click();
await page.locator('[aria-label="Notebook Entry Input"]').fill(`First Entry`);
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
await page.locator('[aria-label="Notebook Entry Input"] >> nth=1').click();
await page.locator('[aria-label="Notebook Entry Input"] >> nth=1').fill(`Second Entry`);
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
await page.locator('[aria-label="Notebook Entry Input"] >> nth=2').click();
await page.locator('[aria-label="Notebook Entry Input"] >> nth=2').fill(`Third Entry`);
// Add three tags
await page.hover(`button:has-text("Add Tag") >> nth=2`);
await page.locator(`button:has-text("Add Tag") >> nth=2`).click();
await page.locator('[placeholder="Type to select tag"]').click();
await page.locator('[aria-label="Autocomplete Options"] >> text=Science').click();
await page.waitForSelector('[aria-label="Tag"]:has-text("Science")');
await page.hover(`button:has-text("Add Tag") >> nth=2`);
await page.locator(`button:has-text("Add Tag") >> nth=2`).click();
await page.locator('[placeholder="Type to select tag"]').click();
await page.locator('[aria-label="Autocomplete Options"] >> text=Drilling').click();
await page.waitForSelector('[aria-label="Tag"]:has-text("Drilling")');
await page.hover(`button:has-text("Add Tag") >> nth=2`);
await page.locator(`button:has-text("Add Tag") >> nth=2`).click();
await page.locator('[placeholder="Type to select tag"]').click();
await page.locator('[aria-label="Autocomplete Options"] >> text=Driving').click();
await page.waitForSelector('[aria-label="Tag"]:has-text("Driving")');
page.waitForLoadState('networkidle');
// Add a fourth entry
// Network requests are:
// 1) Send POST to add new entry
// 2) The shared worker event from 👆 POST request
// 3) Timestamp update on entry
// 4) The shared worker event from 👆 POST request
addingNotebookElementsRequests = [];
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
await page.locator('[aria-label="Notebook Entry Input"] >> nth=3').click();
await page.locator('[aria-label="Notebook Entry Input"] >> nth=3').fill(`Fourth Entry`);
await page.locator('[aria-label="Notebook Entry Input"] >> nth=3').press('Enter');
page.waitForLoadState('networkidle');
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(4);
// Add a fifth entry
// Network requests are:
// 1) Send POST to add new entry
// 2) The shared worker event from 👆 POST request
// 3) Timestamp update on entry
// 4) The shared worker event from 👆 POST request
addingNotebookElementsRequests = [];
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
await page.locator('[aria-label="Notebook Entry Input"] >> nth=4').click();
await page.locator('[aria-label="Notebook Entry Input"] >> nth=4').fill(`Fifth Entry`);
await page.locator('[aria-label="Notebook Entry Input"] >> nth=4').press('Enter');
page.waitForLoadState('networkidle');
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(4);
// Add a sixth entry
// 1) Send POST to add new entry
// 2) The shared worker event from 👆 POST request
// 3) Timestamp update on entry
// 4) The shared worker event from 👆 POST request
addingNotebookElementsRequests = [];
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
await page.locator('[aria-label="Notebook Entry Input"] >> nth=5').click();
await page.locator('[aria-label="Notebook Entry Input"] >> nth=5').fill(`Sixth Entry`);
await page.locator('[aria-label="Notebook Entry Input"] >> nth=5').press('Enter');
page.waitForLoadState('networkidle');
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(4);
});
test('Search tests', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/akhenry/openmct-yamcs/issues/69'
});
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
await page.locator('[aria-label="Notebook Entry Input"]').click();
await page.locator('[aria-label="Notebook Entry Input"]').fill(`First Entry`);
await page.locator('[aria-label="Notebook Entry Input"]').press('Enter');
// Add three tags
await page.hover(`button:has-text("Add Tag")`);
await page.locator(`button:has-text("Add Tag")`).click();
await page.locator('[placeholder="Type to select tag"]').click();
await page.locator('[aria-label="Autocomplete Options"] >> text=Science').click();
await page.waitForSelector('[aria-label="Tag"]:has-text("Science")');
await page.hover(`button:has-text("Add Tag")`);
await page.locator(`button:has-text("Add Tag")`).click();
await page.locator('[placeholder="Type to select tag"]').click();
await page.locator('[aria-label="Autocomplete Options"] >> text=Drilling').click();
await page.waitForSelector('[aria-label="Tag"]:has-text("Drilling")');
await page.hover(`button:has-text("Add Tag")`);
await page.locator(`button:has-text("Add Tag")`).click();
await page.locator('[placeholder="Type to select tag"]').click();
await page.locator('[aria-label="Autocomplete Options"] >> text=Driving').click();
await page.waitForSelector('[aria-label="Tag"]:has-text("Driving")');
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Sc');
await expect(page.locator('[aria-label="Search Result"]').first()).toContainText("Science");
await expect(page.locator('[aria-label="Search Result"]').first()).not.toContainText("Driving");
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Xq');
await expect(page.locator('text=No results found')).toBeVisible();
});
}); });
// Try to reduce indeterminism of browser requests by only returning fetch requests. // Try to reduce indeterminism of browser requests by only returning fetch requests.
// Filter out preflight CORS, fetching stylesheets, page icons, etc. that can occur during tests // Filter out preflight CORS, fetching stylesheets, page icons, etc. that can occur during tests
function filterNonFetchRequests(requests) { function filterNonFetchRequests(requests) {
return requests.filter((request) => { return requests.filter(request => {
return request.resourceType() === 'fetch'; return (request.resourceType() === 'fetch');
}); });
}
/**
* Add a tag to a notebook entry by providing a tagName.
* Reduces indeterminism by waiting until all necessary requests are completed.
* @param {import('@playwright/test').Page} page
* @param {string} tagName
*/
async function addTagAndAwaitNetwork(page, tagName) {
await page.hover(`button:has-text("Add Tag")`);
await page.locator(`button:has-text("Add Tag")`).click();
await page.locator('[placeholder="Type to select tag"]').click();
await Promise.all([
// Waits for the next request with the specified url
page.waitForRequest('**/openmct/_all_docs?include_docs=true'),
// Triggers the request
page.locator(`[aria-label="Autocomplete Options"] >> text=${tagName}`).click(),
expect(page.locator(`[aria-label="Tag"]:has-text("${tagName}")`)).toBeVisible()
]);
await page.waitForLoadState('networkidle');
}
/**
* Remove a tag to a notebook entry by providing a tagName.
* Reduces indeterminism by waiting until all necessary requests are completed.
* @param {import('@playwright/test').Page} page
* @param {string} tagName
*/
async function removeTagAndAwaitNetwork(page, tagName) {
await page.hover(`[aria-label="Tag"]:has-text("${tagName}")`);
await Promise.all([
page.locator(`[aria-label="Remove tag ${tagName}"]`).click(),
//With this pattern, we're awaiting the response but asserting on the request payload.
page.waitForResponse(
(resp) => resp.request().postData().includes(`"_deleted":true`) && resp.status() === 201
)
]);
await expect(page.locator(`[aria-label="Tag"]:has-text("${tagName}")`)).toBeHidden();
await page.waitForLoadState('networkidle');
} }

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -19,12 +19,9 @@
* this source code distribution or the Licensing information page available * this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
/* global __dirname */
const { test, expect, streamToString } = require('../../../../pluginFixtures'); const { test, expect } = require('../../../../pluginFixtures');
const { const { openObjectTreeContextMenu, createDomainObjectWithDefaults } = require('../../../../appActions');
openObjectTreeContextMenu,
createDomainObjectWithDefaults
} = require('../../../../appActions');
const path = require('path'); const path = require('path');
const nbUtils = require('../../../../helper/notebookUtils'); const nbUtils = require('../../../../helper/notebookUtils');
@@ -33,186 +30,163 @@ const TEST_TEXT_NAME = 'Test Page';
const CUSTOM_NAME = 'CUSTOM_NAME'; const CUSTOM_NAME = 'CUSTOM_NAME';
test.describe('Restricted Notebook', () => { test.describe('Restricted Notebook', () => {
let notebook; let notebook;
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
notebook = await startAndAddRestrictedNotebookObject(page); notebook = await startAndAddRestrictedNotebookObject(page);
}); });
test('Can be renamed @addInit', async ({ page }) => { test('Can be renamed @addInit', async ({ page }) => {
await expect(page.locator('.l-browse-bar__object-name')).toContainText(`${notebook.name}`); await expect(page.locator('.l-browse-bar__object-name')).toContainText(`${notebook.name}`);
}); });
test('Can be deleted if there are no locked pages @addInit', async ({ page }) => { test('Can be deleted if there are no locked pages @addInit', async ({ page }) => {
await openObjectTreeContextMenu(page, notebook.url); await openObjectTreeContextMenu(page, notebook.url);
const menuOptions = page.locator('.c-menu ul'); const menuOptions = page.locator('.c-menu ul');
await expect.soft(menuOptions).toContainText('Remove'); await expect.soft(menuOptions).toContainText('Remove');
const restrictedNotebookTreeObject = page.locator(`a:has-text("${notebook.name}")`); const restrictedNotebookTreeObject = page.locator(`a:has-text("${notebook.name}")`);
// notebook tree object exists // notebook tree object exists
expect.soft(await restrictedNotebookTreeObject.count()).toEqual(1); expect.soft(await restrictedNotebookTreeObject.count()).toEqual(1);
// Click Remove Text // Click Remove Text
await page.locator('li[role="menuitem"]:has-text("Remove")').click(); await page.locator('li[role="menuitem"]:has-text("Remove")').click();
// Click 'OK' on confirmation window and wait for save banner to appear // Click 'OK' on confirmation window and wait for save banner to appear
await Promise.all([ await Promise.all([
page.waitForNavigation(), page.waitForNavigation(),
page.locator('button:has-text("OK")').click(), page.locator('button:has-text("OK")').click(),
page.waitForSelector('.c-message-banner__message') page.waitForSelector('.c-message-banner__message')
]); ]);
// has been deleted // has been deleted
expect(await restrictedNotebookTreeObject.count()).toEqual(0); expect(await restrictedNotebookTreeObject.count()).toEqual(0);
}); });
test('Can be locked if at least one page has one entry @addInit', async ({ page }) => { test('Can be locked if at least one page has one entry @addInit', async ({ page }) => {
await nbUtils.enterTextEntry(page, TEST_TEXT);
await nbUtils.enterTextEntry(page, TEST_TEXT);
const commitButton = page.locator('button:has-text("Commit Entries")');
expect(await commitButton.count()).toEqual(1);
});
const commitButton = page.locator('button:has-text("Commit Entries")');
expect(await commitButton.count()).toEqual(1);
});
}); });
test.describe('Restricted Notebook with at least one entry and with the page locked @addInit', () => { test.describe('Restricted Notebook with at least one entry and with the page locked @addInit', () => {
let notebook; let notebook;
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
notebook = await startAndAddRestrictedNotebookObject(page); notebook = await startAndAddRestrictedNotebookObject(page);
await nbUtils.enterTextEntry(page, TEST_TEXT); await nbUtils.enterTextEntry(page, TEST_TEXT);
await lockPage(page); await lockPage(page);
// open sidebar // open sidebar
await page.locator('button.c-notebook__toggle-nav-button').click(); await page.locator('button.c-notebook__toggle-nav-button').click();
}); });
test('Locked page should now be in a locked state @addInit @unstable', async ({ test('Locked page should now be in a locked state @addInit @unstable', async ({ page }, testInfo) => {
page // eslint-disable-next-line playwright/no-skipped-test
}, testInfo) => { test.skip(testInfo.project === 'chrome-beta', "Test is unreliable on chrome-beta");
// eslint-disable-next-line playwright/no-skipped-test // main lock message on page
test.skip(testInfo.project === 'chrome-beta', 'Test is unreliable on chrome-beta'); const lockMessage = page.locator('text=This page has been committed and cannot be modified or removed');
// main lock message on page expect.soft(await lockMessage.count()).toEqual(1);
const lockMessage = page.locator(
'text=This page has been committed and cannot be modified or removed'
);
expect.soft(await lockMessage.count()).toEqual(1);
// lock icon on page in sidebar // lock icon on page in sidebar
const pageLockIcon = page.locator('ul.c-notebook__pages li div.icon-lock'); const pageLockIcon = page.locator('ul.c-notebook__pages li div.icon-lock');
expect.soft(await pageLockIcon.count()).toEqual(1); expect.soft(await pageLockIcon.count()).toEqual(1);
// no way to remove a restricted notebook with a locked page // no way to remove a restricted notebook with a locked page
await openObjectTreeContextMenu(page, notebook.url); await openObjectTreeContextMenu(page, notebook.url);
const menuOptions = page.locator('.c-menu ul'); const menuOptions = page.locator('.c-menu ul');
await expect(menuOptions).not.toContainText('Remove'); await expect(menuOptions).not.toContainText('Remove');
}); });
test('Can still: add page, rename, add entry, delete unlocked pages @addInit', async ({ test('Can still: add page, rename, add entry, delete unlocked pages @addInit', async ({ page }) => {
page // Click text=Page Add >> button
}) => { await Promise.all([
// Add a new page to the section page.waitForNavigation(),
await page.getByRole('button', { name: 'Add Page' }).click(); page.locator('text=Page Add >> button').click()
// Focus the new page by clicking it ]);
await page.getByText('Unnamed Page').nth(1).click(); // Click text=Unnamed Page >> nth=1
// Rename the new page await page.locator('text=Unnamed Page').nth(1).click();
await page.getByText('Unnamed Page').nth(1).fill(TEST_TEXT_NAME); // Press a with modifiers
await page.locator('text=Unnamed Page').nth(1).fill(TEST_TEXT_NAME);
// expect to be able to rename unlocked pages // expect to be able to rename unlocked pages
const newPageElement = page.getByText(TEST_TEXT_NAME); const newPageElement = page.locator(`text=${TEST_TEXT_NAME}`);
const newPageCount = await newPageElement.count(); const newPageCount = await newPageElement.count();
await newPageElement.press('Enter'); // exit contenteditable state await newPageElement.press('Enter'); // exit contenteditable state
expect.soft(newPageCount).toEqual(1); expect.soft(newPageCount).toEqual(1);
// enter test text // enter test text
await nbUtils.enterTextEntry(page, TEST_TEXT); await nbUtils.enterTextEntry(page, TEST_TEXT);
// expect new page to be lockable // expect new page to be lockable
const commitButton = page.getByRole('button', { name: ' Commit Entries' }); const commitButton = page.locator('BUTTON:HAS-TEXT("COMMIT ENTRIES")');
expect.soft(await commitButton.count()).toEqual(1); expect.soft(await commitButton.count()).toEqual(1);
// Click the context menu button for the new page // Click text=Unnamed PageTest Page >> button
await page.getByTitle('Open context menu').click(); await page.locator('text=Unnamed PageTest Page >> button').click();
// Delete the page // Click text=Delete Page
await page.getByRole('menuitem', { name: 'Delete Page' }).click(); await page.locator('text=Delete Page').click();
// Click OK button // Click text=Ok
await page.getByRole('button', { name: 'Ok' }).click(); await Promise.all([
page.waitForNavigation(),
page.locator('button:has-text("OK")').click()
]);
// deleted page, should no longer exist // deleted page, should no longer exist
const deletedPageElement = page.getByText(TEST_TEXT_NAME); const deletedPageElement = page.locator(`text=${TEST_TEXT_NAME}`);
expect(await deletedPageElement.count()).toEqual(0); expect(await deletedPageElement.count()).toEqual(0);
}); });
}); });
test.describe('Restricted Notebook with a page locked and with an embed @addInit', () => { test.describe('Restricted Notebook with a page locked and with an embed @addInit', () => {
test.beforeEach(async ({ page }) => {
const notebook = await startAndAddRestrictedNotebookObject(page);
await nbUtils.dragAndDropEmbed(page, notebook);
});
test('Allows embeds to be deleted if page unlocked @addInit', async ({ page }) => { test.beforeEach(async ({ page }) => {
// Click .c-ne__embed__name .c-popup-menu-button const notebook = await startAndAddRestrictedNotebookObject(page);
await page.locator('.c-ne__embed__name .c-icon-button').click(); // embed popup menu await nbUtils.dragAndDropEmbed(page, notebook);
});
const embedMenu = page.locator('body >> .c-menu'); test('Allows embeds to be deleted if page unlocked @addInit', async ({ page }) => {
await expect(embedMenu).toContainText('Remove This Embed'); // Click .c-ne__embed__name .c-popup-menu-button
}); await page.locator('.c-ne__embed__name .c-popup-menu-button').click(); // embed popup menu
test('Disallows embeds to be deleted if page locked @addInit', async ({ page }) => { const embedMenu = page.locator('body >> .c-menu');
await lockPage(page); await expect(embedMenu).toContainText('Remove This Embed');
// Click .c-ne__embed__name .c-popup-menu-button });
await page.locator('.c-ne__embed__name .c-icon-button').click(); // embed popup menu
const embedMenu = page.locator('body >> .c-menu'); test('Disallows embeds to be deleted if page locked @addInit', async ({ page }) => {
await expect(embedMenu).not.toContainText('Remove This Embed'); await lockPage(page);
}); // Click .c-ne__embed__name .c-popup-menu-button
}); await page.locator('.c-ne__embed__name .c-popup-menu-button').click(); // embed popup menu
test.describe('can export restricted notebook as text', () => { const embedMenu = page.locator('body >> .c-menu');
test.beforeEach(async ({ page }) => { await expect(embedMenu).not.toContainText('Remove This Embed');
await startAndAddRestrictedNotebookObject(page); });
});
test('basic functionality ', async ({ page }) => {
await nbUtils.enterTextEntry(page, `Foo bar entry`);
// Click on 3 Dot Menu
await page.locator('button[title="More options"]').click();
const downloadPromise = page.waitForEvent('download');
await page.getByRole('menuitem', { name: /Export Notebook as Text/ }).click();
await page.getByRole('button', { name: 'Save' }).click();
const download = await downloadPromise;
const readStream = await download.createReadStream();
const exportedText = await streamToString(readStream);
expect(exportedText).toContain('Foo bar entry');
});
test.fixme('can export multiple notebook entries as text ', async ({ page }) => {});
test.fixme('can export all notebook entry metdata', async ({ page }) => {});
test.fixme('can export all notebook tags', async ({ page }) => {});
test.fixme('can export all notebook snapshots', async ({ page }) => {});
}); });
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function startAndAddRestrictedNotebookObject(page) { async function startAndAddRestrictedNotebookObject(page) {
await page.addInitScript({ // eslint-disable-next-line no-undef
path: path.join(__dirname, '../../../../helper/', 'addInitRestrictedNotebook.js') await page.addInitScript({ path: path.join(__dirname, '../../../../helper/', 'addInitRestrictedNotebook.js') });
}); await page.goto('./', { waitUntil: 'networkidle' });
await page.goto('./', { waitUntil: 'domcontentloaded' });
return createDomainObjectWithDefaults(page, { type: CUSTOM_NAME }); return createDomainObjectWithDefaults(page, { type: CUSTOM_NAME });
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function lockPage(page) { async function lockPage(page) {
const commitButton = page.locator('button:has-text("Commit Entries")'); const commitButton = page.locator('button:has-text("Commit Entries")');
await commitButton.click(); await commitButton.click();
//Wait until Lock Banner is visible //Wait until Lock Banner is visible
await page.locator('text=Lock Page').click(); await page.locator('text=Lock Page').click();
} }

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -21,255 +21,204 @@
*****************************************************************************/ *****************************************************************************/
/* /*
This test suite is dedicated to tests which verify notebook tag functionality. This test suite is dedicated to tests which verify form functionality.
*/ */
const { test, expect } = require('../../../../pluginFixtures'); const { test, expect } = require('../../../../pluginFixtures');
const { createDomainObjectWithDefaults, selectInspectorTab } = require('../../../../appActions'); const { createDomainObjectWithDefaults } = require('../../../../appActions');
const nbUtils = require('../../../../helper/notebookUtils');
/** /**
* Creates a notebook object and adds an entry. * Creates a notebook object and adds an entry.
* @param {import('@playwright/test').Page} - page to load * @param {import('@playwright/test').Page} - page to load
* @param {number} [iterations = 1] - the number of entries to create * @param {number} [iterations = 1] - the number of entries to create
*/ */
async function createNotebookAndEntry(page, iterations = 1) { async function createNotebookAndEntry(page, iterations = 1) {
const notebook = createDomainObjectWithDefaults(page, { type: 'Notebook' }); //Go to baseURL
await page.goto('./', { waitUntil: 'networkidle' });
for (let iteration = 0; iteration < iterations; iteration++) { const notebook = createDomainObjectWithDefaults(page, { type: 'Notebook' });
await nbUtils.enterTextEntry(page, `Entry ${iteration}`);
}
return notebook; for (let iteration = 0; iteration < iterations; iteration++) {
// Create an entry
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
const entryLocator = `[aria-label="Notebook Entry Input"] >> nth = ${iteration}`;
await page.locator(entryLocator).click();
await page.locator(entryLocator).fill(`Entry ${iteration}`);
await page.locator(entryLocator).press('Enter');
}
return notebook;
} }
/** /**
* Creates a notebook object, adds an entry, and adds a tag. * Creates a notebook object, adds an entry, and adds a tag.
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
* @param {number} [iterations = 1] - the number of entries (and tags) to create * @param {number} [iterations = 1] - the number of entries (and tags) to create
*/ */
async function createNotebookEntryAndTags(page, iterations = 1) { async function createNotebookEntryAndTags(page, iterations = 1) {
const notebook = await createNotebookAndEntry(page, iterations); const notebook = await createNotebookAndEntry(page, iterations);
await selectInspectorTab(page, 'Annotations');
for (let iteration = 0; iteration < iterations; iteration++) { for (let iteration = 0; iteration < iterations; iteration++) {
// Hover and click "Add Tag" button // Hover and click "Add Tag" button
// Hover is needed here to "slow down" the actions while running in headless mode // Hover is needed here to "slow down" the actions while running in headless mode
await page.locator(`[aria-label="Notebook Entry"] >> nth = ${iteration}`).click(); await page.hover(`button:has-text("Add Tag") >> nth = ${iteration}`);
await page.hover(`button:has-text("Add Tag")`); await page.locator(`button:has-text("Add Tag") >> nth = ${iteration}`).click();
await page.locator(`button:has-text("Add Tag")`).click();
// Click inside the tag search input // Click inside the tag search input
await page.locator('[placeholder="Type to select tag"]').click(); await page.locator('[placeholder="Type to select tag"]').click();
// Select the "Driving" tag // Select the "Driving" tag
await page.locator('[aria-label="Autocomplete Options"] >> text=Driving').click(); await page.locator('[aria-label="Autocomplete Options"] >> text=Driving').click();
// Hover and click "Add Tag" button // Hover and click "Add Tag" button
// Hover is needed here to "slow down" the actions while running in headless mode // Hover is needed here to "slow down" the actions while running in headless mode
await page.hover(`button:has-text("Add Tag")`); await page.hover(`button:has-text("Add Tag") >> nth = ${iteration}`);
await page.locator(`button:has-text("Add Tag")`).click(); await page.locator(`button:has-text("Add Tag") >> nth = ${iteration}`).click();
// Click inside the tag search input // Click inside the tag search input
await page.locator('[placeholder="Type to select tag"]').click(); await page.locator('[placeholder="Type to select tag"]').click();
// Select the "Science" tag // Select the "Science" tag
await page.locator('[aria-label="Autocomplete Options"] >> text=Science').click(); await page.locator('[aria-label="Autocomplete Options"] >> text=Science').click();
} }
return notebook; return notebook;
} }
test.describe('Tagging in Notebooks @addInit', () => { test.describe('Tagging in Notebooks @addInit', () => {
test.beforeEach(async ({ page }) => { test('Can load tags', async ({ page }) => {
//Go to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' });
});
test('Can load tags', async ({ page }) => {
await createNotebookAndEntry(page);
await selectInspectorTab(page, 'Annotations'); await createNotebookAndEntry(page);
await page.locator('button:has-text("Add Tag")').click();
await page.locator('button:has-text("Add Tag")').click(); await page.locator('[placeholder="Type to select tag"]').click();
await page.locator('[placeholder="Type to select tag"]').click(); await expect(page.locator('[aria-label="Autocomplete Options"]')).toContainText("Science");
await expect(page.locator('[aria-label="Autocomplete Options"]')).toContainText("Drilling");
await expect(page.locator('[aria-label="Autocomplete Options"]')).toContainText("Driving");
});
test('Can add tags', async ({ page }) => {
await createNotebookEntryAndTags(page);
await expect(page.locator('[aria-label="Autocomplete Options"]')).toContainText('Science'); await expect(page.locator('[aria-label="Notebook Entry"]')).toContainText("Science");
await expect(page.locator('[aria-label="Autocomplete Options"]')).toContainText('Drilling'); await expect(page.locator('[aria-label="Notebook Entry"]')).toContainText("Driving");
await expect(page.locator('[aria-label="Autocomplete Options"]')).toContainText('Driving');
});
test('Can add tags', async ({ page }) => {
await createNotebookEntryAndTags(page);
await expect(page.locator('[aria-label="Notebook Entry"]')).toContainText('Science'); await page.locator('button:has-text("Add Tag")').click();
await expect(page.locator('[aria-label="Notebook Entry"]')).toContainText('Driving'); await page.locator('[placeholder="Type to select tag"]').click();
await page.locator('button:has-text("Add Tag")').click(); await expect(page.locator('[aria-label="Autocomplete Options"]')).not.toContainText("Science");
await page.locator('[placeholder="Type to select tag"]').click(); await expect(page.locator('[aria-label="Autocomplete Options"]')).not.toContainText("Driving");
await expect(page.locator('[aria-label="Autocomplete Options"]')).toContainText("Drilling");
});
test('Can search for tags', async ({ page }) => {
await createNotebookEntryAndTags(page);
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
await expect(page.locator('[aria-label="Search Result"]')).toContainText("Science");
await expect(page.locator('[aria-label="Search Result"]')).not.toContainText("Driving");
await expect(page.locator('[aria-label="Autocomplete Options"]')).not.toContainText('Science'); await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
await expect(page.locator('[aria-label="Autocomplete Options"]')).not.toContainText('Driving'); await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Sc');
await expect(page.locator('[aria-label="Autocomplete Options"]')).toContainText('Drilling'); await expect(page.locator('[aria-label="Search Result"]')).toContainText("Science");
}); await expect(page.locator('[aria-label="Search Result"]')).not.toContainText("Driving");
test('Can add tags with blank entry', async ({ page }) => {
await createDomainObjectWithDefaults(page, { type: 'Notebook' });
await selectInspectorTab(page, 'Annotations');
await nbUtils.enterTextEntry(page, ''); await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
await page.hover(`button:has-text("Add Tag")`); await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Xq');
await page.locator(`button:has-text("Add Tag")`).click(); await expect(page.locator('text=No results found')).toBeVisible();
// Click inside the tag search input
await page.locator('[placeholder="Type to select tag"]').click();
// Select the "Driving" tag
await page.locator('[aria-label="Autocomplete Options"] >> text=Driving').click();
await expect(page.locator('[aria-label="Notebook Entry"]')).toContainText('Driving');
});
test('Can cancel adding tags', async ({ page }) => {
await createNotebookAndEntry(page);
await selectInspectorTab(page, 'Annotations');
// Test canceling adding a tag after we click "Type to select tag"
await page.locator('button:has-text("Add Tag")').click();
await page.locator('[placeholder="Type to select tag"]').click();
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
await expect(page.locator('button:has-text("Add Tag")')).toBeVisible();
// Test canceling adding a tag after we just click "Add Tag"
await page.locator('button:has-text("Add Tag")').click();
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
await expect(page.locator('button:has-text("Add Tag")')).toBeVisible();
});
test('Can search for tags and preview works properly', async ({ page }) => {
await createNotebookEntryAndTags(page);
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
await expect(page.locator('[aria-label="Search Result"]')).toContainText('Science');
await expect(page.locator('[aria-label="Search Result"]')).not.toContainText('Driving');
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Sc');
await expect(page.locator('[aria-label="Search Result"]')).toContainText('Science');
await expect(page.locator('[aria-label="Search Result"]')).not.toContainText('Driving');
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Xq');
await expect(page.locator('text=No results found')).toBeVisible();
await createDomainObjectWithDefaults(page, {
type: 'Display Layout'
}); });
// Go back into edit mode for the display layout test('Can delete tags', async ({ page }) => {
await page.locator('button[title="Edit"]').click(); await createNotebookEntryAndTags(page);
await page.locator('[aria-label="Notebook Entries"]').click();
// Delete Driving
await page.hover('[aria-label="Tag"]:has-text("Driving")');
await page.locator('[aria-label="Tag"]:has-text("Driving") ~ .c-completed-tag-deletion').click();
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click(); await expect(page.locator('[aria-label="Notebook Entry"]')).toContainText("Science");
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Sc'); await expect(page.locator('[aria-label="Notebook Entry"]')).not.toContainText("Driving");
await expect(page.locator('[aria-label="Search Result"]')).toContainText('Science');
await page.getByText('Entry 0').click();
await expect(page.locator('.js-preview-window')).toBeVisible();
});
test('Can delete tags', async ({ page }) => { await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
await createNotebookEntryAndTags(page); await expect(page.locator('[aria-label="Search Result"]')).not.toContainText("Driving");
// Delete Driving
await page.hover('[aria-label="Tag"]:has-text("Driving")');
await page.locator('[aria-label="Remove tag Driving"]').click();
await expect(page.locator('[aria-label="Tags Inspector"]')).toContainText('Science');
await expect(page.locator('[aria-label="Tags Inspector"]')).not.toContainText('Driving');
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
await expect(page.locator('[aria-label="Search Result"]')).not.toContainText('Driving');
});
test('Can delete entries without tags', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/5823'
}); });
await createNotebookEntryAndTags(page); test('Can delete entries without tags', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/5823'
});
await page.locator('text=To start a new entry, click here or drag and drop any object').click(); await createNotebookEntryAndTags(page);
const entryLocator = `[aria-label="Notebook Entry Input"] >> nth = 1`;
await page.locator(entryLocator).click();
await page.locator(entryLocator).fill(`An entry without tags`);
await page.locator('[aria-label="Notebook Entry Input"] >> nth=1').press('Enter');
await page.hover('[aria-label="Notebook Entry Input"] >> nth=1'); await page.locator('text=To start a new entry, click here or drag and drop any object').click();
await page.locator('button[title="Delete this entry"]').last().click(); const entryLocator = `[aria-label="Notebook Entry Input"] >> nth = 1`;
await expect( await page.locator(entryLocator).click();
page.locator('text=This action will permanently delete this entry. Do you wish to continue?') await page.locator(entryLocator).fill(`An entry without tags`);
).toBeVisible(); await page.locator('[aria-label="Notebook Entry Input"] >> nth=1').press('Enter');
await page.locator('button:has-text("Ok")').click();
await expect(
page.locator('text=This action will permanently delete this entry. Do you wish to continue?')
).toBeHidden();
});
test('Can delete objects with tags and neither return in search', async ({ page }) => { await page.hover('[aria-label="Notebook Entry Input"] >> nth=1');
await createNotebookEntryAndTags(page); await page.locator('button[title="Delete this entry"]').last().click();
// Delete Notebook await expect(page.locator('text=This action will permanently delete this entry. Do you wish to continue?')).toBeVisible();
await page.locator('button[title="More options"]').click(); await page.locator('button:has-text("Ok")').click();
await page.locator('li[title="Remove this object from its containing object."]').click(); await expect(page.locator('text=This action will permanently delete this entry. Do you wish to continue?')).toBeHidden();
await page.locator('button:has-text("OK")').click(); });
await page.goto('./', { waitUntil: 'domcontentloaded' });
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Unnamed'); test('Can delete objects with tags and neither return in search', async ({ page }) => {
await expect(page.locator('text=No results found')).toBeVisible(); await createNotebookEntryAndTags(page);
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sci'); // Delete Notebook
await expect(page.locator('text=No results found')).toBeVisible(); await page.locator('button[title="More options"]').click();
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('dri'); await page.locator('li[title="Remove this object from its containing object."]').click();
await expect(page.locator('text=No results found')).toBeVisible(); await page.locator('button:has-text("OK")').click();
}); await page.goto('./', { waitUntil: 'networkidle' });
test('Tags persist across reload', async ({ page }) => {
//Go to baseURL
await page.goto('./', { waitUntil: 'domcontentloaded' });
const ITERATIONS = 4; await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Unnamed');
const notebook = await createNotebookEntryAndTags(page, ITERATIONS); await expect(page.locator('text=No results found')).toBeVisible();
await page.goto(notebook.url); await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sci');
await expect(page.locator('text=No results found')).toBeVisible();
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('dri');
await expect(page.locator('text=No results found')).toBeVisible();
});
test('Tags persist across reload', async ({ page }) => {
//Go to baseURL
await page.goto('./', { waitUntil: 'networkidle' });
// Verify tags are present const clock = await createDomainObjectWithDefaults(page, { type: 'Clock' });
for (let iteration = 0; iteration < ITERATIONS; iteration++) {
const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`;
await expect(page.locator(entryLocator)).toContainText('Science');
await expect(page.locator(entryLocator)).toContainText('Driving');
}
//Reload Page const ITERATIONS = 4;
await page.reload({ waitUntil: 'domcontentloaded' }); const notebook = await createNotebookEntryAndTags(page, ITERATIONS);
// Verify tags persist across reload for (let iteration = 0; iteration < ITERATIONS; iteration++) {
for (let iteration = 0; iteration < ITERATIONS; iteration++) { const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`;
const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`; await expect(page.locator(entryLocator)).toContainText("Science");
await expect(page.locator(entryLocator)).toContainText('Science'); await expect(page.locator(entryLocator)).toContainText("Driving");
await expect(page.locator(entryLocator)).toContainText('Driving'); }
}
});
test('Can cancel adding a tag', async ({ page }) => {
await createNotebookAndEntry(page);
await selectInspectorTab(page, 'Annotations'); await Promise.all([
page.waitForNavigation(),
page.goto('./#/browse/mine?hideTree=false'),
page.click('.c-disclosure-triangle')
]);
// Click Clock
await page.click(`text=${clock.name}`);
// Click on the "Add Tag" button // Click Notebook
await page.locator('button:has-text("Add Tag")').click(); await page.click(`text=${notebook.name}`);
// Click inside the AutoComplete field for (let iteration = 0; iteration < ITERATIONS; iteration++) {
await page.locator('[placeholder="Type to select tag"]').click(); const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`;
await expect(page.locator(entryLocator)).toContainText("Science");
await expect(page.locator(entryLocator)).toContainText("Driving");
}
// Click on the "Tags" header (simulating a click outside the autocomplete) //Reload Page
await page.locator('div.c-inspect-properties__header:has-text("Tags")').click(); await Promise.all([
page.reload(),
page.waitForLoadState('networkidle')
]);
// Verify there is a button with text "Add Tag" // Click Notebook
await expect(page.locator('button:has-text("Add Tag")')).toBeVisible(); await page.click(`text="${notebook.name}"`);
// Verify the AutoComplete field is hidden for (let iteration = 0; iteration < ITERATIONS; iteration++) {
await expect(page.locator('[placeholder="Type to select tag"]')).toBeHidden(); const entryLocator = `[aria-label="Notebook Entry"] >> nth = ${iteration}`;
}); await expect(page.locator(entryLocator)).toContainText("Science");
await expect(page.locator(entryLocator)).toContainText("Driving");
}
});
}); });

View File

@@ -1,162 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/* global __dirname */
/*
* This test suite is dedicated to testing the operator status plugin.
*/
const path = require('path');
const { test, expect } = require('../../../../pluginFixtures');
/*
Precondition: Inject Example User, Operator Status Plugins
Verify that user 1 sees updates from user/role 2 (Not possible without openmct-yamcs implementation)
Clear Role Status of single user test
STUB (test.fixme) Rolling through each
*/
test.describe('Operator Status', () => {
test.beforeEach(async ({ page }) => {
// FIXME: determine if plugins will be added to index.html or need to be injected
await page.addInitScript({
path: path.join(__dirname, '../../../../helper/', 'addInitExampleUser.js')
});
await page.addInitScript({
path: path.join(__dirname, '../../../../helper/', 'addInitOperatorStatus.js')
});
await page.goto('./', { waitUntil: 'domcontentloaded' });
await expect(page.getByText('Select Role')).toBeVisible();
// set role
await page.getByRole('button', { name: 'Select' }).click();
// dismiss role confirmation popup
await page.getByRole('button', { name: 'Dismiss' }).click();
});
// verify that operator status is visible
test('operator status is visible and expands when clicked', async ({ page }) => {
await expect(page.locator('div[title="Set my operator status"]')).toBeVisible();
await page.locator('div[title="Set my operator status"]').click();
// expect default status to be 'GO'
await expect(page.locator('.c-status-poll-panel')).toBeVisible();
});
test('poll question indicator remains when blank poll set', async ({ page }) => {
await expect(page.locator('div[title="Set the current poll question"]')).toBeVisible();
await page.locator('div[title="Set the current poll question"]').click();
// set to blank
await page.getByRole('button', { name: 'Update' }).click();
// should still be visible
await expect(page.locator('div[title="Set the current poll question"]')).toBeVisible();
});
// Verify that user 1 sees updates from user/role 2 (Not possible without openmct-yamcs implementation)
test('operator status table reflects answered values', async ({ page }) => {
// user navigates to operator status poll
const statusPollIndicator = page.locator('div[title="Set my operator status"]');
await statusPollIndicator.click();
// get user role value
const userRole = page.locator('.c-status-poll-panel__user-role');
const userRoleText = await userRole.innerText();
// get selected status value
const selectStatus = page.locator('select[name="setStatus"]');
await selectStatus.selectOption({ index: 1 });
const initialStatusValue = await selectStatus.inputValue();
// open manage status poll
const manageStatusPollIndicator = page.locator('div[title="Set the current poll question"]');
await manageStatusPollIndicator.click();
// parse the table row values
const row = page.locator(`tr:has-text("${userRoleText}")`);
const rowValues = await row.innerText();
const rowValuesArr = rowValues.split('\t');
const COLUMN_STATUS_INDEX = 1;
// check initial set value matches status table
expect(rowValuesArr[COLUMN_STATUS_INDEX].toLowerCase()).toEqual(
initialStatusValue.toLowerCase()
);
// change user status
await statusPollIndicator.click();
// FIXME: might want to grab a dynamic option instead of arbitrary
await page.locator('select[name="setStatus"]').selectOption({ index: 2 });
const updatedStatusValue = await selectStatus.inputValue();
// verify user status is reflected in table
await manageStatusPollIndicator.click();
const updatedRow = page.locator(`tr:has-text("${userRoleText}")`);
const updatedRowValues = await updatedRow.innerText();
const updatedRowValuesArr = updatedRowValues.split('\t');
expect(updatedRowValuesArr[COLUMN_STATUS_INDEX].toLowerCase()).toEqual(
updatedStatusValue.toLowerCase()
);
});
test('clear poll button removes poll responses', async ({ page }) => {
// user navigates to operator status poll
const statusPollIndicator = page.locator('div[title="Set my operator status"]');
await statusPollIndicator.click();
// get user role value
const userRole = page.locator('.c-status-poll-panel__user-role');
const userRoleText = await userRole.innerText();
// get selected status value
const selectStatus = page.locator('select[name="setStatus"]');
// FIXME: might want to grab a dynamic option instead of arbitrary
await selectStatus.selectOption({ index: 1 });
const initialStatusValue = await selectStatus.inputValue();
// open manage status poll
const manageStatusPollIndicator = page.locator('div[title="Set the current poll question"]');
await manageStatusPollIndicator.click();
// parse the table row values
const row = page.locator(`tr:has-text("${userRoleText}")`);
const rowValues = await row.innerText();
const rowValuesArr = rowValues.split('\t');
const COLUMN_STATUS_INDEX = 1;
// check initial set value matches status table
expect(rowValuesArr[COLUMN_STATUS_INDEX].toLowerCase()).toEqual(
initialStatusValue.toLowerCase()
);
// clear the poll
await page.locator('button[title="Clear the previous poll question"]').click();
const updatedRow = page.locator(`tr:has-text("${userRoleText}")`);
const updatedRowValues = await updatedRow.innerText();
const updatedRowValuesArr = updatedRowValues.split('\t');
const UNSET_VALUE_LABEL = 'Not set';
expect(updatedRowValuesArr[COLUMN_STATUS_INDEX]).toEqual(UNSET_VALUE_LABEL);
});
test.fixme('iterate through all possible response values', async ({ page }) => {
// test all possible respone values for the poll
});
});

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -24,98 +24,64 @@
Testsuite for plot autoscale. Testsuite for plot autoscale.
*/ */
const { selectInspectorTab, setTimeConductorBounds } = require('../../../../appActions');
const { test, expect } = require('../../../../pluginFixtures'); const { test, expect } = require('../../../../pluginFixtures');
test.use({ test.use({
viewport: { viewport: {
width: 1280, width: 1280,
height: 720 height: 720
} }
}); });
test.describe('Autoscale', () => { test.describe('ExportAsJSON', () => {
test('User can set autoscale with a valid range @snapshot', async ({ page, openmctConfig }) => { test('User can set autoscale with a valid range @snapshot', async ({ page, openmctConfig }) => {
const { myItemsFolderName } = openmctConfig; const { myItemsFolderName } = openmctConfig;
//This is necessary due to the size of the test suite. //This is necessary due to the size of the test suite.
test.slow(); test.slow();
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
await setTimeRange(page); await setTimeRange(page);
await createSinewaveOverlayPlot(page, myItemsFolderName); await createSinewaveOverlayPlot(page, myItemsFolderName);
await testYTicks(page, ['-1.00', '-0.50', '0.00', '0.50', '1.00']); await testYTicks(page, ['-1.00', '-0.50', '0.00', '0.50', '1.00']);
// enter edit mode await turnOffAutoscale(page);
await page.click('button[title="Edit"]');
await selectInspectorTab(page, 'Config'); // Make sure that after turning off autoscale, the user selected range values start at the same values the plot had prior.
await turnOffAutoscale(page); await testYTicks(page, ['-1.00', '-0.50', '0.00', '0.50', '1.00']);
await setUserDefinedMinAndMax(page, '-2', '2'); const canvas = page.locator('canvas').nth(1);
// save await canvas.hover({trial: true});
await page.click('button[title="Save"]');
await Promise.all([
page.locator('li[title = "Save and Finish Editing"]').click(),
//Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message')
]);
//Wait until Save Banner is gone
await page.locator('.c-message-banner__close-button').click();
await page.waitForSelector('.c-message-banner__message', { state: 'detached' });
// Make sure that after turning off autoscale, the user entered range values are reflexted in the ticks. expect(await canvas.screenshot()).toMatchSnapshot('autoscale-canvas-prepan.png', { animations: 'disabled' });
await testYTicks(page, [
'-2.00',
'-1.50',
'-1.00',
'-0.50',
'0.00',
'0.50',
'1.00',
'1.50',
'2.00'
]);
const canvas = page.locator('canvas').nth(1); //Alt Drag Start
await page.keyboard.down('Alt');
await canvas.hover({ trial: true }); await canvas.dragTo(canvas, {
await expect(page.locator('.js-series-data-loaded')).toBeVisible(); sourcePosition: {
x: 200,
y: 200
},
targetPosition: {
x: 400,
y: 400
}
});
expect //Alt Drag End
.soft(await canvas.screenshot()) await page.keyboard.up('Alt');
.toMatchSnapshot('autoscale-canvas-prepan.png', { animations: 'disabled' });
//Alt Drag Start // Ensure the drag worked.
await page.keyboard.down('Alt'); await testYTicks(page, ['0.00', '0.50', '1.00', '1.50', '2.00']);
await canvas.dragTo(canvas, { await canvas.hover({trial: true});
sourcePosition: {
x: 200, expect(await canvas.screenshot()).toMatchSnapshot('autoscale-canvas-panned.png', { animations: 'disabled' });
y: 200
},
targetPosition: {
x: 400,
y: 400
}
}); });
//Alt Drag End
await page.keyboard.up('Alt');
// Ensure the drag worked.
await testYTicks(page, ['-0.50', '0.00', '0.50', '1.00', '1.50', '2.00', '2.50', '3.00']);
//Wait for canvas to stablize.
await canvas.hover({ trial: true });
expect
.soft(await canvas.screenshot())
.toMatchSnapshot('autoscale-canvas-panned.png', { animations: 'disabled' });
});
}); });
/** /**
@@ -123,15 +89,16 @@ test.describe('Autoscale', () => {
* @param {string} start * @param {string} start
* @param {string} end * @param {string} end
*/ */
async function setTimeRange( async function setTimeRange(page, start = '2022-03-29 22:00:00.000Z', end = '2022-03-29 22:00:30.000Z') {
page, // Set a specific time range for consistency, otherwise it will change
start = '2022-03-29 22:00:00.000Z', // on every test to a range based on the current time.
end = '2022-03-29 22:00:30.000Z'
) {
// Set a specific time range for consistency, otherwise it will change
// on every test to a range based on the current time.
await setTimeConductorBounds(page, start, end); const timeInputs = page.locator('input.c-input--datetime');
await timeInputs.first().click();
await timeInputs.first().fill(start);
await timeInputs.nth(1).click();
await timeInputs.nth(1).fill(end);
} }
/** /**
@@ -139,82 +106,81 @@ async function setTimeRange(
* @param {string} myItemsFolderName * @param {string} myItemsFolderName
*/ */
async function createSinewaveOverlayPlot(page, myItemsFolderName) { async function createSinewaveOverlayPlot(page, myItemsFolderName) {
// click create button // click create button
await page.locator('button:has-text("Create")').click(); await page.locator('button:has-text("Create")').click();
// add overlay plot with defaults // add overlay plot with defaults
await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click(); await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click();
await Promise.all([ await Promise.all([
page.waitForNavigation(), page.waitForNavigation(),
page.locator('button:has-text("OK")').click(), page.locator('button:has-text("OK")').click(),
//Wait for Save Banner to appear1 //Wait for Save Banner to appear1
page.waitForSelector('.c-message-banner__message') page.waitForSelector('.c-message-banner__message')
]); ]);
//Wait until Save Banner is gone //Wait until Save Banner is gone
await page.locator('.c-message-banner__close-button').click(); await page.locator('.c-message-banner__close-button').click();
await page.waitForSelector('.c-message-banner__message', { state: 'detached' }); await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
// save (exit edit mode) // save (exit edit mode)
await page await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1).click();
.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button') await page.locator('text=Save and Finish Editing').click();
.nth(1)
.click();
await page.locator('text=Save and Finish Editing').click();
// click create button // click create button
await page.locator('button:has-text("Create")').click(); await page.locator('button:has-text("Create")').click();
// add sine wave generator with defaults // add sine wave generator with defaults
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click(); await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
await Promise.all([ await Promise.all([
page.waitForNavigation(), page.waitForNavigation(),
page.locator('button:has-text("OK")').click(), page.locator('button:has-text("OK")').click(),
//Wait for Save Banner to appear1 //Wait for Save Banner to appear1
page.waitForSelector('.c-message-banner__message') page.waitForSelector('.c-message-banner__message')
]); ]);
//Wait until Save Banner is gone //Wait until Save Banner is gone
await page.locator('.c-message-banner__close-button').click(); await page.locator('.c-message-banner__close-button').click();
await page.waitForSelector('.c-message-banner__message', { state: 'detached' }); await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
// focus the overlay plot // focus the overlay plot
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click(); await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
await Promise.all([ await Promise.all([
page.waitForNavigation(), page.waitForNavigation(),
page.locator('text=Unnamed Overlay Plot').first().click() page.locator('text=Unnamed Overlay Plot').first().click()
]); ]);
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function turnOffAutoscale(page) { async function turnOffAutoscale(page) {
// uncheck autoscale // enter edit mode
await page.getByRole('checkbox', { name: 'Auto scale' }).uncheck(); await page.locator('text=Unnamed Overlay Plot Snapshot >> button').nth(3).click();
}
/** // uncheck autoscale
* @param {import('@playwright/test').Page} page await page.locator('text=Y Axis Label Log mode Auto scale Padding >> input[type="checkbox"] >> nth=1').uncheck();
* @param {string} min
* @param {string} max // save
*/ await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1).click();
async function setUserDefinedMinAndMax(page, min, max) { await Promise.all([
// set minimum value page.locator('text=Save and Finish Editing').click(),
await page.getByRole('spinbutton').first().fill(min); //Wait for Save Banner to appear
// set maximum value page.waitForSelector('.c-message-banner__message')
await page.getByRole('spinbutton').nth(1).fill(max); ]);
//Wait until Save Banner is gone
await page.locator('.c-message-banner__close-button').click();
await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function testYTicks(page, values) { async function testYTicks(page, values) {
const yTicks = page.locator('.gl-plot-y-tick-label'); const yTicks = page.locator('.gl-plot-y-tick-label');
await page.locator('canvas >> nth=1').hover(); await page.locator('canvas >> nth=1').hover();
let promises = [yTicks.count().then((c) => expect(c).toBe(values.length))]; let promises = [yTicks.count().then(c => expect(c).toBe(values.length))];
for (let i = 0, l = values.length; i < l; i += 1) { for (let i = 0, l = values.length; i < l; i += 1) {
promises.push(expect.soft(yTicks.nth(i)).toHaveText(values[i])); // eslint-disable-line promises.push(expect(yTicks.nth(i)).toHaveText(values[i])); // eslint-disable-line
} }
await Promise.all(promises); await Promise.all(promises);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -26,53 +26,44 @@ necessarily be used for reference when writing new tests in this area.
*/ */
const { test, expect } = require('../../../../pluginFixtures'); const { test, expect } = require('../../../../pluginFixtures');
const { selectInspectorTab, setTimeConductorBounds } = require('../../../../appActions');
test.describe('Log plot tests', () => { test.describe('Log plot tests', () => {
test('Log Plot ticks are functionally correct in regular and log mode and after refresh', async ({ test('Log Plot ticks are functionally correct in regular and log mode and after refresh', async ({ page, openmctConfig }) => {
page, const { myItemsFolderName } = openmctConfig;
openmctConfig
}) => {
const { myItemsFolderName } = openmctConfig;
//Test.slow decorator is currently broken. Needs to be fixed in https://github.com/nasa/openmct/issues/5374 //Test.slow decorator is currently broken. Needs to be fixed in https://github.com/nasa/openmct/issues/5374
test.slow(); test.slow();
await makeOverlayPlot(page, myItemsFolderName); await makeOverlayPlot(page, myItemsFolderName);
await testRegularTicks(page); await testRegularTicks(page);
await enableEditMode(page); await enableEditMode(page);
await selectInspectorTab(page, 'Config'); await enableLogMode(page);
await enableLogMode(page); await testLogTicks(page);
await testLogTicks(page); await disableLogMode(page);
await disableLogMode(page); await testRegularTicks(page);
await testRegularTicks(page); await enableLogMode(page);
await enableLogMode(page); await testLogTicks(page);
await testLogTicks(page); await saveOverlayPlot(page);
await saveOverlayPlot(page); await testLogTicks(page);
await testLogTicks(page); });
});
// Leaving test as 'TODO' for now. // Leaving test as 'TODO' for now.
// NOTE: Not eligible for community contributions. // NOTE: Not eligible for community contributions.
test.fixme( test.fixme('Verify that log mode option is reflected in import/export JSON', async ({ page, openmctConfig }) => {
'Verify that log mode option is reflected in import/export JSON', const { myItemsFolderName } = openmctConfig;
async ({ page, openmctConfig }) => {
const { myItemsFolderName } = openmctConfig;
await makeOverlayPlot(page, myItemsFolderName); await makeOverlayPlot(page, myItemsFolderName);
await enableEditMode(page); await enableEditMode(page);
await enableLogMode(page); await enableLogMode(page);
await saveOverlayPlot(page); await saveOverlayPlot(page);
// TODO ...export, delete the overlay, then import it... // TODO ...export, delete the overlay, then import it...
//await testLogTicks(page); //await testLogTicks(page);
// TODO, the plot is slightly at different position that in the other test, so this fails. // TODO, the plot is slightly at different position that in the other test, so this fails.
// ...We can fix it by copying all steps from the first test... // ...We can fix it by copying all steps from the first test...
// await testLogPlotPixels(page); // await testLogPlotPixels(page);
} });
);
}); });
/** /**
@@ -81,147 +72,165 @@ test.describe('Log plot tests', () => {
* @param {string} myItemsFolderName * @param {string} myItemsFolderName
*/ */
async function makeOverlayPlot(page, myItemsFolderName) { async function makeOverlayPlot(page, myItemsFolderName) {
// fresh page with time range from 2022-03-29 22:00:00.000Z to 2022-03-29 22:00:30.000Z // fresh page with time range from 2022-03-29 22:00:00.000Z to 2022-03-29 22:00:30.000Z
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
// Set a specific time range for consistency, otherwise it will change // Set a specific time range for consistency, otherwise it will change
// on every test to a range based on the current time. // on every test to a range based on the current time.
const start = '2022-03-29 22:00:00.000Z'; const timeInputs = page.locator('input.c-input--datetime');
const end = '2022-03-29 22:00:30.000Z'; await timeInputs.first().click();
await timeInputs.first().fill('2022-03-29 22:00:00.000Z');
await setTimeConductorBounds(page, start, end); await timeInputs.nth(1).click();
await timeInputs.nth(1).fill('2022-03-29 22:00:30.000Z');
// create overlay plot // create overlay plot
await page.locator('button.c-create-button').click(); await page.locator('button.c-create-button').click();
await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click(); await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click();
await Promise.all([ await Promise.all([
page.waitForNavigation({ waitUntil: 'networkidle' }), page.waitForNavigation({ waitUntil: 'networkidle'}),
page.locator('button:has-text("OK")').click(), page.locator('button:has-text("OK")').click(),
//Wait for Save Banner to appear //Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message') page.waitForSelector('.c-message-banner__message')
]); ]);
//Wait until Save Banner is gone //Wait until Save Banner is gone
await page.locator('.c-message-banner__close-button').click(); await page.locator('.c-message-banner__close-button').click();
await page.waitForSelector('.c-message-banner__message', { state: 'detached' }); await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
// save the overlay plot // save the overlay plot
await saveOverlayPlot(page); await saveOverlayPlot(page);
// create a sinewave generator // create a sinewave generator
await page.locator('button.c-create-button').click(); await page.locator('button.c-create-button').click();
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click(); await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
// set amplitude to 6, offset 4, period 2 // set amplitude to 6, offset 4, period 2
await page.locator('div:nth-child(5) .c-form-row__controls .form-control .field input').click(); await page.locator('div:nth-child(5) .c-form-row__controls .form-control .field input').click();
await page.locator('div:nth-child(5) .c-form-row__controls .form-control .field input').fill('6'); await page.locator('div:nth-child(5) .c-form-row__controls .form-control .field input').fill('6');
await page.locator('div:nth-child(6) .c-form-row__controls .form-control .field input').click(); await page.locator('div:nth-child(6) .c-form-row__controls .form-control .field input').click();
await page.locator('div:nth-child(6) .c-form-row__controls .form-control .field input').fill('4'); await page.locator('div:nth-child(6) .c-form-row__controls .form-control .field input').fill('4');
await page.locator('div:nth-child(7) .c-form-row__controls .form-control .field input').click(); await page.locator('div:nth-child(7) .c-form-row__controls .form-control .field input').click();
await page.locator('div:nth-child(7) .c-form-row__controls .form-control .field input').fill('2'); await page.locator('div:nth-child(7) .c-form-row__controls .form-control .field input').fill('2');
// Click OK to make generator // Click OK to make generator
await Promise.all([ await Promise.all([
page.waitForNavigation({ waitUntil: 'networkidle' }), page.waitForNavigation({ waitUntil: 'networkidle'}),
page.locator('button:has-text("OK")').click(), page.locator('button:has-text("OK")').click(),
//Wait for Save Banner to appear //Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message') page.waitForSelector('.c-message-banner__message')
]); ]);
//Wait until Save Banner is gone //Wait until Save Banner is gone
await page.locator('.c-message-banner__close-button').click(); await page.locator('.c-message-banner__close-button').click();
await page.waitForSelector('.c-message-banner__message', { state: 'detached' }); await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
// click on overlay plot // click on overlay plot
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click(); await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
await Promise.all([ await Promise.all([
page.waitForNavigation(), page.waitForNavigation(),
page.locator('text=Unnamed Overlay Plot').first().click() page.locator('text=Unnamed Overlay Plot').first().click()
]); ]);
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function testRegularTicks(page) { async function testRegularTicks(page) {
const yTicks = page.locator('.gl-plot-y-tick-label'); const yTicks = await page.locator('.gl-plot-y-tick-label');
expect(await yTicks.count()).toBe(7); expect(await yTicks.count()).toBe(7);
await expect(yTicks.nth(0)).toHaveText('-2'); await expect(yTicks.nth(0)).toHaveText('-2');
await expect(yTicks.nth(1)).toHaveText('0'); await expect(yTicks.nth(1)).toHaveText('0');
await expect(yTicks.nth(2)).toHaveText('2'); await expect(yTicks.nth(2)).toHaveText('2');
await expect(yTicks.nth(3)).toHaveText('4'); await expect(yTicks.nth(3)).toHaveText('4');
await expect(yTicks.nth(4)).toHaveText('6'); await expect(yTicks.nth(4)).toHaveText('6');
await expect(yTicks.nth(5)).toHaveText('8'); await expect(yTicks.nth(5)).toHaveText('8');
await expect(yTicks.nth(6)).toHaveText('10'); await expect(yTicks.nth(6)).toHaveText('10');
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function testLogTicks(page) { async function testLogTicks(page) {
const yTicks = page.locator('.gl-plot-y-tick-label'); const yTicks = await page.locator('.gl-plot-y-tick-label');
expect(await yTicks.count()).toBe(9); expect(await yTicks.count()).toBe(28);
await expect(yTicks.nth(0)).toHaveText('-2.98'); await expect(yTicks.nth(0)).toHaveText('-2.98');
await expect(yTicks.nth(1)).toHaveText('-1.51'); await expect(yTicks.nth(1)).toHaveText('-2.50');
await expect(yTicks.nth(2)).toHaveText('-0.58'); await expect(yTicks.nth(2)).toHaveText('-2.00');
await expect(yTicks.nth(3)).toHaveText('-0.00'); await expect(yTicks.nth(3)).toHaveText('-1.51');
await expect(yTicks.nth(4)).toHaveText('0.58'); await expect(yTicks.nth(4)).toHaveText('-1.20');
await expect(yTicks.nth(5)).toHaveText('1.51'); await expect(yTicks.nth(5)).toHaveText('-1.00');
await expect(yTicks.nth(6)).toHaveText('2.98'); await expect(yTicks.nth(6)).toHaveText('-0.80');
await expect(yTicks.nth(7)).toHaveText('5.31'); await expect(yTicks.nth(7)).toHaveText('-0.58');
await expect(yTicks.nth(8)).toHaveText('9.00'); await expect(yTicks.nth(8)).toHaveText('-0.40');
await expect(yTicks.nth(9)).toHaveText('-0.20');
await expect(yTicks.nth(10)).toHaveText('-0.00');
await expect(yTicks.nth(11)).toHaveText('0.20');
await expect(yTicks.nth(12)).toHaveText('0.40');
await expect(yTicks.nth(13)).toHaveText('0.58');
await expect(yTicks.nth(14)).toHaveText('0.80');
await expect(yTicks.nth(15)).toHaveText('1.00');
await expect(yTicks.nth(16)).toHaveText('1.20');
await expect(yTicks.nth(17)).toHaveText('1.51');
await expect(yTicks.nth(18)).toHaveText('2.00');
await expect(yTicks.nth(19)).toHaveText('2.50');
await expect(yTicks.nth(20)).toHaveText('2.98');
await expect(yTicks.nth(21)).toHaveText('3.50');
await expect(yTicks.nth(22)).toHaveText('4.00');
await expect(yTicks.nth(23)).toHaveText('4.50');
await expect(yTicks.nth(24)).toHaveText('5.31');
await expect(yTicks.nth(25)).toHaveText('7.00');
await expect(yTicks.nth(26)).toHaveText('8.00');
await expect(yTicks.nth(27)).toHaveText('9.00');
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function enableEditMode(page) { async function enableEditMode(page) {
// turn on edit mode // turn on edit mode
await page.getByRole('button', { name: 'Edit' }).click(); await page.locator('text=Unnamed Overlay Plot Snapshot >> button').nth(3).click();
await expect(page.getByRole('button', { name: 'Save' })).toBeVisible(); await expect(await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1)).toBeVisible();
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function enableLogMode(page) { async function enableLogMode(page) {
await expect(page.getByRole('checkbox', { name: 'Log mode' })).not.toBeChecked(); // turn on log mode
await page.getByRole('checkbox', { name: 'Log mode' }).check(); await page.locator('text=Y Axis Label Log mode Auto scale Padding >> input[type="checkbox"]').first().check();
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function disableLogMode(page) { async function disableLogMode(page) {
await expect(page.getByRole('checkbox', { name: 'Log mode' })).toBeChecked(); // turn off log mode
await page.getByRole('checkbox', { name: 'Log mode' }).uncheck(); await page.locator('text=Y Axis Label Log mode Auto scale Padding >> input[type="checkbox"]').first().uncheck();
} }
/** /**
* @param {import('@playwright/test').Page} page * @param {import('@playwright/test').Page} page
*/ */
async function saveOverlayPlot(page) { async function saveOverlayPlot(page) {
// save overlay plot // save overlay plot
await page await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1).click();
.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button')
.nth(1)
.click();
await Promise.all([ await Promise.all([
page.locator('text=Save and Finish Editing').click(), page.locator('text=Save and Finish Editing').click(),
//Wait for Save Banner to appear //Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message') page.waitForSelector('.c-message-banner__message')
]); ]);
//Wait until Save Banner is gone //Wait until Save Banner is gone
await page.locator('.c-message-banner__close-button').click(); await page.locator('.c-message-banner__close-button').click();
await page.waitForSelector('.c-message-banner__message', { state: 'detached' }); await page.waitForSelector('.c-message-banner__message', { state: 'detached' });
} }
/** /**
@@ -230,63 +239,63 @@ async function saveOverlayPlot(page) {
// FIXME: Remove this eslint exception once implemented // FIXME: Remove this eslint exception once implemented
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
async function testLogPlotPixels(page) { async function testLogPlotPixels(page) {
const pixelsMatch = await page.evaluate(async () => { const pixelsMatch = await page.evaluate(async () => {
// TODO get canvas pixels at a few locations to make sure they're the correct color, to test that the plot comes out as expected. // TODO get canvas pixels at a few locations to make sure they're the correct color, to test that the plot comes out as expected.
await new Promise((r) => setTimeout(r, 5 * 1000)); await new Promise((r) => setTimeout(r, 5 * 1000));
// These are some pixels that should be blue points in the log plot. // These are some pixels that should be blue points in the log plot.
// If the plot changes shape to an unexpected shape, this will // If the plot changes shape to an unexpected shape, this will
// likely fail, which is what we want. // likely fail, which is what we want.
// //
// I found these pixels by pausing playwright in debug mode at this // I found these pixels by pausing playwright in debug mode at this
// point, and using similar code as below to output the pixel data, then // point, and using similar code as below to output the pixel data, then
// I logged those pixels here. // I logged those pixels here.
const expectedBluePixels = [ const expectedBluePixels = [
// TODO these pixel sets only work with the first test, but not the second test. // TODO these pixel sets only work with the first test, but not the second test.
// [60, 35], // [60, 35],
// [121, 125], // [121, 125],
// [156, 377], // [156, 377],
// [264, 73], // [264, 73],
// [372, 186], // [372, 186],
// [576, 73], // [576, 73],
// [659, 439], // [659, 439],
// [675, 423] // [675, 423]
[60, 35], [60, 35],
[120, 125], [120, 125],
[156, 375], [156, 375],
[264, 73], [264, 73],
[372, 185], [372, 185],
[575, 72], [575, 72],
[659, 437], [659, 437],
[675, 421] [675, 421]
]; ];
// The first canvas in the DOM is the one that has the plot point // The first canvas in the DOM is the one that has the plot point
// icons (canvas 2d), which is the one we are testing. The second // icons (canvas 2d), which is the one we are testing. The second
// one in the DOM is the WebGL canvas with the line. (Why aren't // one in the DOM is the WebGL canvas with the line. (Why aren't
// they both WebGL?) // they both WebGL?)
const canvas = document.querySelector('canvas'); const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
for (const pixel of expectedBluePixels) { for (const pixel of expectedBluePixels) {
// XXX Possible optimization: call getImageData only once with // XXX Possible optimization: call getImageData only once with
// area including all pixels to be tested. // area including all pixels to be tested.
const data = ctx.getImageData(pixel[0], pixel[1], 1, 1).data; const data = ctx.getImageData(pixel[0], pixel[1], 1, 1).data;
// #43b0ffff <-- openmct cyanish-blue with 100% opacity // #43b0ffff <-- openmct cyanish-blue with 100% opacity
// if (data[0] !== 0x43 || data[1] !== 0xb0 || data[2] !== 0xff || data[3] !== 0xff) { // if (data[0] !== 0x43 || data[1] !== 0xb0 || data[2] !== 0xff || data[3] !== 0xff) {
if (data[0] === 0 && data[1] === 0 && data[2] === 0 && data[3] === 0) { if (data[0] === 0 && data[1] === 0 && data[2] === 0 && data[3] === 0) {
// If any pixel is empty, it means we didn't hit a plot point. // If any pixel is empty, it means we didn't hit a plot point.
return false; return false;
} }
} }
return true; return true;
}); });
expect(pixelsMatch).toBe(true); expect(pixelsMatch).toBe(true);
} }

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -27,56 +27,55 @@ Tests to verify log plot functionality when objects are missing
const { test, expect } = require('../../../../pluginFixtures'); const { test, expect } = require('../../../../pluginFixtures');
test.describe('Handle missing object for plots', () => { test.describe('Handle missing object for plots', () => {
test('Displays empty div for missing stacked plot item @unstable', async ({ test('Displays empty div for missing stacked plot item @unstable', async ({ page, browserName, openmctConfig }) => {
page, // eslint-disable-next-line playwright/no-skipped-test
browserName, test.skip(browserName === 'firefox', 'Firefox failing due to console events being missed');
openmctConfig
}) => {
// eslint-disable-next-line playwright/no-skipped-test
test.skip(browserName === 'firefox', 'Firefox failing due to console events being missed');
const { myItemsFolderName } = openmctConfig; const { myItemsFolderName } = openmctConfig;
const errorLogs = []; const errorLogs = [];
page.on('console', (message) => { page.on("console", (message) => {
if (message.type() === 'warning' && message.text().includes('Missing domain object')) { if (message.type() === 'warning' && message.text().includes('Missing domain object')) {
errorLogs.push(message.text()); errorLogs.push(message.text());
} }
});
//Make stacked plot
await makeStackedPlot(page, myItemsFolderName);
//Gets local storage and deletes the last sine wave generator in the stacked plot
const localStorage = await page.evaluate(() => window.localStorage);
const parsedData = JSON.parse(localStorage.mct);
const keys = Object.keys(parsedData);
const lastKey = keys[keys.length - 1];
delete parsedData[lastKey];
//Sets local storage with missing object
await page.evaluate(
`window.localStorage.setItem('mct', '${JSON.stringify(parsedData)}')`
);
//Reloads page and clicks on stacked plot
await Promise.all([
page.reload(),
page.waitForLoadState('networkidle')
]);
//Verify Main section is there on load
await expect.soft(page.locator('.l-browse-bar__object-name')).toContainText('Unnamed Stacked Plot');
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
await Promise.all([
page.waitForNavigation(),
page.locator('text=Unnamed Stacked Plot').first().click()
]);
//Check that there is only one stacked item plot with a plot, the missing one will be empty
await expect(page.locator(".c-plot--stacked-container:has(.gl-plot)")).toHaveCount(1);
//Verify that console.warn is thrown
expect(errorLogs).toHaveLength(1);
}); });
//Make stacked plot
await makeStackedPlot(page, myItemsFolderName);
//Gets local storage and deletes the last sine wave generator in the stacked plot
const localStorage = await page.evaluate(() => window.localStorage);
const parsedData = JSON.parse(localStorage.mct);
const keys = Object.keys(parsedData);
const lastKey = keys[keys.length - 1];
delete parsedData[lastKey];
//Sets local storage with missing object
await page.evaluate(`window.localStorage.setItem('mct', '${JSON.stringify(parsedData)}')`);
//Reloads page and clicks on stacked plot
await Promise.all([page.reload(), page.waitForLoadState('networkidle')]);
//Verify Main section is there on load
await expect
.soft(page.locator('.l-browse-bar__object-name'))
.toContainText('Unnamed Stacked Plot');
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
await Promise.all([
page.waitForNavigation(),
page.locator('text=Unnamed Stacked Plot').first().click()
]);
//Check that there is only one stacked item plot with a plot, the missing one will be empty
await expect(page.locator('.c-plot--stacked-container:has(.gl-plot)')).toHaveCount(1);
//Verify that console.warn is thrown
expect(errorLogs).toHaveLength(1);
});
}); });
/** /**
@@ -84,42 +83,42 @@ test.describe('Handle missing object for plots', () => {
* @private * @private
*/ */
async function makeStackedPlot(page, myItemsFolderName) { async function makeStackedPlot(page, myItemsFolderName) {
// fresh page with time range from 2022-03-29 22:00:00.000Z to 2022-03-29 22:00:30.000Z // fresh page with time range from 2022-03-29 22:00:00.000Z to 2022-03-29 22:00:30.000Z
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
// create stacked plot // create stacked plot
await page.locator('button.c-create-button').click(); await page.locator('button.c-create-button').click();
await page.locator('li[role="menuitem"]:has-text("Stacked Plot")').click(); await page.locator('li[role="menuitem"]:has-text("Stacked Plot")').click();
await Promise.all([ await Promise.all([
page.waitForNavigation({ waitUntil: 'networkidle' }), page.waitForNavigation({ waitUntil: 'networkidle'}),
page.locator('button:has-text("OK")').click(), page.locator('button:has-text("OK")').click(),
//Wait for Save Banner to appear //Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message') page.waitForSelector('.c-message-banner__message')
]); ]);
// save the stacked plot // save the stacked plot
await saveStackedPlot(page); await saveStackedPlot(page);
// create a sinewave generator // create a sinewave generator
await createSineWaveGenerator(page); await createSineWaveGenerator(page);
// click on stacked plot // click on stacked plot
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click(); await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
await Promise.all([ await Promise.all([
page.waitForNavigation(), page.waitForNavigation(),
page.locator('text=Unnamed Stacked Plot').first().click() page.locator('text=Unnamed Stacked Plot').first().click()
]); ]);
// create a second sinewave generator // create a second sinewave generator
await createSineWaveGenerator(page); await createSineWaveGenerator(page);
// click on stacked plot // click on stacked plot
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click(); await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
await Promise.all([ await Promise.all([
page.waitForNavigation(), page.waitForNavigation(),
page.locator('text=Unnamed Stacked Plot').first().click() page.locator('text=Unnamed Stacked Plot').first().click()
]); ]);
} }
/** /**
@@ -127,20 +126,17 @@ async function makeStackedPlot(page, myItemsFolderName) {
* @private * @private
*/ */
async function saveStackedPlot(page) { async function saveStackedPlot(page) {
// save stacked plot // save stacked plot
await page await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1).click();
.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button')
.nth(1)
.click();
await Promise.all([ await Promise.all([
page.locator('text=Save and Finish Editing').click(), page.locator('text=Save and Finish Editing').click(),
//Wait for Save Banner to appear //Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message') page.waitForSelector('.c-message-banner__message')
]); ]);
//Wait until Save Banner is gone //Wait until Save Banner is gone
await page.locator('.c-message-banner__close-button').click(); await page.locator('.c-message-banner__close-button').click();
await page.waitForSelector('.c-message-banner__message', { state: 'detached' }); await page.waitForSelector('.c-message-banner__message', { state: 'detached' });
} }
/** /**
@@ -148,14 +144,14 @@ async function saveStackedPlot(page) {
* @private * @private
*/ */
async function createSineWaveGenerator(page) { async function createSineWaveGenerator(page) {
//Create sine wave generator //Create sine wave generator
await page.locator('button.c-create-button').click(); await page.locator('button.c-create-button').click();
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click(); await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
await Promise.all([ await Promise.all([
page.waitForNavigation({ waitUntil: 'networkidle' }), page.waitForNavigation({ waitUntil: 'networkidle'}),
page.locator('button:has-text("OK")').click(), page.locator('button:has-text("OK")').click(),
//Wait for Save Banner to appear //Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message') page.waitForSelector('.c-message-banner__message')
]); ]);
} }

View File

@@ -1,270 +0,0 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*
Tests to verify log plot functionality. Note this test suite if very much under active development and should not
necessarily be used for reference when writing new tests in this area.
*/
const { test, expect } = require('../../../../pluginFixtures');
const {
createDomainObjectWithDefaults,
getCanvasPixels,
selectInspectorTab,
waitForPlotsToRender
} = require('../../../../appActions');
test.describe('Overlay Plot', () => {
test.beforeEach(async ({ page }) => {
await page.goto('./', { waitUntil: 'domcontentloaded' });
});
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
});
await page.goto(overlayPlot.url);
await selectInspectorTab(page, 'Config');
// navigate to plot series color palette
await page.click('.l-browse-bar__actions__edit');
await page.locator('li.c-tree__item.menus-to-left .c-disclosure-triangle').click();
await page.locator('.c-click-swatch--menu').click();
await page.locator('.c-palette__item[style="background: rgb(255, 166, 61);"]').click();
// gets color for swatch located in legend
const seriesColorSwatch = page.locator(
'.gl-plot-y-label-swatch-container > .plot-series-color-swatch'
);
await expect(seriesColorSwatch).toHaveCSS('background-color', 'rgb(255, 166, 61)');
});
test('Limit lines persist when series is moved to another Y Axis and on refresh', async ({
page
}) => {
test.info().annotations.push({
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',
parent: overlayPlot.uuid
});
await page.goto(overlayPlot.url);
// Assert that no limit lines are shown by default
await page.waitForSelector('.js-limit-area', { state: 'attached' });
expect(await page.locator('.c-plot-limit-line').count()).toBe(0);
// Enter edit mode
await page.click('button[title="Edit"]');
// Expand the "Sine Wave Generator" plot series options and enable limit lines
await selectInspectorTab(page, 'Config');
await page
.getByRole('list', { name: 'Plot Series Properties' })
.locator('span')
.first()
.click();
await page
.getByRole('list', { name: 'Plot Series Properties' })
.locator('[title="Display limit lines"]~div input')
.check();
await assertLimitLinesExistAndAreVisible(page);
// Save (exit edit mode)
await page.locator('button[title="Save"]').click();
await page.locator('li[title="Save and Finish Editing"]').click();
await assertLimitLinesExistAndAreVisible(page);
await page.reload();
await assertLimitLinesExistAndAreVisible(page);
// Enter edit mode
await page.click('button[title="Edit"]');
await selectInspectorTab(page, 'Elements');
// Drag Sine Wave Generator series from Y Axis 1 into Y Axis 2
await page
.locator(`#inspector-elements-tree >> text=${swgA.name}`)
.dragTo(page.locator('[aria-label="Element Item Group Y Axis 2"]'));
await assertLimitLinesExistAndAreVisible(page);
// Save (exit edit mode)
await page.locator('button[title="Save"]').click();
await page.locator('li[title="Save and Finish Editing"]').click();
await assertLimitLinesExistAndAreVisible(page);
await page.reload();
await assertLimitLinesExistAndAreVisible(page);
});
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
});
const swgB = await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
parent: overlayPlot.uuid
});
const swgC = await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
parent: overlayPlot.uuid
});
const swgD = await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
parent: overlayPlot.uuid
});
const swgE = await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
parent: overlayPlot.uuid
});
await page.goto(overlayPlot.url);
await page.click('button[title="Edit"]');
await selectInspectorTab(page, 'Elements');
// Drag swg a, c, e into Y Axis 2
await page
.locator(`#inspector-elements-tree >> text=${swgA.name}`)
.dragTo(page.locator('[aria-label="Element Item Group Y Axis 2"]'));
await page
.locator(`#inspector-elements-tree >> text=${swgC.name}`)
.dragTo(page.locator('[aria-label="Element Item Group Y Axis 2"]'));
await page
.locator(`#inspector-elements-tree >> text=${swgE.name}`)
.dragTo(page.locator('[aria-label="Element Item Group Y Axis 2"]'));
// Assert that Y Axis 1 and Y Axis 2 property groups are visible only
await selectInspectorTab(page, 'Config');
const yAxis1PropertyGroup = page.locator('[aria-label="Y Axis Properties"]');
const yAxis2PropertyGroup = page.locator('[aria-label="Y Axis 2 Properties"]');
const yAxis3PropertyGroup = page.locator('[aria-label="Y Axis 3 Properties"]');
await expect(yAxis1PropertyGroup).toBeVisible();
await expect(yAxis2PropertyGroup).toBeVisible();
await expect(yAxis3PropertyGroup).toBeHidden();
const yAxis1Group = page.getByLabel('Y Axis 1');
const yAxis2Group = page.getByLabel('Y Axis 2');
const yAxis3Group = page.getByLabel('Y Axis 3');
await selectInspectorTab(page, 'Elements');
// Drag swg b into Y Axis 3
await page
.locator(`#inspector-elements-tree >> text=${swgB.name}`)
.dragTo(page.locator('[aria-label="Element Item Group Y Axis 3"]'));
// Assert that all Y Axis property groups are visible
await selectInspectorTab(page, 'Config');
await expect(yAxis1PropertyGroup).toBeVisible();
await expect(yAxis2PropertyGroup).toBeVisible();
await expect(yAxis3PropertyGroup).toBeVisible();
// Verify that the elements are in the correct buckets and in the correct order
await selectInspectorTab(page, 'Elements');
expect(yAxis1Group.getByRole('listitem', { name: swgD.name })).toBeTruthy();
expect(yAxis1Group.getByRole('listitem').nth(0).getByText(swgD.name)).toBeTruthy();
expect(yAxis2Group.getByRole('listitem', { name: swgE.name })).toBeTruthy();
expect(yAxis2Group.getByRole('listitem').nth(0).getByText(swgE.name)).toBeTruthy();
expect(yAxis2Group.getByRole('listitem', { name: swgC.name })).toBeTruthy();
expect(yAxis2Group.getByRole('listitem').nth(1).getByText(swgC.name)).toBeTruthy();
expect(yAxis2Group.getByRole('listitem', { name: swgA.name })).toBeTruthy();
expect(yAxis2Group.getByRole('listitem').nth(2).getByText(swgA.name)).toBeTruthy();
expect(yAxis3Group.getByRole('listitem', { name: swgB.name })).toBeTruthy();
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'
});
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.click('button[title="Edit"]');
await selectInspectorTab(page, 'Elements');
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);
});
});
/**
* Asserts that limit lines exist and are visible
* @param {import('@playwright/test').Page} page
*/
async function assertLimitLinesExistAndAreVisible(page) {
// Wait for plot series data to load
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);
for (let i = 0; i < limitLineCount; i++) {
await expect(page.locator('.c-plot-limit-line').nth(i)).toBeVisible();
}
}

View File

@@ -0,0 +1,110 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*
Tests to verify log plot functionality. Note this test suite if very much under active development and should not
necessarily be used for reference when writing new tests in this area.
*/
const { test, expect } = require('../../../../pluginFixtures');
test.describe('Legend color in sync with plot color', () => {
test('Testing', async ({ page }) => {
await makeOverlayPlot(page);
// navigate to plot series color palette
await page.click('.l-browse-bar__actions__edit');
await page.locator('li.c-tree__item.menus-to-left .c-disclosure-triangle').click();
await page.locator('.c-click-swatch--menu').click();
await page.locator('.c-palette__item[style="background: rgb(255, 166, 61);"]').click();
// gets color for swatch located in legend
const element = await page.waitForSelector('.plot-series-color-swatch');
const color = await element.evaluate((el) => {
return window.getComputedStyle(el).getPropertyValue('background-color');
});
expect(color).toBe('rgb(255, 166, 61)');
});
});
async function saveOverlayPlot(page) {
// save overlay plot
await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1).click();
await Promise.all([
page.locator('text=Save and Finish Editing').click(),
//Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message')
]);
//Wait until Save Banner is gone
await page.locator('.c-message-banner__close-button').click();
await page.waitForSelector('.c-message-banner__message', { state: 'detached' });
}
async function makeOverlayPlot(page) {
// fresh page with time range from 2022-03-29 22:00:00.000Z to 2022-03-29 22:00:30.000Z
await page.goto('/', { waitUntil: 'networkidle' });
// create overlay plot
await page.locator('button.c-create-button').click();
await page.locator('li[role="menuitem"]:has-text("Overlay Plot")').click();
await Promise.all([
page.waitForNavigation({ waitUntil: 'networkidle'}),
page.locator('button:has-text("OK")').click(),
//Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message')
]);
//Wait until Save Banner is gone
await page.locator('.c-message-banner__close-button').click();
await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
// save the overlay plot
await saveOverlayPlot(page);
// create a sinewave generator
await page.locator('button.c-create-button').click();
await page.locator('li[role="menuitem"]:has-text("Sine Wave Generator")').click();
// Click OK to make generator
await Promise.all([
page.waitForNavigation({ waitUntil: 'networkidle'}),
page.locator('button:has-text("OK")').click(),
//Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message')
]);
//Wait until Save Banner is gone
await page.locator('.c-message-banner__close-button').click();
await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
// click on overlay plot
await page.locator('text=Open MCT My Items >> span').nth(3).click();
await Promise.all([
page.waitForNavigation(),
page.locator('text=Unnamed Overlay Plot').first().click()
]);
}

View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government * Open MCT, Copyright (c) 2014-2022, United States Government
* as represented by the Administrator of the National Aeronautics and Space * as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved. * Administration. All rights reserved.
* *
@@ -21,46 +21,44 @@
*****************************************************************************/ *****************************************************************************/
/* /*
* This test suite is dedicated to testing the rendering and interaction of plots. * This test suite is dedicated to testing the rendering and interaction of plots.
* *
*/ */
const { test, expect } = require('../../../../pluginFixtures'); const { test, expect } = require('../../../../pluginFixtures');
const { createDomainObjectWithDefaults, getCanvasPixels } = require('../../../../appActions'); const { createDomainObjectWithDefaults} = require('../../../../appActions');
test.describe('Plot Rendering', () => { test.describe('Plot Integrity Testing @unstable', () => {
let sineWaveGeneratorObject; let sineWaveGeneratorObject;
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
// Open a browser, navigate to the main page, and wait until all networkevents to resolve //Open a browser, navigate to the main page, and wait until all networkevents to resolve
await page.goto('./', { waitUntil: 'domcontentloaded' }); await page.goto('./', { waitUntil: 'networkidle' });
sineWaveGeneratorObject = await createDomainObjectWithDefaults(page, { sineWaveGeneratorObject = await createDomainObjectWithDefaults(page, { type: 'Sine Wave Generator' });
type: 'Sine Wave Generator'
}); });
});
test('Plots do not re-request data when a plot is clicked', async ({ page }) => { test('Plots do not re-request data when a plot is clicked', async ({ page }) => {
// Navigate to Sine Wave Generator //Navigate to Sine Wave Generator
await page.goto(sineWaveGeneratorObject.url); await page.goto(sineWaveGeneratorObject.url);
// Click on the plot canvas //Click on the plot canvas
await page.locator('canvas').nth(1).click(); await page.locator('canvas').nth(1).click();
// No request was made to get historical data //No request was made to get historical data
const createMineFolderRequests = []; const createMineFolderRequests = [];
page.on('request', (req) => { page.on('request', req => {
createMineFolderRequests.push(req); // eslint-disable-next-line playwright/no-conditional-in-test
createMineFolderRequests.push(req);
});
expect(createMineFolderRequests.length).toEqual(0);
}); });
expect(createMineFolderRequests.length).toEqual(0);
});
test('Plot is rendered when infinity values exist', async ({ page }) => { test('Plot is rendered when infinity values exist', async ({ page }) => {
// Edit Plot // Edit Plot
await editSineWaveToUseInfinityOption(page, sineWaveGeneratorObject); await editSineWaveToUseInfinityOption(page, sineWaveGeneratorObject);
//Get pixel data from Canvas //Get pixel data from Canvas
const plotPixels = await getCanvasPixels(page, 'canvas'); const plotPixelSize = await getCanvasPixelsWithData(page);
const plotPixelSize = plotPixels.length; expect(plotPixelSize).toBeGreaterThan(0);
expect(plotPixelSize).toBeGreaterThan(0); });
});
}); });
/** /**
@@ -71,24 +69,71 @@ test.describe('Plot Rendering', () => {
* @returns {Promise<CreatedObjectInfo>} An object containing information about the edited domain object. * @returns {Promise<CreatedObjectInfo>} An object containing information about the edited domain object.
*/ */
async function editSineWaveToUseInfinityOption(page, sineWaveGeneratorObject) { async function editSineWaveToUseInfinityOption(page, sineWaveGeneratorObject) {
await page.goto(sineWaveGeneratorObject.url); await page.goto(sineWaveGeneratorObject.url);
// Edit SWG properties to include infinity values // Edit LAD table
await page.locator('[title="More options"]').click(); await page.locator('[title="More options"]').click();
await page.locator('[title="Edit properties of this object."]').click(); await page.locator('[title="Edit properties of this object."]').click();
await page // Modify the infinity option to true
.getByRole('switch', { const infinityInput = page.locator('[aria-label="Include Infinity Values"]');
name: 'Include Infinity Values' await infinityInput.click();
})
.check();
await page // Click OK button and wait for Navigate event
.getByRole('button', { await Promise.all([
name: 'Save' page.waitForLoadState(),
}) page.click('[aria-label="Save"]'),
.click(); // Wait for Save Banner to appear
page.waitForSelector('.c-message-banner__message')
]);
// FIXME: Changes to SWG properties should be reflected on save, but they're not? // FIXME: Changes to SWG properties should be reflected on save, but they're not?
// Thus, navigate away and back to the object. // Thus, navigate away and back to the object.
await page.goto('./#/browse/mine'); await page.goto('./#/browse/mine');
await page.goto(sineWaveGeneratorObject.url); await page.goto(sineWaveGeneratorObject.url);
await page.locator('c-progress-bar c-telemetry-table__progress-bar').waitFor({
state: 'hidden'
});
// FIXME: The progress bar disappears on series data load, not on plot render,
// so wait for a half a second before evaluating the canvas.
// eslint-disable-next-line playwright/no-wait-for-timeout
await page.waitForTimeout(500);
}
/**
* @param {import('@playwright/test').Page} page
*/
async function getCanvasPixelsWithData(page) {
const getTelemValuePromise = new Promise(resolve => page.exposeFunction('getCanvasValue', resolve));
await page.evaluate(() => {
// The document canvas is where the plot points and lines are drawn.
// The only way to access the canvas is using document (using page.evaluate)
let data;
let canvas;
let ctx;
canvas = document.querySelector('canvas');
ctx = canvas.getContext('2d');
data = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
const imageDataValues = Object.values(data);
let plotPixels = [];
// Each pixel consists of four values within the ImageData.data array. The for loop iterates by multiples of four.
// The values associated with each pixel are R (red), G (green), B (blue), and A (alpha), in that order.
for (let i = 0; i < imageDataValues.length;) {
if (imageDataValues[i] > 0) {
plotPixels.push({
startIndex: i,
endIndex: i + 3,
value: `rgb(${imageDataValues[i]}, ${imageDataValues[i + 1]}, ${imageDataValues[i + 2]}, ${imageDataValues[i + 3]})`
});
}
i = i + 4;
}
window.getCanvasValue(plotPixels.length);
});
return getTelemValuePromise;
} }

Some files were not shown because too many files have changed in this diff Show More