Compare commits
106 Commits
vue-3-migr
...
playwright
Author | SHA1 | Date | |
---|---|---|---|
98fd496c1f | |||
0dd12bce85 | |||
9c9e0442f1 | |||
d49f057698 | |||
c74ad1279c | |||
470a451956 | |||
fa6cbb6f4d | |||
52c00cfaef | |||
96d723a424 | |||
fb4b80862e | |||
bb2c8cfa63 | |||
ceffee9f22 | |||
a08ccd80dc | |||
3509eacdec | |||
d4496cba41 | |||
64f300d466 | |||
8de24a109a | |||
6d62e0e73c | |||
5da1c9c0d7 | |||
4fa9a9697b | |||
bf48a6e306 | |||
00ad452930 | |||
8df1f6406b | |||
a50960d66c | |||
e3a69c8856 | |||
672cb7e621 | |||
7dcccee1ae | |||
302dbe7359 | |||
b4df01965e | |||
5a8f1d542e | |||
10decda94e | |||
5b1f8d0eac | |||
2f6e1b703a | |||
5384022a59 | |||
b57974b462 | |||
3c36ba9a71 | |||
2ac463de90 | |||
be38c3e654 | |||
0f312a88bb | |||
422b7f3e09 | |||
800062d37e | |||
c1e8c7915c | |||
c1c1d87953 | |||
0382d22f7f | |||
f570424357 | |||
393c801426 | |||
6d63339b23 | |||
66d7c626e1 | |||
2246f33023 | |||
871362d469 | |||
cc1bf47f5a | |||
9c784398b3 | |||
21ce013df2 | |||
d20c2a3e3c | |||
8d1a2e6716 | |||
01f724959d | |||
3ae6290ec3 | |||
ba5ed27e74 | |||
ca737d8afa | |||
33a275e8bc | |||
60e808689c | |||
8847c862fa | |||
1b71a3bf33 | |||
9980aab18f | |||
5e530aa625 | |||
986c596d90 | |||
4d84b16d8b | |||
20c7b23a4f | |||
d1c7d133fc | |||
edbbebe329 | |||
f98a2cdd6b | |||
22621aaaf8 | |||
e0ca6200bb | |||
70074c52c8 | |||
d5adaf6e8c | |||
8125632728 | |||
14c9dd0a32 | |||
9ae58f8441 | |||
4889284335 | |||
c2183d4de2 | |||
902d80c214 | |||
22ce817443 | |||
cdb202d8ba | |||
905373f294 | |||
60c07ab506 | |||
7336abc111 | |||
8fe9da89a3 | |||
e6bdaa957a | |||
93b5519c4b | |||
04ef4b369c | |||
5424a62db5 | |||
9ed9e62202 | |||
327fc826c1 | |||
a9e3eca35c | |||
cbecd79f71 | |||
3deb2e3dc2 | |||
d6e80447ab | |||
1a4bd0fb55 | |||
80f89c7609 | |||
b82649772f | |||
7f2ed27106 | |||
57e02db6b5 | |||
d54335d21c | |||
e0ed0bb6e2 | |||
ed3fd8f965 | |||
e6d59c61d1 |
@ -2,7 +2,7 @@ version: 2.1
|
|||||||
executors:
|
executors:
|
||||||
pw-focal-development:
|
pw-focal-development:
|
||||||
docker:
|
docker:
|
||||||
- image: mcr.microsoft.com/playwright:v1.25.2-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
|
||||||
|
2
.github/workflows/e2e-couchdb.yml
vendored
@ -23,7 +23,7 @@ jobs:
|
|||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '16'
|
node-version: '16'
|
||||||
- run: npx playwright@1.25.2 install
|
- run: npx playwright@1.29.0 install
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: sh src/plugins/persistence/couch/replace-localstorage-with-couchdb-indexhtml.sh
|
- run: sh src/plugins/persistence/couch/replace-localstorage-with-couchdb-indexhtml.sh
|
||||||
- run: npm run test:e2e:couchdb
|
- run: npm run test:e2e:couchdb
|
||||||
|
2
.github/workflows/e2e-pr.yml
vendored
@ -30,7 +30,7 @@ jobs:
|
|||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '16'
|
node-version: '16'
|
||||||
- run: npx playwright@1.25.2 install
|
- run: npx playwright@1.29.0 install
|
||||||
- run: npx playwright install chrome-beta
|
- run: npx playwright install chrome-beta
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm run test:e2e:full
|
- run: npm run test:e2e:full
|
||||||
|
176
.webpack/webpack.common.js
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
/* global __dirname module */
|
||||||
|
|
||||||
|
/*
|
||||||
|
This is the OpenMCT common webpack file. It is imported by the other three webpack configurations:
|
||||||
|
- webpack.prod.js - the production configuration for OpenMCT (default)
|
||||||
|
- webpack.dev.js - the development configuration for OpenMCT
|
||||||
|
- webpack.coverage.js - imports webpack.dev.js and adds code coverage
|
||||||
|
There are separate npm scripts to use these configurations, though simply running `npm install`
|
||||||
|
will use the default production configuration.
|
||||||
|
*/
|
||||||
|
const path = require("path");
|
||||||
|
const packageDefinition = require("../package.json");
|
||||||
|
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
||||||
|
const webpack = require("webpack");
|
||||||
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||||
|
|
||||||
|
const { VueLoaderPlugin } = require("vue-loader");
|
||||||
|
let gitRevision = "error-retrieving-revision";
|
||||||
|
let gitBranch = "error-retrieving-branch";
|
||||||
|
|
||||||
|
try {
|
||||||
|
gitRevision = require("child_process")
|
||||||
|
.execSync("git rev-parse HEAD")
|
||||||
|
.toString()
|
||||||
|
.trim();
|
||||||
|
gitBranch = require("child_process")
|
||||||
|
.execSync("git rev-parse --abbrev-ref HEAD")
|
||||||
|
.toString()
|
||||||
|
.trim();
|
||||||
|
} catch (err) {
|
||||||
|
console.warn(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
const projectRootDir = path.resolve(__dirname, "..");
|
||||||
|
|
||||||
|
/** @type {import('webpack').Configuration} */
|
||||||
|
const config = {
|
||||||
|
context: projectRootDir,
|
||||||
|
entry: {
|
||||||
|
openmct: "./openmct.js",
|
||||||
|
generatorWorker: "./example/generator/generatorWorker.js",
|
||||||
|
couchDBChangesFeed:
|
||||||
|
"./src/plugins/persistence/couch/CouchChangesFeed.js",
|
||||||
|
inMemorySearchWorker: "./src/api/objects/InMemorySearchWorker.js",
|
||||||
|
espressoTheme: "./src/plugins/themes/espresso-theme.scss",
|
||||||
|
snowTheme: "./src/plugins/themes/snow-theme.scss"
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
globalObject: "this",
|
||||||
|
filename: "[name].js",
|
||||||
|
path: path.resolve(projectRootDir, "dist"),
|
||||||
|
library: "openmct",
|
||||||
|
libraryTarget: "umd",
|
||||||
|
publicPath: "",
|
||||||
|
hashFunction: "xxhash64",
|
||||||
|
clean: true
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
"@": path.join(projectRootDir, "src"),
|
||||||
|
legacyRegistry: path.join(projectRootDir, "src/legacyRegistry"),
|
||||||
|
saveAs: "file-saver/src/FileSaver.js",
|
||||||
|
csv: "comma-separated-values",
|
||||||
|
EventEmitter: "eventemitter3",
|
||||||
|
bourbon: "bourbon.scss",
|
||||||
|
"plotly-basic": "plotly.js-basic-dist",
|
||||||
|
"plotly-gl2d": "plotly.js-gl2d-dist",
|
||||||
|
"d3-scale": path.join(
|
||||||
|
projectRootDir,
|
||||||
|
"node_modules/d3-scale/dist/d3-scale.min.js"
|
||||||
|
),
|
||||||
|
printj: path.join(
|
||||||
|
projectRootDir,
|
||||||
|
"node_modules/printj/dist/printj.min.js"
|
||||||
|
),
|
||||||
|
styles: path.join(projectRootDir, "src/styles"),
|
||||||
|
MCT: path.join(projectRootDir, "src/MCT"),
|
||||||
|
testUtils: path.join(projectRootDir, "src/utils/testUtils.js"),
|
||||||
|
objectUtils: path.join(
|
||||||
|
projectRootDir,
|
||||||
|
"src/api/objects/object-utils.js"
|
||||||
|
),
|
||||||
|
"kdbush": path.join(projectRootDir, "node_modules/kdbush/kdbush.min.js"),
|
||||||
|
utils: path.join(projectRootDir, "src/utils")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
__OPENMCT_VERSION__: `'${packageDefinition.version}'`,
|
||||||
|
__OPENMCT_BUILD_DATE__: `'${new Date()}'`,
|
||||||
|
__OPENMCT_REVISION__: `'${gitRevision}'`,
|
||||||
|
__OPENMCT_BUILD_BRANCH__: `'${gitBranch}'`
|
||||||
|
}),
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
new MiniCssExtractPlugin({
|
||||||
|
filename: "[name].css",
|
||||||
|
chunkFilename: "[name].css"
|
||||||
|
})
|
||||||
|
],
|
||||||
|
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: {
|
||||||
|
// We should eventually consider chunking to decrease
|
||||||
|
// these values
|
||||||
|
maxEntrypointSize: 27000000,
|
||||||
|
maxAssetSize: 27000000
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = config;
|
@ -6,9 +6,9 @@ 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;
|
||||||
|
|
||||||
@ -18,13 +18,18 @@ 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: [['babel-plugin-istanbul', {
|
plugins: [
|
||||||
extension: ['.js', '.vue']
|
[
|
||||||
}]]
|
"babel-plugin-istanbul",
|
||||||
|
{
|
||||||
|
extension: [".js", ".vue"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -5,28 +5,29 @@ 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 { merge } = require('webpack-merge');
|
const path = require("path");
|
||||||
const common = require('./webpack.common');
|
const webpack = require("webpack");
|
||||||
|
const { merge } = require("webpack-merge");
|
||||||
|
|
||||||
const path = require('path');
|
const common = require("./webpack.common");
|
||||||
const webpack = require('webpack');
|
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
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
"vue": path.join(__dirname, "node_modules/vue/dist/vue.js")
|
vue: path.join(projectRootDir, "node_modules/vue/dist/vue.js")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
@ -34,20 +35,20 @@ module.exports = merge(common, {
|
|||||||
__OPENMCT_ROOT_RELATIVE__: '"dist/"'
|
__OPENMCT_ROOT_RELATIVE__: '"dist/"'
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
devtool: 'eval-source-map',
|
devtool: "eval-source-map",
|
||||||
devServer: {
|
devServer: {
|
||||||
devMiddleware: {
|
devMiddleware: {
|
||||||
writeToDisk: (filePathString) => {
|
writeToDisk: (filePathString) => {
|
||||||
const filePath = path.parse(filePathString);
|
const filePath = path.parse(filePathString);
|
||||||
const shouldWrite = !(filePath.base.includes('hot-update'));
|
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: {
|
@ -4,17 +4,18 @@
|
|||||||
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 { merge } = require('webpack-merge');
|
const path = require("path");
|
||||||
const common = require('./webpack.common');
|
const webpack = require("webpack");
|
||||||
|
const { merge } = require("webpack-merge");
|
||||||
|
|
||||||
const path = require('path');
|
const common = require("./webpack.common");
|
||||||
const webpack = require('webpack');
|
const projectRootDir = path.resolve(__dirname, "..");
|
||||||
|
|
||||||
module.exports = merge(common, {
|
module.exports = merge(common, {
|
||||||
mode: 'production',
|
mode: "production",
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
"vue": path.join(__dirname, "node_modules/vue/dist/vue.min.js")
|
vue: path.join(projectRootDir, "node_modules/vue/dist/vue.min.js")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
@ -22,5 +23,5 @@ module.exports = merge(common, {
|
|||||||
__OPENMCT_ROOT_RELATIVE__: '""'
|
__OPENMCT_ROOT_RELATIVE__: '""'
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
devtool: 'source-map'
|
devtool: "source-map"
|
||||||
});
|
});
|
@ -1,4 +1,4 @@
|
|||||||
# Open MCT [](http://www.apache.org/licenses/LICENSE-2.0) [](https://lgtm.com/projects/g/nasa/openmct/context:javascript) [](https://codecov.io/gh/nasa/openmct) [](https://percy.io/b2e34b17/openmct) [](https://www.npmjs.com/package/openmct)
|
# Open MCT [](http://www.apache.org/licenses/LICENSE-2.0) [](https://codecov.io/gh/nasa/openmct) [](https://percy.io/b2e34b17/openmct) [](https://www.npmjs.com/package/openmct)
|
||||||
|
|
||||||
Open MCT (Open Mission Control Technologies) is a next-generation mission control framework for visualization of data on desktop and mobile devices. It is developed at NASA's Ames Research Center, and is being used by NASA for data analysis of spacecraft missions, as well as planning and operation of experimental rover systems. As a generalizable and open source framework, Open MCT could be used as the basis for building applications for planning, operation, and analysis of any systems producing telemetry data.
|
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/) 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).
|
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).
|
||||||
|
|
||||||
### Test Reporting and Code Coverage
|
### Test Reporting and Code Coverage
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ This document is designed to capture on the What, Why, and How's of writing and
|
|||||||
|
|
||||||
1. [Getting Started](#getting-started)
|
1. [Getting Started](#getting-started)
|
||||||
2. [Types of Testing](#types-of-e2e-testing)
|
2. [Types of Testing](#types-of-e2e-testing)
|
||||||
3. [Architecture](#architecture)
|
3. [Architecture](#test-architecture-and-ci)
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
@ -89,17 +89,37 @@ 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.
|
- 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:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:[GET THIS VERSION FROM OUR CIRCLECI CONFIG FILE]-focal /bin/bash
|
// 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 install
|
||||||
npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @snapshot
|
npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @snapshot
|
||||||
```
|
```
|
||||||
|
|
||||||
### (WIP) Updating Snapshots
|
### Updating Snapshots
|
||||||
|
|
||||||
When the `@snapshot` tests fail, they will need to be evaluated to see if the failure is an acceptable change or
|
When the `@snapshot` tests fail, they will need to be evaluated to determine if the failure is an acceptable and desireable or an unintended regression.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
@ -276,14 +296,36 @@ Skipping based on browser version (Rarely used): <https://github.com/microsoft/p
|
|||||||
- Leverage `await page.goto('./', { waitUntil: 'networkidle' });`
|
- Leverage `await page.goto('./', { waitUntil: 'networkidle' });`
|
||||||
- Avoid repeated setup to test to test a single assertion. Write longer tests with multiple soft assertions.
|
- Avoid repeated setup to test to test a single assertion. Write longer tests with multiple soft assertions.
|
||||||
|
|
||||||
### How to write a great test (TODO)
|
### How to write a great test (WIP)
|
||||||
|
|
||||||
|
- Use our [App Actions](./appActions.js) for performing common actions whenever applicable.
|
||||||
|
- If you create an object outside of using the `createDomainObjectWithDefaults` App Action, make sure to fill in the 'Notes' section of your object with `page.testNotes`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Fill the "Notes" section with information about the
|
||||||
|
// currently running test and its project.
|
||||||
|
const { testNotes } = page;
|
||||||
|
const notesInput = page.locator('form[name="mctForm"] #notes-textarea');
|
||||||
|
await notesInput.fill(testNotes);
|
||||||
|
```
|
||||||
|
|
||||||
#### How to write a great visual test (TODO)
|
#### How to write a great visual test (TODO)
|
||||||
|
|
||||||
|
#### How to write a great network test
|
||||||
|
|
||||||
|
- Where possible, it is best to mock out third-party network activity to ensure we are testing application behavior of Open MCT.
|
||||||
|
- It is best to be as specific as possible about the expected network request/response structures in creating your mocks.
|
||||||
|
- Make sure to only mock requests which are relevant to the specific behavior being tested.
|
||||||
|
- Where possible, network requests and responses should be treated in an order-agnostic manner, as the order in which certain requests/responses happen is dynamic and subject to change.
|
||||||
|
|
||||||
|
Some examples of mocking network responses in regards to CouchDB can be found in our [couchdb.e2e.spec.js](./tests/functional/couchdb.e2e.spec.js) test file.
|
||||||
|
|
||||||
### Best Practices
|
### Best Practices
|
||||||
|
|
||||||
For now, our best practices exist as self-tested, living documentation in our [exampleTemplate.e2e.spec.js](./tests/framework/exampleTemplate.e2e.spec.js) file.
|
For now, our best practices exist as self-tested, living documentation in our [exampleTemplate.e2e.spec.js](./tests/framework/exampleTemplate.e2e.spec.js) file.
|
||||||
|
|
||||||
|
For best practices with regards to mocking network responses, see our [couchdb.e2e.spec.js](./tests/functional/couchdb.e2e.spec.js) file.
|
||||||
|
|
||||||
### Tips & Tricks (TODO)
|
### Tips & Tricks (TODO)
|
||||||
|
|
||||||
The following contains a list of tips and tricks which don't exactly fit into a FAQ or Best Practices doc.
|
The following contains a list of tips and tricks which don't exactly fit into a FAQ or Best Practices doc.
|
||||||
@ -378,3 +420,23 @@ A single e2e test in Open MCT is extended to run:
|
|||||||
- Tests won't start because 'Error: <http://localhost:8080/># is already used...'
|
- Tests won't start because 'Error: <http://localhost:8080/># is already used...'
|
||||||
This error will appear when running the tests locally. Sometimes, the webserver is left in an orphaned state and needs to be cleaned up. To clear up the orphaned webserver, execute the following from your Terminal:
|
This error will appear when running the tests locally. Sometimes, the webserver is left in an orphaned state and needs to be cleaned up. To clear up the orphaned webserver, execute the following from your Terminal:
|
||||||
```lsof -n -i4TCP:8080 | awk '{print$2}' | tail -1 | xargs kill -9```
|
```lsof -n -i4TCP:8080 | awk '{print$2}' | tail -1 | xargs kill -9```
|
||||||
|
|
||||||
|
### Upgrading Playwright
|
||||||
|
|
||||||
|
In order to upgrade from one version of Playwright to another, the version should be updated in several places in both `openmct` and `openmct-yamcs` repos. An easy way to identify these locations is to search for the current version in all files and find/replace.
|
||||||
|
|
||||||
|
For reference, all of the locations where the version should be updated are listed below:
|
||||||
|
|
||||||
|
#### **In `openmct`:**
|
||||||
|
|
||||||
|
- `package.json`
|
||||||
|
- Both packages `@playwright/test` and `playwright-core` should be updated to the same target version.
|
||||||
|
- `.circleci/config.yml`
|
||||||
|
- `.github/workflows/e2e-couchdb.yml`
|
||||||
|
- `.github/workflows/e2e-pr.yml`
|
||||||
|
|
||||||
|
#### **In `openmct-yamcs`:**
|
||||||
|
|
||||||
|
- `package.json`
|
||||||
|
- `@playwright/test` should be updated to the target version.
|
||||||
|
- `.github/workflows/yamcs-quickstart-e2e.yml`
|
||||||
|
@ -45,6 +45,14 @@
|
|||||||
* @property {string} url the relative url to the object (for use with `page.goto()`)
|
* @property {string} url the relative url to the object (for use with `page.goto()`)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines parameters to be used in the creation of a notification.
|
||||||
|
* @typedef {Object} CreateNotificationOptions
|
||||||
|
* @property {string} message the message
|
||||||
|
* @property {'info' | 'alert' | 'error'} severity the severity
|
||||||
|
* @property {import('../src/api/notifications/NotificationAPI').NotificationOptions} [notificationOptions] additional options
|
||||||
|
*/
|
||||||
|
|
||||||
const Buffer = require('buffer').Buffer;
|
const Buffer = require('buffer').Buffer;
|
||||||
const genUuid = require('uuid').v4;
|
const genUuid = require('uuid').v4;
|
||||||
|
|
||||||
@ -112,12 +120,33 @@ async function createDomainObjectWithDefaults(page, { type, name, parent = 'mine
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a notification with the given options.
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {CreateNotificationOptions} createNotificationOptions
|
||||||
|
*/
|
||||||
|
async function createNotification(page, createNotificationOptions) {
|
||||||
|
await page.evaluate((_createNotificationOptions) => {
|
||||||
|
const { message, severity, options } = _createNotificationOptions;
|
||||||
|
const notificationApi = window.openmct.notifications;
|
||||||
|
if (severity === 'info') {
|
||||||
|
notificationApi.info(message, options);
|
||||||
|
} else if (severity === 'alert') {
|
||||||
|
notificationApi.alert(message, options);
|
||||||
|
} else {
|
||||||
|
notificationApi.error(message, options);
|
||||||
|
}
|
||||||
|
}, createNotificationOptions);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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.locator('#tree-pane');
|
const treePane = page.getByRole('tree', {
|
||||||
|
name: 'Main Tree'
|
||||||
|
});
|
||||||
const treeItem = treePane.locator(`role=treeitem[expanded=false][name=/${name}/]`);
|
const treeItem = treePane.locator(`role=treeitem[expanded=false][name=/${name}/]`);
|
||||||
const expandTriangle = treeItem.locator('.c-disclosure-triangle');
|
const expandTriangle = treeItem.locator('.c-disclosure-triangle');
|
||||||
await expandTriangle.click();
|
await expandTriangle.click();
|
||||||
@ -191,6 +220,30 @@ async function openObjectTreeContextMenu(page, url) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the UUID of the currently focused object by parsing the current URL
|
* Gets the UUID of the currently focused object by parsing the current URL
|
||||||
* and returning the last UUID in the path.
|
* and returning the last UUID in the path.
|
||||||
@ -333,7 +386,9 @@ async function setEndOffset(page, offset) {
|
|||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
module.exports = {
|
module.exports = {
|
||||||
createDomainObjectWithDefaults,
|
createDomainObjectWithDefaults,
|
||||||
|
createNotification,
|
||||||
expandTreePaneItemByName,
|
expandTreePaneItemByName,
|
||||||
|
expandEntireTree,
|
||||||
createPlanFromJSON,
|
createPlanFromJSON,
|
||||||
openObjectTreeContextMenu,
|
openObjectTreeContextMenu,
|
||||||
getHashUrlToDomainObject,
|
getHashUrlToDomainObject,
|
||||||
|
27
e2e/helper/addInitExampleUser.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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());
|
||||||
|
});
|
76
e2e/helper/addInitFileInputObject.js
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
class DomainObjectViewProvider {
|
||||||
|
constructor(openmct) {
|
||||||
|
this.key = 'doViewProvider';
|
||||||
|
this.name = 'Domain Object View Provider';
|
||||||
|
this.openmct = openmct;
|
||||||
|
}
|
||||||
|
|
||||||
|
canView(domainObject) {
|
||||||
|
return domainObject.type === 'imageFileInput'
|
||||||
|
|| domainObject.type === 'jsonFileInput';
|
||||||
|
}
|
||||||
|
|
||||||
|
view(domainObject, objectPath) {
|
||||||
|
let content;
|
||||||
|
|
||||||
|
return {
|
||||||
|
show: function (element) {
|
||||||
|
const body = domainObject.selectFile.body;
|
||||||
|
const type = typeof body;
|
||||||
|
|
||||||
|
content = document.createElement('div');
|
||||||
|
content.id = 'file-input-type';
|
||||||
|
content.textContent = JSON.stringify(type);
|
||||||
|
element.appendChild(content);
|
||||||
|
},
|
||||||
|
destroy: function (element) {
|
||||||
|
element.removeChild(content);
|
||||||
|
content = undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const openmct = window.openmct;
|
||||||
|
|
||||||
|
openmct.types.addType('jsonFileInput', {
|
||||||
|
key: 'jsonFileInput',
|
||||||
|
name: "JSON File Input Object",
|
||||||
|
creatable: true,
|
||||||
|
form: [
|
||||||
|
{
|
||||||
|
name: 'Upload File',
|
||||||
|
key: 'selectFile',
|
||||||
|
control: 'file-input',
|
||||||
|
required: true,
|
||||||
|
text: 'Select File...',
|
||||||
|
type: 'application/json',
|
||||||
|
property: [
|
||||||
|
"selectFile"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
openmct.types.addType('imageFileInput', {
|
||||||
|
key: 'imageFileInput',
|
||||||
|
name: "Image File Input Object",
|
||||||
|
creatable: true,
|
||||||
|
form: [
|
||||||
|
{
|
||||||
|
name: 'Upload File',
|
||||||
|
key: 'selectFile',
|
||||||
|
control: 'file-input',
|
||||||
|
required: true,
|
||||||
|
text: 'Select File...',
|
||||||
|
type: 'image/*',
|
||||||
|
property: [
|
||||||
|
"selectFile"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
openmct.objectViews.addProvider(new DomainObjectViewProvider(openmct));
|
||||||
|
});
|
32
e2e/helper/addInitNotebookWithUrls.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
// This 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));
|
||||||
|
});
|
27
e2e/helper/addInitOperatorStatus.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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());
|
||||||
|
});
|
51
e2e/playwright-a11y.config.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/* eslint-disable no-undef */
|
||||||
|
// playwright.config.js
|
||||||
|
// @ts-check
|
||||||
|
|
||||||
|
/** @type {import('@playwright/test').PlaywrightTestConfig<{ theme: string }>} */
|
||||||
|
const config = {
|
||||||
|
retries: 0, // Visual tests should never retry due to snapshot comparison errors. Leaving as a shim
|
||||||
|
testDir: 'tests/a11y',
|
||||||
|
testMatch: '**/*.a11y.spec.js', // only run visual tests
|
||||||
|
timeout: 60 * 1000,
|
||||||
|
workers: 1, //Lower stress on Circle CI Agent for Visual tests https://github.com/percy/cli/discussions/1067
|
||||||
|
webServer: {
|
||||||
|
command: 'npm run start:coverage',
|
||||||
|
url: 'http://localhost:8080/#',
|
||||||
|
timeout: 200 * 1000,
|
||||||
|
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'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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: 'never',
|
||||||
|
outputFolder: '../html-test-results' //Must be in different location due to https://github.com/microsoft/playwright/issues/12840
|
||||||
|
}]
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = config;
|
@ -73,7 +73,7 @@ const config = {
|
|||||||
open: 'never',
|
open: 'never',
|
||||||
outputFolder: '../html-test-results' //Must be in different location due to https://github.com/microsoft/playwright/issues/12840
|
outputFolder: '../html-test-results' //Must be in different location due to https://github.com/microsoft/playwright/issues/12840
|
||||||
}],
|
}],
|
||||||
['junit', { outputFile: 'test-results/results.xml' }],
|
['junit', { outputFile: '../test-results/results.xml' }],
|
||||||
['github']
|
['github']
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
@ -35,8 +35,8 @@ const config = {
|
|||||||
],
|
],
|
||||||
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' }]
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ const config = {
|
|||||||
],
|
],
|
||||||
reporter: [
|
reporter: [
|
||||||
['list'],
|
['list'],
|
||||||
['junit', { outputFile: 'test-results/results.xml' }],
|
['junit', { outputFile: '../test-results/results.xml' }],
|
||||||
['html', {
|
['html', {
|
||||||
open: 'on-failure',
|
open: 'on-failure',
|
||||||
outputFolder: '../html-test-results' //Must be in different location due to https://github.com/microsoft/playwright/issues/12840
|
outputFolder: '../html-test-results' //Must be in different location due to https://github.com/microsoft/playwright/issues/12840
|
||||||
|
BIN
e2e/test-data/rick.jpg
Normal file
After Width: | Height: | Size: 10 KiB |
129
e2e/tests/a11y/default.a11y.spec.js
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
const { test, expect } = require('../../pluginFixtures');
|
||||||
|
const { createDomainObjectWithDefaults, expandTreePaneItemByName } = require('../../appActions');
|
||||||
|
const { injectAxe, checkA11y, getViolations, reportViolations } = require('axe-playwright');
|
||||||
|
const { createHtmlReport } = require('axe-html-reporter');
|
||||||
|
const AxeBuilder = require('@axe-core/playwright').default; // 1
|
||||||
|
|
||||||
|
test.describe('Visual - Default', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
//Go to baseURL and Hide Tree
|
||||||
|
await page.goto('./#/browse/mine?hideTree=true', { waitUntil: 'networkidle' });
|
||||||
|
await injectAxe(page);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.only('axe-playwright - basic reporting', async ({ page, theme }) => {
|
||||||
|
// Verify that Create button is actionable
|
||||||
|
await expect(page.locator('button:has-text("Create")')).toBeEnabled();
|
||||||
|
|
||||||
|
await checkA11y(page, null, {
|
||||||
|
detailedReport: true,
|
||||||
|
detailedReportOptions: { html: true }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('axe-playwright - notebook', async ({ page, theme, openmctConfig }) => {
|
||||||
|
const { myItemsFolderName } = openmctConfig;
|
||||||
|
|
||||||
|
// Create Notebook
|
||||||
|
const notebook = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Notebook',
|
||||||
|
name: "Embed Test Notebook"
|
||||||
|
});
|
||||||
|
// Create Overlay Plot
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Overlay Plot',
|
||||||
|
name: "Dropped Overlay Plot"
|
||||||
|
});
|
||||||
|
|
||||||
|
await expandTreePaneItemByName(page, myItemsFolderName);
|
||||||
|
|
||||||
|
await page.goto(notebook.url);
|
||||||
|
await page.dragAndDrop('role=treeitem[name=/Dropped Overlay Plot/]', '.c-notebook__drag-area');
|
||||||
|
|
||||||
|
await percySnapshot(page, `Notebook w/ dropped embed (theme: ${theme})`);
|
||||||
|
|
||||||
|
await checkA11y(page, null, {
|
||||||
|
detailedReport: true,
|
||||||
|
detailedReportOptions: { html: true }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('axe-playwright - html reporting with wcag2aa rules 2', async ({ page, theme }) => {
|
||||||
|
// Verify that Create button is actionable
|
||||||
|
await expect(page.locator('button:has-text("Create")')).toBeEnabled();
|
||||||
|
|
||||||
|
await checkA11y(page, null,
|
||||||
|
{
|
||||||
|
axeOptions: {
|
||||||
|
runOnly: {
|
||||||
|
type: 'tag',
|
||||||
|
values: ['wcag2aa']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true, 'default',
|
||||||
|
{
|
||||||
|
outputDirPath: './results',
|
||||||
|
outputDir: 'accessibility',
|
||||||
|
reportFileName: 'accessibility-audit.html'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('axe-playwright - html reporting with wcag2aa rules', async ({ page, theme }) => {
|
||||||
|
// Verify that Create button is actionable
|
||||||
|
await expect(page.locator('button:has-text("Create")')).toBeEnabled();
|
||||||
|
|
||||||
|
await checkA11y(page, null,
|
||||||
|
{
|
||||||
|
axeOptions: {
|
||||||
|
runOnly: {
|
||||||
|
type: 'tag',
|
||||||
|
values: ['wcag2aa']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true, 'default',
|
||||||
|
{ reporter: 'html' }
|
||||||
|
);
|
||||||
|
await createHtmlReport(
|
||||||
|
{ results: { violations: args.violations } }
|
||||||
|
);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
test('axeBuilder - should not have any automatically detectable accessibility issues', async ({ page }, testInfo) => {
|
||||||
|
|
||||||
|
const accessibilityScanResults = await new AxeBuilder({ page }).withTags(['wcag2aa']).analyze(); // 4
|
||||||
|
|
||||||
|
await testInfo.attach('accessibility-scan-results', {
|
||||||
|
body: JSON.stringify(accessibilityScanResults, null, 2),
|
||||||
|
contentType: 'application/json'
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(accessibilityScanResults.violations).toEqual([]); // 5
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -21,7 +21,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
const { test, expect } = require('../../pluginFixtures.js');
|
const { test, expect } = require('../../pluginFixtures.js');
|
||||||
const { createDomainObjectWithDefaults } = require('../../appActions.js');
|
const { createDomainObjectWithDefaults, createNotification, expandEntireTree } = require('../../appActions.js');
|
||||||
|
|
||||||
test.describe('AppActions', () => {
|
test.describe('AppActions', () => {
|
||||||
test('createDomainObjectsWithDefaults', async ({ page }) => {
|
test('createDomainObjectsWithDefaults', async ({ page }) => {
|
||||||
@ -49,11 +49,11 @@ test.describe('AppActions', () => {
|
|||||||
parent: e2eFolder.uuid
|
parent: e2eFolder.uuid
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.goto(timer1.url, { waitUntil: 'networkidle' });
|
await page.goto(timer1.url);
|
||||||
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, { waitUntil: 'networkidle' });
|
await page.goto(timer2.url);
|
||||||
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, { waitUntil: 'networkidle' });
|
await page.goto(timer3.url);
|
||||||
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer3.name);
|
await expect(page.locator('.l-browse-bar__object-name')).toHaveText(timer3.name);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -73,11 +73,11 @@ test.describe('AppActions', () => {
|
|||||||
name: 'Folder Baz',
|
name: 'Folder Baz',
|
||||||
parent: folder2.uuid
|
parent: folder2.uuid
|
||||||
});
|
});
|
||||||
await page.goto(folder1.url, { waitUntil: 'networkidle' });
|
await page.goto(folder1.url);
|
||||||
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, { waitUntil: 'networkidle' });
|
await page.goto(folder2.url);
|
||||||
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, { waitUntil: 'networkidle' });
|
await page.goto(folder3.url);
|
||||||
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}`);
|
||||||
@ -85,4 +85,81 @@ test.describe('AppActions', () => {
|
|||||||
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 }) => {
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
await createNotification(page, {
|
||||||
|
message: 'Test info notification',
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
test('expandEntireTree', async ({ page }) => {
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
const { test, expect } = require('../../pluginFixtures');
|
const { test, expect } = require('../../pluginFixtures');
|
||||||
|
|
||||||
test.describe("CouchDB Status Indicator @couchdb", () => {
|
test.describe("CouchDB Status Indicator with mocked responses @couchdb", () => {
|
||||||
test.use({ failOnConsoleError: false });
|
test.use({ failOnConsoleError: false });
|
||||||
//TODO BeforeAll Verify CouchDB Connectivity with APIContext
|
//TODO BeforeAll Verify CouchDB Connectivity with APIContext
|
||||||
test('Shows green if connected', async ({ page }) => {
|
test('Shows green if connected', async ({ page }) => {
|
||||||
@ -71,38 +71,41 @@ test.describe("CouchDB Status Indicator @couchdb", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe("CouchDB initialization @couchdb", () => {
|
test.describe("CouchDB initialization with mocked responses @couchdb", () => {
|
||||||
test.use({ failOnConsoleError: false });
|
test.use({ failOnConsoleError: false });
|
||||||
test("'My Items' folder is created if it doesn't exist", async ({ page }) => {
|
test("'My Items' folder is created if it doesn't exist", async ({ page }) => {
|
||||||
// Store any relevant PUT requests that happen on the page
|
const mockedMissingObjectResponsefromCouchDB = {
|
||||||
const createMineFolderRequests = [];
|
|
||||||
page.on('request', req => {
|
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
if (req.method() === 'PUT' && req.url().endsWith('openmct/mine')) {
|
|
||||||
createMineFolderRequests.push(req);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Override the first request to GET openmct/mine to return a 404
|
|
||||||
await page.route('**/openmct/mine', route => {
|
|
||||||
route.fulfill({
|
|
||||||
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.
|
||||||
|
// This simulates the case of starting Open MCT with a fresh database
|
||||||
|
// and no "My Items" folder created yet.
|
||||||
|
await page.route('**/mine', route => {
|
||||||
|
route.fulfill(mockedMissingObjectResponsefromCouchDB);
|
||||||
}, { times: 1 });
|
}, { times: 1 });
|
||||||
|
|
||||||
// Go to baseURL
|
// Set up promise to verify that a PUT request to create "My Items"
|
||||||
|
// folder was made.
|
||||||
|
const putMineFolderRequest = page.waitForRequest(req =>
|
||||||
|
req.url().endsWith('/mine')
|
||||||
|
&& req.method() === 'PUT');
|
||||||
|
|
||||||
|
// Set up promise to verify that a GET request to retrieve "My Items"
|
||||||
|
// folder was made.
|
||||||
|
const getMineFolderRequest = page.waitForRequest(req =>
|
||||||
|
req.url().endsWith('/mine')
|
||||||
|
&& req.method() === 'GET');
|
||||||
|
|
||||||
|
// Go to baseURL.
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
// Verify that error banner is displayed
|
// Wait for both requests to resolve.
|
||||||
const bannerMessage = await page.locator('.c-message-banner__message').innerText();
|
await Promise.all([
|
||||||
expect(bannerMessage).toEqual('Failed to retrieve object mine');
|
putMineFolderRequest,
|
||||||
|
getMineFolderRequest
|
||||||
// Verify that a PUT request to create "My Items" folder was made
|
]);
|
||||||
await expect.poll(() => createMineFolderRequests.length, {
|
|
||||||
message: 'Verify that PUT request to create "mine" folder was made',
|
|
||||||
timeout: 1000
|
|
||||||
}).toBeGreaterThanOrEqual(1);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -24,11 +24,14 @@
|
|||||||
This test suite is dedicated to tests which verify form functionality in isolation
|
This test suite is dedicated to tests which verify form functionality in isolation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { test, expect } = require('../../baseFixtures');
|
const { test, expect } = require('../../pluginFixtures');
|
||||||
const { createDomainObjectWithDefaults } = require('../../appActions');
|
const { createDomainObjectWithDefaults } = require('../../appActions');
|
||||||
|
const genUuid = require('uuid').v4;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const TEST_FOLDER = 'test folder';
|
const TEST_FOLDER = 'test folder';
|
||||||
|
const jsonFilePath = 'e2e/test-data/ExampleLayouts.json';
|
||||||
|
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 ({ page }) => {
|
test('Required Field indicators appear if title is empty and can be corrected', async ({ page }) => {
|
||||||
@ -67,6 +70,41 @@ test.describe('Form Validation Behavior', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test.describe('Form File Input Behavior', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
await page.addInitScript({ path: path.join(__dirname, '../../helper', 'addInitFileInputObject.js') });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Can select a JSON file type', async ({ page }) => {
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: ' Create ' }).click();
|
||||||
|
await page.getByRole('menuitem', { name: 'JSON File Input Object' }).click();
|
||||||
|
|
||||||
|
await page.setInputFiles('#fileElem', jsonFilePath);
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'Save' }).click();
|
||||||
|
|
||||||
|
const type = await page.locator('#file-input-type').textContent();
|
||||||
|
await expect(type).toBe(`"string"`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Can select an image file type', async ({ page }) => {
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: ' Create ' }).click();
|
||||||
|
await page.getByRole('menuitem', { name: 'Image File Input Object' }).click();
|
||||||
|
|
||||||
|
await page.setInputFiles('#fileElem', imageFilePath);
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'Save' }).click();
|
||||||
|
|
||||||
|
const type = await page.locator('#file-input-type').textContent();
|
||||||
|
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 }) => {
|
||||||
@ -128,6 +166,108 @@ test.describe('Persistence operations @couchdb', () => {
|
|||||||
timeout: 1000
|
timeout: 1000
|
||||||
}).toEqual(1);
|
}).toEqual(1);
|
||||||
});
|
});
|
||||||
|
test('Can create an object after a conflict error @couchdb @2p', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/5982'
|
||||||
|
});
|
||||||
|
|
||||||
|
const page2 = await page.context().newPage();
|
||||||
|
|
||||||
|
// Both pages: Go to baseURL
|
||||||
|
await Promise.all([
|
||||||
|
page.goto('./', { waitUntil: 'networkidle' }),
|
||||||
|
page2.goto('./', { waitUntil: 'networkidle' })
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Both pages: Click the Create button
|
||||||
|
await Promise.all([
|
||||||
|
page.click('button:has-text("Create")'),
|
||||||
|
page2.click('button:has-text("Create")')
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Both pages: Click "Clock" in the Create menu
|
||||||
|
await Promise.all([
|
||||||
|
page.click(`li[role='menuitem']:text("Clock")`),
|
||||||
|
page2.click(`li[role='menuitem']:text("Clock")`)
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Generate unique names for both objects
|
||||||
|
const nameInput = page.locator('form[name="mctForm"] .first input[type="text"]');
|
||||||
|
const nameInput2 = page2.locator('form[name="mctForm"] .first input[type="text"]');
|
||||||
|
|
||||||
|
// Both pages: Fill in the 'Name' form field.
|
||||||
|
await Promise.all([
|
||||||
|
nameInput.fill(""),
|
||||||
|
nameInput.fill(`Clock:${genUuid()}`),
|
||||||
|
nameInput2.fill(""),
|
||||||
|
nameInput2.fill(`Clock:${genUuid()}`)
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Both pages: Fill the "Notes" section with information about the
|
||||||
|
// currently running test and its project.
|
||||||
|
const testNotes = page.testNotes;
|
||||||
|
const notesInput = page.locator('form[name="mctForm"] #notes-textarea');
|
||||||
|
const notesInput2 = page2.locator('form[name="mctForm"] #notes-textarea');
|
||||||
|
await Promise.all([
|
||||||
|
notesInput.fill(testNotes),
|
||||||
|
notesInput2.fill(testNotes)
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Page 2: Click "OK" to create the domain object and wait for navigation.
|
||||||
|
// This will update the composition of the parent folder, setting the
|
||||||
|
// conditions for a conflict error from the first page.
|
||||||
|
await Promise.all([
|
||||||
|
page2.waitForLoadState(),
|
||||||
|
page2.click('[aria-label="Save"]'),
|
||||||
|
// Wait for Save Banner to appear
|
||||||
|
page2.waitForSelector('.c-message-banner__message')
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Close Page 2, we're done with it.
|
||||||
|
await page2.close();
|
||||||
|
|
||||||
|
// Page 1: Click "OK" to create the domain object and wait for navigation.
|
||||||
|
// This will trigger a conflict error upon attempting to update
|
||||||
|
// the composition of the parent folder.
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForLoadState(),
|
||||||
|
page.click('[aria-label="Save"]'),
|
||||||
|
// Wait for Save Banner to appear
|
||||||
|
page.waitForSelector('.c-message-banner__message')
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Page 1: Verify that the conflict has occurred and an error notification is displayed.
|
||||||
|
await expect(page.locator('.c-message-banner__message', {
|
||||||
|
hasText: "Conflict detected while saving mine"
|
||||||
|
})).toBeVisible();
|
||||||
|
|
||||||
|
// Page 1: Start logging console errors from this point on
|
||||||
|
let errors = [];
|
||||||
|
page.on('console', (msg) => {
|
||||||
|
if (msg.type() === 'error') {
|
||||||
|
errors.push(msg.text());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Page 1: Try to create a clock with the page that received the conflict.
|
||||||
|
const clockAfterConflict = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Clock'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Page 1: Wait for save progress dialog to appear/disappear
|
||||||
|
await page.locator('.c-message-banner__message', {
|
||||||
|
hasText: 'Do not navigate away from this page or close this browser tab while this message is displayed.',
|
||||||
|
state: 'visible'
|
||||||
|
}).waitFor({ state: 'hidden' });
|
||||||
|
|
||||||
|
// Page 1: Navigate to 'My Items' and verify that the second clock was created
|
||||||
|
await page.goto('./#/browse/mine');
|
||||||
|
await expect(page.locator(`.c-grid-item__name[title="${clockAfterConflict.name}"]`)).toBeVisible();
|
||||||
|
|
||||||
|
// Verify no console errors occurred
|
||||||
|
expect(errors).toHaveLength(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe('Form Correctness by Object Type', () => {
|
test.describe('Form Correctness by Object Type', () => {
|
||||||
|
@ -43,48 +43,80 @@ test.describe('Move & link item tests', () => {
|
|||||||
name: 'Child Folder',
|
name: 'Child Folder',
|
||||||
parent: parentFolder.uuid
|
parent: parentFolder.uuid
|
||||||
});
|
});
|
||||||
await createDomainObjectWithDefaults(page, {
|
const grandchildFolder = await createDomainObjectWithDefaults(page, {
|
||||||
type: 'Folder',
|
type: 'Folder',
|
||||||
name: 'Grandchild Folder',
|
name: 'Grandchild Folder',
|
||||||
parent: childFolder.uuid
|
parent: childFolder.uuid
|
||||||
});
|
});
|
||||||
|
|
||||||
// Attempt to move parent to its own grandparent
|
// Attempt to move parent to its own grandparent
|
||||||
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
|
await page.locator('button[title="Show selected item in tree"]').click();
|
||||||
await page.locator('.c-disclosure-triangle >> nth=0').click();
|
|
||||||
|
|
||||||
await page.locator(`a:has-text("Parent Folder") >> nth=0`).click({
|
const treePane = page.getByRole('tree', {
|
||||||
|
name: 'Main Tree'
|
||||||
|
});
|
||||||
|
await treePane.getByRole('treeitem', {
|
||||||
|
name: 'Parent Folder'
|
||||||
|
}).click({
|
||||||
button: 'right'
|
button: 'right'
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.locator('li.icon-move').click();
|
await page.getByRole('menuitem', {
|
||||||
await page.locator('form[name="mctForm"] >> .c-disclosure-triangle >> nth=0').click();
|
name: /Move/
|
||||||
await page.locator('form[name="mctForm"] >> text=Parent Folder').click();
|
}).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();
|
await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
|
||||||
await page.locator('form[name="mctForm"] >> .c-disclosure-triangle >> nth=1').click();
|
|
||||||
await page.locator('form[name="mctForm"] >> text=Child Folder').click();
|
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();
|
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();
|
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 expect(page.locator('[aria-label="Save"]')).toBeDisabled();
|
||||||
await page.locator('form[name="mctForm"] >> text=Parent Folder').click();
|
|
||||||
|
await parentFolderLocatorTreeItem.click();
|
||||||
await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
|
await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
|
||||||
await page.locator('[aria-label="Cancel"]').click();
|
await page.locator('[aria-label="Cancel"]').click();
|
||||||
|
|
||||||
// Move Child Folder from Parent Folder to My Items
|
// Move Child Folder from Parent Folder to My Items
|
||||||
await page.locator('.c-disclosure-triangle >> nth=0').click();
|
await treePane.getByRole('treeitem', {
|
||||||
await page.locator('.c-disclosure-triangle >> nth=1').click();
|
name: new RegExp(childFolder.name)
|
||||||
|
}).click({
|
||||||
await page.locator(`a:has-text("Child Folder") >> nth=0`).click({
|
|
||||||
button: 'right'
|
button: 'right'
|
||||||
});
|
});
|
||||||
await page.locator('li.icon-move').click();
|
await page.getByRole('menuitem', {
|
||||||
await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
|
name: /Move/
|
||||||
|
}).click();
|
||||||
|
await myItemsLocatorTreeItem.click();
|
||||||
|
|
||||||
await page.locator('button:has-text("OK")').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 that Child Folder is in My Items, the root folder
|
||||||
expect(page.locator(`text=${myItemsFolderName} >> nth=0:has(text=Child Folder)`)).toBeTruthy();
|
expect(myItemsPaneTreeItem.locator('nth=0:has(text=Child Folder)')).toBeTruthy();
|
||||||
});
|
});
|
||||||
test('Create a basic object and verify that it cannot be moved to telemetry object without Composition Provider', async ({ page, openmctConfig }) => {
|
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 { myItemsFolderName } = openmctConfig;
|
||||||
@ -114,7 +146,7 @@ test.describe('Move & link item tests', () => {
|
|||||||
|
|
||||||
// See if it's possible to put the folder in the Telemetry object during creation (Soft Assert)
|
// 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.locator(`form[name="mctForm"] >> text=${telemetryTable}`).click();
|
||||||
let okButton = await page.locator('button.c-button.c-button--major:has-text("OK")');
|
let okButton = page.locator('button.c-button.c-button--major:has-text("OK")');
|
||||||
let okButtonStateDisabled = await okButton.isDisabled();
|
let okButtonStateDisabled = await okButton.isDisabled();
|
||||||
expect.soft(okButtonStateDisabled).toBeTruthy();
|
expect.soft(okButtonStateDisabled).toBeTruthy();
|
||||||
|
|
||||||
@ -138,7 +170,7 @@ test.describe('Move & link item tests', () => {
|
|||||||
// See if it's possible to put the folder in the Telemetry object after creation
|
// See if it's possible to put the folder in the Telemetry object after creation
|
||||||
await page.locator(`text=Location Open MCT ${myItemsFolderName} >> span`).nth(3).click();
|
await page.locator(`text=Location Open MCT ${myItemsFolderName} >> span`).nth(3).click();
|
||||||
await page.locator(`form[name="mctForm"] >> text=${telemetryTable}`).click();
|
await page.locator(`form[name="mctForm"] >> text=${telemetryTable}`).click();
|
||||||
let okButton2 = await page.locator('button.c-button.c-button--major:has-text("OK")');
|
let okButton2 = page.locator('button.c-button.c-button--major:has-text("OK")');
|
||||||
let okButtonStateDisabled2 = await okButton2.isDisabled();
|
let okButtonStateDisabled2 = await okButton2.isDisabled();
|
||||||
expect(okButtonStateDisabled2).toBeTruthy();
|
expect(okButtonStateDisabled2).toBeTruthy();
|
||||||
});
|
});
|
||||||
@ -158,48 +190,80 @@ test.describe('Move & link item tests', () => {
|
|||||||
name: 'Child Folder',
|
name: 'Child Folder',
|
||||||
parent: parentFolder.uuid
|
parent: parentFolder.uuid
|
||||||
});
|
});
|
||||||
await createDomainObjectWithDefaults(page, {
|
const grandchildFolder = await createDomainObjectWithDefaults(page, {
|
||||||
type: 'Folder',
|
type: 'Folder',
|
||||||
name: 'Grandchild Folder',
|
name: 'Grandchild Folder',
|
||||||
parent: childFolder.uuid
|
parent: childFolder.uuid
|
||||||
});
|
});
|
||||||
|
|
||||||
// Attempt to link parent to its own grandparent
|
// Attempt to move parent to its own grandparent
|
||||||
await page.locator(`text=Open MCT ${myItemsFolderName} >> span`).nth(3).click();
|
await page.locator('button[title="Show selected item in tree"]').click();
|
||||||
await page.locator('.c-disclosure-triangle >> nth=0').click();
|
|
||||||
|
|
||||||
await page.locator(`a:has-text("Parent Folder") >> nth=0`).click({
|
const treePane = page.getByRole('tree', {
|
||||||
|
name: 'Main Tree'
|
||||||
|
});
|
||||||
|
await treePane.getByRole('treeitem', {
|
||||||
|
name: 'Parent Folder'
|
||||||
|
}).click({
|
||||||
button: 'right'
|
button: 'right'
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.locator('li.icon-link').click();
|
await page.getByRole('menuitem', {
|
||||||
await page.locator('form[name="mctForm"] >> .c-disclosure-triangle >> nth=0').click();
|
name: /Move/
|
||||||
await page.locator('form[name="mctForm"] >> text=Parent Folder').click();
|
}).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();
|
await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
|
||||||
await page.locator('form[name="mctForm"] >> .c-disclosure-triangle >> nth=1').click();
|
|
||||||
await page.locator('form[name="mctForm"] >> text=Child Folder').click();
|
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();
|
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();
|
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 expect(page.locator('[aria-label="Save"]')).toBeDisabled();
|
||||||
await page.locator('form[name="mctForm"] >> text=Parent Folder').click();
|
|
||||||
|
await parentFolderLocatorTreeItem.click();
|
||||||
await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
|
await expect(page.locator('[aria-label="Save"]')).toBeDisabled();
|
||||||
await page.locator('[aria-label="Cancel"]').click();
|
await page.locator('[aria-label="Cancel"]').click();
|
||||||
|
|
||||||
// Link Child Folder from Parent Folder to My Items
|
// Move Child Folder from Parent Folder to My Items
|
||||||
await page.locator('.c-disclosure-triangle >> nth=0').click();
|
await treePane.getByRole('treeitem', {
|
||||||
await page.locator('.c-disclosure-triangle >> nth=1').click();
|
name: new RegExp(childFolder.name)
|
||||||
|
}).click({
|
||||||
await page.locator(`a:has-text("Child Folder") >> nth=0`).click({
|
|
||||||
button: 'right'
|
button: 'right'
|
||||||
});
|
});
|
||||||
await page.locator('li.icon-link').click();
|
await page.getByRole('menuitem', {
|
||||||
await page.locator(`form[name="mctForm"] >> text=${myItemsFolderName}`).click();
|
name: /Link/
|
||||||
|
}).click();
|
||||||
|
await myItemsLocatorTreeItem.click();
|
||||||
|
|
||||||
await page.locator('button:has-text("OK")').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 that Child Folder is in My Items, the root folder
|
||||||
expect(page.locator(`text=${myItemsFolderName} >> nth=0:has(text=Child Folder)`)).toBeTruthy();
|
expect(myItemsPaneTreeItem.locator('nth=0:has(text=Child Folder)')).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
112
e2e/tests/functional/notification.e2e.spec.js
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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 Open MCT's Notification functionality
|
||||||
|
*/
|
||||||
|
|
||||||
|
const { createDomainObjectWithDefaults, createNotification } = require('../../appActions');
|
||||||
|
const { test, expect } = require('../../pluginFixtures');
|
||||||
|
|
||||||
|
test.describe('Notifications List', () => {
|
||||||
|
test('Notifications can be dismissed individually', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/6122'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Go to baseURL
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
// 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: 'networkidle' });
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
});
|
||||||
|
});
|
@ -98,8 +98,8 @@ test.describe.serial('Condition Set CRUD Operations on @localStorage', () => {
|
|||||||
await page.locator('text=Conditions View Snapshot >> button').nth(3).click();
|
await page.locator('text=Conditions View Snapshot >> button').nth(3).click();
|
||||||
|
|
||||||
//Edit Condition Set Name from main view
|
//Edit Condition Set Name from main view
|
||||||
await page.locator('text=Unnamed Condition Set').first().fill('Renamed Condition Set');
|
await page.locator('.l-browse-bar__object-name').filter({ hasText: 'Unnamed Condition Set' }).first().fill('Renamed Condition Set');
|
||||||
await page.locator('text=Renamed Condition Set').first().press('Enter');
|
await page.locator('.l-browse-bar__object-name').filter({ hasText: 'Renamed Condition Set' }).first().press('Enter');
|
||||||
// Click Save Button
|
// Click Save Button
|
||||||
await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1).click();
|
await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1).click();
|
||||||
// Click Save and Finish Editing Option
|
// Click Save and Finish Editing Option
|
||||||
@ -181,10 +181,11 @@ test.describe.serial('Condition Set CRUD Operations on @localStorage', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test.describe('Basic Condition Set Use', () => {
|
test.describe('Basic Condition Set Use', () => {
|
||||||
test('Can add a condition', async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
//Navigate to baseURL
|
// Open a browser, navigate to the main page, and wait until all network events to resolve
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
});
|
||||||
|
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',
|
||||||
@ -199,4 +200,50 @@ test.describe('Basic Condition Set Use', () => {
|
|||||||
const numOfUnnamedConditions = await page.locator('text=Unnamed Condition').count();
|
const numOfUnnamedConditions = await page.locator('text=Unnamed Condition').count();
|
||||||
expect(numOfUnnamedConditions).toEqual(1);
|
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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -24,6 +24,7 @@ const { test, expect } = require('../../../../pluginFixtures');
|
|||||||
const { createDomainObjectWithDefaults, setStartOffset, setFixedTimeMode, setRealTimeMode } = require('../../../../appActions');
|
const { createDomainObjectWithDefaults, setStartOffset, setFixedTimeMode, setRealTimeMode } = 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: 'networkidle' });
|
||||||
@ -31,8 +32,7 @@ test.describe('Display Layout', () => {
|
|||||||
|
|
||||||
// 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 ({ page }) => {
|
||||||
@ -47,7 +47,14 @@ test.describe('Display Layout', () => {
|
|||||||
// 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
|
||||||
await page.dragAndDrop('text=Test Sine Wave Generator', '.l-layout__grid-holder');
|
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('button[title="Save"]').click();
|
||||||
await page.locator('text=Save and Finish Editing').click();
|
await page.locator('text=Save and Finish Editing').click();
|
||||||
|
|
||||||
@ -74,7 +81,14 @@ test.describe('Display Layout', () => {
|
|||||||
// 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
|
||||||
await page.dragAndDrop('text=Test Sine Wave Generator', '.l-layout__grid-holder');
|
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('button[title="Save"]').click();
|
||||||
await page.locator('text=Save and Finish Editing').click();
|
await page.locator('text=Save and Finish Editing').click();
|
||||||
|
|
||||||
@ -105,7 +119,14 @@ test.describe('Display Layout', () => {
|
|||||||
// 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
|
||||||
await page.dragAndDrop('text=Test Sine Wave Generator', '.l-layout__grid-holder');
|
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('button[title="Save"]').click();
|
||||||
await page.locator('text=Save and Finish Editing').click();
|
await page.locator('text=Save and Finish Editing').click();
|
||||||
|
|
||||||
@ -115,7 +136,7 @@ test.describe('Display Layout', () => {
|
|||||||
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
|
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
|
||||||
|
|
||||||
// Bring up context menu and remove
|
// Bring up context menu and remove
|
||||||
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').first().click({ button: 'right' });
|
await sineWaveGeneratorTreeItem.nth(1).click({ button: 'right' });
|
||||||
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||||
await page.locator('button:has-text("OK")').click();
|
await page.locator('button:has-text("OK")').click();
|
||||||
|
|
||||||
@ -130,8 +151,7 @@ test.describe('Display Layout', () => {
|
|||||||
});
|
});
|
||||||
// Create a Display Layout
|
// Create a Display Layout
|
||||||
const displayLayout = await createDomainObjectWithDefaults(page, {
|
const displayLayout = await createDomainObjectWithDefaults(page, {
|
||||||
type: 'Display Layout',
|
type: 'Display Layout'
|
||||||
name: "Test Display Layout"
|
|
||||||
});
|
});
|
||||||
// Edit Display Layout
|
// Edit Display Layout
|
||||||
await page.locator('[title="Edit"]').click();
|
await page.locator('[title="Edit"]').click();
|
||||||
@ -139,7 +159,14 @@ test.describe('Display Layout', () => {
|
|||||||
// 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
|
||||||
await page.dragAndDrop('text=Test Sine Wave Generator', '.l-layout__grid-holder');
|
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('button[title="Save"]').click();
|
||||||
await page.locator('text=Save and Finish Editing').click();
|
await page.locator('text=Save and Finish Editing').click();
|
||||||
|
|
||||||
@ -152,7 +179,7 @@ test.describe('Display Layout', () => {
|
|||||||
await page.goto(sineWaveObject.url);
|
await page.goto(sineWaveObject.url);
|
||||||
|
|
||||||
// Bring up context menu and remove
|
// Bring up context menu and remove
|
||||||
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').click({ button: 'right' });
|
await sineWaveGeneratorTreeItem.first().click({ button: 'right' });
|
||||||
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||||
await page.locator('button:has-text("OK")').click();
|
await page.locator('button:has-text("OK")').click();
|
||||||
|
|
||||||
|
@ -25,26 +25,33 @@ const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
|||||||
|
|
||||||
test.describe('Flexible Layout', () => {
|
test.describe('Flexible Layout', () => {
|
||||||
let sineWaveObject;
|
let sineWaveObject;
|
||||||
|
let clockObject;
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
// 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
|
// Create Clock Object
|
||||||
await createDomainObjectWithDefaults(page, {
|
clockObject = await createDomainObjectWithDefaults(page, {
|
||||||
type: 'Clock',
|
type: 'Clock'
|
||||||
name: "Test Clock"
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('panes have the appropriate draggable attribute while in Edit and Browse modes', async ({ page }) => {
|
test('panes have the appropriate draggable attribute while in Edit and Browse modes', async ({ page }) => {
|
||||||
|
const treePane = page.getByRole('tree', {
|
||||||
|
name: 'Main Tree'
|
||||||
|
});
|
||||||
|
const sineWaveGeneratorTreeItem = treePane.getByRole('treeitem', {
|
||||||
|
name: new RegExp(sineWaveObject.name)
|
||||||
|
});
|
||||||
|
const clockTreeItem = treePane.getByRole('treeitem', {
|
||||||
|
name: new RegExp(clockObject.name)
|
||||||
|
});
|
||||||
// Create a Flexible Layout
|
// Create a Flexible Layout
|
||||||
await createDomainObjectWithDefaults(page, {
|
await createDomainObjectWithDefaults(page, {
|
||||||
type: 'Flexible Layout',
|
type: 'Flexible Layout'
|
||||||
name: "Test Flexible Layout"
|
|
||||||
});
|
});
|
||||||
// Edit Flexible Layout
|
// Edit Flexible Layout
|
||||||
await page.locator('[title="Edit"]').click();
|
await page.locator('[title="Edit"]').click();
|
||||||
@ -52,8 +59,8 @@ test.describe('Flexible Layout', () => {
|
|||||||
// 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').first().click();
|
await page.locator('.c-tree__item__view-control.c-disclosure-triangle').first().click();
|
||||||
// Add the Sine Wave Generator and Clock to the Flexible Layout
|
// 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 sineWaveGeneratorTreeItem.dragTo(page.locator('.c-fl__container.is-empty').first());
|
||||||
await page.dragAndDrop('text=Test Clock', '.c-fl__container.is-empty');
|
await clockTreeItem.dragTo(page.locator('.c-fl__container.is-empty'));
|
||||||
// Check that panes can be dragged while Flexible Layout is in Edit mode
|
// 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();
|
let dragWrapper = page.locator('.c-fl-container__frames-holder .c-fl-frame__drag-wrapper').first();
|
||||||
await expect(dragWrapper).toHaveAttribute('draggable', 'true');
|
await expect(dragWrapper).toHaveAttribute('draggable', 'true');
|
||||||
@ -65,10 +72,15 @@ test.describe('Flexible Layout', () => {
|
|||||||
await expect(dragWrapper).toHaveAttribute('draggable', 'false');
|
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 }) => {
|
test('items in a flexible layout can be removed with object tree context menu when viewing the flexible layout', async ({ page }) => {
|
||||||
|
const treePane = page.getByRole('tree', {
|
||||||
|
name: 'Main Tree'
|
||||||
|
});
|
||||||
|
const sineWaveGeneratorTreeItem = treePane.getByRole('treeitem', {
|
||||||
|
name: new RegExp(sineWaveObject.name)
|
||||||
|
});
|
||||||
// Create a Display Layout
|
// Create a Display Layout
|
||||||
await createDomainObjectWithDefaults(page, {
|
await createDomainObjectWithDefaults(page, {
|
||||||
type: 'Flexible Layout',
|
type: 'Flexible Layout'
|
||||||
name: "Test Flexible Layout"
|
|
||||||
});
|
});
|
||||||
// Edit Flexible Layout
|
// Edit Flexible Layout
|
||||||
await page.locator('[title="Edit"]').click();
|
await page.locator('[title="Edit"]').click();
|
||||||
@ -76,7 +88,7 @@ test.describe('Flexible Layout', () => {
|
|||||||
// 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').first().click();
|
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
|
// 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 sineWaveGeneratorTreeItem.dragTo(page.locator('.c-fl__container.is-empty').first());
|
||||||
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();
|
||||||
|
|
||||||
@ -86,7 +98,7 @@ test.describe('Flexible Layout', () => {
|
|||||||
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
|
await page.locator('.c-tree__item.is-navigated-object .c-disclosure-triangle').click();
|
||||||
|
|
||||||
// Bring up context menu and remove
|
// Bring up context menu and remove
|
||||||
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').first().click({ button: 'right' });
|
await sineWaveGeneratorTreeItem.first().click({ button: 'right' });
|
||||||
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||||
await page.locator('button:has-text("OK")').click();
|
await page.locator('button:has-text("OK")').click();
|
||||||
|
|
||||||
@ -98,10 +110,16 @@ test.describe('Flexible Layout', () => {
|
|||||||
type: 'issue',
|
type: 'issue',
|
||||||
description: 'https://github.com/nasa/openmct/issues/3117'
|
description: 'https://github.com/nasa/openmct/issues/3117'
|
||||||
});
|
});
|
||||||
|
const treePane = page.getByRole('tree', {
|
||||||
|
name: 'Main Tree'
|
||||||
|
});
|
||||||
|
const sineWaveGeneratorTreeItem = treePane.getByRole('treeitem', {
|
||||||
|
name: new RegExp(sineWaveObject.name)
|
||||||
|
});
|
||||||
|
|
||||||
// Create a Flexible Layout
|
// Create a Flexible Layout
|
||||||
const flexibleLayout = await createDomainObjectWithDefaults(page, {
|
const flexibleLayout = await createDomainObjectWithDefaults(page, {
|
||||||
type: 'Flexible Layout',
|
type: 'Flexible Layout'
|
||||||
name: "Test Flexible Layout"
|
|
||||||
});
|
});
|
||||||
// Edit Flexible Layout
|
// Edit Flexible Layout
|
||||||
await page.locator('[title="Edit"]').click();
|
await page.locator('[title="Edit"]').click();
|
||||||
@ -109,7 +127,7 @@ test.describe('Flexible Layout', () => {
|
|||||||
// 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 Flexible Layout and save changes
|
// 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 sineWaveGeneratorTreeItem.dragTo(page.locator('.c-fl__container.is-empty').first());
|
||||||
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();
|
||||||
|
|
||||||
@ -122,7 +140,7 @@ test.describe('Flexible Layout', () => {
|
|||||||
await page.goto(sineWaveObject.url);
|
await page.goto(sineWaveObject.url);
|
||||||
|
|
||||||
// Bring up context menu and remove
|
// Bring up context menu and remove
|
||||||
await page.locator('.c-tree__item.is-alias .c-tree__item__name:text("Test Sine Wave Generator")').click({ button: 'right' });
|
await sineWaveGeneratorTreeItem.first().click({ button: 'right' });
|
||||||
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
await page.locator('li[role="menuitem"]:has-text("Remove")').click();
|
||||||
await page.locator('button:has-text("OK")').click();
|
await page.locator('button:has-text("OK")').click();
|
||||||
|
|
||||||
|
@ -25,13 +25,13 @@ This test suite is dedicated to tests which verify the basic operations surround
|
|||||||
but only assume that example imagery is present.
|
but only assume that example imagery is present.
|
||||||
*/
|
*/
|
||||||
/* globals process */
|
/* globals process */
|
||||||
const { v4: uuid } = require('uuid');
|
|
||||||
const { waitForAnimations } = require('../../../../baseFixtures');
|
const { waitForAnimations } = require('../../../../baseFixtures');
|
||||||
const { test, expect } = require('../../../../pluginFixtures');
|
const { test, expect } = require('../../../../pluginFixtures');
|
||||||
const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||||
const backgroundImageSelector = '.c-imagery__main-image__background-image';
|
const backgroundImageSelector = '.c-imagery__main-image__background-image';
|
||||||
const panHotkey = process.platform === 'linux' ? ['Control', 'Alt'] : ['Alt'];
|
const panHotkey = process.platform === 'linux' ? ['Control', 'Alt'] : ['Alt'];
|
||||||
const expectedAltText = process.platform === 'linux' ? 'Ctrl+Alt drag to pan' : 'Alt drag to pan';
|
const expectedAltText = process.platform === 'linux' ? 'Ctrl+Alt drag to pan' : 'Alt drag to pan';
|
||||||
|
const thumbnailUrlParamsRegexp = /\?w=100&h=100/;
|
||||||
|
|
||||||
//The following block of tests verifies the basic functionality of example imagery and serves as a template for Imagery objects embedded in other objects.
|
//The following block of tests verifies the basic functionality of example imagery and serves as a template for Imagery objects embedded in other objects.
|
||||||
test.describe('Example Imagery Object', () => {
|
test.describe('Example Imagery Object', () => {
|
||||||
@ -207,6 +207,58 @@ test.describe('Example Imagery in Display Layout', () => {
|
|||||||
await page.goto(displayLayout.url);
|
await page.goto(displayLayout.url);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('View Large action pauses imagery when in realtime and returns to realtime', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/3647'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Click time conductor mode button
|
||||||
|
await page.locator('.c-mode-button').click();
|
||||||
|
|
||||||
|
// set realtime mode
|
||||||
|
await page.locator('[data-testid="conductor-modeOption-realtime"]').click();
|
||||||
|
|
||||||
|
// pause/play button
|
||||||
|
const pausePlayButton = await page.locator('.c-button.pause-play');
|
||||||
|
|
||||||
|
await expect.soft(pausePlayButton).not.toHaveClass(/is-paused/);
|
||||||
|
|
||||||
|
// Open context menu and click view large menu item
|
||||||
|
await page.locator('button[title="View menu items"]').click();
|
||||||
|
await page.locator('li[title="View Large"]').click();
|
||||||
|
await expect(pausePlayButton).toHaveClass(/is-paused/);
|
||||||
|
|
||||||
|
await page.locator('[aria-label="Close"]').click();
|
||||||
|
await expect.soft(pausePlayButton).not.toHaveClass(/is-paused/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('View Large action leaves keeps realtime mode paused', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/3647'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Click time conductor mode button
|
||||||
|
await page.locator('.c-mode-button').click();
|
||||||
|
|
||||||
|
// set realtime mode
|
||||||
|
await page.locator('[data-testid="conductor-modeOption-realtime"]').click();
|
||||||
|
|
||||||
|
// pause/play button
|
||||||
|
const pausePlayButton = await page.locator('.c-button.pause-play');
|
||||||
|
await pausePlayButton.click();
|
||||||
|
await expect.soft(pausePlayButton).toHaveClass(/is-paused/);
|
||||||
|
|
||||||
|
// Open context menu and click view large menu item
|
||||||
|
await page.locator('button[title="View menu items"]').click();
|
||||||
|
await page.locator('li[title="View Large"]').click();
|
||||||
|
await expect(pausePlayButton).toHaveClass(/is-paused/);
|
||||||
|
|
||||||
|
await page.locator('[aria-label="Close"]').click();
|
||||||
|
await expect.soft(pausePlayButton).toHaveClass(/is-paused/);
|
||||||
|
});
|
||||||
|
|
||||||
test('Imagery View operations @unstable', async ({ page }) => {
|
test('Imagery View operations @unstable', async ({ page }) => {
|
||||||
test.info().annotations.push({
|
test.info().annotations.push({
|
||||||
type: 'issue',
|
type: 'issue',
|
||||||
@ -345,13 +397,11 @@ test.describe('Example Imagery in Time Strip', () => {
|
|||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
timeStripObject = await createDomainObjectWithDefaults(page, {
|
timeStripObject = await createDomainObjectWithDefaults(page, {
|
||||||
type: 'Time Strip',
|
type: 'Time Strip'
|
||||||
name: 'Time Strip'.concat(' ', uuid())
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await createDomainObjectWithDefaults(page, {
|
await createDomainObjectWithDefaults(page, {
|
||||||
type: 'Example Imagery',
|
type: 'Example Imagery',
|
||||||
name: 'Example Imagery'.concat(' ', uuid()),
|
|
||||||
parent: timeStripObject.uuid
|
parent: timeStripObject.uuid
|
||||||
});
|
});
|
||||||
// Navigate to timestrip
|
// Navigate to timestrip
|
||||||
@ -362,17 +412,28 @@ test.describe('Example Imagery in Time Strip', () => {
|
|||||||
type: 'issue',
|
type: 'issue',
|
||||||
description: 'https://github.com/nasa/openmct/issues/5632'
|
description: 'https://github.com/nasa/openmct/issues/5632'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hover over the timestrip to reveal a thumbnail image
|
||||||
await page.locator('.c-imagery-tsv-container').hover();
|
await page.locator('.c-imagery-tsv-container').hover();
|
||||||
// get url of the hovered image
|
|
||||||
const hoveredImg = page.locator('.c-imagery-tsv div.c-imagery-tsv__image-wrapper:hover img');
|
// Get the img src of the hovered image thumbnail
|
||||||
const hoveredImgSrc = await hoveredImg.getAttribute('src');
|
const hoveredThumbnailImg = page.locator('.c-imagery-tsv div.c-imagery-tsv__image-wrapper:hover img');
|
||||||
expect(hoveredImgSrc).toBeTruthy();
|
const hoveredThumbnailImgSrc = await hoveredThumbnailImg.getAttribute('src');
|
||||||
|
|
||||||
|
// Verify that imagery timestrip view uses the thumbnailUrl as img src for thumbnails
|
||||||
|
expect(hoveredThumbnailImgSrc).toBeTruthy();
|
||||||
|
expect(hoveredThumbnailImgSrc).toMatch(thumbnailUrlParamsRegexp);
|
||||||
|
|
||||||
|
// Click on the hovered thumbnail to open "View Large" view
|
||||||
await page.locator('.c-imagery-tsv-container').click();
|
await page.locator('.c-imagery-tsv-container').click();
|
||||||
// get image of view large container
|
|
||||||
|
// Get the img src of the large view image
|
||||||
const viewLargeImg = page.locator('img.c-imagery__main-image__image');
|
const viewLargeImg = page.locator('img.c-imagery__main-image__image');
|
||||||
const viewLargeImgSrc = await viewLargeImg.getAttribute('src');
|
const viewLargeImgSrc = await viewLargeImg.getAttribute('src');
|
||||||
expect(viewLargeImgSrc).toBeTruthy();
|
expect(viewLargeImgSrc).toBeTruthy();
|
||||||
expect(viewLargeImgSrc).toEqual(hoveredImgSrc);
|
|
||||||
|
// Verify that the image in the large view is the same as the hovered thumbnail
|
||||||
|
expect(viewLargeImgSrc).toEqual(hoveredThumbnailImgSrc.split('?')[0]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -389,6 +450,12 @@ test.describe('Example Imagery in Time Strip', () => {
|
|||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
*/
|
*/
|
||||||
async function performImageryViewOperationsAndAssert(page) {
|
async function performImageryViewOperationsAndAssert(page) {
|
||||||
|
// Verify that imagery thumbnails use a thumbnail url
|
||||||
|
const thumbnailImages = page.locator('.c-thumb__image');
|
||||||
|
const mainImage = page.locator('.c-imagery__main-image__image');
|
||||||
|
await expect(thumbnailImages.first()).toHaveAttribute('src', thumbnailUrlParamsRegexp);
|
||||||
|
await expect(mainImage).not.toHaveAttribute('src', thumbnailUrlParamsRegexp);
|
||||||
|
|
||||||
// Click previous image button
|
// Click previous image button
|
||||||
const previousImageButton = page.locator('.c-nav--prev');
|
const previousImageButton = page.locator('.c-nav--prev');
|
||||||
await previousImageButton.click();
|
await previousImageButton.click();
|
||||||
|
@ -24,11 +24,12 @@
|
|||||||
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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 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');
|
||||||
const { expandTreePaneItemByName, createDomainObjectWithDefaults } = require('../../../../appActions');
|
const { 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 }) => {
|
||||||
@ -75,8 +76,7 @@ test.describe('Notebook section tests', () => {
|
|||||||
|
|
||||||
// Create Notebook
|
// Create Notebook
|
||||||
await createDomainObjectWithDefaults(page, {
|
await createDomainObjectWithDefaults(page, {
|
||||||
type: 'Notebook',
|
type: NOTEBOOK_NAME
|
||||||
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 ({ page }) => {
|
||||||
@ -137,8 +137,7 @@ test.describe('Notebook page tests', () => {
|
|||||||
|
|
||||||
// Create Notebook
|
// Create Notebook
|
||||||
await createDomainObjectWithDefaults(page, {
|
await createDomainObjectWithDefaults(page, {
|
||||||
type: 'Notebook',
|
type: NOTEBOOK_NAME
|
||||||
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
|
||||||
@ -209,24 +208,30 @@ test.describe('Notebook search tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test.describe('Notebook entry tests', () => {
|
test.describe('Notebook entry tests', () => {
|
||||||
|
// Create Notebook with URL Whitelist
|
||||||
|
let notebookObject;
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
await page.addInitScript({ path: path.join(__dirname, '../../../../helper/', 'addInitNotebookWithUrls.js') });
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
notebookObject = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: NOTEBOOK_NAME
|
||||||
|
});
|
||||||
|
});
|
||||||
test.fixme('When a new entry is created, it should be focused', async ({ page }) => {});
|
test.fixme('When a new entry is created, it should be focused', async ({ page }) => {});
|
||||||
test('When an object is dropped into a notebook, a new entry is created and it should be focused @unstable', async ({ page }) => {
|
test('When an object is dropped into a notebook, a new entry is created and it should be focused @unstable', async ({ page }) => {
|
||||||
await page.goto('./#/browse/mine', { waitUntil: 'networkidle' });
|
|
||||||
|
|
||||||
// Create Notebook
|
|
||||||
const notebook = await createDomainObjectWithDefaults(page, {
|
|
||||||
type: 'Notebook',
|
|
||||||
name: "Embed Test Notebook"
|
|
||||||
});
|
|
||||||
// Create Overlay Plot
|
// Create Overlay Plot
|
||||||
await createDomainObjectWithDefaults(page, {
|
await createDomainObjectWithDefaults(page, {
|
||||||
type: 'Overlay Plot',
|
type: 'Overlay Plot'
|
||||||
name: "Dropped Overlay Plot"
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await expandTreePaneItemByName(page, 'My Items');
|
// 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.goto(notebook.url);
|
|
||||||
await page.dragAndDrop('role=treeitem[name=/Dropped Overlay Plot/]', '.c-notebook__drag-area');
|
await page.dragAndDrop('role=treeitem[name=/Dropped Overlay Plot/]', '.c-notebook__drag-area');
|
||||||
|
|
||||||
const embed = page.locator('.c-ne__embed__link');
|
const embed = page.locator('.c-ne__embed__link');
|
||||||
@ -236,22 +241,16 @@ test.describe('Notebook entry tests', () => {
|
|||||||
expect(embedName).toBe('Dropped Overlay Plot');
|
expect(embedName).toBe('Dropped Overlay Plot');
|
||||||
});
|
});
|
||||||
test('When an object is dropped into a notebooks existing entry, it should be focused @unstable', async ({ page }) => {
|
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' });
|
|
||||||
|
|
||||||
// Create Notebook
|
|
||||||
const notebook = await createDomainObjectWithDefaults(page, {
|
|
||||||
type: 'Notebook',
|
|
||||||
name: "Embed Test Notebook"
|
|
||||||
});
|
|
||||||
// Create Overlay Plot
|
// Create Overlay Plot
|
||||||
await createDomainObjectWithDefaults(page, {
|
await createDomainObjectWithDefaults(page, {
|
||||||
type: 'Overlay Plot',
|
type: 'Overlay Plot'
|
||||||
name: "Dropped Overlay Plot"
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await expandTreePaneItemByName(page, 'My Items');
|
// Navigate to the notebook object
|
||||||
|
await page.goto(notebookObject.url);
|
||||||
|
|
||||||
await page.goto(notebook.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 nbUtils.enterTextEntry(page, 'Entry to drop into');
|
||||||
await page.dragAndDrop('role=treeitem[name=/Dropped Overlay Plot/]', 'text=Entry to drop into');
|
await page.dragAndDrop('role=treeitem[name=/Dropped Overlay Plot/]', 'text=Entry to drop into');
|
||||||
@ -265,71 +264,117 @@ test.describe('Notebook entry tests', () => {
|
|||||||
});
|
});
|
||||||
test.fixme('new entries persist through navigation events without save', async ({ page }) => {});
|
test.fixme('new entries persist through navigation events without save', async ({ page }) => {});
|
||||||
test.fixme('previous and new entries can be deleted', async ({ page }) => {});
|
test.fixme('previous and new entries can be deleted', async ({ page }) => {});
|
||||||
});
|
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';
|
||||||
|
|
||||||
test.describe('Snapshot Menu tests', () => {
|
// Navigate to the notebook object
|
||||||
test.fixme('When no default notebook is selected, Snapshot Menu dropdown should only have a single option', async ({ page }) => {
|
await page.goto(notebookObject.url);
|
||||||
// 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', () => {
|
// Reveal the notebook in the tree
|
||||||
test.fixme('5 Snapshots can be added to a container', async ({ page }) => {});
|
await page.getByTitle('Show selected item in tree').click();
|
||||||
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 }) => {});
|
await nbUtils.enterTextEntry(page, `This should be a link: ${TEST_LINK} is it?`);
|
||||||
test.fixme('A snapshot can be Previewed from Container', async ({ page }) => {});
|
|
||||||
test.fixme('A snapshot Container can be open and closed', async ({ page }) => {});
|
const validLink = page.locator(`a[href="${TEST_LINK}"]`);
|
||||||
test.fixme('Can add object to Snapshot container and pull into notebook and create a new entry', async ({ page }) => {
|
|
||||||
//Create Notebook
|
// Start waiting for popup before clicking. Note no await.
|
||||||
//Create Telemetry Object
|
const popupPromise = page.waitForEvent('popup');
|
||||||
//From Telemetry Object, use 'save to Notebook Snapshots'
|
|
||||||
//Snapshots indicator should blink, click on it to view snapshots
|
await validLink.click();
|
||||||
//Navigate to Notebook
|
const popup = await popupPromise;
|
||||||
//Drag and Drop onto droppable area for new entry
|
|
||||||
//New Entry created with given snapshot added
|
// Wait for the popup to load.
|
||||||
//Snapshot removed from container?
|
await popup.waitForLoadState();
|
||||||
|
expect.soft(popup.url()).toContain('www.google.com');
|
||||||
|
|
||||||
|
expect(await validLink.count()).toBe(1);
|
||||||
});
|
});
|
||||||
test.fixme('Can add object to Snapshot container and pull into notebook and existing entry', async ({ page }) => {
|
test('when an invalid link is entered into a notebook entry, it does not become clickable when viewing', async ({ page }) => {
|
||||||
//Create Notebook
|
const TEST_LINK = 'www.google.com';
|
||||||
//Create Telemetry Object
|
|
||||||
//From Telemetry Object, use 'save to Notebook Snapshots'
|
// Navigate to the notebook object
|
||||||
//Snapshots indicator should blink, click on it to view snapshots
|
await page.goto(notebookObject.url);
|
||||||
//Navigate to Notebook
|
|
||||||
//Drag and Drop into exiting entry
|
// Reveal the notebook in the tree
|
||||||
//Existing Entry updated with given snapshot
|
await page.getByTitle('Show selected item in tree').click();
|
||||||
//Snapshot removed from container?
|
|
||||||
|
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.fixme('Verify Embedded options for PNG, JPG, and Annotate work correctly', async ({ page }) => {
|
test('when a link is entered, but it is not in the whitelisted urls, it does not become clickable when viewing', async ({ page }) => {
|
||||||
//Add snapshot to container
|
const TEST_LINK = 'http://www.bing.com';
|
||||||
//Verify PNG, JPG, and Annotate buttons work correctly
|
|
||||||
|
// 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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,134 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
This test suite is dedicated to tests which verify the basic operations surrounding Notebooks.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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: 'networkidle' });
|
||||||
|
|
||||||
|
// 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
|
||||||
|
});
|
||||||
|
});
|
@ -41,6 +41,7 @@ test.describe('Notebook Tests with CouchDB @couchdb', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Inspect Notebook Entry Network Requests', async ({ page }) => {
|
test('Inspect Notebook Entry Network Requests', async ({ page }) => {
|
||||||
|
await page.getByText('Annotations').click();
|
||||||
// Expand sidebar
|
// Expand sidebar
|
||||||
await page.locator('.c-notebook__toggle-nav-button').click();
|
await page.locator('.c-notebook__toggle-nav-button').click();
|
||||||
|
|
||||||
@ -76,6 +77,7 @@ test.describe('Notebook Tests with CouchDB @couchdb', () => {
|
|||||||
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
||||||
await page.locator('[aria-label="Notebook Entry Input"]').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"]').fill(`First Entry`);
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"]').press('Enter');
|
||||||
await page.waitForLoadState('networkidle');
|
await page.waitForLoadState('networkidle');
|
||||||
expect(addingNotebookElementsRequests.length).toBeLessThanOrEqual(2);
|
expect(addingNotebookElementsRequests.length).toBeLessThanOrEqual(2);
|
||||||
|
|
||||||
@ -129,13 +131,13 @@ test.describe('Notebook Tests with CouchDB @couchdb', () => {
|
|||||||
// This happens for 3 tags so 12 requests
|
// This happens for 3 tags so 12 requests
|
||||||
addingNotebookElementsRequests = [];
|
addingNotebookElementsRequests = [];
|
||||||
await page.hover('[aria-label="Tag"]:has-text("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="Remove tag Driving"]').click();
|
||||||
await page.waitForSelector('[aria-label="Tag"]:has-text("Driving")', {state: 'hidden'});
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Driving")', {state: 'hidden'});
|
||||||
await page.hover('[aria-label="Tag"]:has-text("Drilling")');
|
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.locator('[aria-label="Remove tag Drilling"]').click();
|
||||||
await page.waitForSelector('[aria-label="Tag"]:has-text("Drilling")', {state: 'hidden'});
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Drilling")', {state: 'hidden'});
|
||||||
page.hover('[aria-label="Tag"]:has-text("Science")');
|
page.hover('[aria-label="Tag"]:has-text("Science")');
|
||||||
await page.locator('[aria-label="Tag"]:has-text("Science") ~ .c-completed-tag-deletion').click();
|
await page.locator('[aria-label="Remove tag Science"]').click();
|
||||||
await page.waitForSelector('[aria-label="Tag"]:has-text("Science")', {state: 'hidden'});
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Science")', {state: 'hidden'});
|
||||||
page.waitForLoadState('networkidle');
|
page.waitForLoadState('networkidle');
|
||||||
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(12);
|
expect(filterNonFetchRequests(addingNotebookElementsRequests).length).toBeLessThanOrEqual(12);
|
||||||
@ -148,30 +150,33 @@ test.describe('Notebook Tests with CouchDB @couchdb', () => {
|
|||||||
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
||||||
await page.locator('[aria-label="Notebook Entry Input"]').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"]').fill(`First Entry`);
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"]').press('Enter');
|
||||||
|
|
||||||
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
||||||
await page.locator('[aria-label="Notebook Entry Input"] >> nth=1').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('[aria-label="Notebook Entry Input"] >> nth=1').fill(`Second Entry`);
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=1').press('Enter');
|
||||||
|
|
||||||
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
||||||
await page.locator('[aria-label="Notebook Entry Input"] >> nth=2').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`);
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=2').fill(`Third Entry`);
|
||||||
|
await page.locator('[aria-label="Notebook Entry Input"] >> nth=2').press('Enter');
|
||||||
|
|
||||||
// Add three tags
|
// Add three tags
|
||||||
await page.hover(`button:has-text("Add Tag") >> nth=2`);
|
await page.hover(`button:has-text("Add Tag")`);
|
||||||
await page.locator(`button:has-text("Add Tag") >> nth=2`).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 page.locator('[aria-label="Autocomplete Options"] >> text=Science').click();
|
await page.locator('[aria-label="Autocomplete Options"] >> text=Science').click();
|
||||||
await page.waitForSelector('[aria-label="Tag"]:has-text("Science")');
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Science")');
|
||||||
|
|
||||||
await page.hover(`button:has-text("Add Tag") >> nth=2`);
|
await page.hover(`button:has-text("Add Tag")`);
|
||||||
await page.locator(`button:has-text("Add Tag") >> nth=2`).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 page.locator('[aria-label="Autocomplete Options"] >> text=Drilling').click();
|
await page.locator('[aria-label="Autocomplete Options"] >> text=Drilling').click();
|
||||||
await page.waitForSelector('[aria-label="Tag"]:has-text("Drilling")');
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Drilling")');
|
||||||
|
|
||||||
await page.hover(`button:has-text("Add Tag") >> nth=2`);
|
await page.hover(`button:has-text("Add Tag")`);
|
||||||
await page.locator(`button:has-text("Add Tag") >> nth=2`).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 page.locator('[aria-label="Autocomplete Options"] >> text=Driving').click();
|
await page.locator('[aria-label="Autocomplete Options"] >> text=Driving').click();
|
||||||
await page.waitForSelector('[aria-label="Tag"]:has-text("Driving")');
|
await page.waitForSelector('[aria-label="Tag"]:has-text("Driving")');
|
||||||
@ -227,6 +232,7 @@ test.describe('Notebook Tests with CouchDB @couchdb', () => {
|
|||||||
type: 'issue',
|
type: 'issue',
|
||||||
description: 'https://github.com/akhenry/openmct-yamcs/issues/69'
|
description: 'https://github.com/akhenry/openmct-yamcs/issues/69'
|
||||||
});
|
});
|
||||||
|
await page.getByText('Annotations').click();
|
||||||
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
await page.locator('text=To start a new entry, click here or drag and drop any object').click();
|
||||||
await page.locator('[aria-label="Notebook Entry Input"]').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"]').fill(`First Entry`);
|
||||||
|
@ -152,7 +152,7 @@ test.describe('Restricted Notebook with a page locked and with an embed @addInit
|
|||||||
|
|
||||||
test('Allows embeds to be deleted if page unlocked @addInit', async ({ page }) => {
|
test('Allows embeds to be deleted if page unlocked @addInit', async ({ page }) => {
|
||||||
// Click .c-ne__embed__name .c-popup-menu-button
|
// Click .c-ne__embed__name .c-popup-menu-button
|
||||||
await page.locator('.c-ne__embed__name .c-popup-menu-button').click(); // embed popup menu
|
await page.locator('.c-ne__embed__name .c-icon-button').click(); // embed popup menu
|
||||||
|
|
||||||
const embedMenu = page.locator('body >> .c-menu');
|
const embedMenu = page.locator('body >> .c-menu');
|
||||||
await expect(embedMenu).toContainText('Remove This Embed');
|
await expect(embedMenu).toContainText('Remove This Embed');
|
||||||
@ -161,7 +161,7 @@ test.describe('Restricted Notebook with a page locked and with an embed @addInit
|
|||||||
test('Disallows embeds to be deleted if page locked @addInit', async ({ page }) => {
|
test('Disallows embeds to be deleted if page locked @addInit', async ({ page }) => {
|
||||||
await lockPage(page);
|
await lockPage(page);
|
||||||
// Click .c-ne__embed__name .c-popup-menu-button
|
// Click .c-ne__embed__name .c-popup-menu-button
|
||||||
await page.locator('.c-ne__embed__name .c-popup-menu-button').click(); // embed popup menu
|
await page.locator('.c-ne__embed__name .c-icon-button').click(); // embed popup menu
|
||||||
|
|
||||||
const embedMenu = page.locator('body >> .c-menu');
|
const embedMenu = page.locator('body >> .c-menu');
|
||||||
await expect(embedMenu).not.toContainText('Remove This Embed');
|
await expect(embedMenu).not.toContainText('Remove This Embed');
|
||||||
|
@ -44,6 +44,7 @@ async function createNotebookAndEntry(page, iterations = 1) {
|
|||||||
const entryLocator = `[aria-label="Notebook Entry Input"] >> nth = ${iteration}`;
|
const entryLocator = `[aria-label="Notebook Entry Input"] >> nth = ${iteration}`;
|
||||||
await page.locator(entryLocator).click();
|
await page.locator(entryLocator).click();
|
||||||
await page.locator(entryLocator).fill(`Entry ${iteration}`);
|
await page.locator(entryLocator).fill(`Entry ${iteration}`);
|
||||||
|
await page.locator(entryLocator).press('Enter');
|
||||||
}
|
}
|
||||||
|
|
||||||
return notebook;
|
return notebook;
|
||||||
@ -56,12 +57,14 @@ async function createNotebookAndEntry(page, iterations = 1) {
|
|||||||
*/
|
*/
|
||||||
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 page.locator('text=Annotations').click();
|
||||||
|
|
||||||
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.hover(`button:has-text("Add Tag") >> nth = ${iteration}`);
|
await page.locator(`[aria-label="Notebook Entry"] >> nth = ${iteration}`).click();
|
||||||
await page.locator(`button:has-text("Add Tag") >> nth = ${iteration}`).click();
|
await page.hover(`button:has-text("Add Tag")`);
|
||||||
|
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();
|
||||||
@ -70,8 +73,8 @@ async function createNotebookEntryAndTags(page, iterations = 1) {
|
|||||||
|
|
||||||
// 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") >> 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 "Science" tag
|
// Select the "Science" tag
|
||||||
@ -83,8 +86,10 @@ async function createNotebookEntryAndTags(page, iterations = 1) {
|
|||||||
|
|
||||||
test.describe('Tagging in Notebooks @addInit', () => {
|
test.describe('Tagging in Notebooks @addInit', () => {
|
||||||
test('Can load tags', async ({ page }) => {
|
test('Can load tags', async ({ page }) => {
|
||||||
|
|
||||||
await createNotebookAndEntry(page);
|
await createNotebookAndEntry(page);
|
||||||
|
|
||||||
|
await page.locator('text=Annotations').click();
|
||||||
|
|
||||||
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();
|
||||||
@ -106,7 +111,7 @@ test.describe('Tagging in Notebooks @addInit', () => {
|
|||||||
await expect(page.locator('[aria-label="Autocomplete Options"]')).not.toContainText("Driving");
|
await expect(page.locator('[aria-label="Autocomplete Options"]')).not.toContainText("Driving");
|
||||||
await expect(page.locator('[aria-label="Autocomplete Options"]')).toContainText("Drilling");
|
await expect(page.locator('[aria-label="Autocomplete Options"]')).toContainText("Drilling");
|
||||||
});
|
});
|
||||||
test('Can search for tags', async ({ page }) => {
|
test('Can search for tags and preview works properly', async ({ page }) => {
|
||||||
await createNotebookEntryAndTags(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"]').click();
|
||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
|
||||||
@ -121,17 +126,29 @@ test.describe('Tagging in Notebooks @addInit', () => {
|
|||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Xq');
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('Xq');
|
||||||
await expect(page.locator('text=No results found')).toBeVisible();
|
await expect(page.locator('text=No results found')).toBeVisible();
|
||||||
|
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Display Layout'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Go back into edit mode for the display layout
|
||||||
|
await page.locator('button[title="Edit"]').click();
|
||||||
|
|
||||||
|
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 page.getByText('Entry 0').click();
|
||||||
|
await expect(page.locator('.js-preview-window')).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Can delete tags', async ({ page }) => {
|
test('Can delete tags', async ({ page }) => {
|
||||||
await createNotebookEntryAndTags(page);
|
await createNotebookEntryAndTags(page);
|
||||||
await page.locator('[aria-label="Notebook Entries"]').click();
|
|
||||||
// Delete Driving
|
// Delete Driving
|
||||||
await page.hover('[aria-label="Tag"]:has-text("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="Remove tag Driving"]').click();
|
||||||
|
|
||||||
await expect(page.locator('[aria-label="Notebook Entry"]')).toContainText("Science");
|
await expect(page.locator('[aria-label="Tags Inspector"]')).toContainText("Science");
|
||||||
await expect(page.locator('[aria-label="Notebook Entry"]')).not.toContainText("Driving");
|
await expect(page.locator('[aria-label="Tags Inspector"]')).not.toContainText("Driving");
|
||||||
|
|
||||||
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
|
||||||
await expect(page.locator('[aria-label="Search Result"]')).not.toContainText("Driving");
|
await expect(page.locator('[aria-label="Search Result"]')).not.toContainText("Driving");
|
||||||
@ -193,11 +210,18 @@ test.describe('Tagging in Notebooks @addInit', () => {
|
|||||||
page.goto('./#/browse/mine?hideTree=false'),
|
page.goto('./#/browse/mine?hideTree=false'),
|
||||||
page.click('.c-disclosure-triangle')
|
page.click('.c-disclosure-triangle')
|
||||||
]);
|
]);
|
||||||
// Click Clock
|
|
||||||
await page.click(`text=${clock.name}`);
|
|
||||||
|
|
||||||
|
const treePane = page.getByRole('tree', {
|
||||||
|
name: 'Main Tree'
|
||||||
|
});
|
||||||
|
// Click Clock
|
||||||
|
await treePane.getByRole('treeitem', {
|
||||||
|
name: clock.name
|
||||||
|
}).click();
|
||||||
// Click Notebook
|
// Click Notebook
|
||||||
await page.click(`text=${notebook.name}`);
|
await page.getByRole('treeitem', {
|
||||||
|
name: notebook.name
|
||||||
|
}).click();
|
||||||
|
|
||||||
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}`;
|
||||||
@ -220,4 +244,25 @@ test.describe('Tagging in Notebooks @addInit', () => {
|
|||||||
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);
|
||||||
|
|
||||||
|
// Click on Annotations tab
|
||||||
|
await page.locator('.c-inspector__tab', { hasText: "Annotations" }).click();
|
||||||
|
|
||||||
|
// Click on the "Add Tag" button
|
||||||
|
await page.locator('button:has-text("Add Tag")').click();
|
||||||
|
|
||||||
|
// Click inside the AutoComplete field
|
||||||
|
await page.locator('[placeholder="Type to select tag"]').click();
|
||||||
|
|
||||||
|
// Click on the "Tags" header (simulating a click outside the autocomplete)
|
||||||
|
await page.locator('div.c-inspect-properties__header:has-text("Tags")').click();
|
||||||
|
|
||||||
|
// Verify there is a button with text "Add Tag"
|
||||||
|
await expect(page.locator('button:has-text("Add Tag")')).toBeVisible();
|
||||||
|
|
||||||
|
// Verify the AutoComplete field is hidden
|
||||||
|
await expect(page.locator('[placeholder="Type to select tag"]')).toBeHidden();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,156 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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 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
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
await page.addInitScript({ path: path.join(__dirname, '../../../../helper/', 'addInitExampleUser.js')});
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
await page.addInitScript({ path: path.join(__dirname, '../../../../helper/', 'addInitOperatorStatus.js')});
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
});
|
||||||
|
|
||||||
|
// 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
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -32,7 +32,7 @@ test.use({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe('ExportAsJSON', () => {
|
test.describe('Autoscale', () => {
|
||||||
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;
|
||||||
|
|
||||||
@ -47,16 +47,32 @@ test.describe('ExportAsJSON', () => {
|
|||||||
|
|
||||||
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 page.click('button[title="Edit"]');
|
||||||
|
|
||||||
await turnOffAutoscale(page);
|
await turnOffAutoscale(page);
|
||||||
|
|
||||||
// Make sure that after turning off autoscale, the user selected range values start at the same values the plot had prior.
|
await setUserDefinedMinAndMax(page, '-2', '2');
|
||||||
await testYTicks(page, ['-1.00', '-0.50', '0.00', '0.50', '1.00']);
|
|
||||||
|
// save
|
||||||
|
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.
|
||||||
|
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);
|
const canvas = page.locator('canvas').nth(1);
|
||||||
|
|
||||||
await canvas.hover({trial: true});
|
await canvas.hover({trial: true});
|
||||||
|
|
||||||
expect(await canvas.screenshot()).toMatchSnapshot('autoscale-canvas-prepan.png', { animations: 'disabled' });
|
expect.soft(await canvas.screenshot()).toMatchSnapshot('autoscale-canvas-prepan.png', { animations: 'disabled' });
|
||||||
|
|
||||||
//Alt Drag Start
|
//Alt Drag Start
|
||||||
await page.keyboard.down('Alt');
|
await page.keyboard.down('Alt');
|
||||||
@ -76,11 +92,12 @@ test.describe('ExportAsJSON', () => {
|
|||||||
await page.keyboard.up('Alt');
|
await page.keyboard.up('Alt');
|
||||||
|
|
||||||
// Ensure the drag worked.
|
// Ensure the drag worked.
|
||||||
await testYTicks(page, ['0.00', '0.50', '1.00', '1.50', '2.00']);
|
await testYTicks(page, ['0.00', '0.50', '1.00', '1.50', '2.00', '2.50', '3.00', '3.50']);
|
||||||
|
|
||||||
|
//Wait for canvas to stablize.
|
||||||
await canvas.hover({trial: true});
|
await canvas.hover({trial: true});
|
||||||
|
|
||||||
expect(await canvas.screenshot()).toMatchSnapshot('autoscale-canvas-panned.png', { animations: 'disabled' });
|
expect.soft(await canvas.screenshot()).toMatchSnapshot('autoscale-canvas-panned.png', { animations: 'disabled' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -152,22 +169,25 @@ async function createSinewaveOverlayPlot(page, myItemsFolderName) {
|
|||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
*/
|
*/
|
||||||
async function turnOffAutoscale(page) {
|
async function turnOffAutoscale(page) {
|
||||||
// enter edit mode
|
|
||||||
await page.locator('text=Unnamed Overlay Plot Snapshot >> button').nth(3).click();
|
|
||||||
|
|
||||||
// uncheck autoscale
|
// uncheck autoscale
|
||||||
await page.locator('text=Y Axis Label Log mode Auto scale Padding >> input[type="checkbox"] >> nth=1').uncheck();
|
await page.getByRole('listitem').filter({ hasText: 'Auto scale' }).getByRole('checkbox').uncheck();
|
||||||
|
}
|
||||||
|
|
||||||
// save
|
/**
|
||||||
await page.locator('text=Snapshot Save and Finish Editing Save and Continue Editing >> button').nth(1).click();
|
* @param {import('@playwright/test').Page} page
|
||||||
await Promise.all([
|
* @param {string} min
|
||||||
page.locator('text=Save and Finish Editing').click(),
|
* @param {string} max
|
||||||
//Wait for Save Banner to appear
|
*/
|
||||||
page.waitForSelector('.c-message-banner__message')
|
async function setUserDefinedMinAndMax(page, min, max) {
|
||||||
]);
|
// set minimum value
|
||||||
//Wait until Save Banner is gone
|
const minRangeInput = page.getByRole('listitem').filter({ hasText: 'Minimum Value' }).locator('input[type="number"]');
|
||||||
await page.locator('.c-message-banner__close-button').click();
|
await minRangeInput.click();
|
||||||
await page.waitForSelector('.c-message-banner__message', { state: 'detached'});
|
await minRangeInput.fill(min);
|
||||||
|
|
||||||
|
// set maximum value
|
||||||
|
const maxRangeInput = page.getByRole('listitem').filter({ hasText: 'Maximum Value' }).locator('input[type="number"]');
|
||||||
|
await maxRangeInput.click();
|
||||||
|
await maxRangeInput.fill(max);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -179,7 +199,7 @@ async function testYTicks(page, values) {
|
|||||||
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(yTicks.nth(i)).toHaveText(values[i])); // eslint-disable-line
|
promises.push(expect.soft(yTicks.nth(i)).toHaveText(values[i])); // eslint-disable-line
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
|
After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 16 KiB |
@ -160,35 +160,16 @@ async function testRegularTicks(page) {
|
|||||||
*/
|
*/
|
||||||
async function testLogTicks(page) {
|
async function testLogTicks(page) {
|
||||||
const yTicks = await page.locator('.gl-plot-y-tick-label');
|
const yTicks = await page.locator('.gl-plot-y-tick-label');
|
||||||
expect(await yTicks.count()).toBe(28);
|
expect(await yTicks.count()).toBe(9);
|
||||||
await expect(yTicks.nth(0)).toHaveText('-2.98');
|
await expect(yTicks.nth(0)).toHaveText('-2.98');
|
||||||
await expect(yTicks.nth(1)).toHaveText('-2.50');
|
await expect(yTicks.nth(1)).toHaveText('-1.51');
|
||||||
await expect(yTicks.nth(2)).toHaveText('-2.00');
|
await expect(yTicks.nth(2)).toHaveText('-0.58');
|
||||||
await expect(yTicks.nth(3)).toHaveText('-1.51');
|
await expect(yTicks.nth(3)).toHaveText('-0.00');
|
||||||
await expect(yTicks.nth(4)).toHaveText('-1.20');
|
await expect(yTicks.nth(4)).toHaveText('0.58');
|
||||||
await expect(yTicks.nth(5)).toHaveText('-1.00');
|
await expect(yTicks.nth(5)).toHaveText('1.51');
|
||||||
await expect(yTicks.nth(6)).toHaveText('-0.80');
|
await expect(yTicks.nth(6)).toHaveText('2.98');
|
||||||
await expect(yTicks.nth(7)).toHaveText('-0.58');
|
await expect(yTicks.nth(7)).toHaveText('5.31');
|
||||||
await expect(yTicks.nth(8)).toHaveText('-0.40');
|
await expect(yTicks.nth(8)).toHaveText('9.00');
|
||||||
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');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -205,7 +186,8 @@ async function enableEditMode(page) {
|
|||||||
*/
|
*/
|
||||||
async function enableLogMode(page) {
|
async function enableLogMode(page) {
|
||||||
// turn on log mode
|
// turn on log mode
|
||||||
await page.locator('text=Y Axis Label Log mode Auto scale Padding >> input[type="checkbox"]').first().check();
|
await page.getByRole('listitem').filter({ hasText: 'Log mode' }).getByRole('checkbox').check();
|
||||||
|
// await page.locator('text=Y Axis Label Log mode Auto scale Padding >> input[type="checkbox"]').first().check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -213,7 +195,7 @@ async function enableLogMode(page) {
|
|||||||
*/
|
*/
|
||||||
async function disableLogMode(page) {
|
async function disableLogMode(page) {
|
||||||
// turn off log mode
|
// turn off log mode
|
||||||
await page.locator('text=Y Axis Label Log mode Auto scale Padding >> input[type="checkbox"]').first().uncheck();
|
await page.getByRole('listitem').filter({ hasText: 'Log mode' }).getByRole('checkbox').uncheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
200
e2e/tests/functional/plugins/plot/overlayPlot.e2e.spec.js
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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');
|
||||||
|
const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||||
|
|
||||||
|
test.describe('Overlay Plot', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
// 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)');
|
||||||
|
});
|
||||||
|
|
||||||
|
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"]');
|
||||||
|
|
||||||
|
// Expand the elements pool vertically
|
||||||
|
await page.locator('.l-pane.l-pane--vertical-handle-before', {
|
||||||
|
hasText: 'Elements'
|
||||||
|
}).locator('.l-pane__handle').hover();
|
||||||
|
await page.mouse.down();
|
||||||
|
await page.mouse.move(0, 100);
|
||||||
|
await page.mouse.up();
|
||||||
|
|
||||||
|
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"]');
|
||||||
|
|
||||||
|
// Assert that Y Axis 1 property group is visible only
|
||||||
|
await expect(yAxis1PropertyGroup).toBeVisible();
|
||||||
|
await expect(yAxis2PropertyGroup).toBeHidden();
|
||||||
|
await expect(yAxis3PropertyGroup).toBeHidden();
|
||||||
|
|
||||||
|
// 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 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");
|
||||||
|
|
||||||
|
// 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 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
|
||||||
|
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);
|
||||||
|
await page.click('button[title="Edit"]');
|
||||||
|
|
||||||
|
await page.locator(`#inspector-elements-tree >> text=${swgA.name}`).click();
|
||||||
|
await page.locator('.js-overlay canvas').nth(1);
|
||||||
|
const plotPixelSize = await getCanvasPixelsWithData(page);
|
||||||
|
expect(plotPixelSize).toBeGreaterThan(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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('.js-overlay 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;
|
||||||
|
}
|
@ -40,7 +40,6 @@ test.describe('Plot Integrity Testing @unstable', () => {
|
|||||||
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);
|
||||||
//Capture the number of plots points and store as const name numberOfPlotPoints
|
|
||||||
//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
|
||||||
@ -51,4 +50,90 @@ test.describe('Plot Integrity Testing @unstable', () => {
|
|||||||
});
|
});
|
||||||
expect(createMineFolderRequests.length).toEqual(0);
|
expect(createMineFolderRequests.length).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Plot is rendered when infinity values exist', async ({ page }) => {
|
||||||
|
// Edit Plot
|
||||||
|
await editSineWaveToUseInfinityOption(page, sineWaveGeneratorObject);
|
||||||
|
|
||||||
|
//Get pixel data from Canvas
|
||||||
|
const plotPixelSize = await getCanvasPixelsWithData(page);
|
||||||
|
expect(plotPixelSize).toBeGreaterThan(0);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function edits a sine wave generator with the default options and enables the infinity values option.
|
||||||
|
*
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
* @param {import('../../../../appActions').CreateObjectInfo} sineWaveGeneratorObject
|
||||||
|
* @returns {Promise<CreatedObjectInfo>} An object containing information about the edited domain object.
|
||||||
|
*/
|
||||||
|
async function editSineWaveToUseInfinityOption(page, sineWaveGeneratorObject) {
|
||||||
|
await page.goto(sineWaveGeneratorObject.url);
|
||||||
|
// Edit LAD table
|
||||||
|
await page.locator('[title="More options"]').click();
|
||||||
|
await page.locator('[title="Edit properties of this object."]').click();
|
||||||
|
// Modify the infinity option to true
|
||||||
|
const infinityInput = page.locator('[aria-label="Include Infinity Values"]');
|
||||||
|
await infinityInput.click();
|
||||||
|
|
||||||
|
// Click OK button and wait for Navigate event
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForLoadState(),
|
||||||
|
page.click('[aria-label="Save"]'),
|
||||||
|
// Wait for Save Banner to appear
|
||||||
|
page.waitForSelector('.c-message-banner__message')
|
||||||
|
]);
|
||||||
|
|
||||||
|
// FIXME: Changes to SWG properties should be reflected on save, but they're not?
|
||||||
|
// Thus, navigate away and back to the object.
|
||||||
|
await page.goto('./#/browse/mine');
|
||||||
|
await page.goto(sineWaveGeneratorObject.url);
|
||||||
|
|
||||||
|
await page.locator('c-progress-bar c-telemetry-table__progress-bar').waitFor({
|
||||||
|
state: 'hidden'
|
||||||
|
});
|
||||||
|
|
||||||
|
// FIXME: The progress bar disappears on series data load, not on plot render,
|
||||||
|
// so wait for a half a second before evaluating the canvas.
|
||||||
|
// eslint-disable-next-line playwright/no-wait-for-timeout
|
||||||
|
await page.waitForTimeout(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('@playwright/test').Page} page
|
||||||
|
*/
|
||||||
|
async function getCanvasPixelsWithData(page) {
|
||||||
|
const getTelemValuePromise = new Promise(resolve => page.exposeFunction('getCanvasValue', resolve));
|
||||||
|
|
||||||
|
await page.evaluate(() => {
|
||||||
|
// The document canvas is where the plot points and lines are drawn.
|
||||||
|
// The only way to access the canvas is using document (using page.evaluate)
|
||||||
|
let data;
|
||||||
|
let canvas;
|
||||||
|
let ctx;
|
||||||
|
canvas = document.querySelector('canvas');
|
||||||
|
ctx = canvas.getContext('2d');
|
||||||
|
data = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
|
||||||
|
const imageDataValues = Object.values(data);
|
||||||
|
let plotPixels = [];
|
||||||
|
// Each pixel consists of four values within the ImageData.data array. The for loop iterates by multiples of four.
|
||||||
|
// The values associated with each pixel are R (red), G (green), B (blue), and A (alpha), in that order.
|
||||||
|
for (let i = 0; i < imageDataValues.length;) {
|
||||||
|
if (imageDataValues[i] > 0) {
|
||||||
|
plotPixels.push({
|
||||||
|
startIndex: i,
|
||||||
|
endIndex: i + 3,
|
||||||
|
value: `rgb(${imageDataValues[i]}, ${imageDataValues[i + 1]}, ${imageDataValues[i + 2]}, ${imageDataValues[i + 3]})`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
i = i + 4;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
window.getCanvasValue(plotPixels.length);
|
||||||
|
});
|
||||||
|
|
||||||
|
return getTelemValuePromise;
|
||||||
|
}
|
||||||
|
190
e2e/tests/functional/plugins/plot/stackedPlot.e2e.spec.js
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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');
|
||||||
|
const { createDomainObjectWithDefaults } = require('../../../../appActions');
|
||||||
|
|
||||||
|
test.describe('Stacked Plot', () => {
|
||||||
|
let stackedPlot;
|
||||||
|
let swgA;
|
||||||
|
let swgB;
|
||||||
|
let swgC;
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// Open a browser, navigate to the main page, and wait until all networkevents to resolve
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
stackedPlot = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: "Stacked Plot"
|
||||||
|
});
|
||||||
|
|
||||||
|
swgA = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: "Sine Wave Generator",
|
||||||
|
parent: stackedPlot.uuid
|
||||||
|
});
|
||||||
|
swgB = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: "Sine Wave Generator",
|
||||||
|
parent: stackedPlot.uuid
|
||||||
|
});
|
||||||
|
swgC = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: "Sine Wave Generator",
|
||||||
|
parent: stackedPlot.uuid
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Using the remove action removes the correct plot', async ({ page }) => {
|
||||||
|
const swgAElementsPoolItem = page.locator('#inspector-elements-tree').locator('.c-object-label', { hasText: swgA.name });
|
||||||
|
const swgBElementsPoolItem = page.locator('#inspector-elements-tree').locator('.c-object-label', { hasText: swgB.name });
|
||||||
|
const swgCElementsPoolItem = page.locator('#inspector-elements-tree').locator('.c-object-label', { hasText: swgC.name });
|
||||||
|
|
||||||
|
await page.goto(stackedPlot.url);
|
||||||
|
|
||||||
|
await page.click('button[title="Edit"]');
|
||||||
|
|
||||||
|
// Expand the elements pool vertically
|
||||||
|
await page.locator('.l-pane__handle').nth(2).hover({ trial: true });
|
||||||
|
await page.mouse.down();
|
||||||
|
await page.mouse.move(0, 100);
|
||||||
|
await page.mouse.up();
|
||||||
|
|
||||||
|
await swgBElementsPoolItem.click({ button: 'right' });
|
||||||
|
await page.getByRole('menuitem').filter({ hasText: /Remove/ }).click();
|
||||||
|
await page.getByRole('button').filter({ hasText: "OK" }).click();
|
||||||
|
|
||||||
|
await expect(page.locator('#inspector-elements-tree .js-elements-pool__item')).toHaveCount(2);
|
||||||
|
|
||||||
|
// Confirm that the elements pool contains the items we expect
|
||||||
|
await expect(swgAElementsPoolItem).toHaveCount(1);
|
||||||
|
await expect(swgBElementsPoolItem).toHaveCount(0);
|
||||||
|
await expect(swgCElementsPoolItem).toHaveCount(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Can reorder Stacked Plot items', async ({ page }) => {
|
||||||
|
const swgAElementsPoolItem = page.locator('#inspector-elements-tree').locator('.c-object-label', { hasText: swgA.name });
|
||||||
|
const swgBElementsPoolItem = page.locator('#inspector-elements-tree').locator('.c-object-label', { hasText: swgB.name });
|
||||||
|
const swgCElementsPoolItem = page.locator('#inspector-elements-tree').locator('.c-object-label', { hasText: swgC.name });
|
||||||
|
|
||||||
|
await page.goto(stackedPlot.url);
|
||||||
|
|
||||||
|
await page.click('button[title="Edit"]');
|
||||||
|
|
||||||
|
// Expand the elements pool vertically
|
||||||
|
await page.locator('.l-pane__handle').nth(2).hover({ trial: true });
|
||||||
|
await page.mouse.down();
|
||||||
|
await page.mouse.move(0, 100);
|
||||||
|
await page.mouse.up();
|
||||||
|
|
||||||
|
const stackedPlotItem1 = page.locator('.c-plot--stacked-container').nth(0);
|
||||||
|
const stackedPlotItem2 = page.locator('.c-plot--stacked-container').nth(1);
|
||||||
|
const stackedPlotItem3 = page.locator('.c-plot--stacked-container').nth(2);
|
||||||
|
|
||||||
|
// assert initial plot order - [swgA, swgB, swgC]
|
||||||
|
await expect(stackedPlotItem1).toHaveAttribute('aria-label', `Stacked Plot Item ${swgA.name}`);
|
||||||
|
await expect(stackedPlotItem2).toHaveAttribute('aria-label', `Stacked Plot Item ${swgB.name}`);
|
||||||
|
await expect(stackedPlotItem3).toHaveAttribute('aria-label', `Stacked Plot Item ${swgC.name}`);
|
||||||
|
|
||||||
|
// Drag and drop to reorder - [swgB, swgA, swgC]
|
||||||
|
await swgBElementsPoolItem.dragTo(swgAElementsPoolItem);
|
||||||
|
|
||||||
|
// assert plot order after reorder - [swgB, swgA, swgC]
|
||||||
|
await expect(stackedPlotItem1).toHaveAttribute('aria-label', `Stacked Plot Item ${swgB.name}`);
|
||||||
|
await expect(stackedPlotItem2).toHaveAttribute('aria-label', `Stacked Plot Item ${swgA.name}`);
|
||||||
|
await expect(stackedPlotItem3).toHaveAttribute('aria-label', `Stacked Plot Item ${swgC.name}`);
|
||||||
|
|
||||||
|
// Drag and drop to reorder - [swgB, swgC, swgA]
|
||||||
|
await swgCElementsPoolItem.dragTo(swgAElementsPoolItem);
|
||||||
|
|
||||||
|
// assert plot order after second reorder - [swgB, swgC, swgA]
|
||||||
|
await expect(stackedPlotItem1).toHaveAttribute('aria-label', `Stacked Plot Item ${swgB.name}`);
|
||||||
|
await expect(stackedPlotItem2).toHaveAttribute('aria-label', `Stacked Plot Item ${swgC.name}`);
|
||||||
|
await expect(stackedPlotItem3).toHaveAttribute('aria-label', `Stacked Plot Item ${swgA.name}`);
|
||||||
|
|
||||||
|
// Save (exit edit mode)
|
||||||
|
await page.locator('button[title="Save"]').click();
|
||||||
|
await page.locator('li[title="Save and Finish Editing"]').click();
|
||||||
|
|
||||||
|
// assert plot order persists after save - [swgB, swgC, swgA]
|
||||||
|
await expect(stackedPlotItem1).toHaveAttribute('aria-label', `Stacked Plot Item ${swgB.name}`);
|
||||||
|
await expect(stackedPlotItem2).toHaveAttribute('aria-label', `Stacked Plot Item ${swgC.name}`);
|
||||||
|
await expect(stackedPlotItem3).toHaveAttribute('aria-label', `Stacked Plot Item ${swgA.name}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Selecting a child plot while in browse and edit modes shows its properties in the inspector', async ({ page }) => {
|
||||||
|
await page.goto(stackedPlot.url);
|
||||||
|
|
||||||
|
// Click on the 1st plot
|
||||||
|
await page.locator(`[aria-label="Stacked Plot Item ${swgA.name}"] canvas`).nth(1).click();
|
||||||
|
|
||||||
|
// Assert that the inspector shows the Y Axis properties for swgA
|
||||||
|
await expect(page.locator('[aria-label="Plot Series Properties"] >> h2')).toContainText("Plot Series");
|
||||||
|
await expect(page.getByRole('list', { name: "Y Axis Properties" }).locator("h2")).toContainText("Y Axis");
|
||||||
|
await expect(page.locator('[aria-label="Plot Series Properties"] .c-object-label')).toContainText(swgA.name);
|
||||||
|
|
||||||
|
// Click on the 2nd plot
|
||||||
|
await page.locator(`[aria-label="Stacked Plot Item ${swgB.name}"] canvas`).nth(1).click();
|
||||||
|
|
||||||
|
// Assert that the inspector shows the Y Axis properties for swgB
|
||||||
|
await expect(page.locator('[aria-label="Plot Series Properties"] >> h2')).toContainText("Plot Series");
|
||||||
|
await expect(page.getByRole('list', { name: "Y Axis Properties" }).locator("h2")).toContainText("Y Axis");
|
||||||
|
await expect(page.locator('[aria-label="Plot Series Properties"] .c-object-label')).toContainText(swgB.name);
|
||||||
|
|
||||||
|
// Click on the 3rd plot
|
||||||
|
await page.locator(`[aria-label="Stacked Plot Item ${swgC.name}"] canvas`).nth(1).click();
|
||||||
|
|
||||||
|
// Assert that the inspector shows the Y Axis properties for swgC
|
||||||
|
await expect(page.locator('[aria-label="Plot Series Properties"] >> h2')).toContainText("Plot Series");
|
||||||
|
await expect(page.getByRole('list', { name: "Y Axis Properties" }).locator("h2")).toContainText("Y Axis");
|
||||||
|
await expect(page.locator('[aria-label="Plot Series Properties"] .c-object-label')).toContainText(swgC.name);
|
||||||
|
|
||||||
|
// Go into edit mode
|
||||||
|
await page.click('button[title="Edit"]');
|
||||||
|
|
||||||
|
// Click on canvas for the 1st plot
|
||||||
|
await page.locator(`[aria-label="Stacked Plot Item ${swgA.name}"]`).click();
|
||||||
|
|
||||||
|
// Assert that the inspector shows the Y Axis properties for swgA
|
||||||
|
await expect(page.locator('[aria-label="Plot Series Properties"] >> h2')).toContainText("Plot Series");
|
||||||
|
await expect(page.getByRole('list', { name: "Y Axis Properties" }).locator("h2")).toContainText("Y Axis");
|
||||||
|
await expect(page.locator('[aria-label="Plot Series Properties"] .c-object-label')).toContainText(swgA.name);
|
||||||
|
|
||||||
|
//Click on canvas for the 2nd plot
|
||||||
|
await page.locator(`[aria-label="Stacked Plot Item ${swgB.name}"]`).click();
|
||||||
|
|
||||||
|
// Assert that the inspector shows the Y Axis properties for swgB
|
||||||
|
await expect(page.locator('[aria-label="Plot Series Properties"] >> h2')).toContainText("Plot Series");
|
||||||
|
await expect(page.getByRole('list', { name: "Y Axis Properties" }).locator("h2")).toContainText("Y Axis");
|
||||||
|
await expect(page.locator('[aria-label="Plot Series Properties"] .c-object-label')).toContainText(swgB.name);
|
||||||
|
|
||||||
|
//Click on canvas for the 3rd plot
|
||||||
|
await page.locator(`[aria-label="Stacked Plot Item ${swgC.name}"]`).click();
|
||||||
|
|
||||||
|
// Assert that the inspector shows the Y Axis properties for swgC
|
||||||
|
await expect(page.locator('[aria-label="Plot Series Properties"] >> h2')).toContainText("Plot Series");
|
||||||
|
await expect(page.getByRole('list', { name: "Y Axis Properties" }).locator("h2")).toContainText("Y Axis");
|
||||||
|
await expect(page.locator('[aria-label="Plot Series Properties"] .c-object-label')).toContainText(swgC.name);
|
||||||
|
});
|
||||||
|
});
|
223
e2e/tests/functional/plugins/plot/tagging.e2e.spec.js
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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 plot tagging functionality.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const { test, expect } = require('../../../../pluginFixtures');
|
||||||
|
const { createDomainObjectWithDefaults, setRealTimeMode, setFixedTimeMode } = require('../../../../appActions');
|
||||||
|
|
||||||
|
test.describe('Plot Tagging', () => {
|
||||||
|
async function createTags({page, canvas, xEnd, yEnd}) {
|
||||||
|
await canvas.hover({trial: true});
|
||||||
|
|
||||||
|
//Alt+Shift Drag Start to select some points to tag
|
||||||
|
await page.keyboard.down('Alt');
|
||||||
|
await page.keyboard.down('Shift');
|
||||||
|
|
||||||
|
await canvas.dragTo(canvas, {
|
||||||
|
sourcePosition: {
|
||||||
|
x: 1,
|
||||||
|
y: 1
|
||||||
|
},
|
||||||
|
targetPosition: {
|
||||||
|
x: xEnd,
|
||||||
|
y: yEnd
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Alt Drag End
|
||||||
|
await page.keyboard.up('Alt');
|
||||||
|
await page.keyboard.up('Shift');
|
||||||
|
|
||||||
|
//Wait for canvas to stablize.
|
||||||
|
await canvas.hover({trial: true});
|
||||||
|
|
||||||
|
// add some tags
|
||||||
|
await page.getByText('Annotations').click();
|
||||||
|
await page.getByRole('button', { name: /Add Tag/ }).click();
|
||||||
|
await page.getByPlaceholder('Type to select tag').click();
|
||||||
|
await page.getByText('Driving').click();
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: /Add Tag/ }).click();
|
||||||
|
await page.getByPlaceholder('Type to select tag').click();
|
||||||
|
await page.getByText('Science').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function testTelemetryItem(page, canvas, telemetryItem) {
|
||||||
|
// Check that telemetry item also received the tag
|
||||||
|
await page.goto(telemetryItem.url);
|
||||||
|
|
||||||
|
await expect(page.getByText('No tags to display for this item')).toBeVisible();
|
||||||
|
|
||||||
|
//Wait for canvas to stablize.
|
||||||
|
await canvas.hover({trial: true});
|
||||||
|
|
||||||
|
// click on the tagged plot point
|
||||||
|
await canvas.click({
|
||||||
|
position: {
|
||||||
|
x: 325,
|
||||||
|
y: 377
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(page.getByText('Science')).toBeVisible();
|
||||||
|
await expect(page.getByText('Driving')).toBeHidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function basicTagsTests(page, canvas) {
|
||||||
|
// Search for Science
|
||||||
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||||
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('sc');
|
||||||
|
await expect(page.locator('[aria-label="Search Result"]').nth(0)).toContainText("Science");
|
||||||
|
await expect(page.locator('[aria-label="Search Result"]').nth(0)).not.toContainText("Drilling");
|
||||||
|
|
||||||
|
// 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");
|
||||||
|
|
||||||
|
// Search for Driving
|
||||||
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').click();
|
||||||
|
await page.locator('[aria-label="OpenMCT Search"] input[type="search"]').fill('driv');
|
||||||
|
await expect(page.getByText('No results found')).toBeVisible();
|
||||||
|
|
||||||
|
//Reload Page
|
||||||
|
await Promise.all([
|
||||||
|
page.reload(),
|
||||||
|
page.waitForLoadState('networkidle')
|
||||||
|
]);
|
||||||
|
// wait for plot progress bar to disappear
|
||||||
|
await page.locator('.l-view-section.c-progress-bar').waitFor({ state: 'detached' });
|
||||||
|
|
||||||
|
await page.getByText('Annotations').click();
|
||||||
|
await expect(page.getByText('No tags to display for this item')).toBeVisible();
|
||||||
|
|
||||||
|
// click on the tagged plot point
|
||||||
|
await canvas.click({
|
||||||
|
position: {
|
||||||
|
x: 100,
|
||||||
|
y: 100
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(page.getByText('Science')).toBeVisible();
|
||||||
|
await expect(page.getByText('Driving')).toBeHidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Tags work with Overlay Plots', async ({ page }) => {
|
||||||
|
//Test.slow decorator is currently broken. Needs to be fixed in https://github.com/nasa/openmct/issues/5374
|
||||||
|
test.slow();
|
||||||
|
|
||||||
|
const overlayPlot = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: "Overlay Plot"
|
||||||
|
});
|
||||||
|
|
||||||
|
const alphaSineWave = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: "Sine Wave Generator",
|
||||||
|
name: "Alpha Sine Wave",
|
||||||
|
parent: overlayPlot.uuid
|
||||||
|
});
|
||||||
|
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: "Sine Wave Generator",
|
||||||
|
name: "Beta Sine Wave",
|
||||||
|
parent: overlayPlot.uuid
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.goto(overlayPlot.url);
|
||||||
|
|
||||||
|
let canvas = page.locator('canvas').nth(1);
|
||||||
|
|
||||||
|
// Switch to real-time mode
|
||||||
|
// Adding tags should pause the plot
|
||||||
|
await setRealTimeMode(page);
|
||||||
|
|
||||||
|
await createTags({
|
||||||
|
page,
|
||||||
|
canvas,
|
||||||
|
xEnd: 700,
|
||||||
|
yEnd: 480
|
||||||
|
});
|
||||||
|
|
||||||
|
await setFixedTimeMode(page);
|
||||||
|
|
||||||
|
// changing to fixed time mode rebuilds canvas?
|
||||||
|
canvas = page.locator('canvas').nth(1);
|
||||||
|
|
||||||
|
await basicTagsTests(page, canvas);
|
||||||
|
await testTelemetryItem(page, canvas, alphaSineWave);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Tags work with Plot View of telemetry items', async ({ page }) => {
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: "Sine Wave Generator"
|
||||||
|
});
|
||||||
|
|
||||||
|
const canvas = page.locator('canvas').nth(1);
|
||||||
|
await createTags({
|
||||||
|
page,
|
||||||
|
canvas,
|
||||||
|
xEnd: 700,
|
||||||
|
yEnd: 480
|
||||||
|
});
|
||||||
|
await basicTagsTests(page, canvas);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Tags work with Stacked Plots', async ({ page }) => {
|
||||||
|
const stackedPlot = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: "Stacked Plot"
|
||||||
|
});
|
||||||
|
|
||||||
|
const alphaSineWave = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: "Sine Wave Generator",
|
||||||
|
name: "Alpha Sine Wave",
|
||||||
|
parent: stackedPlot.uuid
|
||||||
|
});
|
||||||
|
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: "Sine Wave Generator",
|
||||||
|
name: "Beta Sine Wave",
|
||||||
|
parent: stackedPlot.uuid
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.goto(stackedPlot.url);
|
||||||
|
|
||||||
|
const canvas = page.locator('canvas').nth(1);
|
||||||
|
|
||||||
|
await createTags({
|
||||||
|
page,
|
||||||
|
canvas,
|
||||||
|
xEnd: 700,
|
||||||
|
yEnd: 215
|
||||||
|
});
|
||||||
|
await basicTagsTests(page, canvas);
|
||||||
|
await testTelemetryItem(page, canvas, alphaSineWave);
|
||||||
|
});
|
||||||
|
});
|
255
e2e/tests/functional/recentObjects.e2e.spec.js
Normal file
@ -0,0 +1,255 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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.js');
|
||||||
|
const { createDomainObjectWithDefaults } = require('../../appActions.js');
|
||||||
|
const { waitForAnimations } = require('../../baseFixtures.js');
|
||||||
|
|
||||||
|
test.describe('Recent Objects', () => {
|
||||||
|
/** @type {import('@playwright/test').Locator} */
|
||||||
|
let recentObjectsList;
|
||||||
|
/** @type {import('@playwright/test').Locator} */
|
||||||
|
let clock;
|
||||||
|
/** @type {import('@playwright/test').Locator} */
|
||||||
|
let folderA;
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
|
||||||
|
// Set Recent Objects List locator for subsequent tests
|
||||||
|
recentObjectsList = page.getByRole('list', {
|
||||||
|
name: 'Recent Objects'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a folder and nest a Clock within it
|
||||||
|
folderA = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Folder'
|
||||||
|
});
|
||||||
|
clock = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Clock',
|
||||||
|
parent: folderA.uuid
|
||||||
|
});
|
||||||
|
|
||||||
|
// Drag the Recent Objects panel up a bit
|
||||||
|
await page.locator('.l-pane.l-pane--vertical-handle-before', {
|
||||||
|
hasText: 'Recently Viewed'
|
||||||
|
}).locator('.l-pane__handle').hover();
|
||||||
|
await page.mouse.down();
|
||||||
|
await page.mouse.move(0, 100);
|
||||||
|
await page.mouse.up();
|
||||||
|
});
|
||||||
|
test('Navigated objects show up in recents, object renames and deletions are reflected', async ({ page }) => {
|
||||||
|
// Verify that both created objects appear in the list and are in the correct order
|
||||||
|
assertInitialRecentObjectsListState();
|
||||||
|
|
||||||
|
// Navigate to the folder by clicking on the main object name in the recent objects list item
|
||||||
|
await page.getByRole('listitem', { name: folderA.name }).getByText(folderA.name).click();
|
||||||
|
await page.waitForURL(`**/${folderA.uuid}?*`);
|
||||||
|
expect(recentObjectsList.getByRole('listitem').nth(0).getByText(folderA.name)).toBeTruthy();
|
||||||
|
|
||||||
|
// Rename
|
||||||
|
folderA.name = `${folderA.name}-NEW!`;
|
||||||
|
await page.locator('.l-browse-bar__object-name').fill("");
|
||||||
|
await page.locator('.l-browse-bar__object-name').fill(folderA.name);
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
|
||||||
|
// Verify rename has been applied in recent objects list item and objects paths
|
||||||
|
expect(await page.getByRole('navigation', {
|
||||||
|
name: clock.name
|
||||||
|
}).locator('a').filter({
|
||||||
|
hasText: folderA.name
|
||||||
|
}).count()).toBeGreaterThan(0);
|
||||||
|
expect(recentObjectsList.getByRole('listitem', { name: folderA.name })).toBeTruthy();
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
await page.click('button[title="Show selected item in tree"]');
|
||||||
|
// Delete the folder via the left tree pane treeitem context menu
|
||||||
|
await page.getByRole('treeitem', { name: new RegExp(folderA.name) }).locator('a').click({
|
||||||
|
button: 'right'
|
||||||
|
});
|
||||||
|
await page.getByRole('menuitem', { name: /Remove/ }).click();
|
||||||
|
await page.getByRole('button', { name: 'OK' }).click();
|
||||||
|
|
||||||
|
// Verify that the folder and clock are no longer in the recent objects list
|
||||||
|
await expect(recentObjectsList.getByRole('listitem', { name: folderA.name })).toBeHidden();
|
||||||
|
await expect(recentObjectsList.getByRole('listitem', { name: clock.name })).toBeHidden();
|
||||||
|
});
|
||||||
|
test("Clicking on an object in the path of a recent object navigates to the object", async ({ page, openmctConfig }) => {
|
||||||
|
const { myItemsFolderName } = openmctConfig;
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/6151'
|
||||||
|
});
|
||||||
|
await page.goto('./#/browse/mine');
|
||||||
|
|
||||||
|
// Navigate to the folder by clicking on its entry in the Clock's breadcrumb
|
||||||
|
const waitForFolderNavigation = page.waitForURL(`**/${folderA.uuid}?*`);
|
||||||
|
await page.getByRole('navigation', {
|
||||||
|
name: clock.name
|
||||||
|
}).locator('a').filter({
|
||||||
|
hasText: folderA.name
|
||||||
|
}).click();
|
||||||
|
|
||||||
|
// Verify that the hash URL updates correctly
|
||||||
|
await waitForFolderNavigation;
|
||||||
|
expect(page.url()).toMatch(new RegExp(`.*${folderA.uuid}?.*`));
|
||||||
|
|
||||||
|
// Navigate to My Items by clicking on its entry in the Clock's breadcrumb
|
||||||
|
const waitForMyItemsNavigation = page.waitForURL(`**/mine?*`);
|
||||||
|
await page.getByRole('navigation', {
|
||||||
|
name: clock.name
|
||||||
|
}).locator('a').filter({
|
||||||
|
hasText: myItemsFolderName
|
||||||
|
}).click();
|
||||||
|
|
||||||
|
// Verify that the hash URL updates correctly
|
||||||
|
await waitForMyItemsNavigation;
|
||||||
|
expect(page.url()).toMatch(new RegExp(`.*mine?.*`));
|
||||||
|
});
|
||||||
|
test("Clicking on the 'target button' scrolls the object into view in the tree and highlights it", async ({ page }) => {
|
||||||
|
const clockTreeItem = page.getByRole('tree', { name: 'Main Tree'}).getByRole('treeitem', { name: clock.name });
|
||||||
|
const folderTreeItem = page.getByRole('tree', { name: 'Main Tree'})
|
||||||
|
.getByRole('treeitem', {
|
||||||
|
name: folderA.name,
|
||||||
|
expanded: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// Click the "Target" button for the Clock which is nested in a folder
|
||||||
|
await page.getByRole('button', { name: `Open and scroll to ${clock.name}`}).click();
|
||||||
|
|
||||||
|
// Assert that the Clock parent folder has expanded and the Clock is visible)
|
||||||
|
await expect(folderTreeItem.locator('.c-disclosure-triangle')).toHaveClass(/--expanded/);
|
||||||
|
await expect(clockTreeItem).toBeVisible();
|
||||||
|
|
||||||
|
// Assert that the Clock treeitem is highlighted
|
||||||
|
await expect(clockTreeItem.locator('.c-tree__item')).toHaveClass(/is-targeted-item/);
|
||||||
|
|
||||||
|
// Wait for highlight animation to end
|
||||||
|
await waitForAnimations(clockTreeItem.locator('.c-tree__item'));
|
||||||
|
|
||||||
|
// Assert that the Clock treeitem is no longer highlighted
|
||||||
|
await expect(clockTreeItem.locator('.c-tree__item')).not.toHaveClass(/is-targeted-item/);
|
||||||
|
});
|
||||||
|
test("Persists on refresh", async ({ page }) => {
|
||||||
|
assertInitialRecentObjectsListState();
|
||||||
|
await page.reload();
|
||||||
|
assertInitialRecentObjectsListState();
|
||||||
|
});
|
||||||
|
test("Displays objects and aliases uniquely", async ({ page }) => {
|
||||||
|
const mainTree = page.getByRole('tree', { name: 'Main Tree'});
|
||||||
|
|
||||||
|
// Navigate to the clock and reveal it in the tree
|
||||||
|
await page.goto(clock.url);
|
||||||
|
await page.getByTitle('Show selected item in tree').click();
|
||||||
|
|
||||||
|
// Right click the clock and create an alias using the "link" context menu action
|
||||||
|
const clockTreeItem = page.getByRole('tree', {
|
||||||
|
name: 'Main Tree'
|
||||||
|
}).getByRole('treeitem', {
|
||||||
|
name: clock.name
|
||||||
|
});
|
||||||
|
await clockTreeItem.click({
|
||||||
|
button: 'right'
|
||||||
|
});
|
||||||
|
await page.getByRole('menuitem', {
|
||||||
|
name: /Create Link/
|
||||||
|
}).click();
|
||||||
|
await page.getByRole('tree', { name: 'Create Modal Tree'}).getByRole('treeitem').first().click();
|
||||||
|
await page.getByRole('button', { name: 'Save' }).click();
|
||||||
|
|
||||||
|
// Click the newly created object alias in the tree
|
||||||
|
await mainTree.getByRole('treeitem', {
|
||||||
|
name: new RegExp(clock.name)
|
||||||
|
}).filter({
|
||||||
|
has: page.locator('.is-alias')
|
||||||
|
}).click();
|
||||||
|
|
||||||
|
// Assert that two recent objects are displayed and one of them is an alias
|
||||||
|
expect(await recentObjectsList.getByRole('listitem', { name: clock.name }).count()).toBe(2);
|
||||||
|
expect(await recentObjectsList.locator('.is-alias').count()).toBe(1);
|
||||||
|
|
||||||
|
// Assert that the alias and the original's breadcrumbs are different
|
||||||
|
const clockBreadcrumbs = recentObjectsList.getByRole('listitem', {name: clock.name}).getByRole('navigation');
|
||||||
|
expect(await clockBreadcrumbs.count()).toBe(2);
|
||||||
|
expect(await clockBreadcrumbs.nth(0).innerText()).not.toEqual(await clockBreadcrumbs.nth(1).innerText());
|
||||||
|
});
|
||||||
|
test("Enforces a limit of 20 recent objects", async ({ page }) => {
|
||||||
|
// Creating 21 objects takes a while, so increase the timeout
|
||||||
|
test.slow();
|
||||||
|
|
||||||
|
// Assert that the list initially contains 3 objects (clock, folder, my items)
|
||||||
|
expect(await recentObjectsList.locator('.c-recentobjects-listitem').count()).toBe(3);
|
||||||
|
|
||||||
|
let lastFolder;
|
||||||
|
let lastClock;
|
||||||
|
// Create 19 more objects (3 in beforeEach() + 18 new = 21 total)
|
||||||
|
for (let i = 0; i < 9; i++) {
|
||||||
|
lastFolder = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: "Folder",
|
||||||
|
parent: lastFolder?.uuid
|
||||||
|
});
|
||||||
|
lastClock = await createDomainObjectWithDefaults(page, {
|
||||||
|
type: "Clock",
|
||||||
|
parent: lastFolder?.uuid
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assert that the list contains 20 objects
|
||||||
|
expect(await recentObjectsList.locator('.c-recentobjects-listitem').count()).toBe(20);
|
||||||
|
|
||||||
|
// Collapse the tree
|
||||||
|
await page.getByTitle("Collapse all tree items").click();
|
||||||
|
const lastFolderTreeItem = page.getByRole('tree', { name: 'Main Tree'})
|
||||||
|
.getByRole('treeitem', {
|
||||||
|
name: lastFolder.name,
|
||||||
|
expanded: true
|
||||||
|
});
|
||||||
|
const lastClockTreeItem = page.getByRole('tree', { name: 'Main Tree'})
|
||||||
|
.getByRole('treeitem', {
|
||||||
|
name: lastClock.name
|
||||||
|
});
|
||||||
|
|
||||||
|
// Test "Open and Scroll To" in a deeply nested tree, while we're here
|
||||||
|
await page.getByRole('button', { name: `Open and scroll to ${lastClock.name}`}).click();
|
||||||
|
|
||||||
|
// Assert that the Clock parent folder has expanded and the Clock is visible)
|
||||||
|
await expect(lastFolderTreeItem.locator('.c-disclosure-triangle')).toHaveClass(/--expanded/);
|
||||||
|
await expect(lastClockTreeItem).toBeVisible();
|
||||||
|
|
||||||
|
// Assert that the Clock treeitem is highlighted
|
||||||
|
await expect(lastClockTreeItem.locator('.c-tree__item')).toHaveClass(/is-targeted-item/);
|
||||||
|
|
||||||
|
// Wait for highlight animation to end
|
||||||
|
await waitForAnimations(lastClockTreeItem.locator('.c-tree__item'));
|
||||||
|
|
||||||
|
// Assert that the Clock treeitem is no longer highlighted
|
||||||
|
await expect(lastClockTreeItem.locator('.c-tree__item')).not.toHaveClass(/is-targeted-item/);
|
||||||
|
});
|
||||||
|
|
||||||
|
function assertInitialRecentObjectsListState() {
|
||||||
|
expect(recentObjectsList.getByRole('listitem', { name: clock.name })).toBeTruthy();
|
||||||
|
expect(recentObjectsList.getByRole('listitem', { name: folderA.name })).toBeTruthy();
|
||||||
|
expect(recentObjectsList.getByRole('listitem', { name: clock.name }).locator('a').getByText(folderA.name)).toBeTruthy();
|
||||||
|
expect(recentObjectsList.getByRole('listitem').nth(0).getByText(clock.name)).toBeTruthy();
|
||||||
|
expect(recentObjectsList.getByRole('listitem', { name: clock.name }).locator('a').getByText(folderA.name)).toBeTruthy();
|
||||||
|
expect(recentObjectsList.getByRole('listitem').nth(1).getByText(folderA.name)).toBeTruthy();
|
||||||
|
}
|
||||||
|
});
|
@ -28,6 +28,14 @@ const { createDomainObjectWithDefaults } = require('../../appActions');
|
|||||||
const { v4: uuid } = require('uuid');
|
const { v4: uuid } = require('uuid');
|
||||||
|
|
||||||
test.describe('Grand Search', () => {
|
test.describe('Grand Search', () => {
|
||||||
|
const searchResultSelector = '.c-gsearch-result__title';
|
||||||
|
const searchResultDropDownSelector = '.c-gsearch__results';
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// Go to baseURL
|
||||||
|
await page.goto("./", { waitUntil: "networkidle" });
|
||||||
|
});
|
||||||
|
|
||||||
test('Can search for objects, and subsequent search dropdown behaves properly', async ({ page, openmctConfig }) => {
|
test('Can search for objects, and subsequent search dropdown behaves properly', async ({ page, openmctConfig }) => {
|
||||||
const { myItemsFolderName } = openmctConfig;
|
const { myItemsFolderName } = openmctConfig;
|
||||||
|
|
||||||
@ -72,7 +80,7 @@ test.describe('Grand Search', () => {
|
|||||||
await page.locator('[aria-label="OpenMCT Search"] [aria-label="Search Input"]').fill('Cl');
|
await page.locator('[aria-label="OpenMCT Search"] [aria-label="Search Input"]').fill('Cl');
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForNavigation(),
|
page.waitForNavigation(),
|
||||||
page.locator('text=Clock A').click()
|
page.locator('[aria-label="Clock A clock result"] >> text=Clock A').click()
|
||||||
]);
|
]);
|
||||||
await expect(page.locator('.is-object-type-clock')).toBeVisible();
|
await expect(page.locator('.is-object-type-clock')).toBeVisible();
|
||||||
|
|
||||||
@ -89,15 +97,8 @@ test.describe('Grand Search', () => {
|
|||||||
await expect(page.locator('[aria-label="Search Result"] >> nth=2')).toContainText(`Clock C ${myItemsFolderName} Red Folder Blue Folder`);
|
await expect(page.locator('[aria-label="Search Result"] >> nth=2')).toContainText(`Clock C ${myItemsFolderName} Red Folder Blue Folder`);
|
||||||
await expect(page.locator('[aria-label="Search Result"] >> nth=3')).toContainText(`Clock D ${myItemsFolderName} Red Folder Blue Folder`);
|
await expect(page.locator('[aria-label="Search Result"] >> nth=3')).toContainText(`Clock D ${myItemsFolderName} Red Folder Blue Folder`);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
test.describe("Search Tests @unstable", () => {
|
|
||||||
const searchResultSelector = '.c-gsearch-result__title';
|
|
||||||
|
|
||||||
test('Validate empty search result', async ({ page }) => {
|
test('Validate empty search result', async ({ page }) => {
|
||||||
// Go to baseURL
|
|
||||||
await page.goto("./", { waitUntil: "networkidle" });
|
|
||||||
|
|
||||||
// Invalid search for objects
|
// Invalid search for objects
|
||||||
await page.type("input[type=search]", 'not found');
|
await page.type("input[type=search]", 'not found');
|
||||||
|
|
||||||
@ -105,7 +106,7 @@ test.describe("Search Tests @unstable", () => {
|
|||||||
await waitForSearchCompletion(page);
|
await waitForSearchCompletion(page);
|
||||||
|
|
||||||
// Get the search results
|
// Get the search results
|
||||||
const searchResults = await page.locator(searchResultSelector);
|
const searchResults = page.locator(searchResultSelector);
|
||||||
|
|
||||||
// Verify that no results are found
|
// Verify that no results are found
|
||||||
expect(await searchResults.count()).toBe(0);
|
expect(await searchResults.count()).toBe(0);
|
||||||
@ -115,9 +116,6 @@ test.describe("Search Tests @unstable", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Validate single object in search result @couchdb', async ({ page }) => {
|
test('Validate single object in search result @couchdb', async ({ page }) => {
|
||||||
//Go to baseURL
|
|
||||||
await page.goto("./", { waitUntil: "networkidle" });
|
|
||||||
|
|
||||||
// Create a folder object
|
// Create a folder object
|
||||||
const folderName = uuid();
|
const folderName = uuid();
|
||||||
await createDomainObjectWithDefaults(page, {
|
await createDomainObjectWithDefaults(page, {
|
||||||
@ -139,21 +137,56 @@ test.describe("Search Tests @unstable", () => {
|
|||||||
await expect(searchResults).toHaveText(folderName);
|
await expect(searchResults).toHaveText(folderName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Search results are debounced @couchdb', async ({ page }) => {
|
||||||
|
test.info().annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/nasa/openmct/issues/6179'
|
||||||
|
});
|
||||||
|
await createObjectsForSearch(page);
|
||||||
|
|
||||||
|
let networkRequests = [];
|
||||||
|
page.on('request', (request) => {
|
||||||
|
const searchRequest = request.url().endsWith('_find');
|
||||||
|
const fetchRequest = request.resourceType() === 'fetch';
|
||||||
|
if (searchRequest && fetchRequest) {
|
||||||
|
networkRequests.push(request);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Full search for object
|
||||||
|
await page.type("input[type=search]", 'Clock', { delay: 100 });
|
||||||
|
|
||||||
|
// Wait for search to finish
|
||||||
|
await waitForSearchCompletion(page);
|
||||||
|
|
||||||
|
// Network requests for the composite telemetry with multiple items should be:
|
||||||
|
// 1. batched request for latest telemetry using the bulk API
|
||||||
|
expect(networkRequests.length).toBe(1);
|
||||||
|
|
||||||
|
const searchResultDropDown = await page.locator(searchResultDropDownSelector);
|
||||||
|
|
||||||
|
await expect(searchResultDropDown).toContainText('Clock A');
|
||||||
|
});
|
||||||
|
|
||||||
test("Validate multiple objects in search results return partial matches", async ({ page }) => {
|
test("Validate multiple objects in search results return partial matches", async ({ page }) => {
|
||||||
test.info().annotations.push({
|
test.info().annotations.push({
|
||||||
type: 'issue',
|
type: 'issue',
|
||||||
description: 'https://github.com/nasa/openmct/issues/4667'
|
description: 'https://github.com/nasa/openmct/issues/4667'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Go to baseURL
|
|
||||||
await page.goto("/", { waitUntil: "networkidle" });
|
|
||||||
|
|
||||||
// Create folder objects
|
// Create folder objects
|
||||||
const folderName = "e928a26e-e924-4ea0";
|
const folderName1 = "e928a26e-e924-4ea0";
|
||||||
const folderName2 = "e928a26e-e924-4001";
|
const folderName2 = "e928a26e-e924-4001";
|
||||||
|
|
||||||
await createFolderObject(page, folderName);
|
await createDomainObjectWithDefaults(page, {
|
||||||
await createFolderObject(page, folderName2);
|
type: 'Folder',
|
||||||
|
name: folderName1
|
||||||
|
});
|
||||||
|
|
||||||
|
await createDomainObjectWithDefaults(page, {
|
||||||
|
type: 'Folder',
|
||||||
|
name: folderName2
|
||||||
|
});
|
||||||
|
|
||||||
// Partial search for objects
|
// Partial search for objects
|
||||||
await page.type("input[type=search]", 'e928a26e');
|
await page.type("input[type=search]", 'e928a26e');
|
||||||
@ -161,36 +194,22 @@ test.describe("Search Tests @unstable", () => {
|
|||||||
// Wait for search to finish
|
// Wait for search to finish
|
||||||
await waitForSearchCompletion(page);
|
await waitForSearchCompletion(page);
|
||||||
|
|
||||||
// Get the search results
|
const searchResultDropDown = await page.locator(searchResultDropDownSelector);
|
||||||
const searchResults = await page.locator(searchResultSelector);
|
|
||||||
|
|
||||||
// Verify that the search result/s correctly match the search query
|
// Verify that the search result/s correctly match the search query
|
||||||
|
await expect(searchResultDropDown).toContainText(folderName1);
|
||||||
|
await expect(searchResultDropDown).toContainText(folderName2);
|
||||||
|
|
||||||
|
// Get the search results
|
||||||
|
const searchResults = page.locator(searchResultSelector);
|
||||||
|
// Verify that two results are found
|
||||||
expect(await searchResults.count()).toBe(2);
|
expect(await searchResults.count()).toBe(2);
|
||||||
await expect(await searchResults.first()).toHaveText(folderName);
|
|
||||||
await expect(await searchResults.last()).toHaveText(folderName2);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
async function createFolderObject(page, folderName) {
|
|
||||||
// Open Create menu
|
|
||||||
await page.locator('button:has-text("Create")').click();
|
|
||||||
|
|
||||||
// Select Folder object
|
|
||||||
await page.locator('text=Folder').nth(1).click();
|
|
||||||
|
|
||||||
// Click folder title to enter edit mode
|
|
||||||
await page.locator('text=Properties Title Notes >> input[type="text"]').click();
|
|
||||||
|
|
||||||
// Enter folder name
|
|
||||||
await page.locator('text=Properties Title Notes >> input[type="text"]').fill(folderName);
|
|
||||||
|
|
||||||
// Create folder object
|
|
||||||
await page.locator('button:has-text("OK")').click();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function waitForSearchCompletion(page) {
|
async function waitForSearchCompletion(page) {
|
||||||
// Wait loading spinner to disappear
|
// Wait loading spinner to disappear
|
||||||
await page.waitForSelector('.c-tree-and-search__loading', { state: 'detached' });
|
await page.waitForSelector('.search-finished');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,9 +217,6 @@ async function waitForSearchCompletion(page) {
|
|||||||
* @param {import('@playwright/test').Page} page
|
* @param {import('@playwright/test').Page} page
|
||||||
*/
|
*/
|
||||||
async function createObjectsForSearch(page) {
|
async function createObjectsForSearch(page) {
|
||||||
//Go to baseURL
|
|
||||||
await page.goto('./', { waitUntil: 'networkidle' });
|
|
||||||
|
|
||||||
const redFolder = await createDomainObjectWithDefaults(page, {
|
const redFolder = await createDomainObjectWithDefaults(page, {
|
||||||
type: 'Folder',
|
type: 'Folder',
|
||||||
name: 'Red Folder'
|
name: 'Red Folder'
|
||||||
|
@ -116,7 +116,9 @@ async function getAndAssertTreeItems(page, expected) {
|
|||||||
* @param {string} name
|
* @param {string} name
|
||||||
*/
|
*/
|
||||||
async function expandTreePaneItemByName(page, name) {
|
async function expandTreePaneItemByName(page, name) {
|
||||||
const treePane = page.locator('#tree-pane');
|
const treePane = page.getByRole('tree', {
|
||||||
|
name: 'Main Tree'
|
||||||
|
});
|
||||||
const treeItem = treePane.locator(`role=treeitem[expanded=false][name=/${name}/]`);
|
const treeItem = treePane.locator(`role=treeitem[expanded=false][name=/${name}/]`);
|
||||||
const expandTriangle = treeItem.locator('.c-disclosure-triangle');
|
const expandTriangle = treeItem.locator('.c-disclosure-triangle');
|
||||||
await expandTriangle.click();
|
await expandTriangle.click();
|
||||||
|
68
e2e/tests/visual/addTag.visual.spec.js
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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 is dedicated to test the blur behavior of the add tag button.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const { test } = require("../../pluginFixtures");
|
||||||
|
const percySnapshot = require('@percy/playwright');
|
||||||
|
const { createDomainObjectWithDefaults } = require('../../appActions');
|
||||||
|
|
||||||
|
test.describe("Visual - Check blur of Add Tag button", () => {
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// Open a browser, navigate to the main page, and wait until all network events to resolve
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Blur 'Add tag'", async ({ page, theme }) => {
|
||||||
|
createDomainObjectWithDefaults(page, { type: 'Notebook' });
|
||||||
|
|
||||||
|
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 = 0`;
|
||||||
|
await page.locator(entryLocator).click();
|
||||||
|
await page.locator(entryLocator).fill(`Entry 0`);
|
||||||
|
await page.locator(entryLocator).press('Enter');
|
||||||
|
|
||||||
|
// Click on Annotations tab
|
||||||
|
await page.locator('.c-inspector__tab', { hasText: "Annotations" }).click();
|
||||||
|
|
||||||
|
// Take snapshot of the notebook with the Annotations tab opened
|
||||||
|
await percySnapshot(page, `Notebook Annotation (theme: '${theme}')`);
|
||||||
|
|
||||||
|
// Click on the "Add Tag" button
|
||||||
|
await page.locator('button:has-text("Add Tag")').click();
|
||||||
|
|
||||||
|
// Take snapshot of the notebook with the AutoComplete field visible
|
||||||
|
await percySnapshot(page, `Notebook Add Tag (theme: '${theme}')`);
|
||||||
|
|
||||||
|
// Click inside the AutoComplete field
|
||||||
|
await page.locator('[placeholder="Type to select tag"]').click();
|
||||||
|
|
||||||
|
// Click on the "Tags" header (simulating a click outside the autocomplete field)
|
||||||
|
await page.locator('div.c-inspect-properties__header:has-text("Tags")').click();
|
||||||
|
|
||||||
|
// Take snapshot of the notebook with the AutoComplete field hidden and with the "Add Tag" button visible
|
||||||
|
await percySnapshot(page, `Notebook Annotation de-select blur (theme: '${theme}')`);
|
||||||
|
});
|
||||||
|
});
|
@ -57,7 +57,7 @@ test.describe('Visual - Tree Pane', () => {
|
|||||||
name: 'Z Clock'
|
name: 'Z Clock'
|
||||||
});
|
});
|
||||||
|
|
||||||
const treePane = "#tree-pane";
|
const treePane = "[role=tree][aria-label='Main Tree']";
|
||||||
|
|
||||||
await percySnapshot(page, `Tree Pane w/ collapsed tree (theme: ${theme})`, {
|
await percySnapshot(page, `Tree Pane w/ collapsed tree (theme: ${theme})`, {
|
||||||
scope: treePane
|
scope: treePane
|
||||||
@ -94,7 +94,7 @@ test.describe('Visual - Tree Pane', () => {
|
|||||||
* @param {string} name
|
* @param {string} name
|
||||||
*/
|
*/
|
||||||
async function expandTreePaneItemByName(page, name) {
|
async function expandTreePaneItemByName(page, name) {
|
||||||
const treePane = page.locator('#tree-pane');
|
const treePane = page.getByTestId('tree-pane');
|
||||||
const treeItem = treePane.locator(`role=treeitem[expanded=false][name=/${name}/]`);
|
const treeItem = treePane.locator(`role=treeitem[expanded=false][name=/${name}/]`);
|
||||||
const expandTriangle = treeItem.locator('.c-disclosure-triangle');
|
const expandTriangle = treeItem.locator('.c-disclosure-triangle');
|
||||||
await expandTriangle.click();
|
await expandTriangle.click();
|
||||||
|
58
e2e/tests/visual/notification.visual.spec.js
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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 is dedicated to test notification banner functionality and its accessibility attributes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const { test, expect } = require('../../pluginFixtures');
|
||||||
|
const percySnapshot = require('@percy/playwright');
|
||||||
|
const { createDomainObjectWithDefaults } = require('../../appActions');
|
||||||
|
|
||||||
|
test.describe('Visual - Check Notification Info Banner of \'Save successful\'', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// Go to baseURL and Hide Tree
|
||||||
|
await page.goto('./', { waitUntil: 'networkidle' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Create a clock, click on \'Save successful\' banner and dismiss it', async ({ page }) => {
|
||||||
|
// Create a clock domain object
|
||||||
|
await createDomainObjectWithDefaults(page, { type: 'Clock' });
|
||||||
|
// Verify there is a button with aria-label="Review 1 Notification"
|
||||||
|
expect(await page.locator('button[aria-label="Review 1 Notification"]').isVisible()).toBe(true);
|
||||||
|
// Verify there is a button with aria-label="Clear all notifications"
|
||||||
|
expect(await page.locator('button[aria-label="Clear all notifications"]').isVisible()).toBe(true);
|
||||||
|
// Click on the div with role="alert" that has "Save successful" text
|
||||||
|
await page.locator('div[role="alert"]:has-text("Save successful")').click();
|
||||||
|
// Verify there is a div with role="dialog"
|
||||||
|
expect(await page.locator('div[role="dialog"]').isVisible()).toBe(true);
|
||||||
|
// Verify the div with role="dialog" contains text "Save successful"
|
||||||
|
expect(await page.locator('div[role="dialog"]').innerText()).toContain('Save successful');
|
||||||
|
await percySnapshot(page, 'Notification banner');
|
||||||
|
// Verify there is a button with text "Dismiss"
|
||||||
|
expect(await page.locator('button:has-text("Dismiss")').isVisible()).toBe(true);
|
||||||
|
// Click on button with text "Dismiss"
|
||||||
|
await page.locator('button:has-text("Dismiss")').click();
|
||||||
|
// Verify there is no div with role="dialog"
|
||||||
|
expect(await page.locator('div[role="dialog"]').isVisible()).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
@ -20,11 +20,23 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
import availableTags from './tags.json';
|
import availableTags from './tags.json';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@typedef {{
|
||||||
|
namespaceToSaveAnnotations: string
|
||||||
|
}} TagsPluginOptions
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {TagsPluginOptions} options
|
||||||
* @returns {function} The plugin install function
|
* @returns {function} The plugin install function
|
||||||
*/
|
*/
|
||||||
export default function exampleTagsPlugin() {
|
export default function exampleTagsPlugin(options) {
|
||||||
return function install(openmct) {
|
return function install(openmct) {
|
||||||
|
if (options?.namespaceToSaveAnnotations) {
|
||||||
|
openmct.annotation.setNamespaceToSaveAnnotations(options?.namespaceToSaveAnnotations);
|
||||||
|
}
|
||||||
|
|
||||||
Object.keys(availableTags.tags).forEach(tagKey => {
|
Object.keys(availableTags.tags).forEach(tagKey => {
|
||||||
const tagDefinition = availableTags.tags[tagKey];
|
const tagDefinition = availableTags.tags[tagKey];
|
||||||
openmct.annotation.defineTag(tagKey, tagDefinition);
|
openmct.annotation.defineTag(tagKey, tagDefinition);
|
||||||
|
@ -65,7 +65,7 @@ export default class ExampleUserProvider extends EventEmitter {
|
|||||||
this.user = undefined;
|
this.user = undefined;
|
||||||
this.loggedIn = false;
|
this.loggedIn = false;
|
||||||
this.autoLoginUser = undefined;
|
this.autoLoginUser = undefined;
|
||||||
this.status = STATUSES[1];
|
this.status = STATUSES[0];
|
||||||
this.pollQuestion = undefined;
|
this.pollQuestion = undefined;
|
||||||
this.defaultStatusRole = defaultStatusRole;
|
this.defaultStatusRole = defaultStatusRole;
|
||||||
|
|
||||||
@ -124,6 +124,7 @@ export default class ExampleUserProvider extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setStatusForRole(role, status) {
|
setStatusForRole(role, status) {
|
||||||
|
status.timestamp = Date.now();
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.emit('statusChange', {
|
this.emit('statusChange', {
|
||||||
role,
|
role,
|
||||||
@ -133,14 +134,23 @@ export default class ExampleUserProvider extends EventEmitter {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
getPollQuestion() {
|
// eslint-disable-next-line require-await
|
||||||
return Promise.resolve({
|
async getPollQuestion() {
|
||||||
question: 'Set "GO" if your position is ready for a boarding action on the Klingon cruiser',
|
if (this.pollQuestion) {
|
||||||
timestamp: Date.now()
|
return this.pollQuestion;
|
||||||
});
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setPollQuestion(pollQuestion) {
|
setPollQuestion(pollQuestion) {
|
||||||
|
if (!pollQuestion) {
|
||||||
|
// If the poll question is undefined, set it to a blank string.
|
||||||
|
// This behavior better reflects how other telemetry systems
|
||||||
|
// deal with undefined poll questions.
|
||||||
|
pollQuestion = '';
|
||||||
|
}
|
||||||
|
|
||||||
this.pollQuestion = {
|
this.pollQuestion = {
|
||||||
question: pollQuestion,
|
question: pollQuestion,
|
||||||
timestamp: Date.now()
|
timestamp: Date.now()
|
||||||
|
@ -33,11 +33,13 @@ define([
|
|||||||
dataRateInHz: 1,
|
dataRateInHz: 1,
|
||||||
randomness: 0,
|
randomness: 0,
|
||||||
phase: 0,
|
phase: 0,
|
||||||
loadDelay: 0
|
loadDelay: 0,
|
||||||
|
infinityValues: false
|
||||||
};
|
};
|
||||||
|
|
||||||
function GeneratorProvider(openmct) {
|
function GeneratorProvider(openmct, StalenessProvider) {
|
||||||
this.workerInterface = new WorkerInterface(openmct);
|
this.openmct = openmct;
|
||||||
|
this.workerInterface = new WorkerInterface(openmct, StalenessProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneratorProvider.prototype.canProvideTelemetry = function (domainObject) {
|
GeneratorProvider.prototype.canProvideTelemetry = function (domainObject) {
|
||||||
@ -56,7 +58,8 @@ define([
|
|||||||
'dataRateInHz',
|
'dataRateInHz',
|
||||||
'randomness',
|
'randomness',
|
||||||
'phase',
|
'phase',
|
||||||
'loadDelay'
|
'loadDelay',
|
||||||
|
'infinityValues'
|
||||||
];
|
];
|
||||||
|
|
||||||
request = request || {};
|
request = request || {};
|
||||||
@ -79,6 +82,7 @@ define([
|
|||||||
workerRequest[prop] = Number(workerRequest[prop]);
|
workerRequest[prop] = Number(workerRequest[prop]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
workerRequest.id = this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||||
workerRequest.name = domainObject.name;
|
workerRequest.name = domainObject.name;
|
||||||
|
|
||||||
return workerRequest;
|
return workerRequest;
|
||||||
|
157
example/generator/SinewaveStalenessProvider.js
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2022, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
import EventEmitter from 'EventEmitter';
|
||||||
|
|
||||||
|
export default class SinewaveLimitProvider extends EventEmitter {
|
||||||
|
#openmct;
|
||||||
|
#observingStaleness;
|
||||||
|
#watchingTheClock;
|
||||||
|
#isRealTime;
|
||||||
|
|
||||||
|
constructor(openmct) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.#openmct = openmct;
|
||||||
|
this.#observingStaleness = {};
|
||||||
|
this.#watchingTheClock = false;
|
||||||
|
this.#isRealTime = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
supportsStaleness(domainObject) {
|
||||||
|
return domainObject.type === 'generator';
|
||||||
|
}
|
||||||
|
|
||||||
|
isStale(domainObject, options) {
|
||||||
|
if (!this.#providingStaleness(domainObject)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const id = this.#getObjectKeyString(domainObject);
|
||||||
|
|
||||||
|
if (!this.#observerExists(id)) {
|
||||||
|
this.#createObserver(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.resolve({
|
||||||
|
isStale: this.#observingStaleness[id].isStale,
|
||||||
|
utc: Date.now()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
subscribeToStaleness(domainObject, callback) {
|
||||||
|
const id = this.#getObjectKeyString(domainObject);
|
||||||
|
|
||||||
|
if (this.#isRealTime === undefined) {
|
||||||
|
this.#updateRealTime(this.#openmct.time.clock());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.#handleClockUpdate();
|
||||||
|
|
||||||
|
if (this.#observerExists(id)) {
|
||||||
|
this.#addCallbackToObserver(id, callback);
|
||||||
|
} else {
|
||||||
|
this.#createObserver(id, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
const intervalId = setInterval(() => {
|
||||||
|
if (this.#providingStaleness(domainObject)) {
|
||||||
|
this.#updateStaleness(id, !this.#observingStaleness[id].isStale);
|
||||||
|
}
|
||||||
|
}, 10000);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
clearInterval(intervalId);
|
||||||
|
this.#updateStaleness(id, false);
|
||||||
|
this.#handleClockUpdate();
|
||||||
|
this.#destroyObserver(id);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#handleClockUpdate() {
|
||||||
|
let observers = Object.values(this.#observingStaleness).length > 0;
|
||||||
|
|
||||||
|
if (observers && !this.#watchingTheClock) {
|
||||||
|
this.#watchingTheClock = true;
|
||||||
|
this.#openmct.time.on('clock', this.#updateRealTime, this);
|
||||||
|
} else if (!observers && this.#watchingTheClock) {
|
||||||
|
this.#watchingTheClock = false;
|
||||||
|
this.#openmct.time.off('clock', this.#updateRealTime, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#updateRealTime(clock) {
|
||||||
|
this.#isRealTime = clock !== undefined;
|
||||||
|
|
||||||
|
if (!this.#isRealTime) {
|
||||||
|
Object.keys(this.#observingStaleness).forEach((id) => {
|
||||||
|
this.#updateStaleness(id, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#updateStaleness(id, isStale) {
|
||||||
|
this.#observingStaleness[id].isStale = isStale;
|
||||||
|
this.#observingStaleness[id].utc = Date.now();
|
||||||
|
this.#observingStaleness[id].callback({
|
||||||
|
isStale: this.#observingStaleness[id].isStale,
|
||||||
|
utc: this.#observingStaleness[id].utc
|
||||||
|
});
|
||||||
|
this.emit('stalenessEvent', {
|
||||||
|
id,
|
||||||
|
isStale: this.#observingStaleness[id].isStale
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#createObserver(id, callback) {
|
||||||
|
this.#observingStaleness[id] = {
|
||||||
|
isStale: false,
|
||||||
|
utc: Date.now()
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
this.#addCallbackToObserver(id, callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#destroyObserver(id) {
|
||||||
|
if (this.#observingStaleness[id]) {
|
||||||
|
delete this.#observingStaleness[id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#providingStaleness(domainObject) {
|
||||||
|
return domainObject.telemetry?.staleness === true && this.#isRealTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
#getObjectKeyString(object) {
|
||||||
|
return this.#openmct.objects.makeKeyString(object.identifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
#addCallbackToObserver(id, callback) {
|
||||||
|
this.#observingStaleness[id].callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
#observerExists(id) {
|
||||||
|
return this.#observingStaleness?.[id];
|
||||||
|
}
|
||||||
|
}
|
@ -25,14 +25,24 @@ define([
|
|||||||
], function (
|
], function (
|
||||||
{ v4: uuid }
|
{ v4: uuid }
|
||||||
) {
|
) {
|
||||||
function WorkerInterface(openmct) {
|
function WorkerInterface(openmct, StalenessProvider) {
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
const workerUrl = `${openmct.getAssetPath()}${__OPENMCT_ROOT_RELATIVE__}generatorWorker.js`;
|
const workerUrl = `${openmct.getAssetPath()}${__OPENMCT_ROOT_RELATIVE__}generatorWorker.js`;
|
||||||
|
this.StalenessProvider = StalenessProvider;
|
||||||
this.worker = new Worker(workerUrl);
|
this.worker = new Worker(workerUrl);
|
||||||
this.worker.onmessage = this.onMessage.bind(this);
|
this.worker.onmessage = this.onMessage.bind(this);
|
||||||
this.callbacks = {};
|
this.callbacks = {};
|
||||||
|
this.staleTelemetryIds = {};
|
||||||
|
|
||||||
|
this.watchStaleness();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WorkerInterface.prototype.watchStaleness = function () {
|
||||||
|
this.StalenessProvider.on('stalenessEvent', ({ id, isStale}) => {
|
||||||
|
this.staleTelemetryIds[id] = isStale;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
WorkerInterface.prototype.onMessage = function (message) {
|
WorkerInterface.prototype.onMessage = function (message) {
|
||||||
message = message.data;
|
message = message.data;
|
||||||
var callback = this.callbacks[message.id];
|
var callback = this.callbacks[message.id];
|
||||||
@ -83,11 +93,12 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
WorkerInterface.prototype.subscribe = function (request, cb) {
|
WorkerInterface.prototype.subscribe = function (request, cb) {
|
||||||
function callback(message) {
|
const id = request.id;
|
||||||
|
const messageId = this.dispatch('subscribe', request, (message) => {
|
||||||
|
if (!this.staleTelemetryIds[id]) {
|
||||||
cb(message.data);
|
cb(message.data);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
var messageId = this.dispatch('subscribe', request, callback);
|
|
||||||
|
|
||||||
return function () {
|
return function () {
|
||||||
this.dispatch('unsubscribe', {
|
this.dispatch('unsubscribe', {
|
||||||
|
@ -76,10 +76,10 @@
|
|||||||
name: data.name,
|
name: data.name,
|
||||||
utc: nextStep,
|
utc: nextStep,
|
||||||
yesterday: nextStep - 60 * 60 * 24 * 1000,
|
yesterday: nextStep - 60 * 60 * 24 * 1000,
|
||||||
sin: sin(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness),
|
sin: sin(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness, data.infinityValues),
|
||||||
wavelengths: wavelengths(),
|
wavelengths: wavelengths(),
|
||||||
intensities: intensities(),
|
intensities: intensities(),
|
||||||
cos: cos(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness)
|
cos: cos(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness, data.infinityValues)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
nextStep += step;
|
nextStep += step;
|
||||||
@ -117,6 +117,7 @@
|
|||||||
var phase = request.phase;
|
var phase = request.phase;
|
||||||
var randomness = request.randomness;
|
var randomness = request.randomness;
|
||||||
var loadDelay = Math.max(request.loadDelay, 0);
|
var loadDelay = Math.max(request.loadDelay, 0);
|
||||||
|
var infinityValues = request.infinityValues;
|
||||||
|
|
||||||
var step = 1000 / dataRateInHz;
|
var step = 1000 / dataRateInHz;
|
||||||
var nextStep = start - (start % step) + step;
|
var nextStep = start - (start % step) + step;
|
||||||
@ -127,10 +128,10 @@
|
|||||||
data.push({
|
data.push({
|
||||||
utc: nextStep,
|
utc: nextStep,
|
||||||
yesterday: nextStep - 60 * 60 * 24 * 1000,
|
yesterday: nextStep - 60 * 60 * 24 * 1000,
|
||||||
sin: sin(nextStep, period, amplitude, offset, phase, randomness),
|
sin: sin(nextStep, period, amplitude, offset, phase, randomness, infinityValues),
|
||||||
wavelengths: wavelengths(),
|
wavelengths: wavelengths(),
|
||||||
intensities: intensities(),
|
intensities: intensities(),
|
||||||
cos: cos(nextStep, period, amplitude, offset, phase, randomness)
|
cos: cos(nextStep, period, amplitude, offset, phase, randomness, infinityValues)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,12 +156,20 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function cos(timestamp, period, amplitude, offset, phase, randomness) {
|
function cos(timestamp, period, amplitude, offset, phase, randomness, infinityValues) {
|
||||||
|
if (infinityValues && Math.random() > 0.5) {
|
||||||
|
return Number.POSITIVE_INFINITY;
|
||||||
|
}
|
||||||
|
|
||||||
return amplitude
|
return amplitude
|
||||||
* Math.cos(phase + (timestamp / period / 1000 * Math.PI * 2)) + (amplitude * Math.random() * randomness) + offset;
|
* Math.cos(phase + (timestamp / period / 1000 * Math.PI * 2)) + (amplitude * Math.random() * randomness) + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sin(timestamp, period, amplitude, offset, phase, randomness) {
|
function sin(timestamp, period, amplitude, offset, phase, randomness, infinityValues) {
|
||||||
|
if (infinityValues && Math.random() > 0.5) {
|
||||||
|
return Number.POSITIVE_INFINITY;
|
||||||
|
}
|
||||||
|
|
||||||
return amplitude
|
return amplitude
|
||||||
* Math.sin(phase + (timestamp / period / 1000 * Math.PI * 2)) + (amplitude * Math.random() * randomness) + offset;
|
* Math.sin(phase + (timestamp / period / 1000 * Math.PI * 2)) + (amplitude * Math.random() * randomness) + offset;
|
||||||
}
|
}
|
||||||
|
@ -20,19 +20,13 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
define([
|
import GeneratorProvider from "./GeneratorProvider";
|
||||||
"./GeneratorProvider",
|
import SinewaveLimitProvider from "./SinewaveLimitProvider";
|
||||||
"./SinewaveLimitProvider",
|
import SinewaveStalenessProvider from "./SinewaveStalenessProvider";
|
||||||
"./StateGeneratorProvider",
|
import StateGeneratorProvider from "./StateGeneratorProvider";
|
||||||
"./GeneratorMetadataProvider"
|
import GeneratorMetadataProvider from "./GeneratorMetadataProvider";
|
||||||
], function (
|
|
||||||
GeneratorProvider,
|
|
||||||
SinewaveLimitProvider,
|
|
||||||
StateGeneratorProvider,
|
|
||||||
GeneratorMetadataProvider
|
|
||||||
) {
|
|
||||||
|
|
||||||
return function (openmct) {
|
export default function (openmct) {
|
||||||
|
|
||||||
openmct.types.addType("example.state-generator", {
|
openmct.types.addType("example.state-generator", {
|
||||||
name: "State Generator",
|
name: "State Generator",
|
||||||
@ -143,6 +137,26 @@ define([
|
|||||||
"telemetry",
|
"telemetry",
|
||||||
"loadDelay"
|
"loadDelay"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Include Infinity Values",
|
||||||
|
control: "toggleSwitch",
|
||||||
|
cssClass: "l-input",
|
||||||
|
key: "infinityValues",
|
||||||
|
property: [
|
||||||
|
"telemetry",
|
||||||
|
"infinityValues"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Provide Staleness Updates",
|
||||||
|
control: "toggleSwitch",
|
||||||
|
cssClass: "l-input",
|
||||||
|
key: "staleness",
|
||||||
|
property: [
|
||||||
|
"telemetry",
|
||||||
|
"staleness"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
initialize: function (object) {
|
initialize: function (object) {
|
||||||
@ -153,14 +167,16 @@ define([
|
|||||||
dataRateInHz: 1,
|
dataRateInHz: 1,
|
||||||
phase: 0,
|
phase: 0,
|
||||||
randomness: 0,
|
randomness: 0,
|
||||||
loadDelay: 0
|
loadDelay: 0,
|
||||||
|
infinityValues: false,
|
||||||
|
staleness: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const stalenessProvider = new SinewaveStalenessProvider(openmct);
|
||||||
|
|
||||||
openmct.telemetry.addProvider(new GeneratorProvider(openmct));
|
openmct.telemetry.addProvider(new GeneratorProvider(openmct, stalenessProvider));
|
||||||
openmct.telemetry.addProvider(new GeneratorMetadataProvider());
|
openmct.telemetry.addProvider(new GeneratorMetadataProvider());
|
||||||
openmct.telemetry.addProvider(new SinewaveLimitProvider());
|
openmct.telemetry.addProvider(new SinewaveLimitProvider());
|
||||||
};
|
openmct.telemetry.addProvider(stalenessProvider);
|
||||||
|
}
|
||||||
});
|
|
||||||
|
@ -107,6 +107,15 @@ export default function () {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Image Thumbnail',
|
||||||
|
key: 'thumbnail-url',
|
||||||
|
format: 'thumbnail',
|
||||||
|
hints: {
|
||||||
|
thumbnail: 1
|
||||||
|
},
|
||||||
|
source: 'url'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Image Download Name',
|
name: 'Image Download Name',
|
||||||
key: 'imageDownloadName',
|
key: 'imageDownloadName',
|
||||||
@ -143,6 +152,16 @@ export default function () {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const formatThumbnail = {
|
||||||
|
format: function (url) {
|
||||||
|
return `${url}?w=100&h=100`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
openmct.telemetry.addFormat({
|
||||||
|
key: 'thumbnail',
|
||||||
|
...formatThumbnail
|
||||||
|
});
|
||||||
openmct.telemetry.addProvider(getRealtimeProvider());
|
openmct.telemetry.addProvider(getRealtimeProvider());
|
||||||
openmct.telemetry.addProvider(getHistoricalProvider());
|
openmct.telemetry.addProvider(getHistoricalProvider());
|
||||||
openmct.telemetry.addProvider(getLadProvider());
|
openmct.telemetry.addProvider(getLadProvider());
|
||||||
@ -242,6 +261,13 @@ function pointForTimestamp(timestamp, name, imageSamples, delay) {
|
|||||||
const url = imageSamples[Math.floor(timestamp / delay) % imageSamples.length];
|
const url = imageSamples[Math.floor(timestamp / delay) % imageSamples.length];
|
||||||
const urlItems = url.split('/');
|
const urlItems = url.split('/');
|
||||||
const imageDownloadName = `example.imagery.${urlItems[urlItems.length - 1]}`;
|
const imageDownloadName = `example.imagery.${urlItems[urlItems.length - 1]}`;
|
||||||
|
const navCamTransformations = {
|
||||||
|
"translateX": 0,
|
||||||
|
"translateY": 18,
|
||||||
|
"rotation": 0,
|
||||||
|
"scale": 0.3,
|
||||||
|
"cameraAngleOfView": 70
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
@ -249,8 +275,9 @@ function pointForTimestamp(timestamp, name, imageSamples, delay) {
|
|||||||
local: Math.floor(timestamp / delay) * delay,
|
local: Math.floor(timestamp / delay) * delay,
|
||||||
url,
|
url,
|
||||||
sunOrientation: getCompassValues(0, 360),
|
sunOrientation: getCompassValues(0, 360),
|
||||||
cameraPan: getCompassValues(0, 360),
|
cameraAzimuth: getCompassValues(0, 360),
|
||||||
heading: getCompassValues(0, 360),
|
heading: getCompassValues(0, 360),
|
||||||
|
transformations: navCamTransformations,
|
||||||
imageDownloadName
|
imageDownloadName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,12 @@ module.exports = (config) => {
|
|||||||
let singleRun;
|
let singleRun;
|
||||||
|
|
||||||
if (process.env.KARMA_DEBUG) {
|
if (process.env.KARMA_DEBUG) {
|
||||||
webpackConfig = require('./webpack.dev.js');
|
webpackConfig = require("./.webpack/webpack.dev.js");
|
||||||
browsers = ['ChromeDebugging'];
|
browsers = ["ChromeDebugging"];
|
||||||
singleRun = false;
|
singleRun = false;
|
||||||
} else {
|
} else {
|
||||||
webpackConfig = require('./webpack.coverage.js');
|
webpackConfig = require("./.webpack/webpack.coverage.js");
|
||||||
browsers = ['ChromeHeadless'];
|
browsers = ["ChromeHeadless"];
|
||||||
singleRun = true;
|
singleRun = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,28 +42,28 @@ module.exports = (config) => {
|
|||||||
delete webpackConfig.entry;
|
delete webpackConfig.entry;
|
||||||
|
|
||||||
config.set({
|
config.set({
|
||||||
basePath: '',
|
basePath: "",
|
||||||
frameworks: ['jasmine', 'webpack'],
|
frameworks: ["jasmine", "webpack"],
|
||||||
files: [
|
files: [
|
||||||
'indexTest.js',
|
"indexTest.js",
|
||||||
// included means: should the files be included in the browser using <script> tag?
|
// included means: should the files be included in the browser using <script> tag?
|
||||||
// We don't want them as a <script> because the shared worker source
|
// We don't want them as a <script> because the shared worker source
|
||||||
// needs loaded remotely by the shared worker process.
|
// needs loaded remotely by the shared worker process.
|
||||||
{
|
{
|
||||||
pattern: 'dist/couchDBChangesFeed.js*',
|
pattern: "dist/couchDBChangesFeed.js*",
|
||||||
included: false
|
included: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: 'dist/inMemorySearchWorker.js*',
|
pattern: "dist/inMemorySearchWorker.js*",
|
||||||
included: false
|
included: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: 'dist/generatorWorker.js*',
|
pattern: "dist/generatorWorker.js*",
|
||||||
included: false
|
included: false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
port: 9876,
|
port: 9876,
|
||||||
reporters: ['spec', 'junit', 'coverage-istanbul'],
|
reporters: ["spec", "junit", "coverage-istanbul"],
|
||||||
browsers,
|
browsers,
|
||||||
client: {
|
client: {
|
||||||
jasmine: {
|
jasmine: {
|
||||||
@ -73,8 +73,8 @@ module.exports = (config) => {
|
|||||||
},
|
},
|
||||||
customLaunchers: {
|
customLaunchers: {
|
||||||
ChromeDebugging: {
|
ChromeDebugging: {
|
||||||
base: 'Chrome',
|
base: "Chrome",
|
||||||
flags: ['--remote-debugging-port=9222'],
|
flags: ["--remote-debugging-port=9222"],
|
||||||
debug: true
|
debug: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -90,7 +90,7 @@ module.exports = (config) => {
|
|||||||
fixWebpackSourcePaths: true,
|
fixWebpackSourcePaths: true,
|
||||||
skipFilesWithNoCoverage: true,
|
skipFilesWithNoCoverage: true,
|
||||||
dir: "coverage/unit", //Sets coverage file to be consumed by codecov.io
|
dir: "coverage/unit", //Sets coverage file to be consumed by codecov.io
|
||||||
reports: ['lcovonly']
|
reports: ["lcovonly"]
|
||||||
},
|
},
|
||||||
specReporter: {
|
specReporter: {
|
||||||
maxLogLines: 5,
|
maxLogLines: 5,
|
||||||
@ -102,11 +102,11 @@ module.exports = (config) => {
|
|||||||
failFast: false
|
failFast: false
|
||||||
},
|
},
|
||||||
preprocessors: {
|
preprocessors: {
|
||||||
'indexTest.js': ['webpack', 'sourcemap']
|
"indexTest.js": ["webpack", "sourcemap"]
|
||||||
},
|
},
|
||||||
webpack: webpackConfig,
|
webpack: webpackConfig,
|
||||||
webpackMiddleware: {
|
webpackMiddleware: {
|
||||||
stats: 'errors-warnings'
|
stats: "errors-warnings"
|
||||||
},
|
},
|
||||||
concurrency: 1,
|
concurrency: 1,
|
||||||
singleRun,
|
singleRun,
|
||||||
|
55
package.json
@ -1,28 +1,29 @@
|
|||||||
{
|
{
|
||||||
"name": "openmct",
|
"name": "openmct",
|
||||||
"version": "2.1.4-SNAPSHOT",
|
"version": "2.2.0-SNAPSHOT",
|
||||||
"description": "The Open MCT core platform",
|
"description": "The Open MCT core platform",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/eslint-parser": "7.18.9",
|
"@babel/eslint-parser": "7.18.9",
|
||||||
"@braintree/sanitize-url": "6.0.2",
|
"@braintree/sanitize-url": "6.0.2",
|
||||||
"@percy/cli": "1.16.0",
|
"@percy/cli": "1.17.0",
|
||||||
"@percy/playwright": "1.0.4",
|
"@percy/playwright": "1.0.4",
|
||||||
"@playwright/test": "1.25.2",
|
"@playwright/test": "1.29.0",
|
||||||
|
"@types/eventemitter3": "1.2.0",
|
||||||
"@types/jasmine": "4.3.1",
|
"@types/jasmine": "4.3.1",
|
||||||
"@types/lodash": "4.14.191",
|
"@types/lodash": "4.14.191",
|
||||||
"babel-loader": "9.0.0",
|
"babel-loader": "9.1.0",
|
||||||
"babel-plugin-istanbul": "6.1.1",
|
"babel-plugin-istanbul": "6.1.1",
|
||||||
"codecov": "3.8.3",
|
"codecov": "3.8.3",
|
||||||
"comma-separated-values": "3.6.4",
|
"comma-separated-values": "3.6.4",
|
||||||
"copy-webpack-plugin": "11.0.0",
|
"copy-webpack-plugin": "11.0.0",
|
||||||
"css-loader": "6.7.1",
|
"css-loader": "6.7.3",
|
||||||
"d3-axis": "3.0.0",
|
"d3-axis": "3.0.0",
|
||||||
"d3-scale": "3.3.0",
|
"d3-scale": "3.3.0",
|
||||||
"d3-selection": "3.0.0",
|
"d3-selection": "3.0.0",
|
||||||
"eslint": "8.29.0",
|
"eslint": "8.35.0",
|
||||||
"eslint-plugin-compat": "4.0.2",
|
"eslint-plugin-compat": "4.1.1",
|
||||||
"eslint-plugin-playwright": "0.11.2",
|
"eslint-plugin-playwright": "0.12.0",
|
||||||
"eslint-plugin-vue": "9.8.0",
|
"eslint-plugin-vue": "9.9.0",
|
||||||
"eslint-plugin-you-dont-need-lodash-underscore": "6.12.0",
|
"eslint-plugin-you-dont-need-lodash-underscore": "6.12.0",
|
||||||
"eventemitter3": "1.2.0",
|
"eventemitter3": "1.2.0",
|
||||||
"file-saver": "2.0.5",
|
"file-saver": "2.0.5",
|
||||||
@ -38,26 +39,31 @@
|
|||||||
"karma-jasmine": "5.1.0",
|
"karma-jasmine": "5.1.0",
|
||||||
"karma-junit-reporter": "2.0.1",
|
"karma-junit-reporter": "2.0.1",
|
||||||
"karma-sourcemap-loader": "0.3.8",
|
"karma-sourcemap-loader": "0.3.8",
|
||||||
"karma-spec-reporter": "0.0.34",
|
"karma-spec-reporter": "0.0.36",
|
||||||
"karma-webpack": "5.0.0",
|
"karma-webpack": "5.0.0",
|
||||||
|
"kdbush": "^3.0.0",
|
||||||
"location-bar": "3.0.1",
|
"location-bar": "3.0.1",
|
||||||
"lodash": "4.17.21",
|
"lodash": "4.17.21",
|
||||||
"mini-css-extract-plugin": "2.7.2",
|
"mini-css-extract-plugin": "2.7.2",
|
||||||
"moment": "2.29.4",
|
"moment": "2.29.4",
|
||||||
"moment-duration-format": "2.3.2",
|
"moment-duration-format": "2.3.2",
|
||||||
"moment-timezone": "0.5.38",
|
"moment-timezone": "0.5.41",
|
||||||
"nyc": "15.1.0",
|
"nyc": "15.1.0",
|
||||||
"painterro": "1.2.78",
|
"painterro": "1.2.78",
|
||||||
"playwright-core": "1.25.2",
|
"playwright-core": "1.29.0",
|
||||||
"plotly.js-basic-dist": "2.14.0",
|
"axe-playwright": "1.2.3",
|
||||||
"plotly.js-gl2d-dist": "2.14.0",
|
"axe-html-reporter": "2.2.3",
|
||||||
|
"@axe-core/playwright": "4.6.0",
|
||||||
|
"plotly.js-basic-dist": "2.17.0",
|
||||||
|
"plotly.js-gl2d-dist": "2.17.1",
|
||||||
"printj": "1.3.1",
|
"printj": "1.3.1",
|
||||||
"resolve-url-loader": "5.0.0",
|
"resolve-url-loader": "5.0.0",
|
||||||
"sass": "1.56.1",
|
"sanitize-html": "2.10.0",
|
||||||
"sass-loader": "13.0.2",
|
"sass": "1.57.1",
|
||||||
"sinon": "14.0.1",
|
"sass-loader": "13.2.0",
|
||||||
|
"sinon": "15.0.1",
|
||||||
"style-loader": "^3.3.1",
|
"style-loader": "^3.3.1",
|
||||||
"typescript": "4.9.3",
|
"typescript": "4.9.5",
|
||||||
"uuid": "9.0.0",
|
"uuid": "9.0.0",
|
||||||
"vue": "2.6.14",
|
"vue": "2.6.14",
|
||||||
"vue-eslint-parser": "9.1.0",
|
"vue-eslint-parser": "9.1.0",
|
||||||
@ -71,18 +77,19 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rm -rf ./dist ./node_modules ./package-lock.json",
|
"clean": "rm -rf ./dist ./node_modules ./package-lock.json",
|
||||||
"clean-test-lint": "npm run clean; npm install; npm run test; npm run lint",
|
"clean-test-lint": "npm run clean; npm install; npm run test; npm run lint",
|
||||||
"start": "npx webpack serve --config ./webpack.dev.js",
|
"start": "npx webpack serve --config ./.webpack/webpack.dev.js",
|
||||||
"start:coverage": "npx webpack serve --config ./webpack.coverage.js",
|
"start:coverage": "npx webpack serve --config ./.webpack/webpack.coverage.js",
|
||||||
"lint": "eslint example src e2e --ext .js,.vue openmct.js --max-warnings=0",
|
"lint": "eslint example src e2e --ext .js,.vue openmct.js --max-warnings=0",
|
||||||
"lint:fix": "eslint example src e2e --ext .js,.vue openmct.js --fix",
|
"lint:fix": "eslint example src e2e --ext .js,.vue openmct.js --fix",
|
||||||
"build:prod": "webpack --config webpack.prod.js",
|
"build:prod": "webpack --config ./.webpack/webpack.prod.js",
|
||||||
"build:dev": "webpack --config webpack.dev.js",
|
"build:dev": "webpack --config ./.webpack/webpack.dev.js",
|
||||||
"build:coverage": "webpack --config webpack.coverage.js",
|
"build:coverage": "webpack --config ./.webpack/webpack.coverage.js",
|
||||||
"build:watch": "webpack --config webpack.dev.js --watch",
|
"build:watch": "webpack --config ./.webpack/webpack.dev.js --watch",
|
||||||
"info": "npx envinfo --system --browsers --npmPackages --binaries --languages --markdown",
|
"info": "npx envinfo --system --browsers --npmPackages --binaries --languages --markdown",
|
||||||
"test": "karma start",
|
"test": "karma start",
|
||||||
"test:debug": "KARMA_DEBUG=true karma start",
|
"test:debug": "KARMA_DEBUG=true karma start",
|
||||||
"test:e2e": "npx playwright test",
|
"test:e2e": "npx playwright test",
|
||||||
|
"test:e2e:a11y": "npx playwright test --config=e2e/playwright-a11y.config.js --project=chrome --grep-invert @unstable",
|
||||||
"test:e2e:couchdb": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @couchdb",
|
"test:e2e:couchdb": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @couchdb",
|
||||||
"test:e2e:stable": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep-invert \"@unstable|@couchdb\"",
|
"test:e2e:stable": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep-invert \"@unstable|@couchdb\"",
|
||||||
"test:e2e:unstable": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @unstable",
|
"test:e2e:unstable": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @unstable",
|
||||||
|
@ -256,6 +256,15 @@ define([
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MCT's annotation API that enables
|
||||||
|
* human-created comments and categorization linked to data products
|
||||||
|
* @type {module:openmct.AnnotationAPI}
|
||||||
|
* @memberof module:openmct.MCT#
|
||||||
|
* @name annotation
|
||||||
|
*/
|
||||||
|
this.annotation = new api.AnnotationAPI(this);
|
||||||
|
|
||||||
// Plugins that are installed by default
|
// Plugins that are installed by default
|
||||||
this.install(this.plugins.Plot());
|
this.install(this.plugins.Plot());
|
||||||
this.install(this.plugins.TelemetryTable.default());
|
this.install(this.plugins.TelemetryTable.default());
|
||||||
|
@ -73,6 +73,10 @@ export default class Editor extends EventEmitter {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const transaction = this.openmct.objects.getActiveTransaction();
|
const transaction = this.openmct.objects.getActiveTransaction();
|
||||||
|
if (!transaction) {
|
||||||
|
return resolve();
|
||||||
|
}
|
||||||
|
|
||||||
transaction.cancel()
|
transaction.cancel()
|
||||||
.then(resolve)
|
.then(resolve)
|
||||||
.catch(reject)
|
.catch(reject)
|
||||||
|
@ -52,6 +52,29 @@ const ANNOTATION_LAST_CREATED = 'annotationLastCreated';
|
|||||||
* @property {String} foregroundColor eg. "#ffffff"
|
* @property {String} foregroundColor eg. "#ffffff"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {import('../objects/ObjectAPI').DomainObject} DomainObject
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {import('../objects/ObjectAPI').Identifier} Identifier
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {import('../../../openmct').OpenMCT} OpenMCT
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An interface for interacting with annotations of domain objects.
|
||||||
|
* An annotation of a domain object is an operator created object for the purposes
|
||||||
|
* of further describing data in plots, notebooks, maps, etc. For example, an annotation
|
||||||
|
* could be a tag on a plot notating an interesting set of points labeled SCIENCE. It could
|
||||||
|
* also be set of notebook entries the operator has tagged DRIVING when a robot monitored by OpenMCT
|
||||||
|
* about rationals behind why the robot has taken a certain path.
|
||||||
|
* Annotations are discoverable using search, and are typically rendered in OpenMCT views to bring attention
|
||||||
|
* to other users.
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
export default class AnnotationAPI extends EventEmitter {
|
export default class AnnotationAPI extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,6 +84,7 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
super();
|
super();
|
||||||
this.openmct = openmct;
|
this.openmct = openmct;
|
||||||
this.availableTags = {};
|
this.availableTags = {};
|
||||||
|
this.namespaceToSaveAnnotations = '';
|
||||||
|
|
||||||
this.ANNOTATION_TYPES = ANNOTATION_TYPES;
|
this.ANNOTATION_TYPES = ANNOTATION_TYPES;
|
||||||
this.ANNOTATION_TYPE = ANNOTATION_TYPE;
|
this.ANNOTATION_TYPE = ANNOTATION_TYPE;
|
||||||
@ -81,24 +105,26 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the a generic annotation
|
* Creates an annotation on a given domain object (e.g., a plot) and a set of targets (e.g., telemetry objects)
|
||||||
* @typedef {Object} CreateAnnotationOptions
|
* @typedef {Object} CreateAnnotationOptions
|
||||||
* @property {String} name a name for the new parameter
|
* @property {String} name a name for the new annotation (e.g., "Plot annnotation")
|
||||||
* @property {import('../objects/ObjectAPI').DomainObject} domainObject the domain object to create
|
* @property {DomainObject} domainObject the domain object this annotation was created with
|
||||||
* @property {ANNOTATION_TYPES} annotationType the type of annotation to create
|
* @property {ANNOTATION_TYPES} annotationType the type of annotation to create (e.g., PLOT_SPATIAL)
|
||||||
* @property {Tag[]} tags
|
* @property {Tag[]} tags tags to add to the annotation, e.g., SCIENCE for science related annotations
|
||||||
* @property {String} contentText
|
* @property {String} contentText Some text to add to the annotation, e.g. ("This annotation is about science")
|
||||||
* @property {import('../objects/ObjectAPI').Identifier[]} targets
|
* @property {Object<string, Object>} targets The targets ID keystrings and their specific properties.
|
||||||
|
* For plots, this will be a bounding box, e.g.: {maxY: 100, minY: 0, maxX: 100, minX: 0}
|
||||||
|
* For notebooks, this will be an entry ID, e.g.: {entryId: "entry-ecb158f5-d23c-45e1-a704-649b382622ba"}
|
||||||
|
* @property {DomainObject>} targetDomainObjects the targets ID keystrings and the domain objects this annotation points to (e.g., telemetry objects for a plot)
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @method create
|
* @method create
|
||||||
* @param {CreateAnnotationOptions} options
|
* @param {CreateAnnotationOptions} options
|
||||||
* @returns {Promise<import('../objects/ObjectAPI').DomainObject>} a promise which will resolve when the domain object
|
* @returns {Promise<DomainObject>} a promise which will resolve when the domain object
|
||||||
* has been created, or be rejected if it cannot be saved
|
* has been created, or be rejected if it cannot be saved
|
||||||
*/
|
*/
|
||||||
async create({name, domainObject, annotationType, tags, contentText, targets}) {
|
async create({name, domainObject, annotationType, tags, contentText, targets, targetDomainObjects}) {
|
||||||
if (!Object.keys(this.ANNOTATION_TYPES).includes(annotationType)) {
|
if (!Object.keys(this.ANNOTATION_TYPES).includes(annotationType)) {
|
||||||
throw new Error(`Unknown annotation type: ${annotationType}`);
|
throw new Error(`Unknown annotation type: ${annotationType}`);
|
||||||
}
|
}
|
||||||
@ -107,10 +133,14 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
throw new Error(`At least one target is required to create an annotation`);
|
throw new Error(`At least one target is required to create an annotation`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Object.keys(targetDomainObjects).length) {
|
||||||
|
throw new Error(`At least one targetDomainObject is required to create an annotation`);
|
||||||
|
}
|
||||||
|
|
||||||
const domainObjectKeyString = this.openmct.objects.makeKeyString(domainObject.identifier);
|
const domainObjectKeyString = this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||||
const originalPathObjects = await this.openmct.objects.getOriginalPath(domainObjectKeyString);
|
const originalPathObjects = await this.openmct.objects.getOriginalPath(domainObjectKeyString);
|
||||||
const originalContextPath = this.openmct.objects.getRelativePath(originalPathObjects);
|
const originalContextPath = this.openmct.objects.getRelativePath(originalPathObjects);
|
||||||
const namespace = domainObject.identifier.namespace;
|
const namespace = this.namespaceToSaveAnnotations;
|
||||||
const type = 'annotation';
|
const type = 'annotation';
|
||||||
const typeDefinition = this.openmct.types.get(type);
|
const typeDefinition = this.openmct.types.get(type);
|
||||||
const definition = typeDefinition.definition;
|
const definition = typeDefinition.definition;
|
||||||
@ -139,7 +169,9 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
const success = await this.openmct.objects.save(createdObject);
|
const success = await this.openmct.objects.save(createdObject);
|
||||||
if (success) {
|
if (success) {
|
||||||
this.emit('annotationCreated', createdObject);
|
this.emit('annotationCreated', createdObject);
|
||||||
this.#updateAnnotationModified(domainObject);
|
Object.values(targetDomainObjects).forEach(targetDomainObject => {
|
||||||
|
this.#updateAnnotationModified(targetDomainObject);
|
||||||
|
});
|
||||||
|
|
||||||
return createdObject;
|
return createdObject;
|
||||||
} else {
|
} else {
|
||||||
@ -147,8 +179,15 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#updateAnnotationModified(domainObject) {
|
#updateAnnotationModified(targetDomainObject) {
|
||||||
this.openmct.objects.mutate(domainObject, this.ANNOTATION_LAST_CREATED, Date.now());
|
// As certain telemetry objects are immutable, we'll need to check here first
|
||||||
|
// to see if we can add the annotation last created property.
|
||||||
|
// TODO: This should be removed once we have a better way to handle immutable telemetry objects
|
||||||
|
if (targetDomainObject.isMutable) {
|
||||||
|
this.openmct.objects.mutate(targetDomainObject, this.ANNOTATION_LAST_CREATED, Date.now());
|
||||||
|
} else {
|
||||||
|
this.emit('targetDomainObjectAnnotated', targetDomainObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -160,9 +199,17 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
this.availableTags[tagKey] = tagsDefinition;
|
this.availableTags[tagKey] = tagsDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method setNamespaceToSaveAnnotations
|
||||||
|
* @param {String} namespace the namespace to save new annotations to
|
||||||
|
*/
|
||||||
|
setNamespaceToSaveAnnotations(namespace) {
|
||||||
|
this.namespaceToSaveAnnotations = namespace;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method isAnnotation
|
* @method isAnnotation
|
||||||
* @param {import('../objects/ObjectAPI').DomainObject} domainObject domainObject the domainObject in question
|
* @param {DomainObject} domainObject the domainObject in question
|
||||||
* @returns {Boolean} Returns true if the domain object is an annotation
|
* @returns {Boolean} Returns true if the domain object is an annotation
|
||||||
*/
|
*/
|
||||||
isAnnotation(domainObject) {
|
isAnnotation(domainObject) {
|
||||||
@ -190,56 +237,19 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @method getAnnotations
|
* @method getAnnotations
|
||||||
* @param {String} query - The keystring of the domain object to search for annotations for
|
* @param {Identifier} domainObjectIdentifier - The domain object identifier to use to search for annotations. For example, a telemetry object identifier.
|
||||||
* @returns {import('../objects/ObjectAPI').DomainObject[]} Returns an array of domain objects that match the search query
|
* @returns {DomainObject[]} Returns an array of annotations that match the search query
|
||||||
*/
|
*/
|
||||||
async getAnnotations(query) {
|
async getAnnotations(domainObjectIdentifier) {
|
||||||
const searchResults = (await Promise.all(this.openmct.objects.search(query, null, this.openmct.objects.SEARCH_TYPES.ANNOTATIONS))).flat();
|
const keyStringQuery = this.openmct.objects.makeKeyString(domainObjectIdentifier);
|
||||||
|
const searchResults = (await Promise.all(this.openmct.objects.search(keyStringQuery, null, this.openmct.objects.SEARCH_TYPES.ANNOTATIONS))).flat();
|
||||||
|
|
||||||
return searchResults;
|
return searchResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @method addSingleAnnotationTag
|
|
||||||
* @param {import('../objects/ObjectAPI').DomainObject=} existingAnnotation - An optional annotation to add the tag to. If not specified, we will create an annotation.
|
|
||||||
* @param {import('../objects/ObjectAPI').DomainObject} targetDomainObject - The domain object the annotation will point to.
|
|
||||||
* @param {Object=} targetSpecificDetails - Optional object to add to the target object. E.g., for notebooks this would be an entryID
|
|
||||||
* @param {AnnotationType} annotationType - The type of annotation this is for.
|
|
||||||
* @returns {import('../objects/ObjectAPI').DomainObject[]} Returns the annotation that was either created or passed as an existingAnnotation
|
|
||||||
*/
|
|
||||||
async addSingleAnnotationTag(existingAnnotation, targetDomainObject, targetSpecificDetails, annotationType, tag) {
|
|
||||||
if (!existingAnnotation) {
|
|
||||||
const targets = {};
|
|
||||||
const targetKeyString = this.openmct.objects.makeKeyString(targetDomainObject.identifier);
|
|
||||||
targets[targetKeyString] = targetSpecificDetails;
|
|
||||||
const contentText = `${annotationType} tag`;
|
|
||||||
const annotationCreationArguments = {
|
|
||||||
name: contentText,
|
|
||||||
domainObject: targetDomainObject,
|
|
||||||
annotationType,
|
|
||||||
tags: [tag],
|
|
||||||
contentText,
|
|
||||||
targets
|
|
||||||
};
|
|
||||||
const newAnnotation = await this.create(annotationCreationArguments);
|
|
||||||
|
|
||||||
return newAnnotation;
|
|
||||||
} else {
|
|
||||||
if (!existingAnnotation.tags.includes(tag)) {
|
|
||||||
throw new Error(`Existing annotation did not contain tag ${tag}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (existingAnnotation._deleted) {
|
|
||||||
this.unDeleteAnnotation(existingAnnotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
return existingAnnotation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method deleteAnnotations
|
* @method deleteAnnotations
|
||||||
* @param {import('../objects/ObjectAPI').DomainObject[]} existingAnnotation - An array of annotations to delete (set _deleted to true)
|
* @param {DomainObject[]} existingAnnotation - An array of annotations to delete (set _deleted to true)
|
||||||
*/
|
*/
|
||||||
deleteAnnotations(annotations) {
|
deleteAnnotations(annotations) {
|
||||||
if (!annotations) {
|
if (!annotations) {
|
||||||
@ -255,7 +265,7 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @method deleteAnnotations
|
* @method deleteAnnotations
|
||||||
* @param {import('../objects/ObjectAPI').DomainObject} existingAnnotation - An annotations to undelete (set _deleted to false)
|
* @param {DomainObject} annotation - An annotation to undelete (set _deleted to false)
|
||||||
*/
|
*/
|
||||||
unDeleteAnnotation(annotation) {
|
unDeleteAnnotation(annotation) {
|
||||||
if (!annotation) {
|
if (!annotation) {
|
||||||
@ -265,6 +275,39 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
this.openmct.objects.mutate(annotation, '_deleted', false);
|
this.openmct.objects.mutate(annotation, '_deleted', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTagsFromAnnotations(annotations, filterDuplicates = true) {
|
||||||
|
if (!annotations) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
let tagsFromAnnotations = annotations.flatMap((annotation) => {
|
||||||
|
if (annotation._deleted) {
|
||||||
|
return [];
|
||||||
|
} else {
|
||||||
|
return annotation.tags;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (filterDuplicates) {
|
||||||
|
tagsFromAnnotations = tagsFromAnnotations.filter((tag, index, tagArray) => {
|
||||||
|
return tagArray.indexOf(tag) === index;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const fullTagModels = this.#addTagMetaInformationToTags(tagsFromAnnotations);
|
||||||
|
|
||||||
|
return fullTagModels;
|
||||||
|
}
|
||||||
|
|
||||||
|
#addTagMetaInformationToTags(tags) {
|
||||||
|
return tags.map(tagKey => {
|
||||||
|
const tagModel = this.availableTags[tagKey];
|
||||||
|
tagModel.tagID = tagKey;
|
||||||
|
|
||||||
|
return tagModel;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#getMatchingTags(query) {
|
#getMatchingTags(query) {
|
||||||
if (!query) {
|
if (!query) {
|
||||||
return [];
|
return [];
|
||||||
@ -283,12 +326,7 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
|
|
||||||
#addTagMetaInformationToResults(results, matchingTagKeys) {
|
#addTagMetaInformationToResults(results, matchingTagKeys) {
|
||||||
const tagsAddedToResults = results.map(result => {
|
const tagsAddedToResults = results.map(result => {
|
||||||
const fullTagModels = result.tags.map(tagKey => {
|
const fullTagModels = this.#addTagMetaInformationToTags(result.tags);
|
||||||
const tagModel = this.availableTags[tagKey];
|
|
||||||
tagModel.tagID = tagKey;
|
|
||||||
|
|
||||||
return tagModel;
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fullTagModels,
|
fullTagModels,
|
||||||
@ -338,6 +376,33 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
return combinedResults;
|
return combinedResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method #breakApartSeparateTargets
|
||||||
|
* @param {Array} results A set of search results that could have the multiple targets for the same result
|
||||||
|
* @returns {Array} The same set of results, but with each target separated out into its own result
|
||||||
|
*/
|
||||||
|
#breakApartSeparateTargets(results) {
|
||||||
|
const separateResults = [];
|
||||||
|
results.forEach(result => {
|
||||||
|
Object.keys(result.targets).forEach(targetID => {
|
||||||
|
const separatedResult = {
|
||||||
|
...result
|
||||||
|
};
|
||||||
|
separatedResult.targets = {
|
||||||
|
[targetID]: result.targets[targetID]
|
||||||
|
};
|
||||||
|
separatedResult.targetModels = result.targetModels.filter(targetModel => {
|
||||||
|
const targetKeyString = this.openmct.objects.makeKeyString(targetModel.identifier);
|
||||||
|
|
||||||
|
return targetKeyString === targetID;
|
||||||
|
});
|
||||||
|
separateResults.push(separatedResult);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return separateResults;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method searchForTags
|
* @method searchForTags
|
||||||
* @param {String} query A query to match against tags. E.g., "dr" will match the tags "drilling" and "driving"
|
* @param {String} query A query to match against tags. E.g., "dr" will match the tags "drilling" and "driving"
|
||||||
@ -360,7 +425,8 @@ export default class AnnotationAPI extends EventEmitter {
|
|||||||
const resultsWithValidPath = appliedTargetsModels.filter(result => {
|
const resultsWithValidPath = appliedTargetsModels.filter(result => {
|
||||||
return this.openmct.objects.isReachable(result.targetModels?.[0]?.originalPath);
|
return this.openmct.objects.isReachable(result.targetModels?.[0]?.originalPath);
|
||||||
});
|
});
|
||||||
|
const breakApartSeparateTargets = this.#breakApartSeparateTargets(resultsWithValidPath);
|
||||||
|
|
||||||
return resultsWithValidPath;
|
return breakApartSeparateTargets;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import ExampleTagsPlugin from "../../../example/exampleTags/plugin";
|
|||||||
describe("The Annotation API", () => {
|
describe("The Annotation API", () => {
|
||||||
let openmct;
|
let openmct;
|
||||||
let mockObjectProvider;
|
let mockObjectProvider;
|
||||||
|
let mockImmutableObjectProvider;
|
||||||
let mockDomainObject;
|
let mockDomainObject;
|
||||||
let mockFolderObject;
|
let mockFolderObject;
|
||||||
let mockAnnotationObject;
|
let mockAnnotationObject;
|
||||||
@ -89,6 +90,23 @@ describe("The Annotation API", () => {
|
|||||||
mockObjectProvider.create.and.returnValue(Promise.resolve(true));
|
mockObjectProvider.create.and.returnValue(Promise.resolve(true));
|
||||||
mockObjectProvider.update.and.returnValue(Promise.resolve(true));
|
mockObjectProvider.update.and.returnValue(Promise.resolve(true));
|
||||||
|
|
||||||
|
mockImmutableObjectProvider = jasmine.createSpyObj("mock immutable provider", [
|
||||||
|
"get"
|
||||||
|
]);
|
||||||
|
// eslint-disable-next-line require-await
|
||||||
|
mockImmutableObjectProvider.get = async (identifier) => {
|
||||||
|
if (identifier.key === mockDomainObject.identifier.key) {
|
||||||
|
return mockDomainObject;
|
||||||
|
} else if (identifier.key === mockAnnotationObject.identifier.key) {
|
||||||
|
return mockAnnotationObject;
|
||||||
|
} else if (identifier.key === mockFolderObject.identifier.key) {
|
||||||
|
return mockFolderObject;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
openmct.objects.addProvider('immutableProvider', mockImmutableObjectProvider);
|
||||||
openmct.objects.addProvider('fooNameSpace', mockObjectProvider);
|
openmct.objects.addProvider('fooNameSpace', mockObjectProvider);
|
||||||
openmct.on('start', done);
|
openmct.on('start', done);
|
||||||
openmct.startHeadless();
|
openmct.startHeadless();
|
||||||
@ -108,12 +126,29 @@ describe("The Annotation API", () => {
|
|||||||
annotationType: openmct.annotation.ANNOTATION_TYPES.NOTEBOOK,
|
annotationType: openmct.annotation.ANNOTATION_TYPES.NOTEBOOK,
|
||||||
tags: ['sometag'],
|
tags: ['sometag'],
|
||||||
contentText: "fooContext",
|
contentText: "fooContext",
|
||||||
|
targetDomainObjects: [mockDomainObject],
|
||||||
targets: {'fooTarget': {}}
|
targets: {'fooTarget': {}}
|
||||||
};
|
};
|
||||||
const annotationObject = await openmct.annotation.create(annotationCreationArguments);
|
const annotationObject = await openmct.annotation.create(annotationCreationArguments);
|
||||||
expect(annotationObject).toBeDefined();
|
expect(annotationObject).toBeDefined();
|
||||||
expect(annotationObject.type).toEqual('annotation');
|
expect(annotationObject.type).toEqual('annotation');
|
||||||
});
|
});
|
||||||
|
it("can create annotations if domain object is immutable", async () => {
|
||||||
|
mockDomainObject.identifier.namespace = 'immutableProvider';
|
||||||
|
const annotationCreationArguments = {
|
||||||
|
name: 'Test Annotation',
|
||||||
|
domainObject: mockDomainObject,
|
||||||
|
annotationType: openmct.annotation.ANNOTATION_TYPES.NOTEBOOK,
|
||||||
|
tags: ['sometag'],
|
||||||
|
contentText: "fooContext",
|
||||||
|
targetDomainObjects: [mockDomainObject],
|
||||||
|
targets: {'fooTarget': {}}
|
||||||
|
};
|
||||||
|
openmct.annotation.setNamespaceToSaveAnnotations('fooNameSpace');
|
||||||
|
const annotationObject = await openmct.annotation.create(annotationCreationArguments);
|
||||||
|
expect(annotationObject).toBeDefined();
|
||||||
|
expect(annotationObject.type).toEqual('annotation');
|
||||||
|
});
|
||||||
it("fails if annotation is an unknown type", async () => {
|
it("fails if annotation is an unknown type", async () => {
|
||||||
try {
|
try {
|
||||||
await openmct.annotation.create('Garbage Annotation', mockDomainObject, 'garbageAnnotation', ['sometag'], "fooContext", {'fooTarget': {}});
|
await openmct.annotation.create('Garbage Annotation', mockDomainObject, 'garbageAnnotation', ['sometag'], "fooContext", {'fooTarget': {}});
|
||||||
@ -121,30 +156,69 @@ describe("The Annotation API", () => {
|
|||||||
expect(error).toBeDefined();
|
expect(error).toBeDefined();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
it("fails if annotation if given an immutable namespace to save to", async () => {
|
||||||
|
try {
|
||||||
|
const annotationCreationArguments = {
|
||||||
|
name: 'Test Annotation',
|
||||||
|
domainObject: mockDomainObject,
|
||||||
|
annotationType: openmct.annotation.ANNOTATION_TYPES.NOTEBOOK,
|
||||||
|
tags: ['sometag'],
|
||||||
|
contentText: "fooContext",
|
||||||
|
targetDomainObjects: [mockDomainObject],
|
||||||
|
targets: {'fooTarget': {}}
|
||||||
|
};
|
||||||
|
openmct.annotation.setNamespaceToSaveAnnotations('nameespaceThatDoesNotExist');
|
||||||
|
await openmct.annotation.create(annotationCreationArguments);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).toBeDefined();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("fails if annotation if given an undefined namespace to save to", async () => {
|
||||||
|
try {
|
||||||
|
const annotationCreationArguments = {
|
||||||
|
name: 'Test Annotation',
|
||||||
|
domainObject: mockDomainObject,
|
||||||
|
annotationType: openmct.annotation.ANNOTATION_TYPES.NOTEBOOK,
|
||||||
|
tags: ['sometag'],
|
||||||
|
contentText: "fooContext",
|
||||||
|
targetDomainObjects: [mockDomainObject],
|
||||||
|
targets: {'fooTarget': {}}
|
||||||
|
};
|
||||||
|
openmct.annotation.setNamespaceToSaveAnnotations('immutableProvider');
|
||||||
|
await openmct.annotation.create(annotationCreationArguments);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).toBeDefined();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Tagging", () => {
|
describe("Tagging", () => {
|
||||||
|
let tagCreationArguments;
|
||||||
|
beforeEach(() => {
|
||||||
|
tagCreationArguments = {
|
||||||
|
name: 'Test Annotation',
|
||||||
|
domainObject: mockDomainObject,
|
||||||
|
annotationType: openmct.annotation.ANNOTATION_TYPES.NOTEBOOK,
|
||||||
|
tags: ['aWonderfulTag'],
|
||||||
|
contentText: 'fooContext',
|
||||||
|
targets: {'fooNameSpace:some-object': {entryId: 'fooBarEntry'}},
|
||||||
|
targetDomainObjects: [mockDomainObject]
|
||||||
|
};
|
||||||
|
});
|
||||||
it("can create a tag", async () => {
|
it("can create a tag", async () => {
|
||||||
const annotationObject = await openmct.annotation.addSingleAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
const annotationObject = await openmct.annotation.create(tagCreationArguments);
|
||||||
expect(annotationObject).toBeDefined();
|
expect(annotationObject).toBeDefined();
|
||||||
expect(annotationObject.type).toEqual('annotation');
|
expect(annotationObject.type).toEqual('annotation');
|
||||||
expect(annotationObject.tags).toContain('aWonderfulTag');
|
expect(annotationObject.tags).toContain('aWonderfulTag');
|
||||||
});
|
});
|
||||||
it("can delete a tag", async () => {
|
it("can delete a tag", async () => {
|
||||||
const annotationObject = await openmct.annotation.addSingleAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
const annotationObject = await openmct.annotation.create(tagCreationArguments);
|
||||||
expect(annotationObject).toBeDefined();
|
expect(annotationObject).toBeDefined();
|
||||||
openmct.annotation.deleteAnnotations([annotationObject]);
|
openmct.annotation.deleteAnnotations([annotationObject]);
|
||||||
expect(annotationObject._deleted).toBeTrue();
|
expect(annotationObject._deleted).toBeTrue();
|
||||||
});
|
});
|
||||||
it("throws an error if deleting non-existent tag", async () => {
|
|
||||||
const annotationObject = await openmct.annotation.addSingleAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
|
||||||
expect(annotationObject).toBeDefined();
|
|
||||||
expect(() => {
|
|
||||||
openmct.annotation.removeAnnotationTag(annotationObject, 'ThisTagShouldNotExist');
|
|
||||||
}).toThrow();
|
|
||||||
});
|
|
||||||
it("can remove all tags", async () => {
|
it("can remove all tags", async () => {
|
||||||
const annotationObject = await openmct.annotation.addSingleAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
const annotationObject = await openmct.annotation.create(tagCreationArguments);
|
||||||
expect(annotationObject).toBeDefined();
|
expect(annotationObject).toBeDefined();
|
||||||
expect(() => {
|
expect(() => {
|
||||||
openmct.annotation.deleteAnnotations([annotationObject]);
|
openmct.annotation.deleteAnnotations([annotationObject]);
|
||||||
@ -152,13 +226,13 @@ describe("The Annotation API", () => {
|
|||||||
expect(annotationObject._deleted).toBeTrue();
|
expect(annotationObject._deleted).toBeTrue();
|
||||||
});
|
});
|
||||||
it("can add/delete/add a tag", async () => {
|
it("can add/delete/add a tag", async () => {
|
||||||
let annotationObject = await openmct.annotation.addSingleAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
let annotationObject = await openmct.annotation.create(tagCreationArguments);
|
||||||
expect(annotationObject).toBeDefined();
|
expect(annotationObject).toBeDefined();
|
||||||
expect(annotationObject.type).toEqual('annotation');
|
expect(annotationObject.type).toEqual('annotation');
|
||||||
expect(annotationObject.tags).toContain('aWonderfulTag');
|
expect(annotationObject.tags).toContain('aWonderfulTag');
|
||||||
openmct.annotation.deleteAnnotations([annotationObject]);
|
openmct.annotation.deleteAnnotations([annotationObject]);
|
||||||
expect(annotationObject._deleted).toBeTrue();
|
expect(annotationObject._deleted).toBeTrue();
|
||||||
annotationObject = await openmct.annotation.addSingleAnnotationTag(null, mockDomainObject, {entryId: 'foo'}, openmct.annotation.ANNOTATION_TYPES.NOTEBOOK, 'aWonderfulTag');
|
annotationObject = await openmct.annotation.create(tagCreationArguments);
|
||||||
expect(annotationObject).toBeDefined();
|
expect(annotationObject).toBeDefined();
|
||||||
expect(annotationObject.type).toEqual('annotation');
|
expect(annotationObject.type).toEqual('annotation');
|
||||||
expect(annotationObject.tags).toContain('aWonderfulTag');
|
expect(annotationObject.tags).toContain('aWonderfulTag');
|
||||||
|
@ -1,47 +1,35 @@
|
|||||||
import CompositionAPI from './CompositionAPI';
|
import { createOpenMct, resetApplicationState } from '../../utils/testing';
|
||||||
import CompositionCollection from './CompositionCollection';
|
import CompositionCollection from './CompositionCollection';
|
||||||
|
|
||||||
describe('The Composition API', function () {
|
describe('The Composition API', function () {
|
||||||
let publicAPI;
|
let publicAPI;
|
||||||
let compositionAPI;
|
let compositionAPI;
|
||||||
let topicService;
|
|
||||||
let mutationTopic;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function (done) {
|
||||||
|
publicAPI = createOpenMct();
|
||||||
|
compositionAPI = publicAPI.composition;
|
||||||
|
|
||||||
mutationTopic = jasmine.createSpyObj('mutationTopic', [
|
const mockObjectProvider = jasmine.createSpyObj("mock provider", [
|
||||||
'listen'
|
"create",
|
||||||
]);
|
"update",
|
||||||
topicService = jasmine.createSpy('topicService');
|
"get"
|
||||||
topicService.and.returnValue(mutationTopic);
|
|
||||||
publicAPI = {};
|
|
||||||
publicAPI.objects = jasmine.createSpyObj('ObjectAPI', [
|
|
||||||
'get',
|
|
||||||
'mutate',
|
|
||||||
'observe',
|
|
||||||
'areIdsEqual'
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
publicAPI.objects.areIdsEqual.and.callFake(function (id1, id2) {
|
mockObjectProvider.create.and.returnValue(Promise.resolve(true));
|
||||||
return id1.namespace === id2.namespace && id1.key === id2.key;
|
mockObjectProvider.update.and.returnValue(Promise.resolve(true));
|
||||||
|
mockObjectProvider.get.and.callFake((identifier) => {
|
||||||
|
return Promise.resolve({identifier});
|
||||||
});
|
});
|
||||||
|
|
||||||
publicAPI.composition = jasmine.createSpyObj('CompositionAPI', [
|
publicAPI.objects.addProvider('test', mockObjectProvider);
|
||||||
'checkPolicy'
|
publicAPI.objects.addProvider('custom', mockObjectProvider);
|
||||||
]);
|
|
||||||
publicAPI.composition.checkPolicy.and.returnValue(true);
|
|
||||||
|
|
||||||
publicAPI.objects.eventEmitter = jasmine.createSpyObj('eventemitter', [
|
publicAPI.on('start', done);
|
||||||
'on'
|
publicAPI.startHeadless();
|
||||||
]);
|
|
||||||
publicAPI.objects.get.and.callFake(function (identifier) {
|
|
||||||
return Promise.resolve({identifier: identifier});
|
|
||||||
});
|
});
|
||||||
publicAPI.$injector = jasmine.createSpyObj('$injector', [
|
|
||||||
'get'
|
afterEach(() => {
|
||||||
]);
|
return resetApplicationState(publicAPI);
|
||||||
publicAPI.$injector.get.and.returnValue(topicService);
|
|
||||||
compositionAPI = new CompositionAPI(publicAPI);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns falsy if an object does not support composition', function () {
|
it('returns falsy if an object does not support composition', function () {
|
||||||
@ -106,6 +94,9 @@ describe('The Composition API', function () {
|
|||||||
let listener;
|
let listener;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
listener = jasmine.createSpy('reorderListener');
|
listener = jasmine.createSpy('reorderListener');
|
||||||
|
spyOn(publicAPI.objects, 'mutate');
|
||||||
|
publicAPI.objects.mutate.and.callThrough();
|
||||||
|
|
||||||
composition.on('reorder', listener);
|
composition.on('reorder', listener);
|
||||||
|
|
||||||
return composition.load();
|
return composition.load();
|
||||||
@ -136,20 +127,22 @@ describe('The Composition API', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('supports adding an object to composition', function () {
|
it('supports adding an object to composition', function () {
|
||||||
let addListener = jasmine.createSpy('addListener');
|
|
||||||
let mockChildObject = {
|
let mockChildObject = {
|
||||||
identifier: {
|
identifier: {
|
||||||
key: 'mock-key',
|
key: 'mock-key',
|
||||||
namespace: ''
|
namespace: ''
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
composition.on('add', addListener);
|
|
||||||
composition.add(mockChildObject);
|
|
||||||
|
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
composition.on('add', resolve);
|
||||||
|
composition.add(mockChildObject);
|
||||||
|
}).then(() => {
|
||||||
expect(domainObject.composition.length).toBe(4);
|
expect(domainObject.composition.length).toBe(4);
|
||||||
expect(domainObject.composition[3]).toEqual(mockChildObject.identifier);
|
expect(domainObject.composition[3]).toEqual(mockChildObject.identifier);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('static custom composition', function () {
|
describe('static custom composition', function () {
|
||||||
let customProvider;
|
let customProvider;
|
||||||
|
@ -224,7 +224,7 @@ export default class CompositionProvider {
|
|||||||
* @private
|
* @private
|
||||||
* @param {DomainObject} oldDomainObject
|
* @param {DomainObject} oldDomainObject
|
||||||
*/
|
*/
|
||||||
#onMutation(oldDomainObject) {
|
#onMutation(newDomainObject, oldDomainObject) {
|
||||||
const id = objectUtils.makeKeyString(oldDomainObject.identifier);
|
const id = objectUtils.makeKeyString(oldDomainObject.identifier);
|
||||||
const listeners = this.#listeningTo[id];
|
const listeners = this.#listeningTo[id];
|
||||||
|
|
||||||
@ -232,8 +232,8 @@ export default class CompositionProvider {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldComposition = listeners.composition.map(objectUtils.makeKeyString);
|
const oldComposition = oldDomainObject.composition.map(objectUtils.makeKeyString);
|
||||||
const newComposition = oldDomainObject.composition.map(objectUtils.makeKeyString);
|
const newComposition = newDomainObject.composition.map(objectUtils.makeKeyString);
|
||||||
|
|
||||||
const added = _.difference(newComposition, oldComposition).map(objectUtils.parseKeyString);
|
const added = _.difference(newComposition, oldComposition).map(objectUtils.parseKeyString);
|
||||||
const removed = _.difference(oldComposition, newComposition).map(objectUtils.parseKeyString);
|
const removed = _.difference(oldComposition, newComposition).map(objectUtils.parseKeyString);
|
||||||
@ -248,8 +248,6 @@ export default class CompositionProvider {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
listeners.composition = newComposition.map(objectUtils.parseKeyString);
|
|
||||||
|
|
||||||
added.forEach(function (addedChild) {
|
added.forEach(function (addedChild) {
|
||||||
listeners.add.forEach(notify(addedChild));
|
listeners.add.forEach(notify(addedChild));
|
||||||
});
|
});
|
||||||
|
@ -99,8 +99,7 @@ export default class DefaultCompositionProvider extends CompositionProvider {
|
|||||||
objectListeners = this.listeningTo[keyString] = {
|
objectListeners = this.listeningTo[keyString] = {
|
||||||
add: [],
|
add: [],
|
||||||
remove: [],
|
remove: [],
|
||||||
reorder: [],
|
reorder: []
|
||||||
composition: [].slice.apply(domainObject.composition)
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,8 +171,9 @@ export default class DefaultCompositionProvider extends CompositionProvider {
|
|||||||
*/
|
*/
|
||||||
add(parent, childId) {
|
add(parent, childId) {
|
||||||
if (!this.includes(parent, childId)) {
|
if (!this.includes(parent, childId)) {
|
||||||
parent.composition.push(childId);
|
const composition = structuredClone(parent.composition);
|
||||||
this.publicAPI.objects.mutate(parent, 'composition', parent.composition);
|
composition.push(childId);
|
||||||
|
this.publicAPI.objects.mutate(parent, 'composition', composition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="!hideOptions"
|
v-if="!hideOptions && filteredOptions.length > 0"
|
||||||
class="c-menu c-input--autocomplete__options"
|
class="c-menu c-input--autocomplete__options"
|
||||||
aria-label="Autocomplete Options"
|
aria-label="Autocomplete Options"
|
||||||
@blur="hideOptions = true"
|
@blur="hideOptions = true"
|
||||||
@ -230,10 +230,10 @@ export default {
|
|||||||
this.showFilteredOptions = false;
|
this.showFilteredOptions = false;
|
||||||
this.autocompleteInputElement.select();
|
this.autocompleteInputElement.select();
|
||||||
|
|
||||||
if (this.hideOptions) {
|
if (!this.hideOptions && this.filteredOptions.length > 0) {
|
||||||
this.showOptions();
|
|
||||||
} else {
|
|
||||||
this.hideOptions = true;
|
this.hideOptions = true;
|
||||||
|
} else {
|
||||||
|
this.showOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -242,6 +242,7 @@ export default {
|
|||||||
// dropdown is visible, this will collapse the dropdown.
|
// dropdown is visible, this will collapse the dropdown.
|
||||||
const clickedInsideAutocomplete = this.autocompleteInputAndArrow.contains(event.target);
|
const clickedInsideAutocomplete = this.autocompleteInputAndArrow.contains(event.target);
|
||||||
if (!clickedInsideAutocomplete && !this.hideOptions) {
|
if (!clickedInsideAutocomplete && !this.hideOptions) {
|
||||||
|
this.$emit('autoCompleteBlur');
|
||||||
this.hideOptions = true;
|
this.hideOptions = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
id="fileElem"
|
id="fileElem"
|
||||||
ref="fileInput"
|
ref="fileInput"
|
||||||
type="file"
|
type="file"
|
||||||
accept=".json"
|
:accept="acceptableFileTypes"
|
||||||
style="display:none"
|
style="display:none"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
@ -72,6 +72,13 @@ export default {
|
|||||||
},
|
},
|
||||||
removable() {
|
removable() {
|
||||||
return (this.fileInfo || this.model.value) && this.model.removable;
|
return (this.fileInfo || this.model.value) && this.model.removable;
|
||||||
|
},
|
||||||
|
acceptableFileTypes() {
|
||||||
|
if (this.model.type) {
|
||||||
|
return this.model.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'application/json';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -80,7 +87,13 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
handleFiles() {
|
handleFiles() {
|
||||||
const fileList = this.$refs.fileInput.files;
|
const fileList = this.$refs.fileInput.files;
|
||||||
this.readFile(fileList[0]);
|
const file = fileList[0];
|
||||||
|
|
||||||
|
if (this.acceptableFileTypes === 'application/json') {
|
||||||
|
this.readFile(file);
|
||||||
|
} else {
|
||||||
|
this.handleRawFile(file);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
readFile(file) {
|
readFile(file) {
|
||||||
const self = this;
|
const self = this;
|
||||||
@ -104,6 +117,21 @@ export default {
|
|||||||
|
|
||||||
fileReader.readAsText(file);
|
fileReader.readAsText(file);
|
||||||
},
|
},
|
||||||
|
handleRawFile(file) {
|
||||||
|
const fileInfo = {
|
||||||
|
name: file.name,
|
||||||
|
body: file
|
||||||
|
};
|
||||||
|
|
||||||
|
this.fileInfo = Object.assign({}, fileInfo);
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
model: this.model,
|
||||||
|
value: fileInfo
|
||||||
|
};
|
||||||
|
|
||||||
|
this.$emit('onChange', data);
|
||||||
|
},
|
||||||
selectFile() {
|
selectFile() {
|
||||||
this.$refs.fileInput.click();
|
this.$refs.fileInput.click();
|
||||||
},
|
},
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
<ToggleSwitch
|
<ToggleSwitch
|
||||||
id="switchId"
|
id="switchId"
|
||||||
:checked="isChecked"
|
:checked="isChecked"
|
||||||
|
:name="model.name"
|
||||||
@change="toggleCheckBox"
|
@change="toggleCheckBox"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
@ -31,7 +31,31 @@
|
|||||||
* @namespace platform/api/notifications
|
* @namespace platform/api/notifications
|
||||||
*/
|
*/
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import EventEmitter from 'EventEmitter';
|
import EventEmitter from 'eventemitter3';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} NotificationProperties
|
||||||
|
* @property {function} dismiss Dismiss the notification
|
||||||
|
* @property {NotificationModel} model The Notification model
|
||||||
|
* @property {(progressPerc: number, progressText: string) => void} [progress] Update the progress of the notification
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {EventEmitter & NotificationProperties} Notification
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} NotificationLink
|
||||||
|
* @property {function} onClick The function to be called when the link is clicked
|
||||||
|
* @property {string} cssClass A CSS class name to style the link
|
||||||
|
* @property {string} text The text to be displayed for the link
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} NotificationOptions
|
||||||
|
* @property {number} [autoDismissTimeout] Milliseconds to wait before automatically dismissing the notification
|
||||||
|
* @property {NotificationLink} [link] A link for the notification
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A representation of a banner notification. Banner notifications
|
* A representation of a banner notification. Banner notifications
|
||||||
@ -40,13 +64,17 @@ import EventEmitter from 'EventEmitter';
|
|||||||
* dialogs so that the same information can be provided in a dialog
|
* dialogs so that the same information can be provided in a dialog
|
||||||
* and then minimized to a banner notification if needed, or vice-versa.
|
* and then minimized to a banner notification if needed, or vice-versa.
|
||||||
*
|
*
|
||||||
|
* @see DialogModel
|
||||||
* @typedef {object} NotificationModel
|
* @typedef {object} NotificationModel
|
||||||
* @property {string} message The message to be displayed by the notification
|
* @property {string} message The message to be displayed by the notification
|
||||||
* @property {number | 'unknown'} [progress] The progress of some ongoing task. Should be a number between 0 and 100, or
|
* @property {number | 'unknown'} [progress] The progress of some ongoing task. Should be a number between 0 and 100, or
|
||||||
* with the string literal 'unknown'.
|
* with the string literal 'unknown'.
|
||||||
* @property {string} [progressText] A message conveying progress of some ongoing task.
|
* @property {string} [progressText] A message conveying progress of some ongoing task.
|
||||||
|
* @property {string} [severity] The severity of the notification. Should be one of 'info', 'alert', or 'error'.
|
||||||
* @see DialogModel
|
* @property {string} [timestamp] The time at which the notification was created. Should be a string in ISO 8601 format.
|
||||||
|
* @property {boolean} [minimized] Whether or not the notification has been minimized
|
||||||
|
* @property {boolean} [autoDismiss] Whether the notification should be automatically dismissed after a short period of time.
|
||||||
|
* @property {NotificationOptions} options The notification options
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const DEFAULT_AUTO_DISMISS_TIMEOUT = 3000;
|
const DEFAULT_AUTO_DISMISS_TIMEOUT = 3000;
|
||||||
@ -55,18 +83,19 @@ const MINIMIZE_ANIMATION_TIMEOUT = 300;
|
|||||||
/**
|
/**
|
||||||
* The notification service is responsible for informing the user of
|
* The notification service is responsible for informing the user of
|
||||||
* events via the use of banner notifications.
|
* events via the use of banner notifications.
|
||||||
* @memberof ui/notification
|
*/
|
||||||
* @constructor */
|
|
||||||
|
|
||||||
export default class NotificationAPI extends EventEmitter {
|
export default class NotificationAPI extends EventEmitter {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
/** @type {Notification[]} */
|
||||||
this.notifications = [];
|
this.notifications = [];
|
||||||
|
/** @type {{severity: "info" | "alert" | "error"}} */
|
||||||
this.highest = { severity: "info" };
|
this.highest = { severity: "info" };
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* A context in which to hold the active notification and a
|
* A context in which to hold the active notification and a
|
||||||
* handle to its timeout.
|
* handle to its timeout.
|
||||||
|
* @type {Notification | undefined}
|
||||||
*/
|
*/
|
||||||
this.activeNotification = undefined;
|
this.activeNotification = undefined;
|
||||||
}
|
}
|
||||||
@ -75,16 +104,12 @@ export default class NotificationAPI extends EventEmitter {
|
|||||||
* Info notifications are low priority informational messages for the user. They will be auto-destroy after a brief
|
* Info notifications are low priority informational messages for the user. They will be auto-destroy after a brief
|
||||||
* period of time.
|
* period of time.
|
||||||
* @param {string} message The message to display to the user
|
* @param {string} message The message to display to the user
|
||||||
* @param {Object} [options] object with following properties
|
* @param {NotificationOptions} [options] The notification options
|
||||||
* autoDismissTimeout: {number} in miliseconds to automatically dismisses notification
|
* @returns {Notification}
|
||||||
* link: {Object} Add a link to notifications for navigation
|
|
||||||
* onClick: callback function
|
|
||||||
* cssClass: css class name to add style on link
|
|
||||||
* text: text to display for link
|
|
||||||
* @returns {InfoNotification}
|
|
||||||
*/
|
*/
|
||||||
info(message, options = {}) {
|
info(message, options = {}) {
|
||||||
let notificationModel = {
|
/** @type {NotificationModel} */
|
||||||
|
const notificationModel = {
|
||||||
message: message,
|
message: message,
|
||||||
autoDismiss: true,
|
autoDismiss: true,
|
||||||
severity: "info",
|
severity: "info",
|
||||||
@ -97,7 +122,7 @@ export default class NotificationAPI extends EventEmitter {
|
|||||||
/**
|
/**
|
||||||
* Present an alert to the user.
|
* Present an alert to the user.
|
||||||
* @param {string} message The message to display to the user.
|
* @param {string} message The message to display to the user.
|
||||||
* @param {Object} [options] object with following properties
|
* @param {NotificationOptions} [options] object with following properties
|
||||||
* autoDismissTimeout: {number} in milliseconds to automatically dismisses notification
|
* autoDismissTimeout: {number} in milliseconds to automatically dismisses notification
|
||||||
* link: {Object} Add a link to notifications for navigation
|
* link: {Object} Add a link to notifications for navigation
|
||||||
* onClick: callback function
|
* onClick: callback function
|
||||||
@ -106,7 +131,7 @@ export default class NotificationAPI extends EventEmitter {
|
|||||||
* @returns {Notification}
|
* @returns {Notification}
|
||||||
*/
|
*/
|
||||||
alert(message, options = {}) {
|
alert(message, options = {}) {
|
||||||
let notificationModel = {
|
const notificationModel = {
|
||||||
message: message,
|
message: message,
|
||||||
severity: "alert",
|
severity: "alert",
|
||||||
options
|
options
|
||||||
@ -147,7 +172,8 @@ export default class NotificationAPI extends EventEmitter {
|
|||||||
message: message,
|
message: message,
|
||||||
progressPerc: progressPerc,
|
progressPerc: progressPerc,
|
||||||
progressText: progressText,
|
progressText: progressText,
|
||||||
severity: "info"
|
severity: "info",
|
||||||
|
options: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
return this._notify(notificationModel);
|
return this._notify(notificationModel);
|
||||||
@ -165,8 +191,13 @@ export default class NotificationAPI extends EventEmitter {
|
|||||||
* dismissed.
|
* dismissed.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @param {Notification | undefined} notification
|
||||||
*/
|
*/
|
||||||
_minimize(notification) {
|
_minimize(notification) {
|
||||||
|
if (!notification) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Check this is a known notification
|
//Check this is a known notification
|
||||||
let index = this.notifications.indexOf(notification);
|
let index = this.notifications.indexOf(notification);
|
||||||
|
|
||||||
@ -204,8 +235,13 @@ export default class NotificationAPI extends EventEmitter {
|
|||||||
* dismiss
|
* dismiss
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @param {Notification | undefined} notification
|
||||||
*/
|
*/
|
||||||
_dismiss(notification) {
|
_dismiss(notification) {
|
||||||
|
if (!notification) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Check this is a known notification
|
//Check this is a known notification
|
||||||
let index = this.notifications.indexOf(notification);
|
let index = this.notifications.indexOf(notification);
|
||||||
|
|
||||||
@ -236,10 +272,11 @@ export default class NotificationAPI extends EventEmitter {
|
|||||||
* dismiss or minimize where appropriate.
|
* dismiss or minimize where appropriate.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @param {Notification | undefined} notification
|
||||||
*/
|
*/
|
||||||
_dismissOrMinimize(notification) {
|
_dismissOrMinimize(notification) {
|
||||||
let model = notification.model;
|
let model = notification?.model;
|
||||||
if (model.severity === "info") {
|
if (model?.severity === "info") {
|
||||||
this._dismiss(notification);
|
this._dismiss(notification);
|
||||||
} else {
|
} else {
|
||||||
this._minimize(notification);
|
this._minimize(notification);
|
||||||
@ -251,10 +288,11 @@ export default class NotificationAPI extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
_setHighestSeverity() {
|
_setHighestSeverity() {
|
||||||
let severity = {
|
let severity = {
|
||||||
"info": 1,
|
info: 1,
|
||||||
"alert": 2,
|
alert: 2,
|
||||||
"error": 3
|
error: 3
|
||||||
};
|
};
|
||||||
|
|
||||||
this.highest.severity = this.notifications.reduce((previous, notification) => {
|
this.highest.severity = this.notifications.reduce((previous, notification) => {
|
||||||
if (severity[notification.model.severity] > severity[previous]) {
|
if (severity[notification.model.severity] > severity[previous]) {
|
||||||
return notification.model.severity;
|
return notification.model.severity;
|
||||||
@ -312,8 +350,11 @@ export default class NotificationAPI extends EventEmitter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
|
* @param {NotificationModel} notificationModel
|
||||||
|
* @returns {Notification}
|
||||||
*/
|
*/
|
||||||
_createNotification(notificationModel) {
|
_createNotification(notificationModel) {
|
||||||
|
/** @type {Notification} */
|
||||||
let notification = new EventEmitter();
|
let notification = new EventEmitter();
|
||||||
notification.model = notificationModel;
|
notification.model = notificationModel;
|
||||||
notification.dismiss = () => {
|
notification.dismiss = () => {
|
||||||
@ -333,6 +374,7 @@ export default class NotificationAPI extends EventEmitter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
|
* @param {Notification | undefined} notification
|
||||||
*/
|
*/
|
||||||
_setActiveNotification(notification) {
|
_setActiveNotification(notification) {
|
||||||
this.activeNotification = notification;
|
this.activeNotification = notification;
|
||||||
|
@ -75,21 +75,23 @@ class MutableDomainObject {
|
|||||||
return eventOff;
|
return eventOff;
|
||||||
}
|
}
|
||||||
$set(path, value) {
|
$set(path, value) {
|
||||||
|
const oldModel = JSON.parse(JSON.stringify(this));
|
||||||
|
const oldValue = _.get(oldModel, path);
|
||||||
MutableDomainObject.mutateObject(this, path, value);
|
MutableDomainObject.mutateObject(this, path, value);
|
||||||
|
|
||||||
//Emit secret synchronization event first, so that all objects are in sync before subsequent events fired.
|
//Emit secret synchronization event first, so that all objects are in sync before subsequent events fired.
|
||||||
this._globalEventEmitter.emit(qualifiedEventName(this, '$_synchronize_model'), this);
|
this._globalEventEmitter.emit(qualifiedEventName(this, '$_synchronize_model'), this);
|
||||||
|
|
||||||
//Emit a general "any object" event
|
//Emit a general "any object" event
|
||||||
this._globalEventEmitter.emit(ANY_OBJECT_EVENT, this);
|
this._globalEventEmitter.emit(ANY_OBJECT_EVENT, this, oldModel);
|
||||||
//Emit wildcard event, with path so that callback knows what changed
|
//Emit wildcard event, with path so that callback knows what changed
|
||||||
this._globalEventEmitter.emit(qualifiedEventName(this, '*'), this, path, value);
|
this._globalEventEmitter.emit(qualifiedEventName(this, '*'), this, path, value, oldModel, oldValue);
|
||||||
|
|
||||||
//Emit events specific to properties affected
|
//Emit events specific to properties affected
|
||||||
let parentPropertiesList = path.split('.');
|
let parentPropertiesList = path.split('.');
|
||||||
for (let index = parentPropertiesList.length; index > 0; index--) {
|
for (let index = parentPropertiesList.length; index > 0; index--) {
|
||||||
let parentPropertyPath = parentPropertiesList.slice(0, index).join('.');
|
let parentPropertyPath = parentPropertiesList.slice(0, index).join('.');
|
||||||
this._globalEventEmitter.emit(qualifiedEventName(this, parentPropertyPath), _.get(this, parentPropertyPath));
|
this._globalEventEmitter.emit(qualifiedEventName(this, parentPropertyPath), _.get(this, parentPropertyPath), _.get(oldModel, parentPropertyPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Emit events for listeners of child properties when parent changes.
|
//TODO: Emit events for listeners of child properties when parent changes.
|
||||||
|
@ -189,16 +189,17 @@ export default class ObjectAPI {
|
|||||||
/**
|
/**
|
||||||
* Get a domain object.
|
* Get a domain object.
|
||||||
*
|
*
|
||||||
* @method get
|
|
||||||
* @memberof module:openmct.ObjectProvider#
|
|
||||||
* @param {string} key the key for the domain object to load
|
* @param {string} key the key for the domain object to load
|
||||||
* @param {AbortController.signal} abortSignal (optional) signal to abort fetch requests
|
* @param {AbortSignal} abortSignal (optional) signal to abort fetch requests
|
||||||
* @returns {Promise} a promise which will resolve when the domain object
|
* @param {boolean} [forceRemote=false] defaults to false. If true, will skip cached and
|
||||||
|
* dirty/in-transaction objects use and the provider.get method
|
||||||
|
* @returns {Promise<DomainObject>} a promise which will resolve when the domain object
|
||||||
* has been saved, or be rejected if it cannot be saved
|
* has been saved, or be rejected if it cannot be saved
|
||||||
*/
|
*/
|
||||||
get(identifier, abortSignal) {
|
get(identifier, abortSignal, forceRemote = false) {
|
||||||
let keystring = this.makeKeyString(identifier);
|
let keystring = this.makeKeyString(identifier);
|
||||||
|
|
||||||
|
if (!forceRemote) {
|
||||||
if (this.cache[keystring] !== undefined) {
|
if (this.cache[keystring] !== undefined) {
|
||||||
return this.cache[keystring];
|
return this.cache[keystring];
|
||||||
}
|
}
|
||||||
@ -212,35 +213,33 @@ export default class ObjectAPI {
|
|||||||
return Promise.resolve(dirtyObject);
|
return Promise.resolve(dirtyObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const provider = this.getProvider(identifier);
|
const provider = this.getProvider(identifier);
|
||||||
|
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
throw new Error('No Provider Matched');
|
throw new Error(`No Provider Matched for keyString "${this.makeKeyString(identifier)}}"`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!provider.get) {
|
if (!provider.get) {
|
||||||
throw new Error('Provider does not support get!');
|
throw new Error('Provider does not support get!');
|
||||||
}
|
}
|
||||||
|
|
||||||
let objectPromise = provider.get(identifier, abortSignal).then(result => {
|
let objectPromise = provider.get(identifier, abortSignal).then(domainObject => {
|
||||||
delete this.cache[keystring];
|
delete this.cache[keystring];
|
||||||
|
domainObject = this.applyGetInterceptors(identifier, domainObject);
|
||||||
|
|
||||||
result = this.applyGetInterceptors(identifier, result);
|
if (this.supportsMutation(identifier)) {
|
||||||
if (result.isMutable) {
|
const mutableDomainObject = this.toMutable(domainObject);
|
||||||
result.$refresh(result);
|
mutableDomainObject.$refresh(domainObject);
|
||||||
} else {
|
this.destroyMutable(mutableDomainObject);
|
||||||
let mutableDomainObject = this.toMutable(result);
|
|
||||||
mutableDomainObject.$refresh(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return domainObject;
|
||||||
}).catch((result) => {
|
}).catch((error) => {
|
||||||
console.warn(`Failed to retrieve ${keystring}:`, result);
|
console.warn(`Failed to retrieve ${keystring}:`, error);
|
||||||
|
|
||||||
delete this.cache[keystring];
|
delete this.cache[keystring];
|
||||||
|
const result = this.applyGetInterceptors(identifier);
|
||||||
result = this.applyGetInterceptors(identifier);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
@ -391,7 +390,6 @@ export default class ObjectAPI {
|
|||||||
lastPersistedTime = domainObject.persisted;
|
lastPersistedTime = domainObject.persisted;
|
||||||
const persistedTime = Date.now();
|
const persistedTime = Date.now();
|
||||||
this.#mutate(domainObject, 'persisted', persistedTime);
|
this.#mutate(domainObject, 'persisted', persistedTime);
|
||||||
|
|
||||||
savedObjectPromise = provider.update(domainObject);
|
savedObjectPromise = provider.update(domainObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,7 +397,7 @@ export default class ObjectAPI {
|
|||||||
savedObjectPromise.then(response => {
|
savedObjectPromise.then(response => {
|
||||||
savedResolve(response);
|
savedResolve(response);
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if (lastPersistedTime !== undefined) {
|
if (!isNewObject) {
|
||||||
this.#mutate(domainObject, 'persisted', lastPersistedTime);
|
this.#mutate(domainObject, 'persisted', lastPersistedTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,9 +408,20 @@ export default class ObjectAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.catch((error) => {
|
return result.catch(async (error) => {
|
||||||
if (error instanceof this.errors.Conflict) {
|
if (error instanceof this.errors.Conflict) {
|
||||||
|
// Synchronized objects will resolve their own conflicts
|
||||||
|
if (this.SYNCHRONIZED_OBJECT_TYPES.includes(domainObject.type)) {
|
||||||
|
this.openmct.notifications.info(`Conflict detected while saving "${this.makeKeyString(domainObject.name)}", attempting to resolve`);
|
||||||
|
} else {
|
||||||
this.openmct.notifications.error(`Conflict detected while saving ${this.makeKeyString(domainObject.identifier)}`);
|
this.openmct.notifications.error(`Conflict detected while saving ${this.makeKeyString(domainObject.identifier)}`);
|
||||||
|
|
||||||
|
if (this.isTransactionActive()) {
|
||||||
|
this.endTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.refresh(domainObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw error;
|
throw error;
|
||||||
@ -636,7 +645,7 @@ export default class ObjectAPI {
|
|||||||
* @param {module:openmct.DomainObject} object the object to observe
|
* @param {module:openmct.DomainObject} object the object to observe
|
||||||
* @param {string} path the property to observe
|
* @param {string} path the property to observe
|
||||||
* @param {Function} callback a callback to invoke when new values for
|
* @param {Function} callback a callback to invoke when new values for
|
||||||
* this property are observed
|
* this property are observed.
|
||||||
* @method observe
|
* @method observe
|
||||||
* @memberof module:openmct.ObjectAPI#
|
* @memberof module:openmct.ObjectAPI#
|
||||||
*/
|
*/
|
||||||
@ -726,6 +735,46 @@ export default class ObjectAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse and construct an `objectPath` from a `navigationPath`.
|
||||||
|
*
|
||||||
|
* A `navigationPath` is a string of the form `"/browse/<keyString>/<keyString>/..."` that is used
|
||||||
|
* by the Open MCT router to navigate to a specific object.
|
||||||
|
*
|
||||||
|
* Throws an error if the `navigationPath` is malformed.
|
||||||
|
*
|
||||||
|
* @param {string} navigationPath
|
||||||
|
* @returns {DomainObject[]} objectPath
|
||||||
|
*/
|
||||||
|
async getRelativeObjectPath(navigationPath) {
|
||||||
|
if (!navigationPath.startsWith('/browse/')) {
|
||||||
|
throw new Error(`Malformed navigation path: "${navigationPath}"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
navigationPath = navigationPath.replace('/browse/', '');
|
||||||
|
|
||||||
|
if (!navigationPath || navigationPath === '/') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove any query params and split on '/'
|
||||||
|
const keyStrings = navigationPath.split('?')?.[0].split('/');
|
||||||
|
|
||||||
|
if (keyStrings[0] !== 'ROOT') {
|
||||||
|
keyStrings.unshift('ROOT');
|
||||||
|
}
|
||||||
|
|
||||||
|
const objectPath = (await Promise.all(
|
||||||
|
keyStrings.map(
|
||||||
|
keyString => this.supportsMutation(keyString)
|
||||||
|
? this.getMutable(utils.parseKeyString(keyString))
|
||||||
|
: this.get(utils.parseKeyString(keyString))
|
||||||
|
)
|
||||||
|
)).reverse();
|
||||||
|
|
||||||
|
return objectPath;
|
||||||
|
}
|
||||||
|
|
||||||
isObjectPathToALink(domainObject, objectPath) {
|
isObjectPathToALink(domainObject, objectPath) {
|
||||||
return objectPath !== undefined
|
return objectPath !== undefined
|
||||||
&& objectPath.length > 1
|
&& objectPath.length > 1
|
||||||
|
@ -399,7 +399,7 @@ describe("The Object API", () => {
|
|||||||
unlisten = objectAPI.observe(mutableSecondInstance, 'otherAttribute', mutationCallback);
|
unlisten = objectAPI.observe(mutableSecondInstance, 'otherAttribute', mutationCallback);
|
||||||
objectAPI.mutate(mutable, 'otherAttribute', 'some-new-value');
|
objectAPI.mutate(mutable, 'otherAttribute', 'some-new-value');
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
expect(mutationCallback).toHaveBeenCalledWith('some-new-value');
|
expect(mutationCallback).toHaveBeenCalledWith('some-new-value', 'other-attribute-value');
|
||||||
unlisten();
|
unlisten();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -419,14 +419,20 @@ describe("The Object API", () => {
|
|||||||
|
|
||||||
objectAPI.mutate(mutable, 'objectAttribute.embeddedObject.embeddedKey', 'updated-embedded-value');
|
objectAPI.mutate(mutable, 'objectAttribute.embeddedObject.embeddedKey', 'updated-embedded-value');
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
expect(embeddedKeyCallback).toHaveBeenCalledWith('updated-embedded-value');
|
expect(embeddedKeyCallback).toHaveBeenCalledWith('updated-embedded-value', 'embedded-value');
|
||||||
expect(embeddedObjectCallback).toHaveBeenCalledWith({
|
expect(embeddedObjectCallback).toHaveBeenCalledWith({
|
||||||
embeddedKey: 'updated-embedded-value'
|
embeddedKey: 'updated-embedded-value'
|
||||||
|
}, {
|
||||||
|
embeddedKey: 'embedded-value'
|
||||||
});
|
});
|
||||||
expect(objectAttributeCallback).toHaveBeenCalledWith({
|
expect(objectAttributeCallback).toHaveBeenCalledWith({
|
||||||
embeddedObject: {
|
embeddedObject: {
|
||||||
embeddedKey: 'updated-embedded-value'
|
embeddedKey: 'updated-embedded-value'
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
embeddedObject: {
|
||||||
|
embeddedKey: 'embedded-value'
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
listeners.forEach(listener => listener());
|
listeners.forEach(listener => listener());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="c-overlay">
|
<div class="c-overlay js-overlay">
|
||||||
<div
|
<div
|
||||||
class="c-overlay__blocker"
|
class="c-overlay__blocker"
|
||||||
@click="destroy"
|
@click="destroy"
|
||||||
@ -15,6 +15,8 @@
|
|||||||
ref="element"
|
ref="element"
|
||||||
class="c-overlay__contents js-notebook-snapshot-item-wrapper"
|
class="c-overlay__contents js-notebook-snapshot-item-wrapper"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
aria-modal="true"
|
||||||
|
role="dialog"
|
||||||
></div>
|
></div>
|
||||||
<div
|
<div
|
||||||
v-if="buttons"
|
v-if="buttons"
|
||||||
@ -24,7 +26,7 @@
|
|||||||
v-for="(button, index) in buttons"
|
v-for="(button, index) in buttons"
|
||||||
ref="buttons"
|
ref="buttons"
|
||||||
:key="index"
|
:key="index"
|
||||||
class="c-button"
|
class="c-button js-overlay__button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
:class="{'c-button--major': focusIndex===index}"
|
:class="{'c-button--major': focusIndex===index}"
|
||||||
@focus="focusIndex=index"
|
@focus="focusIndex=index"
|
||||||
|
@ -36,6 +36,7 @@ export default class TelemetryAPI {
|
|||||||
this.formatMapCache = new WeakMap();
|
this.formatMapCache = new WeakMap();
|
||||||
this.formatters = new Map();
|
this.formatters = new Map();
|
||||||
this.limitProviders = [];
|
this.limitProviders = [];
|
||||||
|
this.stalenessProviders = [];
|
||||||
this.metadataCache = new WeakMap();
|
this.metadataCache = new WeakMap();
|
||||||
this.metadataProviders = [new DefaultMetadataProvider(this.openmct)];
|
this.metadataProviders = [new DefaultMetadataProvider(this.openmct)];
|
||||||
this.noRequestProviderForAllObjects = false;
|
this.noRequestProviderForAllObjects = false;
|
||||||
@ -114,6 +115,10 @@ export default class TelemetryAPI {
|
|||||||
if (provider.supportsLimits) {
|
if (provider.supportsLimits) {
|
||||||
this.limitProviders.unshift(provider);
|
this.limitProviders.unshift(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (provider.supportsStaleness) {
|
||||||
|
this.stalenessProviders.unshift(provider);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,7 +130,7 @@ export default class TelemetryAPI {
|
|||||||
return provider.supportsSubscribe.apply(provider, args);
|
return provider.supportsSubscribe.apply(provider, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.subscriptionProviders.filter(supportsDomainObject)[0];
|
return this.subscriptionProviders.find(supportsDomainObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,25 +143,25 @@ export default class TelemetryAPI {
|
|||||||
return provider.supportsRequest.apply(provider, args);
|
return provider.supportsRequest.apply(provider, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.requestProviders.filter(supportsDomainObject)[0];
|
return this.requestProviders.find(supportsDomainObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
#findMetadataProvider(domainObject) {
|
#findMetadataProvider(domainObject) {
|
||||||
return this.metadataProviders.filter(function (p) {
|
return this.metadataProviders.find((provider) => {
|
||||||
return p.supportsMetadata(domainObject);
|
return provider.supportsMetadata(domainObject);
|
||||||
})[0];
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
#findLimitEvaluator(domainObject) {
|
#findLimitEvaluator(domainObject) {
|
||||||
return this.limitProviders.filter(function (p) {
|
return this.limitProviders.find((provider) => {
|
||||||
return p.supportsLimits(domainObject);
|
return provider.supportsLimits(domainObject);
|
||||||
})[0];
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -351,6 +356,101 @@ export default class TelemetryAPI {
|
|||||||
}.bind(this);
|
}.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subscribe to staleness updates for a specific domain object.
|
||||||
|
* The callback will be called whenever staleness changes.
|
||||||
|
*
|
||||||
|
* @method subscribeToStaleness
|
||||||
|
* @memberof module:openmct.TelemetryAPI~StalenessProvider#
|
||||||
|
* @param {module:openmct.DomainObject} domainObject the object
|
||||||
|
* to watch for staleness updates
|
||||||
|
* @param {Function} callback the callback to invoke with staleness data,
|
||||||
|
* as it is received: ex.
|
||||||
|
* {
|
||||||
|
* isStale: <Boolean>,
|
||||||
|
* timestamp: <timestamp>
|
||||||
|
* }
|
||||||
|
* @returns {Function} a function which may be called to terminate
|
||||||
|
* the subscription to staleness updates
|
||||||
|
*/
|
||||||
|
subscribeToStaleness(domainObject, callback) {
|
||||||
|
const provider = this.#findStalenessProvider(domainObject);
|
||||||
|
|
||||||
|
if (!this.stalenessSubscriberCache) {
|
||||||
|
this.stalenessSubscriberCache = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const keyString = objectUtils.makeKeyString(domainObject.identifier);
|
||||||
|
let stalenessSubscriber = this.stalenessSubscriberCache[keyString];
|
||||||
|
|
||||||
|
if (!stalenessSubscriber) {
|
||||||
|
stalenessSubscriber = this.stalenessSubscriberCache[keyString] = {
|
||||||
|
callbacks: [callback]
|
||||||
|
};
|
||||||
|
if (provider) {
|
||||||
|
stalenessSubscriber.unsubscribe = provider
|
||||||
|
.subscribeToStaleness(domainObject, (stalenessResponse) => {
|
||||||
|
stalenessSubscriber.callbacks.forEach((cb) => {
|
||||||
|
cb(stalenessResponse);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
stalenessSubscriber.unsubscribe = () => {};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
stalenessSubscriber.callbacks.push(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
return function unsubscribe() {
|
||||||
|
stalenessSubscriber.callbacks = stalenessSubscriber.callbacks.filter((cb) => {
|
||||||
|
return cb !== callback;
|
||||||
|
});
|
||||||
|
if (stalenessSubscriber.callbacks.length === 0) {
|
||||||
|
stalenessSubscriber.unsubscribe();
|
||||||
|
delete this.stalenessSubscriberCache[keyString];
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request telemetry staleness for a domain object.
|
||||||
|
*
|
||||||
|
* @method isStale
|
||||||
|
* @memberof module:openmct.TelemetryAPI~StalenessProvider#
|
||||||
|
* @param {module:openmct.DomainObject} domainObject the object
|
||||||
|
* which has associated telemetry staleness
|
||||||
|
* @returns {Promise.<StalenessResponseObject>} a promise for a StalenessResponseObject
|
||||||
|
* or undefined if no provider exists
|
||||||
|
*/
|
||||||
|
async isStale(domainObject) {
|
||||||
|
const provider = this.#findStalenessProvider(domainObject);
|
||||||
|
|
||||||
|
if (!provider) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const abortController = new AbortController();
|
||||||
|
const options = { signal: abortController.signal };
|
||||||
|
this.requestAbortControllers.add(abortController);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const staleness = await provider.isStale(domainObject, options);
|
||||||
|
|
||||||
|
return staleness;
|
||||||
|
} finally {
|
||||||
|
this.requestAbortControllers.delete(abortController);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
#findStalenessProvider(domainObject) {
|
||||||
|
return this.stalenessProviders.find((provider) => {
|
||||||
|
return provider.supportsStaleness(domainObject);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get telemetry metadata for a given domain object. Returns a telemetry
|
* Get telemetry metadata for a given domain object. Returns a telemetry
|
||||||
* metadata manager which provides methods for interrogating telemetry
|
* metadata manager which provides methods for interrogating telemetry
|
||||||
@ -661,6 +761,29 @@ export default class TelemetryAPI {
|
|||||||
* @memberof module:openmct.TelemetryAPI~
|
* @memberof module:openmct.TelemetryAPI~
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides telemetry staleness data. To subscribe to telemetry stalenes,
|
||||||
|
* new StalenessProvider implementations should be
|
||||||
|
* [registered]{@link module:openmct.TelemetryAPI#addProvider}.
|
||||||
|
*
|
||||||
|
* @interface StalenessProvider
|
||||||
|
* @property {function} supportsStaleness receieves a domainObject and
|
||||||
|
* returns a boolean to indicate it will provide staleness
|
||||||
|
* @property {function} subscribeToStaleness receieves a domainObject to
|
||||||
|
* be subscribed to and a callback to invoke with a StalenessResponseObject
|
||||||
|
* @property {function} isStale an asynchronous method called with a domainObject
|
||||||
|
* and an options object which currently has an abort signal, ex.
|
||||||
|
* { signal: <AbortController.signal> }
|
||||||
|
* this method should return a current StalenessResponseObject
|
||||||
|
* @memberof module:openmct.TelemetryAPI~
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} StalenessResponseObject
|
||||||
|
* @property {Boolean} isStale boolean representing the staleness state
|
||||||
|
* @property {Number} timestamp Unix timestamp in milliseconds
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface for retrieving telemetry data associated with a domain
|
* An interface for retrieving telemetry data associated with a domain
|
||||||
* object.
|
* object.
|
||||||
|
@ -180,6 +180,7 @@ export default class TelemetryCollection extends EventEmitter {
|
|||||||
let beforeStartOfBounds;
|
let beforeStartOfBounds;
|
||||||
let afterEndOfBounds;
|
let afterEndOfBounds;
|
||||||
let added = [];
|
let added = [];
|
||||||
|
let addedIndices = [];
|
||||||
|
|
||||||
// loop through, sort and dedupe
|
// loop through, sort and dedupe
|
||||||
for (let datum of data) {
|
for (let datum of data) {
|
||||||
@ -212,6 +213,7 @@ export default class TelemetryCollection extends EventEmitter {
|
|||||||
let index = endIndex || startIndex;
|
let index = endIndex || startIndex;
|
||||||
|
|
||||||
this.boundedTelemetry.splice(index, 0, datum);
|
this.boundedTelemetry.splice(index, 0, datum);
|
||||||
|
addedIndices.push(index);
|
||||||
added.push(datum);
|
added.push(datum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +232,7 @@ export default class TelemetryCollection extends EventEmitter {
|
|||||||
this.emit('add', this.boundedTelemetry);
|
this.emit('add', this.boundedTelemetry);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.emit('add', added);
|
this.emit('add', added, addedIndices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -330,7 +332,8 @@ export default class TelemetryCollection extends EventEmitter {
|
|||||||
this.boundedTelemetry = added;
|
this.boundedTelemetry = added;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emit('add', added);
|
// Assumption is that added will be of length 1 here, so just send the last index of the boundedTelemetry in the add event
|
||||||
|
this.emit('add', added, [this.boundedTelemetry.length]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// user bounds change, reset
|
// user bounds change, reset
|
||||||
|
@ -32,14 +32,18 @@ class IndependentTimeContext extends TimeContext {
|
|||||||
this.openmct = openmct;
|
this.openmct = openmct;
|
||||||
this.unlisteners = [];
|
this.unlisteners = [];
|
||||||
this.globalTimeContext = globalTimeContext;
|
this.globalTimeContext = globalTimeContext;
|
||||||
this.upstreamTimeContext = undefined;
|
// We always start with the global time context.
|
||||||
|
// This upstream context will be undefined when an independent time context is added later.
|
||||||
|
this.upstreamTimeContext = this.globalTimeContext;
|
||||||
this.objectPath = objectPath;
|
this.objectPath = objectPath;
|
||||||
this.refreshContext = this.refreshContext.bind(this);
|
this.refreshContext = this.refreshContext.bind(this);
|
||||||
this.resetContext = this.resetContext.bind(this);
|
this.resetContext = this.resetContext.bind(this);
|
||||||
|
this.removeIndependentContext = this.removeIndependentContext.bind(this);
|
||||||
|
|
||||||
this.refreshContext();
|
this.refreshContext();
|
||||||
|
|
||||||
this.globalTimeContext.on('refreshContext', this.refreshContext);
|
this.globalTimeContext.on('refreshContext', this.refreshContext);
|
||||||
|
this.globalTimeContext.on('removeOwnContext', this.removeIndependentContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
bounds(newBounds) {
|
bounds(newBounds) {
|
||||||
@ -202,16 +206,16 @@ class IndependentTimeContext extends TimeContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getUpstreamContext() {
|
getUpstreamContext() {
|
||||||
const objectKey = this.openmct.objects.makeKeyString(this.objectPath[this.objectPath.length - 1].identifier);
|
// If a view has an independent context, don't return an upstream context
|
||||||
const doesObjectHaveTimeContext = this.globalTimeContext.independentContexts.get(objectKey);
|
// Be aware that when a new independent time context is created, we assign the global context as default
|
||||||
if (doesObjectHaveTimeContext) {
|
if (this.hasOwnContext()) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
let timeContext = this.globalTimeContext;
|
let timeContext = this.globalTimeContext;
|
||||||
this.objectPath.some((item, index) => {
|
this.objectPath.some((item, index) => {
|
||||||
const key = this.openmct.objects.makeKeyString(item.identifier);
|
const key = this.openmct.objects.makeKeyString(item.identifier);
|
||||||
//last index is the view object itself
|
// we're only interested in parents, not self, so index > 0
|
||||||
const itemContext = this.globalTimeContext.independentContexts.get(key);
|
const itemContext = this.globalTimeContext.independentContexts.get(key);
|
||||||
if (index > 0 && itemContext && itemContext.hasOwnContext()) {
|
if (index > 0 && itemContext && itemContext.hasOwnContext()) {
|
||||||
//upstream time context
|
//upstream time context
|
||||||
@ -225,6 +229,43 @@ class IndependentTimeContext extends TimeContext {
|
|||||||
|
|
||||||
return timeContext;
|
return timeContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the time context of a view to follow any upstream time contexts as necessary (defaulting to the global context)
|
||||||
|
* This needs to be separate from refreshContext
|
||||||
|
*/
|
||||||
|
removeIndependentContext(viewKey) {
|
||||||
|
const key = this.openmct.objects.makeKeyString(this.objectPath[0].identifier);
|
||||||
|
if (viewKey && key === viewKey) {
|
||||||
|
//this is necessary as the upstream context gets reassigned after this
|
||||||
|
this.stopFollowingTimeContext();
|
||||||
|
|
||||||
|
let timeContext = this.globalTimeContext;
|
||||||
|
|
||||||
|
this.objectPath.some((item, index) => {
|
||||||
|
const objectKey = this.openmct.objects.makeKeyString(item.identifier);
|
||||||
|
// we're only interested in any parents, not self, so index > 0
|
||||||
|
const itemContext = this.globalTimeContext.independentContexts.get(objectKey);
|
||||||
|
if (index > 0 && itemContext && itemContext.hasOwnContext()) {
|
||||||
|
//upstream time context
|
||||||
|
timeContext = itemContext;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.upstreamTimeContext = timeContext;
|
||||||
|
|
||||||
|
this.followTimeContext();
|
||||||
|
|
||||||
|
// Emit bounds so that views that are changing context get the upstream bounds
|
||||||
|
this.emit('bounds', this.bounds());
|
||||||
|
// now that the view's context is set, tell others to check theirs in case they were following this view's context.
|
||||||
|
this.globalTimeContext.emit('refreshContext', viewKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default IndependentTimeContext;
|
export default IndependentTimeContext;
|
||||||
|
@ -149,7 +149,7 @@ class TimeAPI extends GlobalTimeContext {
|
|||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
//follow any upstream time context
|
//follow any upstream time context
|
||||||
this.emit('refreshContext');
|
this.emit('removeOwnContext', key);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,21 +93,82 @@ describe("The Independent Time API", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("follows a parent time context given the objectPath", () => {
|
it("follows a parent time context given the objectPath", () => {
|
||||||
let timeContext = api.getContextForView([{
|
api.getContextForView([{
|
||||||
identifier: {
|
identifier: {
|
||||||
namespace: '',
|
namespace: '',
|
||||||
key: 'blah'
|
key: 'blah'
|
||||||
}
|
}
|
||||||
|
}]);
|
||||||
|
let destroyTimeContext = api.addIndependentContext('blah', independentBounds);
|
||||||
|
let timeContext = api.getContextForView([{
|
||||||
|
identifier: {
|
||||||
|
namespace: '',
|
||||||
|
key: domainObjectKey
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
|
identifier: {
|
||||||
|
namespace: '',
|
||||||
|
key: 'blah'
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
expect(timeContext.bounds()).toEqual(independentBounds);
|
||||||
|
destroyTimeContext();
|
||||||
|
expect(timeContext.bounds()).toEqual(bounds);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("uses an object's independent time context if the parent doesn't have one", () => {
|
||||||
|
const domainObjectKey2 = `${domainObjectKey}-2`;
|
||||||
|
const domainObjectKey3 = `${domainObjectKey}-3`;
|
||||||
|
let timeContext = api.getContextForView([{
|
||||||
identifier: {
|
identifier: {
|
||||||
namespace: '',
|
namespace: '',
|
||||||
key: domainObjectKey
|
key: domainObjectKey
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
let destroyTimeContext = api.addIndependentContext('blah', independentBounds);
|
let timeContext2 = api.getContextForView([{
|
||||||
|
identifier: {
|
||||||
|
namespace: '',
|
||||||
|
key: domainObjectKey2
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
let timeContext3 = api.getContextForView([{
|
||||||
|
identifier: {
|
||||||
|
namespace: '',
|
||||||
|
key: domainObjectKey3
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
// all bounds follow global time context
|
||||||
|
expect(timeContext.bounds()).toEqual(bounds);
|
||||||
|
expect(timeContext2.bounds()).toEqual(bounds);
|
||||||
|
expect(timeContext3.bounds()).toEqual(bounds);
|
||||||
|
// only first item has own context
|
||||||
|
let destroyTimeContext = api.addIndependentContext(domainObjectKey, independentBounds);
|
||||||
expect(timeContext.bounds()).toEqual(independentBounds);
|
expect(timeContext.bounds()).toEqual(independentBounds);
|
||||||
|
expect(timeContext2.bounds()).toEqual(bounds);
|
||||||
|
expect(timeContext3.bounds()).toEqual(bounds);
|
||||||
|
// first and second item have own context
|
||||||
|
let destroyTimeContext2 = api.addIndependentContext(domainObjectKey2, independentBounds);
|
||||||
|
expect(timeContext.bounds()).toEqual(independentBounds);
|
||||||
|
expect(timeContext2.bounds()).toEqual(independentBounds);
|
||||||
|
expect(timeContext3.bounds()).toEqual(bounds);
|
||||||
|
// all items have own time context
|
||||||
|
let destroyTimeContext3 = api.addIndependentContext(domainObjectKey3, independentBounds);
|
||||||
|
expect(timeContext.bounds()).toEqual(independentBounds);
|
||||||
|
expect(timeContext2.bounds()).toEqual(independentBounds);
|
||||||
|
expect(timeContext3.bounds()).toEqual(independentBounds);
|
||||||
|
//remove own contexts one at a time - should revert to global time context
|
||||||
destroyTimeContext();
|
destroyTimeContext();
|
||||||
expect(timeContext.bounds()).toEqual(bounds);
|
expect(timeContext.bounds()).toEqual(bounds);
|
||||||
|
expect(timeContext2.bounds()).toEqual(independentBounds);
|
||||||
|
expect(timeContext3.bounds()).toEqual(independentBounds);
|
||||||
|
destroyTimeContext2();
|
||||||
|
expect(timeContext.bounds()).toEqual(bounds);
|
||||||
|
expect(timeContext2.bounds()).toEqual(bounds);
|
||||||
|
expect(timeContext3.bounds()).toEqual(independentBounds);
|
||||||
|
destroyTimeContext3();
|
||||||
|
expect(timeContext.bounds()).toEqual(bounds);
|
||||||
|
expect(timeContext2.bounds()).toEqual(bounds);
|
||||||
|
expect(timeContext3.bounds()).toEqual(bounds);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Allows setting of valid bounds", function () {
|
it("Allows setting of valid bounds", function () {
|
||||||
|
@ -291,5 +291,6 @@ export default class StatusAPI extends EventEmitter {
|
|||||||
* The Status type
|
* The Status type
|
||||||
* @typedef {Object} Status
|
* @typedef {Object} Status
|
||||||
* @property {String} key - A unique identifier for this status
|
* @property {String} key - A unique identifier for this status
|
||||||
* @property {Number} label - A human readable label for this status
|
* @property {String} label - A human readable label for this status
|
||||||
|
* @property {Number} timestamp - The time that the status was set.
|
||||||
*/
|
*/
|
||||||
|
@ -33,9 +33,12 @@ export default class LADTableViewProvider {
|
|||||||
canView(domainObject) {
|
canView(domainObject) {
|
||||||
const supportsComposition = this.openmct.composition.supportsComposition(domainObject);
|
const supportsComposition = this.openmct.composition.supportsComposition(domainObject);
|
||||||
const providesTelemetry = this.openmct.telemetry.isTelemetryObject(domainObject);
|
const providesTelemetry = this.openmct.telemetry.isTelemetryObject(domainObject);
|
||||||
|
const isLadTable = domainObject.type === 'LadTable';
|
||||||
|
const isConditionSet = domainObject.type === 'conditionSet';
|
||||||
|
|
||||||
return domainObject.type === 'LadTable'
|
return !isConditionSet
|
||||||
|| (providesTelemetry && supportsComposition);
|
&& (isLadTable
|
||||||
|
|| (providesTelemetry && supportsComposition));
|
||||||
}
|
}
|
||||||
|
|
||||||
canEdit(domainObject) {
|
canEdit(domainObject) {
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<td class="js-second-data">{{ formattedTimestamp }}</td>
|
<td class="js-second-data">{{ formattedTimestamp }}</td>
|
||||||
<td
|
<td
|
||||||
class="js-third-data"
|
class="js-third-data"
|
||||||
:class="valueClass"
|
:class="valueClasses"
|
||||||
>{{ value }}</td>
|
>{{ value }}</td>
|
||||||
<td
|
<td
|
||||||
v-if="hasUnits"
|
v-if="hasUnits"
|
||||||
@ -63,6 +63,12 @@ export default {
|
|||||||
hasUnits: {
|
hasUnits: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
requred: true
|
requred: true
|
||||||
|
},
|
||||||
|
isStale: {
|
||||||
|
type: Boolean,
|
||||||
|
default() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@ -81,14 +87,22 @@ export default {
|
|||||||
|
|
||||||
return this.formats[this.valueKey].format(this.datum);
|
return this.formats[this.valueKey].format(this.datum);
|
||||||
},
|
},
|
||||||
valueClass() {
|
valueClasses() {
|
||||||
if (!this.datum) {
|
let classes = [];
|
||||||
return '';
|
|
||||||
|
if (this.isStale) {
|
||||||
|
classes.push('is-stale');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.datum) {
|
||||||
const limit = this.limitEvaluator.evaluate(this.datum, this.valueMetadata);
|
const limit = this.limitEvaluator.evaluate(this.datum, this.valueMetadata);
|
||||||
|
|
||||||
return limit ? limit.cssClass : '';
|
if (limit) {
|
||||||
|
classes.push(limit.cssClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return classes;
|
||||||
|
|
||||||
},
|
},
|
||||||
formattedTimestamp() {
|
formattedTimestamp() {
|
||||||
|
@ -21,7 +21,10 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="c-lad-table-wrapper u-style-receiver js-style-receiver">
|
<div
|
||||||
|
class="c-lad-table-wrapper u-style-receiver js-style-receiver"
|
||||||
|
:class="staleClass"
|
||||||
|
>
|
||||||
<table class="c-table c-lad-table">
|
<table class="c-table c-lad-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -38,6 +41,7 @@
|
|||||||
:domain-object="ladRow.domainObject"
|
:domain-object="ladRow.domainObject"
|
||||||
:path-to-table="objectPath"
|
:path-to-table="objectPath"
|
||||||
:has-units="hasUnits"
|
:has-units="hasUnits"
|
||||||
|
:is-stale="staleObjects.includes(ladRow.key)"
|
||||||
@rowContextClick="updateViewContext"
|
@rowContextClick="updateViewContext"
|
||||||
/>
|
/>
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -46,7 +50,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import LadRow from './LADRow.vue';
|
import LadRow from './LADRow.vue';
|
||||||
|
import StalenessUtils from '@/utils/staleness';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -66,7 +72,8 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
items: [],
|
items: [],
|
||||||
viewContext: {}
|
viewContext: {},
|
||||||
|
staleObjects: []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -80,6 +87,13 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return itemsWithUnits.length !== 0;
|
return itemsWithUnits.length !== 0;
|
||||||
|
},
|
||||||
|
staleClass() {
|
||||||
|
if (this.staleObjects.length !== 0) {
|
||||||
|
return 'is-stale';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -88,11 +102,17 @@ export default {
|
|||||||
this.composition.on('remove', this.removeItem);
|
this.composition.on('remove', this.removeItem);
|
||||||
this.composition.on('reorder', this.reorder);
|
this.composition.on('reorder', this.reorder);
|
||||||
this.composition.load();
|
this.composition.load();
|
||||||
|
this.stalenessSubscription = {};
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
this.composition.off('add', this.addItem);
|
this.composition.off('add', this.addItem);
|
||||||
this.composition.off('remove', this.removeItem);
|
this.composition.off('remove', this.removeItem);
|
||||||
this.composition.off('reorder', this.reorder);
|
this.composition.off('reorder', this.reorder);
|
||||||
|
|
||||||
|
Object.values(this.stalenessSubscription).forEach(stalenessSubscription => {
|
||||||
|
stalenessSubscription.unsubscribe();
|
||||||
|
stalenessSubscription.stalenessUtils.destroy();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addItem(domainObject) {
|
addItem(domainObject) {
|
||||||
@ -101,23 +121,55 @@ export default {
|
|||||||
item.key = this.openmct.objects.makeKeyString(domainObject.identifier);
|
item.key = this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||||
|
|
||||||
this.items.push(item);
|
this.items.push(item);
|
||||||
|
|
||||||
|
this.stalenessSubscription[item.key] = {};
|
||||||
|
this.stalenessSubscription[item.key].stalenessUtils = new StalenessUtils(this.openmct, domainObject);
|
||||||
|
this.openmct.telemetry.isStale(domainObject).then((stalenessResponse) => {
|
||||||
|
if (stalenessResponse !== undefined) {
|
||||||
|
this.handleStaleness(item.key, stalenessResponse);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const stalenessSubscription = this.openmct.telemetry.subscribeToStaleness(domainObject, (stalenessResponse) => {
|
||||||
|
this.handleStaleness(item.key, stalenessResponse);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.stalenessSubscription[item.key].unsubscribe = stalenessSubscription;
|
||||||
},
|
},
|
||||||
removeItem(identifier) {
|
removeItem(identifier) {
|
||||||
let index = this.items.findIndex(item => this.openmct.objects.makeKeyString(identifier) === item.key);
|
const SKIP_CHECK = true;
|
||||||
|
const keystring = this.openmct.objects.makeKeyString(identifier);
|
||||||
|
const index = this.items.findIndex(item => keystring === item.key);
|
||||||
|
|
||||||
this.items.splice(index, 1);
|
this.items.splice(index, 1);
|
||||||
|
|
||||||
|
this.stalenessSubscription[keystring].unsubscribe();
|
||||||
|
this.handleStaleness(keystring, { isStale: false }, SKIP_CHECK);
|
||||||
},
|
},
|
||||||
reorder(reorderPlan) {
|
reorder(reorderPlan) {
|
||||||
let oldItems = this.items.slice();
|
const oldItems = this.items.slice();
|
||||||
reorderPlan.forEach((reorderEvent) => {
|
reorderPlan.forEach((reorderEvent) => {
|
||||||
this.$set(this.items, reorderEvent.newIndex, oldItems[reorderEvent.oldIndex]);
|
this.$set(this.items, reorderEvent.newIndex, oldItems[reorderEvent.oldIndex]);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
metadataHasUnits(valueMetadatas) {
|
metadataHasUnits(valueMetadatas) {
|
||||||
let metadataWithUnits = valueMetadatas.filter(metadatum => metadatum.unit);
|
const metadataWithUnits = valueMetadatas.filter(metadatum => metadatum.unit);
|
||||||
|
|
||||||
return metadataWithUnits.length > 0;
|
return metadataWithUnits.length > 0;
|
||||||
},
|
},
|
||||||
|
handleStaleness(id, stalenessResponse, skipCheck = false) {
|
||||||
|
if (skipCheck || this.stalenessSubscription[id].stalenessUtils.shouldUpdateStaleness(stalenessResponse)) {
|
||||||
|
const index = this.staleObjects.indexOf(id);
|
||||||
|
if (stalenessResponse.isStale) {
|
||||||
|
if (index === -1) {
|
||||||
|
this.staleObjects.push(id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (index !== -1) {
|
||||||
|
this.staleObjects.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
updateViewContext(rowContext) {
|
updateViewContext(rowContext) {
|
||||||
this.viewContext.row = rowContext;
|
this.viewContext.row = rowContext;
|
||||||
},
|
},
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<div
|
||||||
|
class="c-lad-table-wrapper u-style-receiver js-style-receiver"
|
||||||
|
:class="staleClass"
|
||||||
|
>
|
||||||
<table class="c-table c-lad-table">
|
<table class="c-table c-lad-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -44,19 +48,23 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<lad-row
|
<lad-row
|
||||||
v-for="ladRow in ladTelemetryObjects[ladTable.key]"
|
v-for="ladRow in ladTelemetryObjects[ladTable.key]"
|
||||||
:key="ladRow.key"
|
:key="combineKeys(ladTable.key, ladRow.key)"
|
||||||
:domain-object="ladRow.domainObject"
|
:domain-object="ladRow.domainObject"
|
||||||
:path-to-table="ladTable.objectPath"
|
:path-to-table="ladTable.objectPath"
|
||||||
:has-units="hasUnits"
|
:has-units="hasUnits"
|
||||||
|
:is-stale="staleObjects.includes(combineKeys(ladTable.key, ladRow.key))"
|
||||||
@rowContextClick="updateViewContext"
|
@rowContextClick="updateViewContext"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import LadRow from './LADRow.vue';
|
import LadRow from './LADRow.vue';
|
||||||
|
import StalenessUtils from '@/utils/staleness';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -74,7 +82,8 @@ export default {
|
|||||||
ladTableObjects: [],
|
ladTableObjects: [],
|
||||||
ladTelemetryObjects: {},
|
ladTelemetryObjects: {},
|
||||||
compositions: [],
|
compositions: [],
|
||||||
viewContext: {}
|
viewContext: {},
|
||||||
|
staleObjects: []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -95,6 +104,13 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
},
|
||||||
|
staleClass() {
|
||||||
|
if (this.staleObjects.length !== 0) {
|
||||||
|
return 'is-stale';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -103,6 +119,8 @@ export default {
|
|||||||
this.composition.on('remove', this.removeLadTable);
|
this.composition.on('remove', this.removeLadTable);
|
||||||
this.composition.on('reorder', this.reorderLadTables);
|
this.composition.on('reorder', this.reorderLadTables);
|
||||||
this.composition.load();
|
this.composition.load();
|
||||||
|
|
||||||
|
this.stalenessSubscription = {};
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
this.composition.off('add', this.addLadTable);
|
this.composition.off('add', this.addLadTable);
|
||||||
@ -112,6 +130,11 @@ export default {
|
|||||||
c.composition.off('add', c.addCallback);
|
c.composition.off('add', c.addCallback);
|
||||||
c.composition.off('remove', c.removeCallback);
|
c.composition.off('remove', c.removeCallback);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Object.values(this.stalenessSubscription).forEach(stalenessSubscription => {
|
||||||
|
stalenessSubscription.unsubscribe();
|
||||||
|
stalenessSubscription.stalenessUtils.destroy();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addLadTable(domainObject) {
|
addLadTable(domainObject) {
|
||||||
@ -137,10 +160,18 @@ export default {
|
|||||||
removeCallback
|
removeCallback
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
combineKeys(ladKey, telemetryObjectKey) {
|
||||||
|
return `${ladKey}-${telemetryObjectKey}`;
|
||||||
|
},
|
||||||
removeLadTable(identifier) {
|
removeLadTable(identifier) {
|
||||||
let index = this.ladTableObjects.findIndex(ladTable => this.openmct.objects.makeKeyString(identifier) === ladTable.key);
|
let index = this.ladTableObjects.findIndex(ladTable => this.openmct.objects.makeKeyString(identifier) === ladTable.key);
|
||||||
let ladTable = this.ladTableObjects[index];
|
let ladTable = this.ladTableObjects[index];
|
||||||
|
|
||||||
|
this.ladTelemetryObjects[ladTable.key].forEach(telemetryObject => {
|
||||||
|
let combinedKey = this.combineKeys(ladTable.key, telemetryObject.key);
|
||||||
|
this.unwatchStaleness(combinedKey);
|
||||||
|
});
|
||||||
|
|
||||||
this.$delete(this.ladTelemetryObjects, ladTable.key);
|
this.$delete(this.ladTelemetryObjects, ladTable.key);
|
||||||
this.ladTableObjects.splice(index, 1);
|
this.ladTableObjects.splice(index, 1);
|
||||||
},
|
},
|
||||||
@ -155,23 +186,61 @@ export default {
|
|||||||
let telemetryObject = {};
|
let telemetryObject = {};
|
||||||
telemetryObject.key = this.openmct.objects.makeKeyString(domainObject.identifier);
|
telemetryObject.key = this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||||
telemetryObject.domainObject = domainObject;
|
telemetryObject.domainObject = domainObject;
|
||||||
|
const combinedKey = this.combineKeys(ladTable.key, telemetryObject.key);
|
||||||
|
|
||||||
let telemetryObjects = this.ladTelemetryObjects[ladTable.key];
|
const telemetryObjects = this.ladTelemetryObjects[ladTable.key];
|
||||||
telemetryObjects.push(telemetryObject);
|
telemetryObjects.push(telemetryObject);
|
||||||
|
|
||||||
this.$set(this.ladTelemetryObjects, ladTable.key, telemetryObjects);
|
this.$set(this.ladTelemetryObjects, ladTable.key, telemetryObjects);
|
||||||
|
|
||||||
|
this.stalenessSubscription[combinedKey] = {};
|
||||||
|
this.stalenessSubscription[combinedKey].stalenessUtils = new StalenessUtils(this.openmct, domainObject);
|
||||||
|
|
||||||
|
this.openmct.telemetry.isStale(domainObject).then((stalenessResponse) => {
|
||||||
|
if (stalenessResponse !== undefined) {
|
||||||
|
this.handleStaleness(combinedKey, stalenessResponse);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const stalenessSubscription = this.openmct.telemetry.subscribeToStaleness(domainObject, (stalenessResponse) => {
|
||||||
|
this.handleStaleness(combinedKey, stalenessResponse);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.stalenessSubscription[combinedKey].unsubscribe = stalenessSubscription;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
removeTelemetryObject(ladTable) {
|
removeTelemetryObject(ladTable) {
|
||||||
return (identifier) => {
|
return (identifier) => {
|
||||||
let telemetryObjects = this.ladTelemetryObjects[ladTable.key];
|
const keystring = this.openmct.objects.makeKeyString(identifier);
|
||||||
let index = telemetryObjects.findIndex(telemetryObject => this.openmct.objects.makeKeyString(identifier) === telemetryObject.key);
|
const telemetryObjects = this.ladTelemetryObjects[ladTable.key];
|
||||||
|
const combinedKey = this.combineKeys(ladTable.key, keystring);
|
||||||
|
let index = telemetryObjects.findIndex(telemetryObject => keystring === telemetryObject.key);
|
||||||
|
|
||||||
|
this.unwatchStaleness(combinedKey);
|
||||||
|
|
||||||
telemetryObjects.splice(index, 1);
|
telemetryObjects.splice(index, 1);
|
||||||
|
|
||||||
this.$set(this.ladTelemetryObjects, ladTable.key, telemetryObjects);
|
this.$set(this.ladTelemetryObjects, ladTable.key, telemetryObjects);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
unwatchStaleness(combinedKey) {
|
||||||
|
const SKIP_CHECK = true;
|
||||||
|
|
||||||
|
this.stalenessSubscription[combinedKey].unsubscribe();
|
||||||
|
this.stalenessSubscription[combinedKey].stalenessUtils.destroy();
|
||||||
|
this.handleStaleness(combinedKey, { isStale: false }, SKIP_CHECK);
|
||||||
|
|
||||||
|
delete this.stalenessSubscription[combinedKey];
|
||||||
|
},
|
||||||
|
handleStaleness(combinedKey, stalenessResponse, skipCheck = false) {
|
||||||
|
if (skipCheck || this.stalenessSubscription[combinedKey].stalenessUtils.shouldUpdateStaleness(stalenessResponse)) {
|
||||||
|
const index = this.staleObjects.indexOf(combinedKey);
|
||||||
|
const foundStaleObject = index > -1;
|
||||||
|
if (stalenessResponse.isStale && !foundStaleObject) {
|
||||||
|
this.staleObjects.push(combinedKey);
|
||||||
|
} else if (!stalenessResponse.isStale && foundStaleObject) {
|
||||||
|
this.staleObjects.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
updateViewContext(rowContext) {
|
updateViewContext(rowContext) {
|
||||||
this.viewContext.row = rowContext;
|
this.viewContext.row = rowContext;
|
||||||
},
|
},
|
||||||
|
@ -121,7 +121,8 @@ describe("The URLTimeSettingsSynchronizer", () => {
|
|||||||
openmct.router.on('change:hash', resolveFunction);
|
openmct.router.on('change:hash', resolveFunction);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reset hash", (done) => {
|
// disabling due to test flakiness
|
||||||
|
xit("reset hash", (done) => {
|
||||||
window.location.hash = oldHash;
|
window.location.hash = oldHash;
|
||||||
resolveFunction = () => {
|
resolveFunction = () => {
|
||||||
expect(window.location.hash).toBe(oldHash);
|
expect(window.location.hash).toBe(oldHash);
|
||||||
|
@ -160,7 +160,8 @@ export default class Condition extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
criterion.on('criterionUpdated', (obj) => this.handleCriterionUpdated(obj));
|
criterion.on('criterionUpdated', (obj) => this.handleCriterionUpdated(obj));
|
||||||
criterion.on('telemetryIsStale', (obj) => this.handleStaleCriterion(obj));
|
criterion.on('telemetryIsOld', (obj) => this.handleOldTelemetryCriterion(obj));
|
||||||
|
criterion.on('telemetryStaleness', () => this.handleTelemetryStaleness());
|
||||||
if (!this.criteria) {
|
if (!this.criteria) {
|
||||||
this.criteria = [];
|
this.criteria = [];
|
||||||
}
|
}
|
||||||
@ -191,12 +192,14 @@ export default class Condition extends EventEmitter {
|
|||||||
const newCriterionConfiguration = this.generateCriterion(criterionConfiguration);
|
const newCriterionConfiguration = this.generateCriterion(criterionConfiguration);
|
||||||
let newCriterion = new TelemetryCriterion(newCriterionConfiguration, this.openmct);
|
let newCriterion = new TelemetryCriterion(newCriterionConfiguration, this.openmct);
|
||||||
newCriterion.on('criterionUpdated', (obj) => this.handleCriterionUpdated(obj));
|
newCriterion.on('criterionUpdated', (obj) => this.handleCriterionUpdated(obj));
|
||||||
newCriterion.on('telemetryIsStale', (obj) => this.handleStaleCriterion(obj));
|
newCriterion.on('telemetryIsOld', (obj) => this.handleOldTelemetryCriterion(obj));
|
||||||
|
newCriterion.on('telemetryStaleness', () => this.handleTelemetryStaleness());
|
||||||
|
|
||||||
let criterion = found.item;
|
let criterion = found.item;
|
||||||
criterion.unsubscribe();
|
criterion.unsubscribe();
|
||||||
criterion.off('criterionUpdated', (obj) => this.handleCriterionUpdated(obj));
|
criterion.off('criterionUpdated', (obj) => this.handleCriterionUpdated(obj));
|
||||||
criterion.off('telemetryIsStale', (obj) => this.handleStaleCriterion(obj));
|
criterion.off('telemetryIsOld', (obj) => this.handleOldTelemetryCriterion(obj));
|
||||||
|
newCriterion.off('telemetryStaleness', () => this.handleTelemetryStaleness());
|
||||||
this.criteria.splice(found.index, 1, newCriterion);
|
this.criteria.splice(found.index, 1, newCriterion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -205,12 +208,9 @@ export default class Condition extends EventEmitter {
|
|||||||
let found = this.findCriterion(id);
|
let found = this.findCriterion(id);
|
||||||
if (found) {
|
if (found) {
|
||||||
let criterion = found.item;
|
let criterion = found.item;
|
||||||
criterion.off('criterionUpdated', (obj) => {
|
criterion.off('criterionUpdated', (obj) => this.handleCriterionUpdated(obj));
|
||||||
this.handleCriterionUpdated(obj);
|
criterion.off('telemetryIsOld', (obj) => this.handleOldTelemetryCriterion(obj));
|
||||||
});
|
criterion.off('telemetryStaleness', () => this.handleTelemetryStaleness());
|
||||||
criterion.off('telemetryIsStale', (obj) => {
|
|
||||||
this.handleStaleCriterion(obj);
|
|
||||||
});
|
|
||||||
criterion.destroy();
|
criterion.destroy();
|
||||||
this.criteria.splice(found.index, 1);
|
this.criteria.splice(found.index, 1);
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ export default class Condition extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleStaleCriterion(updatedCriterion) {
|
handleOldTelemetryCriterion(updatedCriterion) {
|
||||||
this.result = evaluateResults(this.criteria.map(criterion => criterion.result), this.trigger);
|
this.result = evaluateResults(this.criteria.map(criterion => criterion.result), this.trigger);
|
||||||
let latestTimestamp = {};
|
let latestTimestamp = {};
|
||||||
latestTimestamp = getLatestTimestamp(
|
latestTimestamp = getLatestTimestamp(
|
||||||
@ -239,6 +239,11 @@ export default class Condition extends EventEmitter {
|
|||||||
this.conditionManager.updateCurrentCondition(latestTimestamp);
|
this.conditionManager.updateCurrentCondition(latestTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleTelemetryStaleness() {
|
||||||
|
this.result = evaluateResults(this.criteria.map(criterion => criterion.result), this.trigger);
|
||||||
|
this.conditionManager.updateCurrentCondition();
|
||||||
|
}
|
||||||
|
|
||||||
updateDescription() {
|
updateDescription() {
|
||||||
const triggerDescription = this.getTriggerDescription();
|
const triggerDescription = this.getTriggerDescription();
|
||||||
let description = '';
|
let description = '';
|
||||||
|
@ -82,8 +82,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import Condition from './Condition.vue';
|
import Condition from './Condition.vue';
|
||||||
import ConditionManager from '../ConditionManager';
|
import ConditionManager from '../ConditionManager';
|
||||||
|
import StalenessUtils from '@/utils/staleness';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -139,6 +141,13 @@ export default {
|
|||||||
if (this.stopObservingForChanges) {
|
if (this.stopObservingForChanges) {
|
||||||
this.stopObservingForChanges();
|
this.stopObservingForChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.stalenessSubscription) {
|
||||||
|
Object.values(this.stalenessSubscription).forEach(stalenessSubscription => {
|
||||||
|
stalenessSubscription.unsubscribe();
|
||||||
|
stalenessSubscription.stalenessUtils.destroy();
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.composition = this.openmct.composition.get(this.domainObject);
|
this.composition = this.openmct.composition.get(this.domainObject);
|
||||||
@ -150,6 +159,7 @@ export default {
|
|||||||
this.conditionManager = new ConditionManager(this.domainObject, this.openmct);
|
this.conditionManager = new ConditionManager(this.domainObject, this.openmct);
|
||||||
this.conditionManager.on('conditionSetResultUpdated', this.handleConditionSetResultUpdated);
|
this.conditionManager.on('conditionSetResultUpdated', this.handleConditionSetResultUpdated);
|
||||||
this.updateDefaultCondition();
|
this.updateDefaultCondition();
|
||||||
|
this.stalenessSubscription = {};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleConditionSetResultUpdated(data) {
|
handleConditionSetResultUpdated(data) {
|
||||||
@ -210,19 +220,60 @@ export default {
|
|||||||
return arr;
|
return arr;
|
||||||
},
|
},
|
||||||
addTelemetryObject(domainObject) {
|
addTelemetryObject(domainObject) {
|
||||||
|
const keyString = this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||||
|
|
||||||
this.telemetryObjs.push(domainObject);
|
this.telemetryObjs.push(domainObject);
|
||||||
this.$emit('telemetryUpdated', this.telemetryObjs);
|
this.$emit('telemetryUpdated', this.telemetryObjs);
|
||||||
|
|
||||||
|
if (!this.stalenessSubscription[keyString]) {
|
||||||
|
this.stalenessSubscription[keyString] = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
this.stalenessSubscription[keyString].stalenessUtils = new StalenessUtils(this.openmct, domainObject);
|
||||||
|
|
||||||
|
this.openmct.telemetry.isStale(domainObject).then((stalenessResponse) => {
|
||||||
|
if (stalenessResponse !== undefined) {
|
||||||
|
this.handleStaleness(keyString, stalenessResponse);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const stalenessSubscription = this.openmct.telemetry.subscribeToStaleness(domainObject, (stalenessResponse) => {
|
||||||
|
this.handleStaleness(keyString, stalenessResponse);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.stalenessSubscription[keyString].unsubscribe = stalenessSubscription;
|
||||||
},
|
},
|
||||||
removeTelemetryObject(identifier) {
|
removeTelemetryObject(identifier) {
|
||||||
let index = this.telemetryObjs.findIndex(obj => {
|
const keyString = this.openmct.objects.makeKeyString(identifier);
|
||||||
|
const index = this.telemetryObjs.findIndex(obj => {
|
||||||
let objId = this.openmct.objects.makeKeyString(obj.identifier);
|
let objId = this.openmct.objects.makeKeyString(obj.identifier);
|
||||||
let id = this.openmct.objects.makeKeyString(identifier);
|
|
||||||
|
|
||||||
return objId === id;
|
return objId === keyString;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
this.telemetryObjs.splice(index, 1);
|
this.telemetryObjs.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.stalenessSubscription[keyString]) {
|
||||||
|
this.stalenessSubscription[keyString].unsubscribe();
|
||||||
|
this.stalenessSubscription[keyString].stalenessUtils.destroy();
|
||||||
|
this.emitStaleness({
|
||||||
|
keyString,
|
||||||
|
isStale: false
|
||||||
|
});
|
||||||
|
delete this.stalenessSubscription[keyString];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleStaleness(keyString, stalenessResponse) {
|
||||||
|
if (this.stalenessSubscription[keyString].stalenessUtils.shouldUpdateStaleness(stalenessResponse)) {
|
||||||
|
this.emitStaleness({
|
||||||
|
keyString,
|
||||||
|
isStale: stalenessResponse.isStale
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
emitStaleness(stalenessObject) {
|
||||||
|
this.$emit('telemetryStaleness', stalenessObject);
|
||||||
},
|
},
|
||||||
addCondition() {
|
addCondition() {
|
||||||
this.conditionManager.addCondition();
|
this.conditionManager.addCondition();
|
||||||
|
@ -21,7 +21,10 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="c-cs">
|
<div
|
||||||
|
class="c-cs"
|
||||||
|
:class="{'is-stale': isStale }"
|
||||||
|
>
|
||||||
<section class="c-cs__current-output c-section">
|
<section class="c-cs__current-output c-section">
|
||||||
<div class="c-cs__content c-cs__current-output-value">
|
<div class="c-cs__content c-cs__current-output-value">
|
||||||
<span class="c-cs__current-output-value__label">Current Output</span>
|
<span class="c-cs__current-output-value__label">Current Output</span>
|
||||||
@ -50,6 +53,7 @@
|
|||||||
@conditionSetResultUpdated="updateCurrentOutput"
|
@conditionSetResultUpdated="updateCurrentOutput"
|
||||||
@updateDefaultOutput="updateDefaultOutput"
|
@updateDefaultOutput="updateDefaultOutput"
|
||||||
@telemetryUpdated="updateTelemetry"
|
@telemetryUpdated="updateTelemetry"
|
||||||
|
@telemetryStaleness="handleStaleness"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -73,9 +77,15 @@ export default {
|
|||||||
currentConditionOutput: '',
|
currentConditionOutput: '',
|
||||||
defaultConditionOutput: '',
|
defaultConditionOutput: '',
|
||||||
telemetryObjs: [],
|
telemetryObjs: [],
|
||||||
testData: {}
|
testData: {},
|
||||||
|
staleObjects: []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
isStale() {
|
||||||
|
return this.staleObjects.length !== 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.conditionSetIdentifier = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
this.conditionSetIdentifier = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
||||||
this.testData = {
|
this.testData = {
|
||||||
@ -95,6 +105,18 @@ export default {
|
|||||||
},
|
},
|
||||||
updateTestData(testData) {
|
updateTestData(testData) {
|
||||||
this.testData = testData;
|
this.testData = testData;
|
||||||
|
},
|
||||||
|
handleStaleness({ keyString, isStale }) {
|
||||||
|
const index = this.staleObjects.indexOf(keyString);
|
||||||
|
if (isStale) {
|
||||||
|
if (index === -1) {
|
||||||
|
this.staleObjects.push(keyString);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (index !== -1) {
|
||||||
|
this.staleObjects.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -94,7 +94,7 @@
|
|||||||
>
|
>
|
||||||
<span v-if="inputIndex < inputCount-1">and</span>
|
<span v-if="inputIndex < inputCount-1">and</span>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="criterion.metadata === 'dataReceived'">seconds</span>
|
<span v-if="criterion.metadata === 'dataReceived' && criterion.operation.name === IS_OLD_KEY">seconds</span>
|
||||||
</template>
|
</template>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
<span
|
<span
|
||||||
@ -122,7 +122,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { OPERATIONS, INPUT_TYPES } from '../utils/operations';
|
import { OPERATIONS, INPUT_TYPES } from '../utils/operations';
|
||||||
import {TRIGGER_CONJUNCTION} from "../utils/constants";
|
import { TRIGGER_CONJUNCTION, IS_OLD_KEY, IS_STALE_KEY } from "../utils/constants";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: ['openmct'],
|
inject: ['openmct'],
|
||||||
@ -153,7 +153,8 @@ export default {
|
|||||||
rowLabel: '',
|
rowLabel: '',
|
||||||
operationFormat: '',
|
operationFormat: '',
|
||||||
enumerations: [],
|
enumerations: [],
|
||||||
inputTypes: INPUT_TYPES
|
inputTypes: INPUT_TYPES,
|
||||||
|
IS_OLD_KEY
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -164,7 +165,7 @@ export default {
|
|||||||
},
|
},
|
||||||
filteredOps: function () {
|
filteredOps: function () {
|
||||||
if (this.criterion.metadata === 'dataReceived') {
|
if (this.criterion.metadata === 'dataReceived') {
|
||||||
return this.operations.filter(op => op.name === 'isStale');
|
return this.operations.filter(op => op.name === IS_OLD_KEY || op.name === IS_STALE_KEY);
|
||||||
} else {
|
} else {
|
||||||
return this.operations.filter(op => op.appliesTo.indexOf(this.operationFormat) !== -1);
|
return this.operations.filter(op => op.appliesTo.indexOf(this.operationFormat) !== -1);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,10 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
&.is-stale {
|
||||||
|
@include isStaleHolder();
|
||||||
|
}
|
||||||
|
|
||||||
/************************** CONDITION SET LAYOUT */
|
/************************** CONDITION SET LAYOUT */
|
||||||
&__current-output {
|
&__current-output {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
|
@ -21,8 +21,9 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
import TelemetryCriterion from './TelemetryCriterion';
|
import TelemetryCriterion from './TelemetryCriterion';
|
||||||
|
import StalenessUtils from '@/utils/staleness';
|
||||||
import { evaluateResults } from "../utils/evaluator";
|
import { evaluateResults } from "../utils/evaluator";
|
||||||
import {getLatestTimestamp, subscribeForStaleness} from '../utils/time';
|
import { getLatestTimestamp, checkIfOld } from '../utils/time';
|
||||||
import { getOperatorText } from "@/plugins/condition/utils/operations";
|
import { getOperatorText } from "@/plugins/condition/utils/operations";
|
||||||
|
|
||||||
export default class AllTelemetryCriterion extends TelemetryCriterion {
|
export default class AllTelemetryCriterion extends TelemetryCriterion {
|
||||||
@ -38,13 +39,41 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
|
|||||||
initialize() {
|
initialize() {
|
||||||
this.telemetryObjects = { ...this.telemetryDomainObjectDefinition.telemetryObjects };
|
this.telemetryObjects = { ...this.telemetryDomainObjectDefinition.telemetryObjects };
|
||||||
this.telemetryDataCache = {};
|
this.telemetryDataCache = {};
|
||||||
if (this.isValid() && this.isStalenessCheck() && this.isValidInput()) {
|
|
||||||
this.subscribeForStaleData(this.telemetryObjects || {});
|
if (this.isValid() && this.isOldCheck() && this.isValidInput()) {
|
||||||
|
this.checkForOldData(this.telemetryObjects || {});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isValid() && this.isStalenessCheck()) {
|
||||||
|
this.subscribeToStaleness(this.telemetryObjects || {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribeForStaleData(telemetryObjects) {
|
checkForOldData(telemetryObjects) {
|
||||||
|
if (!this.ageCheck) {
|
||||||
|
this.ageCheck = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.values(telemetryObjects).forEach((telemetryObject) => {
|
||||||
|
const id = this.openmct.objects.makeKeyString(telemetryObject.identifier);
|
||||||
|
if (!this.ageCheck[id]) {
|
||||||
|
this.ageCheck[id] = checkIfOld((data) => {
|
||||||
|
this.handleOldTelemetry(id, data);
|
||||||
|
}, this.input[0] * 1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleOldTelemetry(id, data) {
|
||||||
|
if (this.telemetryDataCache) {
|
||||||
|
this.telemetryDataCache[id] = true;
|
||||||
|
this.result = evaluateResults(Object.values(this.telemetryDataCache), this.telemetry);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.emitEvent('telemetryIsOld', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
subscribeToStaleness(telemetryObjects) {
|
||||||
if (!this.stalenessSubscription) {
|
if (!this.stalenessSubscription) {
|
||||||
this.stalenessSubscription = {};
|
this.stalenessSubscription = {};
|
||||||
}
|
}
|
||||||
@ -52,20 +81,32 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
|
|||||||
Object.values(telemetryObjects).forEach((telemetryObject) => {
|
Object.values(telemetryObjects).forEach((telemetryObject) => {
|
||||||
const id = this.openmct.objects.makeKeyString(telemetryObject.identifier);
|
const id = this.openmct.objects.makeKeyString(telemetryObject.identifier);
|
||||||
if (!this.stalenessSubscription[id]) {
|
if (!this.stalenessSubscription[id]) {
|
||||||
this.stalenessSubscription[id] = subscribeForStaleness((data) => {
|
this.stalenessSubscription[id] = {};
|
||||||
this.handleStaleTelemetry(id, data);
|
this.stalenessSubscription[id].stalenessUtils = new StalenessUtils(this.openmct, telemetryObject);
|
||||||
}, this.input[0] * 1000);
|
this.openmct.telemetry.isStale(telemetryObject).then((stalenessResponse) => {
|
||||||
|
if (stalenessResponse !== undefined) {
|
||||||
|
this.handleStaleTelemetry(id, stalenessResponse);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.stalenessSubscription[id].unsubscribe = this.openmct.telemetry.subscribeToStaleness(
|
||||||
|
telemetryObject,
|
||||||
|
(stalenessResponse) => {
|
||||||
|
this.handleStaleTelemetry(id, stalenessResponse);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleStaleTelemetry(id, data) {
|
handleStaleTelemetry(id, stalenessResponse) {
|
||||||
if (this.telemetryDataCache) {
|
if (this.telemetryDataCache) {
|
||||||
this.telemetryDataCache[id] = true;
|
if (this.stalenessSubscription[id].stalenessUtils.shouldUpdateStaleness(stalenessResponse)) {
|
||||||
|
this.telemetryDataCache[id] = stalenessResponse.isStale;
|
||||||
this.result = evaluateResults(Object.values(this.telemetryDataCache), this.telemetry);
|
this.result = evaluateResults(Object.values(this.telemetryDataCache), this.telemetry);
|
||||||
}
|
|
||||||
|
|
||||||
this.emitEvent('telemetryIsStale', data);
|
this.emitEvent('telemetryStaleness');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isValid() {
|
isValid() {
|
||||||
@ -75,8 +116,13 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
|
|||||||
updateTelemetryObjects(telemetryObjects) {
|
updateTelemetryObjects(telemetryObjects) {
|
||||||
this.telemetryObjects = { ...telemetryObjects };
|
this.telemetryObjects = { ...telemetryObjects };
|
||||||
this.removeTelemetryDataCache();
|
this.removeTelemetryDataCache();
|
||||||
if (this.isValid() && this.isStalenessCheck() && this.isValidInput()) {
|
|
||||||
this.subscribeForStaleData(this.telemetryObjects || {});
|
if (this.isValid() && this.isOldCheck() && this.isValidInput()) {
|
||||||
|
this.checkForOldData(this.telemetryObjects || {});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isValid() && this.isStalenessCheck()) {
|
||||||
|
this.subscribeToStaleness(this.telemetryObjects || {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +137,9 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
|
|||||||
});
|
});
|
||||||
telemetryCacheIds.forEach(id => {
|
telemetryCacheIds.forEach(id => {
|
||||||
delete (this.telemetryDataCache[id]);
|
delete (this.telemetryDataCache[id]);
|
||||||
|
delete (this.ageCheck[id]);
|
||||||
|
this.stalenessSubscription[id].unsubscribe();
|
||||||
|
this.stalenessSubscription[id].stalenessUtils.destroy();
|
||||||
delete (this.stalenessSubscription[id]);
|
delete (this.stalenessSubscription[id]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -125,10 +174,10 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
|
|||||||
updateResult(data, telemetryObjects) {
|
updateResult(data, telemetryObjects) {
|
||||||
const validatedData = this.isValid() ? data : {};
|
const validatedData = this.isValid() ? data : {};
|
||||||
|
|
||||||
if (validatedData) {
|
if (validatedData && !this.isStalenessCheck()) {
|
||||||
if (this.isStalenessCheck()) {
|
if (this.isOldCheck()) {
|
||||||
if (this.stalenessSubscription && this.stalenessSubscription[validatedData.id]) {
|
if (this.ageCheck?.[validatedData.id]) {
|
||||||
this.stalenessSubscription[validatedData.id].update(validatedData);
|
this.ageCheck[validatedData.id].update(validatedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.telemetryDataCache[validatedData.id] = false;
|
this.telemetryDataCache[validatedData.id] = false;
|
||||||
@ -226,9 +275,17 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
|
|||||||
destroy() {
|
destroy() {
|
||||||
delete this.telemetryObjects;
|
delete this.telemetryObjects;
|
||||||
delete this.telemetryDataCache;
|
delete this.telemetryDataCache;
|
||||||
|
|
||||||
|
if (this.ageCheck) {
|
||||||
|
Object.values(this.ageCheck).forEach((subscription) => subscription.clear);
|
||||||
|
delete this.ageCheck;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.stalenessSubscription) {
|
if (this.stalenessSubscription) {
|
||||||
Object.values(this.stalenessSubscription).forEach((subscription) => subscription.clear);
|
Object.values(this.stalenessSubscription).forEach(subscription => {
|
||||||
delete this.stalenessSubscription;
|
subscription.unsubscribe();
|
||||||
|
subscription.stalenessUtils.destroy();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,10 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
import EventEmitter from 'EventEmitter';
|
import EventEmitter from 'EventEmitter';
|
||||||
|
import StalenessUtils from '@/utils/staleness';
|
||||||
|
import { IS_OLD_KEY, IS_STALE_KEY } from '../utils/constants';
|
||||||
import { OPERATIONS, getOperatorText } from '../utils/operations';
|
import { OPERATIONS, getOperatorText } from '../utils/operations';
|
||||||
import { subscribeForStaleness } from "../utils/time";
|
import { checkIfOld } from "../utils/time";
|
||||||
|
|
||||||
export default class TelemetryCriterion extends EventEmitter {
|
export default class TelemetryCriterion extends EventEmitter {
|
||||||
|
|
||||||
@ -44,7 +46,8 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
this.input = telemetryDomainObjectDefinition.input;
|
this.input = telemetryDomainObjectDefinition.input;
|
||||||
this.metadata = telemetryDomainObjectDefinition.metadata;
|
this.metadata = telemetryDomainObjectDefinition.metadata;
|
||||||
this.result = undefined;
|
this.result = undefined;
|
||||||
this.stalenessSubscription = undefined;
|
this.ageCheck = undefined;
|
||||||
|
this.unsubscribeFromStaleness = undefined;
|
||||||
|
|
||||||
this.initialize();
|
this.initialize();
|
||||||
this.emitEvent('criterionUpdated', this);
|
this.emitEvent('criterionUpdated', this);
|
||||||
@ -57,8 +60,13 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.updateTelemetryObjects(this.telemetryDomainObjectDefinition.telemetryObjects);
|
this.updateTelemetryObjects(this.telemetryDomainObjectDefinition.telemetryObjects);
|
||||||
if (this.isValid() && this.isStalenessCheck() && this.isValidInput()) {
|
|
||||||
this.subscribeForStaleData();
|
if (this.isValid() && this.isOldCheck() && this.isValidInput()) {
|
||||||
|
this.checkForOldData();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isValid() && this.isStalenessCheck()) {
|
||||||
|
this.subscribeToStaleness();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,25 +74,52 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
return this.telemetryObjectIdAsString && (this.telemetryObjectIdAsString === id);
|
return this.telemetryObjectIdAsString && (this.telemetryObjectIdAsString === id);
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribeForStaleData() {
|
checkForOldData() {
|
||||||
if (this.stalenessSubscription) {
|
if (this.ageCheck) {
|
||||||
this.stalenessSubscription.clear();
|
this.ageCheck.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.stalenessSubscription = subscribeForStaleness(this.handleStaleTelemetry.bind(this), this.input[0] * 1000);
|
this.ageCheck = checkIfOld(this.handleOldTelemetry.bind(this), this.input[0] * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleStaleTelemetry(data) {
|
handleOldTelemetry(data) {
|
||||||
this.result = true;
|
this.result = true;
|
||||||
this.emitEvent('telemetryIsStale', data);
|
this.emitEvent('telemetryIsOld', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
subscribeToStaleness() {
|
||||||
|
if (this.unsubscribeFromStaleness) {
|
||||||
|
this.unsubscribeFromStaleness();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.stalenessUtils) {
|
||||||
|
this.stalenessUtils = new StalenessUtils(this.openmct, this.telemetryObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.openmct.telemetry.isStale(this.telemetryObject).then(this.handleStaleTelemetry.bind(this));
|
||||||
|
this.unsubscribeFromStaleness = this.openmct.telemetry.subscribeToStaleness(
|
||||||
|
this.telemetryObject,
|
||||||
|
this.handleStaleTelemetry.bind(this)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleStaleTelemetry(stalenessResponse) {
|
||||||
|
if (stalenessResponse !== undefined && this.stalenessUtils.shouldUpdateStaleness(stalenessResponse)) {
|
||||||
|
this.result = stalenessResponse.isStale;
|
||||||
|
this.emitEvent('telemetryStaleness');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isValid() {
|
isValid() {
|
||||||
return this.telemetryObject && this.metadata && this.operation;
|
return this.telemetryObject && this.metadata && this.operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isOldCheck() {
|
||||||
|
return this.metadata && this.metadata === 'dataReceived' && this.operation === IS_OLD_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
isStalenessCheck() {
|
isStalenessCheck() {
|
||||||
return this.metadata && this.metadata === 'dataReceived';
|
return this.metadata && this.metadata === 'dataReceived' && this.operation === IS_STALE_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
isValidInput() {
|
isValidInput() {
|
||||||
@ -93,8 +128,13 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
|
|
||||||
updateTelemetryObjects(telemetryObjects) {
|
updateTelemetryObjects(telemetryObjects) {
|
||||||
this.telemetryObject = telemetryObjects[this.telemetryObjectIdAsString];
|
this.telemetryObject = telemetryObjects[this.telemetryObjectIdAsString];
|
||||||
if (this.isValid() && this.isStalenessCheck() && this.isValidInput()) {
|
|
||||||
this.subscribeForStaleData();
|
if (this.isValid() && this.isOldCheck() && this.isValidInput()) {
|
||||||
|
this.checkForOldData();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isValid() && this.isStalenessCheck()) {
|
||||||
|
this.subscribeToStaleness();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,9 +170,11 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
|
|
||||||
updateResult(data) {
|
updateResult(data) {
|
||||||
const validatedData = this.isValid() ? data : {};
|
const validatedData = this.isValid() ? data : {};
|
||||||
if (this.isStalenessCheck()) {
|
|
||||||
if (this.stalenessSubscription) {
|
if (!this.isStalenessCheck()) {
|
||||||
this.stalenessSubscription.update(validatedData);
|
if (this.isOldCheck()) {
|
||||||
|
if (this.ageCheck) {
|
||||||
|
this.ageCheck.update(validatedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.result = false;
|
this.result = false;
|
||||||
@ -140,6 +182,7 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
this.result = this.computeResult(validatedData);
|
this.result = this.computeResult(validatedData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
requestLAD(telemetryObjects, requestOptions) {
|
requestLAD(telemetryObjects, requestOptions) {
|
||||||
let options = {
|
let options = {
|
||||||
@ -268,8 +311,17 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
destroy() {
|
destroy() {
|
||||||
delete this.telemetryObject;
|
delete this.telemetryObject;
|
||||||
delete this.telemetryObjectIdAsString;
|
delete this.telemetryObjectIdAsString;
|
||||||
if (this.stalenessSubscription) {
|
|
||||||
delete this.stalenessSubscription;
|
if (this.ageCheck) {
|
||||||
|
delete this.ageCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.stalenessUtils) {
|
||||||
|
this.stalenessUtils.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.unsubscribeFromStaleness) {
|
||||||
|
this.unsubscribeFromStaleness();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import Vue from 'vue';
|
|||||||
import {getApplicableStylesForItem} from "./utils/styleUtils";
|
import {getApplicableStylesForItem} from "./utils/styleUtils";
|
||||||
import ConditionManager from "@/plugins/condition/ConditionManager";
|
import ConditionManager from "@/plugins/condition/ConditionManager";
|
||||||
import StyleRuleManager from "./StyleRuleManager";
|
import StyleRuleManager from "./StyleRuleManager";
|
||||||
|
import { IS_OLD_KEY } from "./utils/constants";
|
||||||
|
|
||||||
describe('the plugin', function () {
|
describe('the plugin', function () {
|
||||||
let conditionSetDefinition;
|
let conditionSetDefinition;
|
||||||
@ -642,7 +643,7 @@ describe('the plugin', function () {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('the condition check for staleness', () => {
|
describe('the condition check if old', () => {
|
||||||
let conditionSetDomainObject;
|
let conditionSetDomainObject;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -660,13 +661,13 @@ describe('the plugin', function () {
|
|||||||
"id": "39584410-cbf9-499e-96dc-76f27e69885d",
|
"id": "39584410-cbf9-499e-96dc-76f27e69885d",
|
||||||
"configuration": {
|
"configuration": {
|
||||||
"name": "Unnamed Condition",
|
"name": "Unnamed Condition",
|
||||||
"output": "Any stale telemetry",
|
"output": "Any old telemetry",
|
||||||
"trigger": "all",
|
"trigger": "all",
|
||||||
"criteria": [
|
"criteria": [
|
||||||
{
|
{
|
||||||
"id": "35400132-63b0-425c-ac30-8197df7d5862",
|
"id": "35400132-63b0-425c-ac30-8197df7d5862",
|
||||||
"telemetry": "any",
|
"telemetry": "any",
|
||||||
"operation": "isStale",
|
"operation": IS_OLD_KEY,
|
||||||
"input": [
|
"input": [
|
||||||
"0.2"
|
"0.2"
|
||||||
],
|
],
|
||||||
@ -674,7 +675,7 @@ describe('the plugin', function () {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"summary": "Match if all criteria are met: Any telemetry is stale after 5 seconds"
|
"summary": "Match if all criteria are met: Any telemetry is old after 5 seconds"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"isDefault": true,
|
"isDefault": true,
|
||||||
@ -708,7 +709,7 @@ describe('the plugin', function () {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should evaluate as stale when telemetry is not received in the allotted time', (done) => {
|
it('should evaluate as old when telemetry is not received in the allotted time', (done) => {
|
||||||
let conditionMgr = new ConditionManager(conditionSetDomainObject, openmct);
|
let conditionMgr = new ConditionManager(conditionSetDomainObject, openmct);
|
||||||
conditionMgr.on('conditionSetResultUpdated', mockListener);
|
conditionMgr.on('conditionSetResultUpdated', mockListener);
|
||||||
conditionMgr.telemetryObjects = {
|
conditionMgr.telemetryObjects = {
|
||||||
@ -717,7 +718,7 @@ describe('the plugin', function () {
|
|||||||
conditionMgr.updateConditionTelemetryObjects();
|
conditionMgr.updateConditionTelemetryObjects();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
expect(mockListener).toHaveBeenCalledWith({
|
expect(mockListener).toHaveBeenCalledWith({
|
||||||
output: 'Any stale telemetry',
|
output: 'Any old telemetry',
|
||||||
id: {
|
id: {
|
||||||
namespace: '',
|
namespace: '',
|
||||||
key: 'cf4456a9-296a-4e6b-b182-62ed29cd15b9'
|
key: 'cf4456a9-296a-4e6b-b182-62ed29cd15b9'
|
||||||
@ -729,7 +730,7 @@ describe('the plugin', function () {
|
|||||||
}, 400);
|
}, 400);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not evaluate as stale when telemetry is received in the allotted time', (done) => {
|
it('should not evaluate as old when telemetry is received in the allotted time', (done) => {
|
||||||
const date = 1;
|
const date = 1;
|
||||||
conditionSetDomainObject.configuration.conditionCollection[0].configuration.criteria[0].input = ["0.4"];
|
conditionSetDomainObject.configuration.conditionCollection[0].configuration.criteria[0].input = ["0.4"];
|
||||||
let conditionMgr = new ConditionManager(conditionSetDomainObject, openmct);
|
let conditionMgr = new ConditionManager(conditionSetDomainObject, openmct);
|
||||||
|
@ -59,3 +59,6 @@ export const ERROR = {
|
|||||||
errorText: 'Condition not found'
|
errorText: 'Condition not found'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const IS_OLD_KEY = 'isStale';
|
||||||
|
export const IS_STALE_KEY = 'isStale.new';
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
import { IS_OLD_KEY, IS_STALE_KEY } from "./constants";
|
||||||
|
|
||||||
function convertToNumbers(input) {
|
function convertToNumbers(input) {
|
||||||
let numberInputs = [];
|
let numberInputs = [];
|
||||||
input.forEach(inputValue => numberInputs.push(Number(inputValue)));
|
input.forEach(inputValue => numberInputs.push(Number(inputValue)));
|
||||||
@ -295,7 +297,7 @@ export const OPERATIONS = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'isStale',
|
name: IS_OLD_KEY,
|
||||||
operation: function () {
|
operation: function () {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
@ -305,6 +307,18 @@ export const OPERATIONS = [
|
|||||||
getDescription: function (values) {
|
getDescription: function (values) {
|
||||||
return ` is older than ${values[0] || ''} seconds`;
|
return ` is older than ${values[0] || ''} seconds`;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: IS_STALE_KEY,
|
||||||
|
operation: function () {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
text: 'is stale',
|
||||||
|
appliesTo: ["number"],
|
||||||
|
inputCount: 0,
|
||||||
|
getDescription: function () {
|
||||||
|
return ' is stale';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -316,5 +330,5 @@ export const INPUT_TYPES = {
|
|||||||
export function getOperatorText(operationName, values) {
|
export function getOperatorText(operationName, values) {
|
||||||
const found = OPERATIONS.find((operation) => operation.name === operationName);
|
const found = OPERATIONS.find((operation) => operation.name === operationName);
|
||||||
|
|
||||||
return found ? found.getDescription(values) : '';
|
return found?.getDescription(values) ?? '';
|
||||||
}
|
}
|
||||||
|
@ -51,26 +51,26 @@ export function getLatestTimestamp(
|
|||||||
return latest;
|
return latest;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function subscribeForStaleness(callback, timeout) {
|
export function checkIfOld(callback, timeout) {
|
||||||
let stalenessTimer = setTimeout(() => {
|
let oldCheckTimer = setTimeout(() => {
|
||||||
clearTimeout(stalenessTimer);
|
clearTimeout(oldCheckTimer);
|
||||||
callback();
|
callback();
|
||||||
}, timeout);
|
}, timeout);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
update: (data) => {
|
update: (data) => {
|
||||||
if (stalenessTimer) {
|
if (oldCheckTimer) {
|
||||||
clearTimeout(stalenessTimer);
|
clearTimeout(oldCheckTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
stalenessTimer = setTimeout(() => {
|
oldCheckTimer = setTimeout(() => {
|
||||||
clearTimeout(stalenessTimer);
|
clearTimeout(oldCheckTimer);
|
||||||
callback(data);
|
callback(data);
|
||||||
}, timeout);
|
}, timeout);
|
||||||
},
|
},
|
||||||
clear: () => {
|
clear: () => {
|
||||||
if (stalenessTimer) {
|
if (oldCheckTimer) {
|
||||||
clearTimeout(stalenessTimer);
|
clearTimeout(oldCheckTimer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -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.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
import { subscribeForStaleness } from "./time";
|
import { checkIfOld } from "./time";
|
||||||
|
|
||||||
describe('time related utils', () => {
|
describe('time related utils', () => {
|
||||||
let subscription;
|
let subscription;
|
||||||
@ -27,11 +27,11 @@ describe('time related utils', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockListener = jasmine.createSpy('listener');
|
mockListener = jasmine.createSpy('listener');
|
||||||
subscription = subscribeForStaleness(mockListener, 100);
|
subscription = checkIfOld(mockListener, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('subscribe for staleness', () => {
|
describe('check if old', () => {
|
||||||
it('should call listeners when stale', (done) => {
|
it('should call listeners when old', (done) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
expect(mockListener).toHaveBeenCalled();
|
expect(mockListener).toHaveBeenCalled();
|
||||||
done();
|
done();
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
<div
|
<div
|
||||||
v-if="domainObject"
|
v-if="domainObject"
|
||||||
class="c-telemetry-view u-style-receiver"
|
class="c-telemetry-view u-style-receiver"
|
||||||
:class="[statusClass]"
|
:class="[itemClasses]"
|
||||||
:style="styleObject"
|
:style="styleObject"
|
||||||
:data-font-size="item.fontSize"
|
:data-font-size="item.fontSize"
|
||||||
:data-font="item.font"
|
:data-font="item.font"
|
||||||
@ -73,6 +73,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import LayoutFrame from './LayoutFrame.vue';
|
import LayoutFrame from './LayoutFrame.vue';
|
||||||
import conditionalStylesMixin from "../mixins/objectStyles-mixin";
|
import conditionalStylesMixin from "../mixins/objectStyles-mixin";
|
||||||
|
import stalenessMixin from '@/ui/mixins/staleness-mixin';
|
||||||
import { getDefaultNotebook, getNotebookSectionAndPage } from '@/plugins/notebook/utils/notebook-storage.js';
|
import { getDefaultNotebook, getNotebookSectionAndPage } from '@/plugins/notebook/utils/notebook-storage.js';
|
||||||
|
|
||||||
const DEFAULT_TELEMETRY_DIMENSIONS = [10, 5];
|
const DEFAULT_TELEMETRY_DIMENSIONS = [10, 5];
|
||||||
@ -102,7 +103,7 @@ export default {
|
|||||||
components: {
|
components: {
|
||||||
LayoutFrame
|
LayoutFrame
|
||||||
},
|
},
|
||||||
mixins: [conditionalStylesMixin],
|
mixins: [conditionalStylesMixin, stalenessMixin],
|
||||||
inject: ['openmct', 'objectPath', 'currentView'],
|
inject: ['openmct', 'objectPath', 'currentView'],
|
||||||
props: {
|
props: {
|
||||||
item: {
|
item: {
|
||||||
@ -137,8 +138,18 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
statusClass() {
|
itemClasses() {
|
||||||
return (this.status) ? `is-status--${this.status}` : '';
|
let classes = [];
|
||||||
|
|
||||||
|
if (this.status) {
|
||||||
|
classes.push(`is-status--${this.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isStale) {
|
||||||
|
classes.push('is-stale');
|
||||||
|
}
|
||||||
|
|
||||||
|
return classes;
|
||||||
},
|
},
|
||||||
showLabel() {
|
showLabel() {
|
||||||
let displayMode = this.item.displayMode;
|
let displayMode = this.item.displayMode;
|
||||||
@ -310,6 +321,7 @@ export default {
|
|||||||
this.removeSelectable = this.openmct.selection.selectable(
|
this.removeSelectable = this.openmct.selection.selectable(
|
||||||
this.$el, this.context, this.immediatelySelect || this.initSelect);
|
this.$el, this.context, this.immediatelySelect || this.initSelect);
|
||||||
delete this.immediatelySelect;
|
delete this.immediatelySelect;
|
||||||
|
this.subscribeToStaleness(this.domainObject);
|
||||||
},
|
},
|
||||||
updateTelemetryFormat(format) {
|
updateTelemetryFormat(format) {
|
||||||
this.customStringformatter.setFormat(format);
|
this.customStringformatter.setFormat(format);
|
||||||
|