diff --git a/.eslintrc.json b/.eslintrc.json index 3c5c1d052..df1dde61e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -82,7 +82,7 @@ "no-prototype-builtins": "warn", "no-await-in-loop": "warn", "no-dupe-else-if": "warn", - "meteor/no-session": "warn", + "meteor/no-session": "off", "meteor/template-names": "warn", "meteor/eventmap-params": "warn", "meteor/no-template-lifecycle-assignments": "warn", diff --git a/meteor_packages/mats-common/client/error.js b/meteor_packages/mats-common/client/error.js index 27b76e506..af9b9db8b 100644 --- a/meteor_packages/mats-common/client/error.js +++ b/meteor_packages/mats-common/client/error.js @@ -2,6 +2,9 @@ * Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved. */ +/* global setInfo, Session, $ */ +/* eslint-disable no-undef */ + setError = function (error) { let myError = ""; let myStackTrace = ""; @@ -27,7 +30,7 @@ setError = function (error) { $("#error").modal("show"); }; -clearError = function (message) { +clearError = function () { Session.set("errorMessage", ""); Session.set("stackTrace", ""); $("#error").modal("hide"); diff --git a/meteor_packages/mats-common/client/info.js b/meteor_packages/mats-common/client/info.js index 736f65615..5664c22ba 100644 --- a/meteor_packages/mats-common/client/info.js +++ b/meteor_packages/mats-common/client/info.js @@ -2,12 +2,15 @@ * Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved. */ +/* global Session, $ */ +/* eslint-disable no-undef */ + setInfo = function (info) { Session.set("infoMessage", info); $("#info").modal("show"); }; -clearInfo = function (info) { +clearInfo = function () { Session.set("infoMessage", ""); $("#info").modal("hide"); }; diff --git a/meteor_packages/mats-common/client/main.js b/meteor_packages/mats-common/client/main.js index 4a1f74293..9c8cdd8d5 100644 --- a/meteor_packages/mats-common/client/main.js +++ b/meteor_packages/mats-common/client/main.js @@ -6,6 +6,8 @@ * Created by pierce on 8/31/16. */ +/* eslint-disable import/no-unresolved */ + import "../imports/startup/client"; import "../imports/startup/both"; import "@fortawesome/fontawesome-free"; diff --git a/meteor_packages/mats-common/client/status.js b/meteor_packages/mats-common/client/status.js index 8635918dc..a9902617d 100644 --- a/meteor_packages/mats-common/client/status.js +++ b/meteor_packages/mats-common/client/status.js @@ -2,11 +2,14 @@ * Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved. */ +/* global Session */ +/* eslint-disable no-undef */ + setStatus = function (status) { Session.set("statusMessage", status); }; -clearStatus = function (status) { +clearStatus = function () { Session.set("statusMessage", ""); }; diff --git a/meteor_packages/mats-common/imports/startup/api/matsMethods.js b/meteor_packages/mats-common/imports/startup/api/matsMethods.js index 38a70de68..87b4a4c5d 100644 --- a/meteor_packages/mats-common/imports/startup/api/matsMethods.js +++ b/meteor_packages/mats-common/imports/startup/api/matsMethods.js @@ -52,6 +52,12 @@ const status = function (res) { } }; +// wrapper for NaN check +const isThisANaN = function (val) { + // eslint-disable-next-line no-restricted-globals + return !val || isNaN(val); +}; + // private - used to see if the main page needs to update its selectors const checkMetaDataRefresh = async function () { // This routine compares the current last modified time of the tables (MYSQL) or documents (Couchbase) @@ -3946,6 +3952,7 @@ if (Meteor.isServer) { // eslint-disable-next-line no-undef export default matsMethods = { + isThisANaN, addSentAddress, applyAuthorization, applyDatabaseSettings, diff --git a/meteor_packages/mats-common/imports/startup/api/version-info-tests.js b/meteor_packages/mats-common/imports/startup/api/version-info-tests.js index c7b24bf6c..b1d688170 100644 --- a/meteor_packages/mats-common/imports/startup/api/version-info-tests.js +++ b/meteor_packages/mats-common/imports/startup/api/version-info-tests.js @@ -1,5 +1,7 @@ import { versionInfo } from "meteor/randyp:mats-common"; +/* eslint-disable no-undef */ + const assert = require("assert"); describe("getVersionsFromEnv", function () { @@ -25,18 +27,18 @@ describe("getVersionsFromEnv", function () { // Test it("Correctly reads version from env", function () { process.env.VERSION = "4.2.0"; - const { version, commit, branch } = versionInfo.getVersionsFromEnv(); - assert.equal(version, "4.2.0"); + const versionStats = versionInfo.getVersionsFromEnv(); + assert.equal(versionStats.version, "4.2.0"); }); it("Correctly reads commit from env", function () { process.env.COMMIT = "ae214rfda"; - const { version, commit, branch } = versionInfo.getVersionsFromEnv(); - assert.equal(commit, "ae214rfda"); + const versionStats = versionInfo.getVersionsFromEnv(); + assert.equal(versionStats.commit, "ae214rfda"); }); it("Correctly reads version from env", function () { process.env.BRANCH = "test"; - const { version, commit, branch } = versionInfo.getVersionsFromEnv(); - assert.equal(branch, "test"); + const versionStats = versionInfo.getVersionsFromEnv(); + assert.equal(versionStats.branch, "test"); }); it("Correctly handles no env", function () { const { version, commit, branch } = versionInfo.getVersionsFromEnv(); diff --git a/meteor_packages/mats-common/imports/startup/api/version-info.js b/meteor_packages/mats-common/imports/startup/api/version-info.js index d4f985e9e..ba06ef818 100644 --- a/meteor_packages/mats-common/imports/startup/api/version-info.js +++ b/meteor_packages/mats-common/imports/startup/api/version-info.js @@ -20,6 +20,7 @@ function getVersionsFromEnv() { }; } +// eslint-disable-next-line no-undef export default versionInfo = { getVersionsFromEnv, }; diff --git a/meteor_packages/mats-common/imports/startup/both/mats-collections.js b/meteor_packages/mats-common/imports/startup/both/mats-collections.js index dc897386f..7abdea832 100644 --- a/meteor_packages/mats-common/imports/startup/both/mats-collections.js +++ b/meteor_packages/mats-common/imports/startup/both/mats-collections.js @@ -9,6 +9,8 @@ import { Mongo } from "meteor/mongo"; import { Meteor } from "meteor/meteor"; import { curveParamsByApp } from "./mats-curve-params"; +/* eslint-disable no-console */ + const params = curveParamsByApp[Meteor.settings.public.app]; if (!params) { console.log( @@ -20,7 +22,7 @@ if (!params) { } const paramCollections = {}; let currParam; -for (let i = 0; i < params.length; i++) { +for (let i = 0; i < params.length; i += 1) { currParam = params[i]; paramCollections[currParam] = new Mongo.Collection(currParam); } @@ -86,6 +88,7 @@ const explicitCollections = { Scorecard, }; +// eslint-disable-next-line no-undef export default matsCollections = { ...paramCollections, ...explicitCollections, diff --git a/meteor_packages/mats-common/imports/startup/both/mats-curve-params.js b/meteor_packages/mats-common/imports/startup/both/mats-curve-params.js index 5b165afde..32e9f2407 100644 --- a/meteor_packages/mats-common/imports/startup/both/mats-curve-params.js +++ b/meteor_packages/mats-common/imports/startup/both/mats-curve-params.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line no-undef, import/prefer-default-export export const curveParamsByApp = { "cb-metar": [ "label", diff --git a/meteor_packages/mats-common/imports/startup/both/mats-types.js b/meteor_packages/mats-common/imports/startup/both/mats-types.js index 8548d5c7e..0914b4da2 100644 --- a/meteor_packages/mats-common/imports/startup/both/mats-types.js +++ b/meteor_packages/mats-common/imports/startup/both/mats-types.js @@ -185,39 +185,40 @@ of table names. The internal list can be appended. The getRecords returns the in */ class MetaDataDBRecord { constructor(poolName, dbName, tables) { - if (!typeof poolName === "string") { + if (!(typeof poolName === "string")) { throw new Error("MetaDataDBRecord.constructor : poolName is not a string"); } - if (!typeof dbName === "string") { + if (!(typeof dbName === "string")) { throw new Error("MetaDataDBRecord.constructor : dbName is not a string"); } - if (!tables instanceof Array) { + if (!(tables instanceof Array)) { throw new Error("MetaDataDBRecord.constructor : tables is not an array"); } - this._records = []; + this.records = []; const record = { pool: poolName, name: dbName, tables }; - this._records.push(record); + this.records.push(record); } addRecord(poolName, dbName, tables) { - if (!typeof poolName === "string") { + if (!(typeof poolName === "string")) { throw new Error("MetaDataDBRecord.constructor : poolName is not a string"); } - if (!typeof dbName === "string") { + if (!(typeof dbName === "string")) { throw new Error("MetaDataDBRecord.constructor : dbName is not a string"); } - if (!tables instanceof Array) { + if (!(tables instanceof Array)) { throw new Error("MetaDataDBRecord.constructor : tables is not an array"); } const record = { pool: poolName, name: dbName, tables }; - this._records.push(record); + this.records.push(record); } getRecords() { - return this._records; + return this.records; } } +// eslint-disable-next-line no-undef export default matsTypes = { InputTypes, ScorecardStatus, diff --git a/meteor_packages/mats-common/imports/startup/client/curve_util.js b/meteor_packages/mats-common/imports/startup/client/curve_util.js index ca24b486a..1e6cfd1e7 100644 --- a/meteor_packages/mats-common/imports/startup/client/curve_util.js +++ b/meteor_packages/mats-common/imports/startup/client/curve_util.js @@ -5,74 +5,70 @@ import { matsTypes, matsCollections, + matsMethods, matsPlotUtils, matsParamUtils, - Info, - matsMethods, } from "meteor/randyp:mats-common"; -/* - global dataset variable - container for graph dataset. - This (plotResult) is very important. It isn't "var" because it needs to be a meteor global scope. - The page is rendered whe the graph page comes up, but the data from the data processing callback - in plotList.js or curveList.js may not have set the global variable - PlotResult. - */ +/* global $, _, Session, setError, setInfo */ +/* eslint-disable no-console */ // var plotResultData = null; -- this was the global variable for the text output data, but now it is set elsewhere let graphResult = null; // this is the global variable for the data on the graph -let plot; -const sizeof = function (_1) { - const _2 = [_1]; - let _3 = 0; - for (let _4 = 0; _4 < _2.length; _4++) { - switch (typeof _2[_4]) { +const sizeof = function (val1) { + const val2 = [val1]; + let val24Keys = []; + let val3 = 0; + for (let val4 = 0; val4 < val2.length; val4 += 1) { + switch (typeof val2[val4]) { case "boolean": - _3 += 4; + val3 += 4; break; case "number": - _3 += 8; + val3 += 8; break; case "string": - _3 += 2 * _2[_4].length; + val3 += 2 * val2[val4].length; break; case "object": - if (Object.prototype.toString.call(_2[_4]) !== "[object Array]") { - for (var _5 in _2[_4]) { - _3 += 2 * _5.length; + val24Keys = Object.keys(val2[val4]); + if (Object.prototype.toString.call(val2[val4]) !== "[object Array]") { + for (let v24idx = 0; v24idx < val24Keys.length; v24idx += 1) { + const val5 = val2[val4][val24Keys[v24idx]]; + val3 += 2 * val5.length; } } - for (var _5 in _2[_4]) { - let _6 = false; - for (let _7 = 0; _7 < _2.length; _7++) { - if (_2[_7] === _2[_4][_5]) { - _6 = true; + for (let v24idx = 0; v24idx < val24Keys.length; v24idx += 1) { + const val5 = val2[val4][val24Keys[v24idx]]; + let val6 = false; + for (let val7 = 0; val7 < val2.length; val7 += 1) { + if (val2[val7] === val2[val4][val5]) { + val6 = true; break; } } - if (!_6) { - _2.push(_2[_4][_5]); + if (!val6) { + val2.push(val2[val4][val5]); } } + break; + default: + val3 = 0; } } - return _3; + return val3; }; -// Retrieves the globally stored plotResultData for the text output and other things. -// Re-sets the plotResultData if the requested page range has changed, or if it has not been previously set. -const getPlotResultData = function () { - const pageIndex = Session.get("pageIndex"); - const newPageIndex = Session.get("newPageIndex"); - if ( - plotResultData === undefined || - plotResultData === null || - Session.get("textRefreshNeeded") === true - ) { - setPlotResultData(); +const showSpinner = function () { + if (document.getElementById("spinner")) { + document.getElementById("spinner").style.display = "block"; + } +}; +const hideSpinner = function () { + if (document.getElementById("spinner")) { + document.getElementById("spinner").style.display = "none"; } - return plotResultData; }; // Sets the global plotResultData variable for the text output to the requested range from the Results data stored in mongo, via a MatsMethod. @@ -94,15 +90,18 @@ const setPlotResultData = function () { Session.set("textRefreshNeeded", false); } if (!result) { + // eslint-disable-next-line no-undef plotResultData = undefined; Session.set("textRefreshNeeded", false); hideSpinner(); return; } + // eslint-disable-next-line no-undef plotResultData = result; Session.set("pageIndex", result.dsiRealPageIndex); Session.set("pageTextDirection", result.dsiTextDirection); Session.set("textLoaded", new Date()); + // eslint-disable-next-line no-undef console.log("size of plotResultData is ", sizeof(plotResultData)); Session.set("textRefreshNeeded", false); hideSpinner(); @@ -111,8 +110,25 @@ const setPlotResultData = function () { } }; +// Retrieves the globally stored plotResultData for the text output and other things. +// Re-sets the plotResultData if the requested page range has changed, or if it has not been previously set. +const getPlotResultData = function () { + if ( + // eslint-disable-next-line no-undef + plotResultData === undefined || + // eslint-disable-next-line no-undef + plotResultData === null || + Session.get("textRefreshNeeded") === true + ) { + setPlotResultData(); + } + // eslint-disable-next-line no-undef + return plotResultData; +}; + // resets the global plotResultData variable for the text output to null const resetPlotResultData = function () { + // eslint-disable-next-line no-undef plotResultData = null; Session.set("textLoaded", new Date()); }; @@ -145,6 +161,7 @@ const setCurveParamDisplayText = function (paramName, newText) { paramName, newText, }, + // eslint-disable-next-line no-unused-vars function (error, res) { if (error !== undefined) { setError(error); @@ -164,13 +181,6 @@ const getUsedLabels = function () { return Session.get("UsedLabels"); }; -const getNextCurveLabel = function () { - if (Session.get("NextCurveLabel") === undefined) { - setNextCurveLabel(); - } - return Session.get("NextCurveLabel"); -}; - // determine the next curve Label and set it in the session // private, not exported const setNextCurveLabel = function () { @@ -194,7 +204,7 @@ const setNextCurveLabel = function () { if (lastUsedLabel !== undefined) { const minusPrefix = lastUsedLabel.replace(labelPrefix, ""); const tryNum = parseInt(minusPrefix, 10); - if (!isNaN(tryNum)) { + if (!matsMethods.isThisANaN(tryNum)) { lastLabelNumber = tryNum; } } @@ -202,10 +212,23 @@ const setNextCurveLabel = function () { let nextCurveLabel = labelPrefix + newLabelNumber; // the label might be one from a removed curve so the next ones might be used while (_.indexOf(usedLabels, nextCurveLabel) !== -1) { - newLabelNumber++; + newLabelNumber += 1; nextCurveLabel = labelPrefix + newLabelNumber; } Session.set("NextCurveLabel", nextCurveLabel); + return null; +}; + +const getNextCurveLabel = function () { + if (Session.get("NextCurveLabel") === undefined) { + setNextCurveLabel(); + } + return Session.get("NextCurveLabel"); +}; + +// function for random color +const randomRGB = function () { + return Math.floor(Math.random() * 226); }; // determine the next curve color and set it in the session @@ -213,27 +236,17 @@ const setNextCurveLabel = function () { const setNextCurveColor = function () { const usedColors = Session.get("UsedColors"); const { colors } = matsCollections.ColorScheme.findOne({}, { fields: { colors: 1 } }); - let lastUsedIndex = -1; - if (usedColors !== undefined) { - lastUsedIndex = _.indexOf(colors, _.last(usedColors)); - } + const lastUsedIndex = usedColors ? usedColors.length - 1 : -1; let nextCurveColor; if (lastUsedIndex !== undefined && lastUsedIndex !== -1) { if (lastUsedIndex < colors.length - 1) { - let newIndex = lastUsedIndex + 1; - nextCurveColor = colors[newIndex]; - // the color might be one from a removed curve so the next ones might be used - while (_.indexOf(usedColors, nextCurveColor) !== -1) { - newIndex++; - nextCurveColor = colors[newIndex]; - } + nextCurveColor = colors[lastUsedIndex + 1]; } else { // out of defaults - const rint = Math.round(0xffffff * Math.random()); - nextCurveColor = `rgb(${rint >> 16},${(rint >> 8) & 255},${rint & 255})`; + nextCurveColor = `rgb(${randomRGB()},${randomRGB()},${randomRGB()})`; } } else { - nextCurveColor = colors[0]; + [nextCurveColor] = colors; } Session.set("NextCurveColor", nextCurveColor); }; @@ -291,7 +304,7 @@ const clearAllUsed = function () { const setUsedColors = function () { const curves = Session.get("Curves"); const usedColors = []; - for (let i = 0; i < curves.length; i++) { + for (let i = 0; i < curves.length; i += 1) { const { color } = curves[i]; usedColors.push(color); } @@ -303,7 +316,7 @@ const setUsedColors = function () { const setUsedLabels = function () { const curves = Session.get("Curves"); const usedLabels = []; - for (let i = 0; i < curves.length; i++) { + for (let i = 0; i < curves.length; i += 1) { const { label } = curves[i]; usedLabels.push(label); } @@ -341,29 +354,14 @@ const addDiffs = function () { return false; } + let baseIndex = 0; switch (matsPlotUtils.getPlotFormat()) { - case matsTypes.PlotFormats.matching: - var baseIndex = 0; // This will probably not default to curve 0 in the future - for (var ci = 1; ci < curves.length; ci++) { - var newCurve = $.extend(true, {}, curves[ci]); - newCurve.label = `${curves[ci].label}-${curves[0].label}`; - newCurve.color = getNextCurveColor(); - newCurve.diffFrom = [ci, baseIndex]; - // do not create extra diff if it already exists - if (_.findWhere(curves, { label: newCurve.label }) === undefined) { - newCurves.push(newCurve); - Session.set("Curves", newCurves); - setUsedColorsAndLabels(); - } - } - break; case matsTypes.PlotFormats.pairwise: - var baseIndex = 0; // This will probably not default to curve 0 in the future - for (var ci = 1; ci < curves.length; ci++) { + for (let ci = 1; ci < curves.length; ci += 1) { if (ci % 2 !== 0) { // only diff on odd curves against previous curve baseIndex = ci - 1; - var newCurve = $.extend(true, {}, curves[ci]); + const newCurve = $.extend(true, {}, curves[ci]); newCurve.label = `${curves[ci].label}-${curves[baseIndex].label}`; newCurve.color = getNextCurveColor(); newCurve.diffFrom = [ci, baseIndex]; @@ -377,9 +375,23 @@ const addDiffs = function () { } break; case matsTypes.PlotFormats.absolute: - var baseIndex = 0; // This will probably not default to curve 0 in the future - for (var ci = 1; ci < curves.length; ci++) { - var newCurve = $.extend(true, {}, curves[ci]); + for (let ci = 1; ci < curves.length; ci += 1) { + const newCurve = $.extend(true, {}, curves[ci]); + newCurve.label = `${curves[ci].label}-${curves[0].label}`; + newCurve.color = getNextCurveColor(); + newCurve.diffFrom = [ci, baseIndex]; + // do not create extra diff if it already exists + if (_.findWhere(curves, { label: newCurve.label }) === undefined) { + newCurves.push(newCurve); + Session.set("Curves", newCurves); + setUsedColorsAndLabels(); + } + } + break; + case matsTypes.PlotFormats.matching: + default: + for (let ci = 1; ci < curves.length; ci += 1) { + const newCurve = $.extend(true, {}, curves[ci]); newCurve.label = `${curves[ci].label}-${curves[0].label}`; newCurve.color = getNextCurveColor(); newCurve.diffFrom = [ci, baseIndex]; @@ -392,6 +404,7 @@ const addDiffs = function () { } break; } + return null; }; // remove difference curves @@ -427,6 +440,7 @@ const checkDiffs = function () { const checkIfDisplayAllQCParams = function (faceOptions) { // we only want to allow people to filter sub-values for apps with scalar or precalculated stats. // the stats in the list below are representative of these apps. + const theseFaceOptions = faceOptions; const subValueFilterableStats = [ "RMSE", // scalar stats "ACC", // anomalycor stats @@ -447,17 +461,17 @@ const checkIfDisplayAllQCParams = function (faceOptions) { 0 || _.intersection(thisAppsStatistics.options, doNotFilterStats).length > 0) ) { - if (faceOptions.QCParamGroup === "block") { + if (theseFaceOptions.QCParamGroup === "block") { // not a map plot, display only the gaps selector - faceOptions.QCParamGroup = "none"; - faceOptions["QCParamGroup-gaps"] = "block"; - } else if (faceOptions["QCParamGroup-lite"] === "block") { + theseFaceOptions.QCParamGroup = "none"; + theseFaceOptions["QCParamGroup-gaps"] = "block"; + } else if (theseFaceOptions["QCParamGroup-lite"] === "block") { // map plot, display nothing - faceOptions["QCParamGroup-lite"] = "none"; + theseFaceOptions["QCParamGroup-lite"] = "none"; } } } - return faceOptions; + return theseFaceOptions; }; const setSelectorVisibility = function (plotType, faceOptions, selectorsToReset) { @@ -468,7 +482,7 @@ const setSelectorVisibility = function (plotType, faceOptions, selectorsToReset) ) { // reset selectors that may have been set to something invalid for the new plot type const resetSelectors = Object.keys(selectorsToReset); - for (let ridx = 0; ridx < resetSelectors.length; ridx++) { + for (let ridx = 0; ridx < resetSelectors.length; ridx += 1) { if (matsParamUtils.getParameterForName(resetSelectors[ridx]) !== undefined) { if ( matsParamUtils.getParameterForName(resetSelectors[ridx]).type === @@ -489,7 +503,7 @@ const setSelectorVisibility = function (plotType, faceOptions, selectorsToReset) // show/hide selectors appropriate to this plot type let elem; const faceSelectors = Object.keys(faceOptions); - for (let fidx = 0; fidx < faceSelectors.length; fidx++) { + for (let fidx = 0; fidx < faceSelectors.length; fidx += 1) { elem = document.getElementById(`${faceSelectors[fidx]}-item`); if ( elem && @@ -1495,17 +1509,7 @@ const showScatterFace = function () { return selectorsToReset; }; -const showSpinner = function () { - if (document.getElementById("spinner")) { - document.getElementById("spinner").style.display = "block"; - } -}; -const hideSpinner = function () { - if (document.getElementById("spinner")) { - document.getElementById("spinner").style.display = "none"; - } -}; - +// eslint-disable-next-line no-undef export default matsCurveUtils = { addDiffs, checkDiffs, @@ -1525,6 +1529,7 @@ export default matsCurveUtils = { setGraphResult, setUsedColorsAndLabels, setUsedLabels, + setCurveParamDisplayText, showSpinner, showTimeseriesFace, showProfileFace, diff --git a/meteor_packages/mats-common/imports/startup/client/graph_util.js b/meteor_packages/mats-common/imports/startup/client/graph_util.js index b6ab15025..f5a1d5fee 100644 --- a/meteor_packages/mats-common/imports/startup/client/graph_util.js +++ b/meteor_packages/mats-common/imports/startup/client/graph_util.js @@ -2,11 +2,14 @@ * Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved. */ -import { matsTypes, matsCollections } from "meteor/randyp:mats-common"; +import { matsTypes } from "meteor/randyp:mats-common"; + +/* global $, Session */ +/* eslint-disable no-console */ // set the label for the hide show buttons (NO DATA) for the initial time here const setNoDataLabels = function (dataset) { - for (let c = 0; c < dataset.length; c++) { + for (let c = 0; c < dataset.length; c += 1) { if (dataset[c].x.length === 0) { Session.set(`${dataset[c].curveId}hideButtonText`, "NO DATA"); if (document.getElementById(`${dataset[c].curveId}-curve-show-hide`)) { @@ -186,7 +189,7 @@ const setNoDataLabels = function (dataset) { }; const setNoDataLabelsMap = function (dataset) { - for (let c = 0; c < dataset.length; c++) { + for (let c = 0; c < dataset.length; c += 1) { if (dataset[c].lat.length === 0) { Session.set(`${dataset[c].curveId}heatMapButtonText`, "NO DATA"); if (document.getElementById(`${dataset[c].curveId}-curve-show-hide-heatmap`)) { @@ -206,7 +209,7 @@ const setNoDataLabelsMap = function (dataset) { ).style.color = "white"; } } else { - var heatMapText; + let heatMapText; if (dataset[c].datatype === "ctc") { heatMapText = "hide heat map"; } else { @@ -233,6 +236,48 @@ const setNoDataLabelsMap = function (dataset) { } }; +const standAloneSquareWidthHeight = function () { + console.log("squareWidthHeight"); + const vpw = Math.min(document.documentElement.clientWidth, window.innerWidth || 0); + const vph = Math.min(document.documentElement.clientHeight, window.innerHeight || 0); + const min = Math.min(vpw, vph); + return `${(0.9 * min).toString()}px`; +}; +const standAloneRectangleWidth = function () { + console.log("rectangleWidth"); + const vpw = Math.min(document.documentElement.clientWidth, window.innerWidth || 0); + return `${(0.925 * vpw).toString()}px`; +}; +const standAloneRectangleHeight = function () { + console.log("rectangleHeight"); + const vph = Math.min(document.documentElement.clientHeight, window.innerHeight || 0); + return `${(0.825 * vph).toString()}px`; +}; + +const squareWidthHeight = function () { + const vpw = Math.min(document.documentElement.clientWidth, window.innerWidth || 0); + const vph = Math.min(document.documentElement.clientHeight, window.innerHeight || 0); + const min = Math.min(vpw, vph); + if (min < 400) { + return `${(0.9 * min).toString()}px`; + } + return `${(0.7 * min).toString()}px`; +}; +const rectangleWidth = function () { + const vpw = Math.min(document.documentElement.clientWidth, window.innerWidth || 0); + if (vpw < 400) { + return `${(0.9 * vpw).toString()}px`; + } + return `${(0.9 * vpw).toString()}px`; +}; +const rectangleHeight = function () { + const vph = Math.min(document.documentElement.clientHeight, window.innerHeight || 0); + if (vph < 400) { + return `${(0.8 * vph).toString()}px`; + } + return `${(0.7 * vph).toString()}px`; +}; + // plot width helper used in multiple places const width = function (plotType) { switch (plotType) { @@ -353,48 +398,6 @@ const standAloneHeight = function (plotType) { } }; -const standAloneSquareWidthHeight = function () { - console.log("squareWidthHeight"); - const vpw = Math.min(document.documentElement.clientWidth, window.innerWidth || 0); - const vph = Math.min(document.documentElement.clientHeight, window.innerHeight || 0); - const min = Math.min(vpw, vph); - return `${(0.9 * min).toString()}px`; -}; -const standAloneRectangleWidth = function () { - console.log("rectangleWidth"); - const vpw = Math.min(document.documentElement.clientWidth, window.innerWidth || 0); - return `${(0.925 * vpw).toString()}px`; -}; -const standAloneRectangleHeight = function () { - console.log("rectangleHeight"); - const vph = Math.min(document.documentElement.clientHeight, window.innerHeight || 0); - return `${(0.825 * vph).toString()}px`; -}; - -const squareWidthHeight = function () { - const vpw = Math.min(document.documentElement.clientWidth, window.innerWidth || 0); - const vph = Math.min(document.documentElement.clientHeight, window.innerHeight || 0); - const min = Math.min(vpw, vph); - if (min < 400) { - return `${(0.9 * min).toString()}px`; - } - return `${(0.7 * min).toString()}px`; -}; -const rectangleWidth = function () { - const vpw = Math.min(document.documentElement.clientWidth, window.innerWidth || 0); - if (vpw < 400) { - return `${(0.9 * vpw).toString()}px`; - } - return `${(0.9 * vpw).toString()}px`; -}; -const rectangleHeight = function () { - const vph = Math.min(document.documentElement.clientHeight, window.innerHeight || 0); - if (vph < 400) { - return `${(0.8 * vph).toString()}px`; - } - return `${(0.7 * vph).toString()}px`; -}; - const resizeGraph = function (plotType) { document.getElementById("placeholder").style.width = width(plotType); document.getElementById("placeholder").style.height = height(plotType); @@ -586,13 +589,14 @@ const downloadFile = function (fileURL, fileName) { // for IE < 11 else if (!!window.ActiveXObject && document.execCommand) { - const _window = window.open(fileURL, "_blank"); - _window.document.close(); - _window.document.execCommand("SaveAs", true, fileName || fileURL); - _window.close(); + const thisWindow = window.open(fileURL, "_blank"); + thisWindow.document.close(); + thisWindow.document.execCommand("SaveAs", true, fileName || fileURL); + thisWindow.close(); } }; +// eslint-disable-next-line no-undef export default matsGraphUtils = { setNoDataLabels, setNoDataLabelsMap, diff --git a/meteor_packages/mats-common/imports/startup/client/init.js b/meteor_packages/mats-common/imports/startup/client/init.js index 37f432d60..f9d432ca4 100644 --- a/meteor_packages/mats-common/imports/startup/client/init.js +++ b/meteor_packages/mats-common/imports/startup/client/init.js @@ -6,6 +6,9 @@ import { Meteor } from "meteor/meteor"; import matsCollections from "meteor/randyp:mats-common"; import { curveParamsByApp } from "../both/mats-curve-params"; +/* global Accounts, Session */ +/* eslint-disable no-console */ + if (Meteor.isClient) { const params = curveParamsByApp[Meteor.settings.public.app]; if (!params) { @@ -16,7 +19,7 @@ if (Meteor.isClient) { "curveParams are not defined in imports/startup/both/mats-curve-params.js. Please define some curveParams for this app." ); } - for (let i = 0; i < params.length; i++) { + for (let i = 0; i < params.length; i += 1) { Meteor.subscribe(params[i]); } Meteor.subscribe("Scatter2dParams"); @@ -49,8 +52,8 @@ if (Meteor.isClient) { }, }); - const ref = location.href; - const pathArray = location.href.split("/"); + const ref = window.location.href; + const pathArray = window.location.href.split("/"); const protocol = pathArray[0]; const hostport = pathArray[2]; const hostName = hostport.split(":")[0]; diff --git a/meteor_packages/mats-common/imports/startup/client/routes.js b/meteor_packages/mats-common/imports/startup/client/routes.js index 0c320841b..aca60f44c 100644 --- a/meteor_packages/mats-common/imports/startup/client/routes.js +++ b/meteor_packages/mats-common/imports/startup/client/routes.js @@ -5,6 +5,8 @@ import { Meteor } from "meteor/meteor"; import { FlowRouter } from "meteor/ostrio:flow-router-extra"; +/* global Session */ + // localhost routes FlowRouter.route("/", { @@ -27,14 +29,14 @@ FlowRouter.route("/", { FlowRouter.route("/CSV/:graphFunction/:key/:matching/:appName", { name: "csv", - action(params) { + action() { window.location.href = FlowRouter.path; }, }); FlowRouter.route("/JSON/:graphFunction/:key/:matching/:appName", { name: "json", - action(params) { + action() { window.location.href = FlowRouter.path; }, }); @@ -88,7 +90,7 @@ FlowRouter.route( `${Meteor.settings.public.proxy_prefix_path}/CSV/:graphFunction/:key/:matching/:appName`, { name: "csv", - action(params) { + action() { window.location.href = FlowRouter.path; }, } @@ -98,7 +100,7 @@ FlowRouter.route( `${Meteor.settings.public.proxy_prefix_path}/JSON/:graphFunction/:key/:matching/:appName`, { name: "json", - action(params) { + action() { window.location.href = FlowRouter.path; }, } @@ -162,7 +164,7 @@ FlowRouter.route( `${Meteor.settings.public.proxy_prefix_path}/*/CSV/:graphFunction/:key/:matching/:appName`, { name: "csv", - action(params) { + action() { window.location.href = FlowRouter.path; }, } @@ -172,7 +174,7 @@ FlowRouter.route( `${Meteor.settings.public.proxy_prefix_path}/*/JSON/:graphFunction/:key/:matching/:appName`, { name: "json", - action(params) { + action() { window.location.href = FlowRouter.path; }, } @@ -223,7 +225,6 @@ FlowRouter.route(`${Meteor.settings.public.proxy_prefix_path}/*/`, { FlowRouter.route("/*", { action() { - console.log("route: " + " not found"); this.render("notFound"); }, }); diff --git a/meteor_packages/mats-common/imports/startup/server/data_plot_ops_util.js b/meteor_packages/mats-common/imports/startup/server/data_plot_ops_util.js index 4ef5dde68..71952d4d1 100644 --- a/meteor_packages/mats-common/imports/startup/server/data_plot_ops_util.js +++ b/meteor_packages/mats-common/imports/startup/server/data_plot_ops_util.js @@ -2,7 +2,7 @@ * Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved. */ -import { matsCollections, matsTypes, matsDataUtils } from "meteor/randyp:mats-common"; +import { matsCollections, matsTypes, matsMethods } from "meteor/randyp:mats-common"; import { Meteor } from "meteor/meteor"; import { moment } from "meteor/momentjs:moment"; import { _ } from "meteor/underscore"; @@ -1497,7 +1497,7 @@ const generateGridScaleProbPlotOptions = function (axisMap) { const yPad = (ymax - ymin) * 0.025 !== 0 ? (ymax - ymin) * 0.025 : 0.025; const newYmax = Math.log10(ymax + yPad * 100); const newYmin = - matsDataUtils.isThisANaN(Math.log10(ymin - yPad)) || Math.log10(ymin - yPad) < 1 + matsMethods.isThisANaN(Math.log10(ymin - yPad)) || Math.log10(ymin - yPad) < 1 ? 0 : Math.log10(ymin - yPad); layout.yaxis.range = [newYmin, newYmax]; diff --git a/meteor_packages/mats-common/imports/startup/server/data_process_util.js b/meteor_packages/mats-common/imports/startup/server/data_process_util.js index 7382394f7..090aaa9c4 100644 --- a/meteor_packages/mats-common/imports/startup/server/data_process_util.js +++ b/meteor_packages/mats-common/imports/startup/server/data_process_util.js @@ -5,6 +5,7 @@ import { matsTypes, matsCollections, + matsMethods, matsDataUtils, matsDataMatchUtils, matsDataDiffUtils, @@ -125,11 +126,11 @@ const processDataXYCurve = function ( diffFrom === null || !( Array.isArray(returnDataset[diffFrom[0]].subHit[di]) || - !matsDataUtils.isThisANaN(returnDataset[diffFrom[0]].subHit[di]) + !matsMethods.isThisANaN(returnDataset[diffFrom[0]].subHit[di]) ) || !( Array.isArray(returnDataset[diffFrom[1]].subHit[di]) || - !matsDataUtils.isThisANaN(returnDataset[diffFrom[1]].subHit[di]) + !matsMethods.isThisANaN(returnDataset[diffFrom[1]].subHit[di]) ) ) { data.error_y.array[di] = null; @@ -206,46 +207,46 @@ const processDataXYCurve = function ( data.stats[di] = { stat: data.y[di], n: - Array.isArray(data.subHit[di]) || !matsDataUtils.isThisANaN(data.subHit[di]) + Array.isArray(data.subHit[di]) || !matsMethods.isThisANaN(data.subHit[di]) ? data.subHit[di].length : 0, hit: - Array.isArray(data.subHit[di]) || !matsDataUtils.isThisANaN(data.subHit[di]) + Array.isArray(data.subHit[di]) || !matsMethods.isThisANaN(data.subHit[di]) ? matsDataUtils.sum(data.subHit[di]) : null, fa: - Array.isArray(data.subFa[di]) || !matsDataUtils.isThisANaN(data.subFa[di]) + Array.isArray(data.subFa[di]) || !matsMethods.isThisANaN(data.subFa[di]) ? matsDataUtils.sum(data.subFa[di]) : null, miss: - Array.isArray(data.subMiss[di]) || !matsDataUtils.isThisANaN(data.subMiss[di]) + Array.isArray(data.subMiss[di]) || !matsMethods.isThisANaN(data.subMiss[di]) ? matsDataUtils.sum(data.subMiss[di]) : null, cn: - Array.isArray(data.subCn[di]) || !matsDataUtils.isThisANaN(data.subCn[di]) + Array.isArray(data.subCn[di]) || !matsMethods.isThisANaN(data.subCn[di]) ? matsDataUtils.sum(data.subCn[di]) : null, }; data.text[di] = `${data.text[di]}
${statisticSelect}: ${ data.y[di] === null ? null : data.y[di].toPrecision(4) }
n: ${ - Array.isArray(data.subHit[di]) || !matsDataUtils.isThisANaN(data.subHit[di]) + Array.isArray(data.subHit[di]) || !matsMethods.isThisANaN(data.subHit[di]) ? data.subHit[di].length : 0 }
Hits: ${ - Array.isArray(data.subHit[di]) || !matsDataUtils.isThisANaN(data.subHit[di]) + Array.isArray(data.subHit[di]) || !matsMethods.isThisANaN(data.subHit[di]) ? matsDataUtils.sum(data.subHit[di]) : null }
False alarms: ${ - Array.isArray(data.subFa[di]) || !matsDataUtils.isThisANaN(data.subFa[di]) + Array.isArray(data.subFa[di]) || !matsMethods.isThisANaN(data.subFa[di]) ? matsDataUtils.sum(data.subFa[di]) : null }
Misses: ${ - Array.isArray(data.subMiss[di]) || !matsDataUtils.isThisANaN(data.subMiss[di]) + Array.isArray(data.subMiss[di]) || !matsMethods.isThisANaN(data.subMiss[di]) ? matsDataUtils.sum(data.subMiss[di]) : null }
Correct Nulls: ${ - Array.isArray(data.subCn[di]) || !matsDataUtils.isThisANaN(data.subCn[di]) + Array.isArray(data.subCn[di]) || !matsMethods.isThisANaN(data.subCn[di]) ? matsDataUtils.sum(data.subCn[di]) : null }
Errorbars: ${Number(data.y[di] - errorLength).toPrecision(4)} to ${Number( @@ -255,27 +256,32 @@ const processDataXYCurve = function ( data.stats[di] = { stat: data.y[di], n: - Array.isArray(data.subInterest[di]) || !matsDataUtils.isThisANaN(data.subInterest[di]) + Array.isArray(data.subInterest[di]) || + !matsMethods.isThisANaN(data.subInterest[di]) ? data.subInterest[di].length : 0, raw_stat: data.y[di], nGood: - Array.isArray(data.subInterest[di]) || !matsDataUtils.isThisANaN(data.subInterest[di]) + Array.isArray(data.subInterest[di]) || + !matsMethods.isThisANaN(data.subInterest[di]) ? data.subInterest[di].length : 0, avgInterest: - Array.isArray(data.subInterest[di]) || !matsDataUtils.isThisANaN(data.subInterest[di]) + Array.isArray(data.subInterest[di]) || + !matsMethods.isThisANaN(data.subInterest[di]) ? matsDataUtils.average(data.subInterest[di]).toPrecision(4) : null, }; data.text[di] = `${data.text[di]}
${statisticSelect}: ${ data.y[di] === null ? null : data.y[di].toPrecision(4) }
n: ${ - Array.isArray(data.subInterest[di]) || !matsDataUtils.isThisANaN(data.subInterest[di]) + Array.isArray(data.subInterest[di]) || + !matsMethods.isThisANaN(data.subInterest[di]) ? data.subInterest[di].length : 0 }
Average Interest: ${ - Array.isArray(data.subInterest[di]) || !matsDataUtils.isThisANaN(data.subInterest[di]) + Array.isArray(data.subInterest[di]) || + !matsMethods.isThisANaN(data.subInterest[di]) ? matsDataUtils.average(data.subInterest[di]).toPrecision(4) : null }`; @@ -656,11 +662,11 @@ const processDataProfile = function ( diffFrom === null || !( Array.isArray(returnDataset[diffFrom[0]].subHit[di]) || - !matsDataUtils.isThisANaN(returnDataset[diffFrom[0]].subHit[di]) + !matsMethods.isThisANaN(returnDataset[diffFrom[0]].subHit[di]) ) || !( Array.isArray(returnDataset[diffFrom[1]].subHit[di]) || - !matsDataUtils.isThisANaN(returnDataset[diffFrom[1]].subHit[di]) + !matsMethods.isThisANaN(returnDataset[diffFrom[1]].subHit[di]) ) ) { data.error_x.array[di] = null; @@ -696,23 +702,23 @@ const processDataProfile = function ( data.stats[di] = { stat: data.x[di], n: - Array.isArray(data.subHit[di]) || !matsDataUtils.isThisANaN(data.subHit[di]) + Array.isArray(data.subHit[di]) || !matsMethods.isThisANaN(data.subHit[di]) ? data.subHit[di].length : 0, hit: - Array.isArray(data.subHit[di]) || !matsDataUtils.isThisANaN(data.subHit[di]) + Array.isArray(data.subHit[di]) || !matsMethods.isThisANaN(data.subHit[di]) ? matsDataUtils.sum(data.subHit[di]) : null, fa: - Array.isArray(data.subFa[di]) || !matsDataUtils.isThisANaN(data.subFa[di]) + Array.isArray(data.subFa[di]) || !matsMethods.isThisANaN(data.subFa[di]) ? matsDataUtils.sum(data.subFa[di]) : null, miss: - Array.isArray(data.subMiss[di]) || !matsDataUtils.isThisANaN(data.subMiss[di]) + Array.isArray(data.subMiss[di]) || !matsMethods.isThisANaN(data.subMiss[di]) ? matsDataUtils.sum(data.subMiss[di]) : null, cn: - Array.isArray(data.subCn[di]) || !matsDataUtils.isThisANaN(data.subCn[di]) + Array.isArray(data.subCn[di]) || !matsMethods.isThisANaN(data.subCn[di]) ? matsDataUtils.sum(data.subCn[di]) : null, }; @@ -721,23 +727,23 @@ const processDataProfile = function ( `
${statisticSelect}: ${ data.x[di] === null ? null : data.x[di].toPrecision(4) }
n: ${ - Array.isArray(data.subHit[di]) || !matsDataUtils.isThisANaN(data.subHit[di]) + Array.isArray(data.subHit[di]) || !matsMethods.isThisANaN(data.subHit[di]) ? data.subHit[di].length : 0 }
Hits: ${ - Array.isArray(data.subHit[di]) || !matsDataUtils.isThisANaN(data.subHit[di]) + Array.isArray(data.subHit[di]) || !matsMethods.isThisANaN(data.subHit[di]) ? matsDataUtils.sum(data.subHit[di]) : null }
False alarms: ${ - Array.isArray(data.subFa[di]) || !matsDataUtils.isThisANaN(data.subFa[di]) + Array.isArray(data.subFa[di]) || !matsMethods.isThisANaN(data.subFa[di]) ? matsDataUtils.sum(data.subFa[di]) : null }
Misses: ${ - Array.isArray(data.subMiss[di]) || !matsDataUtils.isThisANaN(data.subMiss[di]) + Array.isArray(data.subMiss[di]) || !matsMethods.isThisANaN(data.subMiss[di]) ? matsDataUtils.sum(data.subMiss[di]) : null }
Correct Nulls: ${ - Array.isArray(data.subCn[di]) || !matsDataUtils.isThisANaN(data.subCn[di]) + Array.isArray(data.subCn[di]) || !matsMethods.isThisANaN(data.subCn[di]) ? matsDataUtils.sum(data.subCn[di]) : null }
Errorbars: ${Number(data.x[di] - errorLength).toPrecision( @@ -747,27 +753,32 @@ const processDataProfile = function ( data.stats[di] = { stat: data.x[di], n: - Array.isArray(data.subInterest[di]) || !matsDataUtils.isThisANaN(data.subInterest[di]) + Array.isArray(data.subInterest[di]) || + !matsMethods.isThisANaN(data.subInterest[di]) ? data.subInterest[di].length : 0, raw_stat: data.x[di], nGood: - Array.isArray(data.subInterest[di]) || !matsDataUtils.isThisANaN(data.subInterest[di]) + Array.isArray(data.subInterest[di]) || + !matsMethods.isThisANaN(data.subInterest[di]) ? data.subInterest[di].length : 0, avgInterest: - Array.isArray(data.subInterest[di]) || !matsDataUtils.isThisANaN(data.subInterest[di]) + Array.isArray(data.subInterest[di]) || + !matsMethods.isThisANaN(data.subInterest[di]) ? matsDataUtils.average(data.subInterest[di]).toPrecision(4) : null, }; data.text[di] = `${data.text[di]}
${statisticSelect}: ${ data.x[di] === null ? null : data.x[di].toPrecision(4) }
n: ${ - Array.isArray(data.subInterest[di]) || !matsDataUtils.isThisANaN(data.subInterest[di]) + Array.isArray(data.subInterest[di]) || + !matsMethods.isThisANaN(data.subInterest[di]) ? data.subInterest[di].length : 0 }
Average Interest: ${ - Array.isArray(data.subInterest[di]) || !matsDataUtils.isThisANaN(data.subInterest[di]) + Array.isArray(data.subInterest[di]) || + !matsMethods.isThisANaN(data.subInterest[di]) ? matsDataUtils.average(data.subInterest[di]).toPrecision(4) : null }`; diff --git a/meteor_packages/mats-common/imports/startup/server/data_query_util.js b/meteor_packages/mats-common/imports/startup/server/data_query_util.js index 061270e15..17c5ae4ff 100644 --- a/meteor_packages/mats-common/imports/startup/server/data_query_util.js +++ b/meteor_packages/mats-common/imports/startup/server/data_query_util.js @@ -2,7 +2,12 @@ * Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved. */ -import { matsDataUtils, matsTypes, matsCollections } from "meteor/randyp:mats-common"; +import { + matsDataUtils, + matsTypes, + matsCollections, + matsMethods, +} from "meteor/randyp:mats-common"; import { Meteor } from "meteor/meteor"; import { _ } from "meteor/underscore"; @@ -391,7 +396,7 @@ const parseQueryDataXYCurve = function ( const n = rows[rowIndex].sub_data.toString().split(",").length; if (hit + fa + miss + cn > 0) { stat = matsDataUtils.calculateStatCTC(hit, fa, miss, cn, n, statisticStr); - stat = matsDataUtils.isThisANaN(Number(stat)) ? null : stat; + stat = matsMethods.isThisANaN(Number(stat)) ? null : stat; } else { stat = null; } @@ -417,7 +422,7 @@ const parseQueryDataXYCurve = function ( absSum, statisticStr ); - stat = matsDataUtils.isThisANaN(Number(stat)) ? null : stat; + stat = matsMethods.isThisANaN(Number(stat)) ? null : stat; } else { stat = null; } @@ -470,7 +475,7 @@ const parseQueryDataXYCurve = function ( if (isCTC) { thisSubSecs.push(Number(currSubData[0])); if (hasLevels) { - if (!matsDataUtils.isThisANaN(Number(currSubData[1]))) { + if (!matsMethods.isThisANaN(Number(currSubData[1]))) { thisSubLevs.push(Number(currSubData[1])); } else { thisSubLevs.push(currSubData[1]); @@ -508,7 +513,7 @@ const parseQueryDataXYCurve = function ( } else if (isScalar) { thisSubSecs.push(Number(currSubData[0])); if (hasLevels) { - if (!matsDataUtils.isThisANaN(Number(currSubData[1]))) { + if (!matsMethods.isThisANaN(Number(currSubData[1]))) { thisSubLevs.push(Number(currSubData[1])); } else { thisSubLevs.push(currSubData[1]); @@ -552,7 +557,7 @@ const parseQueryDataXYCurve = function ( } else { thisSubSecs.push(Number(currSubData[0])); if (hasLevels) { - if (!matsDataUtils.isThisANaN(Number(currSubData[1]))) { + if (!matsMethods.isThisANaN(Number(currSubData[1]))) { thisSubLevs.push(Number(currSubData[1])); } else { thisSubLevs.push(currSubData[1]); @@ -1024,7 +1029,7 @@ const parseQueryDataReliability = function (rows, d, appParams, kernel) { currSubData = thisSubData[sdIdx].split(";"); thisSubSecs.push(Number(currSubData[0])); if (hasLevels) { - if (!matsDataUtils.isThisANaN(Number(currSubData[1]))) { + if (!matsMethods.isThisANaN(Number(currSubData[1]))) { thisSubLevs.push(Number(currSubData[1])); } else { thisSubLevs.push(currSubData[1]); @@ -1194,7 +1199,7 @@ const parseQueryDataPerformanceDiagram = function (rows, d, appParams) { currSubData = thisSubData[sdIdx].split(";"); thisSubSecs.push(Number(currSubData[0])); if (hasLevels) { - if (!matsDataUtils.isThisANaN(Number(currSubData[1]))) { + if (!matsMethods.isThisANaN(Number(currSubData[1]))) { thisSubLevs.push(Number(currSubData[1])); } else { thisSubLevs.push(currSubData[1]); @@ -1379,7 +1384,7 @@ const parseQueryDataSimpleScatter = function ( absSumX, statisticXStr ); - xStat = matsDataUtils.isThisANaN(Number(xStat)) ? null : xStat; + xStat = matsMethods.isThisANaN(Number(xStat)) ? null : xStat; yStat = matsDataUtils.calculateStatScalar( squareDiffSumY, NSumY, @@ -1389,7 +1394,7 @@ const parseQueryDataSimpleScatter = function ( absSumY, statisticYStr ); - yStat = matsDataUtils.isThisANaN(Number(yStat)) ? null : yStat; + yStat = matsMethods.isThisANaN(Number(yStat)) ? null : yStat; } else { xStat = null; yStat = null; @@ -1429,7 +1434,7 @@ const parseQueryDataSimpleScatter = function ( currSubData = thisSubData[sdIdx].split(";"); thisSubSecs.push(Number(currSubData[0])); if (hasLevels) { - if (!matsDataUtils.isThisANaN(Number(currSubData[1]))) { + if (!matsMethods.isThisANaN(Number(currSubData[1]))) { thisSubLevs.push(Number(currSubData[1])); } else { thisSubLevs.push(currSubData[1]); @@ -1722,7 +1727,7 @@ const parseQueryDataMapScalar = function ( absSum, `${statistic}_${variable}` ); - queryVal = matsDataUtils.isThisANaN(Number(queryVal)) ? null : queryVal; + queryVal = matsMethods.isThisANaN(Number(queryVal)) ? null : queryVal; } else { queryVal = null; } @@ -1752,7 +1757,7 @@ const parseQueryDataMapScalar = function ( currSubData = thisSubData[sdIdx].split(";"); thisSubSecs.push(Number(currSubData[0])); if (hasLevels) { - if (!matsDataUtils.isThisANaN(Number(currSubData[1]))) { + if (!matsMethods.isThisANaN(Number(currSubData[1]))) { thisSubLevs.push(Number(currSubData[1])); } else { thisSubLevs.push(currSubData[1]); @@ -1830,7 +1835,7 @@ const parseQueryDataMapScalar = function ( absSumSum, `${statistic}_${variable}` ); - queryVal = matsDataUtils.isThisANaN(Number(queryVal)) ? null : queryVal; + queryVal = matsMethods.isThisANaN(Number(queryVal)) ? null : queryVal; } catch (e) { // this is an error produced by a bug in the query function, not an error returned by the mysql database e.message = `Error in parseQueryDataMapScalar. The expected fields don't seem to be present in the results cache: ${e.message}`; @@ -2007,7 +2012,7 @@ const parseQueryDataMapCTC = function ( const n = rows[rowIndex].nTimes; if (hit + fa + miss + cn > 0) { queryVal = matsDataUtils.calculateStatCTC(hit, fa, miss, cn, n, statistic); - queryVal = matsDataUtils.isThisANaN(Number(queryVal)) ? null : queryVal; + queryVal = matsMethods.isThisANaN(Number(queryVal)) ? null : queryVal; switch (statistic) { case "PODy (POD of value < threshold)": case "PODy (POD of value > threshold)": @@ -2068,7 +2073,7 @@ const parseQueryDataMapCTC = function ( currSubData = thisSubData[sdIdx].split(";"); thisSubSecs.push(Number(currSubData[0])); if (hasLevels) { - if (!matsDataUtils.isThisANaN(Number(currSubData[1]))) { + if (!matsMethods.isThisANaN(Number(currSubData[1]))) { thisSubLevs.push(Number(currSubData[1])); } else { thisSubLevs.push(currSubData[1]); @@ -2135,7 +2140,7 @@ const parseQueryDataMapCTC = function ( thisSubHit.length, statistic ); - queryVal = matsDataUtils.isThisANaN(Number(queryVal)) ? null : queryVal; + queryVal = matsMethods.isThisANaN(Number(queryVal)) ? null : queryVal; } catch (e) { // this is an error produced by a bug in the query function, not an error returned by the mysql database e.message = `Error in parseQueryDataMapCTC. The expected fields don't seem to be present in the results cache: ${e.message}`; @@ -2325,7 +2330,7 @@ const parseQueryDataHistogram = function (rows, d, appParams, statisticStr) { const n = rows[rowIndex].sub_data.toString().split(",").length; if (hit + fa + miss + cn > 0) { stat = matsDataUtils.calculateStatCTC(hit, fa, miss, cn, n, statisticStr); - stat = matsDataUtils.isThisANaN(Number(stat)) ? null : stat; + stat = matsMethods.isThisANaN(Number(stat)) ? null : stat; } else { stat = null; } @@ -2351,7 +2356,7 @@ const parseQueryDataHistogram = function (rows, d, appParams, statisticStr) { absSum, statisticStr ); - stat = matsDataUtils.isThisANaN(Number(stat)) ? null : stat; + stat = matsMethods.isThisANaN(Number(stat)) ? null : stat; } else { stat = null; } @@ -2376,7 +2381,7 @@ const parseQueryDataHistogram = function (rows, d, appParams, statisticStr) { if (isCTC) { thisSubSecs.push(Number(currSubData[0])); if (hasLevels) { - if (!matsDataUtils.isThisANaN(Number(currSubData[1]))) { + if (!matsMethods.isThisANaN(Number(currSubData[1]))) { thisSubLevs.push(Number(currSubData[1])); } else { thisSubLevs.push(currSubData[1]); @@ -2406,7 +2411,7 @@ const parseQueryDataHistogram = function (rows, d, appParams, statisticStr) { } else if (isScalar) { thisSubSecs.push(Number(currSubData[0])); if (hasLevels) { - if (!matsDataUtils.isThisANaN(Number(currSubData[1]))) { + if (!matsMethods.isThisANaN(Number(currSubData[1]))) { thisSubLevs.push(Number(currSubData[1])); } else { thisSubLevs.push(currSubData[1]); @@ -2438,7 +2443,7 @@ const parseQueryDataHistogram = function (rows, d, appParams, statisticStr) { } else { thisSubSecs.push(Number(currSubData[0])); if (hasLevels) { - if (!matsDataUtils.isThisANaN(Number(currSubData[1]))) { + if (!matsMethods.isThisANaN(Number(currSubData[1]))) { thisSubLevs.push(Number(currSubData[1])); } else { thisSubLevs.push(currSubData[1]); @@ -2590,7 +2595,7 @@ const parseQueryDataContour = function (rows, d, appParams, statisticStr) { cn = Number(rows[rowIndex].cn); if (hit + fa + miss + cn > 0) { stat = matsDataUtils.calculateStatCTC(hit, fa, miss, cn, n, statisticStr); - stat = matsDataUtils.isThisANaN(Number(stat)) ? null : stat; + stat = matsMethods.isThisANaN(Number(stat)) ? null : stat; } } else if ( rows[rowIndex].stat === undefined && @@ -2614,7 +2619,7 @@ const parseQueryDataContour = function (rows, d, appParams, statisticStr) { absSum, statisticStr ); - stat = matsDataUtils.isThisANaN(Number(stat)) ? null : stat; + stat = matsMethods.isThisANaN(Number(stat)) ? null : stat; const variable = statisticStr.split("_")[1]; stdev = matsDataUtils.calculateStatScalar( squareDiffSum, @@ -2667,7 +2672,7 @@ const parseQueryDataContour = function (rows, d, appParams, statisticStr) { if (isCTC) { thisSubSecs.push(Number(currSubData[0])); if (hasLevels) { - if (!matsDataUtils.isThisANaN(Number(currSubData[1]))) { + if (!matsMethods.isThisANaN(Number(currSubData[1]))) { thisSubLevs.push(Number(currSubData[1])); } else { thisSubLevs.push(currSubData[1]); @@ -2685,7 +2690,7 @@ const parseQueryDataContour = function (rows, d, appParams, statisticStr) { } else if (isScalar) { thisSubSecs.push(Number(currSubData[0])); if (hasLevels) { - if (!matsDataUtils.isThisANaN(Number(currSubData[1]))) { + if (!matsMethods.isThisANaN(Number(currSubData[1]))) { thisSubLevs.push(Number(currSubData[1])); } else { thisSubLevs.push(currSubData[1]); @@ -2707,7 +2712,7 @@ const parseQueryDataContour = function (rows, d, appParams, statisticStr) { } else { thisSubSecs.push(Number(currSubData[0])); if (hasLevels) { - if (!matsDataUtils.isThisANaN(Number(currSubData[1]))) { + if (!matsMethods.isThisANaN(Number(currSubData[1]))) { thisSubLevs.push(Number(currSubData[1])); } else { thisSubLevs.push(currSubData[1]); diff --git a/meteor_packages/mats-common/imports/startup/server/data_util.js b/meteor_packages/mats-common/imports/startup/server/data_util.js index 31a63e32f..677d14bb7 100644 --- a/meteor_packages/mats-common/imports/startup/server/data_util.js +++ b/meteor_packages/mats-common/imports/startup/server/data_util.js @@ -2,19 +2,13 @@ * Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved. */ -import { matsTypes, matsCollections } from "meteor/randyp:mats-common"; +import { matsTypes, matsCollections, matsMethods } from "meteor/randyp:mats-common"; import { Meteor } from "meteor/meteor"; import { HTTP } from "meteor/jkuester:http"; /* eslint-disable global-require */ /* eslint-disable no-console */ -// wrapper for NaN check -const isThisANaN = function (val) { - // eslint-disable-next-line no-restricted-globals - return !val || isNaN(val); -}; - // this function checks if two JSON objects are identical const areObjectsEqual = function (o, p) { if ((o && !p) || (p && !o)) { @@ -284,26 +278,12 @@ const doColorScheme = function () { "rgb(255,0,0)", "rgb(0,0,255)", "rgb(255,165,0)", - "rgb(128,128,128)", - "rgb(238,130,238)", - + "rgb(95,95,95)", "rgb(238,130,238)", "rgb(0,0,139)", "rgb(148,0,211)", - "rgb(105,105,105)", - "rgb(255,140,0)", - - "rgb(235,92,92)", - "rgb(82,92,245)", - "rgb(133,143,143)", - "rgb(235,143,92)", + "rgb(135,135,135)", "rgb(190,120,120)", - - "rgb(225,82,92)", - "rgb(72,82,245)", - "rgb(123,133,143)", - "rgb(225,133,92)", - "rgb(180,120,120)", ], }); } @@ -465,7 +445,12 @@ const callMetadataAPI = function ( // calculates the statistic for ctc plots const calculateStatCTC = function (hit, fa, miss, cn, n, statistic) { - if (isThisANaN(hit) || isThisANaN(fa) || isThisANaN(miss) || isThisANaN(cn)) + if ( + matsMethods.isThisANaN(hit) || + matsMethods.isThisANaN(fa) || + matsMethods.isThisANaN(miss) || + matsMethods.isThisANaN(cn) + ) return null; let queryVal; switch (statistic) { @@ -547,12 +532,12 @@ const calculateStatScalar = function ( statisticAndVariable ) { if ( - isThisANaN(squareDiffSum) || - isThisANaN(NSum) || - isThisANaN(obsModelDiffSum) || - isThisANaN(modelSum) || - isThisANaN(obsSum) || - isThisANaN(absSum) + matsMethods.isThisANaN(squareDiffSum) || + matsMethods.isThisANaN(NSum) || + matsMethods.isThisANaN(obsModelDiffSum) || + matsMethods.isThisANaN(modelSum) || + matsMethods.isThisANaN(obsSum) || + matsMethods.isThisANaN(absSum) ) return null; let queryVal; @@ -585,7 +570,7 @@ const calculateStatScalar = function ( default: queryVal = null; } - if (isThisANaN(queryVal)) return null; + if (matsMethods.isThisANaN(queryVal)) return null; // need to convert to correct units for surface data but not upperair if (statistic !== "N") { if ( @@ -1198,7 +1183,7 @@ const getErr = function (sVals, sSecs, sLevs, appParams) { let secs; let delta; for (i = 0; i < sSecs.length; i += 1) { - if (isThisANaN(sVals[i])) { + if (matsMethods.isThisANaN(sVals[i])) { n -= 1; } else { secs = sSecs[i]; @@ -1221,7 +1206,7 @@ const getErr = function (sVals, sSecs, sLevs, appParams) { console.log(`matsDataUtil.getErr: ${error}`); } for (i = 0; i < sVals.length; i += 1) { - if (!isThisANaN(sVals[i])) { + if (!matsMethods.isThisANaN(sVals[i])) { minVal = minVal < sVals[i] ? minVal : sVals[i]; maxVal = maxVal > sVals[i] ? maxVal : sVals[i]; dataSum += sVals[i]; @@ -1254,7 +1239,7 @@ const getErr = function (sVals, sSecs, sLevs, appParams) { let nDeltas = 0; for (i = 0; i < sSecs.length; i += 1) { - if (!isThisANaN(sVals[i])) { + if (!matsMethods.isThisANaN(sVals[i])) { let sec = sSecs[i]; if (typeof sec === "string" || sec instanceof String) sec = Number(sec); let lev; @@ -1551,7 +1536,7 @@ const setHistogramParameters = function (plotParams) { case "Set number of bins": // get the user's chosen number of bins binNum = Number(plotParams["bin-number"]); - if (isThisANaN(binNum)) { + if (matsMethods.isThisANaN(binNum)) { throw new Error( "Error parsing bin number: please enter the desired number of bins." ); @@ -1566,7 +1551,7 @@ const setHistogramParameters = function (plotParams) { case "Choose a bin bound": // let the histogram routine know that we want the bins shifted over to whatever was input pivotVal = Number(plotParams["bin-pivot"]); - if (isThisANaN(pivotVal)) { + if (matsMethods.isThisANaN(pivotVal)) { throw new Error("Error parsing bin pivot: please enter the desired bin pivot."); } break; @@ -1574,7 +1559,7 @@ const setHistogramParameters = function (plotParams) { case "Set number of bins and make zero a bin bound": // get the user's chosen number of bins and let the histogram routine know that we want the bins shifted over to zero binNum = Number(plotParams["bin-number"]); - if (isThisANaN(binNum)) { + if (matsMethods.isThisANaN(binNum)) { throw new Error( "Error parsing bin number: please enter the desired number of bins." ); @@ -1585,13 +1570,13 @@ const setHistogramParameters = function (plotParams) { case "Set number of bins and choose a bin bound": // get the user's chosen number of bins and let the histogram routine know that we want the bins shifted over to whatever was input binNum = Number(plotParams["bin-number"]); - if (isThisANaN(binNum)) { + if (matsMethods.isThisANaN(binNum)) { throw new Error( "Error parsing bin number: please enter the desired number of bins." ); } pivotVal = Number(plotParams["bin-pivot"]); - if (isThisANaN(pivotVal)) { + if (matsMethods.isThisANaN(pivotVal)) { throw new Error("Error parsing bin pivot: please enter the desired bin pivot."); } break; @@ -1602,7 +1587,7 @@ const setHistogramParameters = function (plotParams) { binBounds = plotParams["bin-bounds"].split(",").map(function (item) { let thisItem = item.trim(); thisItem = Number(thisItem); - if (!isThisANaN(thisItem)) { + if (!matsMethods.isThisANaN(thisItem)) { return thisItem; } throw new Error( @@ -1626,17 +1611,17 @@ const setHistogramParameters = function (plotParams) { case "Manual bin start, number, and stride": // get the bin start, number, and stride. binNum = Number(plotParams["bin-number"]); - if (isThisANaN(binNum)) { + if (matsMethods.isThisANaN(binNum)) { throw new Error( "Error parsing bin number: please enter the desired number of bins." ); } binStart = Number(plotParams["bin-start"]); - if (isThisANaN(binStart)) { + if (matsMethods.isThisANaN(binStart)) { throw new Error("Error parsing bin start: please enter the desired bin start."); } binStride = Number(plotParams["bin-stride"]); - if (isThisANaN(binStride)) { + if (matsMethods.isThisANaN(binStride)) { throw new Error( "Error parsing bin stride: please enter the desired bin stride." ); @@ -1715,7 +1700,7 @@ const calculateHistogramBins = function ( binLowBounds[binParams.binNum - 1] = fullUpBound; binMeans[binParams.binNum - 1] = fullUpBound + binInterval / 2; - if (binParams.pivotVal !== undefined && !isThisANaN(binParams.pivotVal)) { + if (binParams.pivotVal !== undefined && !matsMethods.isThisANaN(binParams.pivotVal)) { // need to shift the bounds and means over so that one of the bounds is on the chosen pivot const closestBoundToPivot = binLowBounds.reduce(function (prev, curr) { return Math.abs(curr - binParams.pivotVal) < Math.abs(prev - binParams.pivotVal) @@ -2187,7 +2172,6 @@ export default matsDataUtils = { average, median, stdev, - isThisANaN, dateConvert, getDateRange, secsConvert, diff --git a/tests/src/steps/given.js b/tests/src/steps/given.js deleted file mode 100644 index 010114335..000000000 --- a/tests/src/steps/given.js +++ /dev/null @@ -1,95 +0,0 @@ -import { Given } from "cucumber"; - -import checkContainsAnyText from "../support/check/checkContainsAnyText"; -import checkIsEmpty from "../support/check/checkIsEmpty"; -import checkContainsText from "../support/check/checkContainsText"; -import checkCookieContent from "../support/check/checkCookieContent"; -import checkCookieExists from "../support/check/checkCookieExists"; -import checkDimension from "../support/check/checkDimension"; -import checkElementExists from "../support/check/checkElementExists"; -import checkEqualsText from "../support/check/checkEqualsText"; -import checkModal from "../support/check/checkModal"; -import checkOffset from "../support/check/checkOffset"; -import checkProperty from "../support/check/checkProperty"; -import checkSelected from "../support/check/checkSelected"; -import checkTitle from "../support/check/checkTitle"; -import checkUrl from "../support/check/checkURL"; -import closeAllButFirstTab from "../support/action/closeAllButFirstTab"; -import compareText from "../support/check/compareText"; -import isEnabled from "../support/check/isEnabled"; -import isDisplayed from "../support/check/isDisplayed"; -import openWebsite from "../support/action/openWebsite"; -import setWindowSize from "../support/action/setWindowSize"; -import openWebsiteAndWaitForPlotType from "../support/action/openWebsiteAndWaitForPlotType"; -import saveMatsParameters from "../support/action/saveMatsParameters"; - -Given(/^I remember the parameter values$/, saveMatsParameters); - -Given(/^I open the (url|site) "([^"]*)?"$/, openWebsite); - -Given( - /^I load the app "([^"]*)?"$/, - { wrapperOptions: { retry: 2 } }, - openWebsiteAndWaitForPlotType -); - -Given(/^the element "([^"]*)?" is( not)* displayed$/, isDisplayed); - -Given(/^the element "([^"]*)?" is( not)* enabled$/, isEnabled); - -Given(/^the element "([^"]*)?" is( not)* selected$/, checkSelected); - -Given(/^the checkbox "([^"]*)?" is( not)* checked$/, checkSelected); - -Given(/^there is (an|no) element "([^"]*)?" on the page$/, checkElementExists); - -Given(/^the title is( not)* "([^"]*)?"$/, checkTitle); - -Given( - /^the element "([^"]*)?" contains( not)* the same text as element "([^"]*)?"$/, - compareText -); - -Given( - /^the (button|element) "([^"]*)?"( not)* matches the text "([^"]*)?"$/, - checkEqualsText -); - -Given( - /^the (button|element|container) "([^"]*)?"( not)* contains the text "([^"]*)?"$/, - checkContainsText -); - -Given( - /^the (button|element) "([^"]*)?"( not)* contains any text$/, - checkContainsAnyText -); - -Given(/^the (button|element) "([^"]*)?" is( not)* empty$/, checkIsEmpty); - -Given(/^the page url is( not)* "([^"]*)?"$/, checkUrl); - -Given( - /^the( css)* attribute "([^"]*)?" from element "([^"]*)?" is( not)* "([^"]*)?"$/, - checkProperty -); - -Given( - /^the cookie "([^"]*)?" contains( not)* the value "([^"]*)?"$/, - checkCookieContent -); - -Given(/^the cookie "([^"]*)?" does( not)* exist$/, checkCookieExists); - -Given(/^the element "([^"]*)?" is( not)* ([\d]+)px (broad|tall)$/, checkDimension); - -Given( - /^the element "([^"]*)?" is( not)* positioned at ([\d]+)px on the (x|y) axis$/, - checkOffset -); - -Given(/^I have a screen that is ([\d]+) by ([\d]+) pixels$/, setWindowSize); - -Given(/^I have closed all but the first (window|tab)$/, closeAllButFirstTab); - -Given(/^a (alertbox|confirmbox|prompt) is( not)* opened$/, checkModal); diff --git a/tests/src/steps/then.js b/tests/src/steps/then.js deleted file mode 100644 index 513b33753..000000000 --- a/tests/src/steps/then.js +++ /dev/null @@ -1,220 +0,0 @@ -import checkClass from "../support/check/checkClass"; -import checkContainsAnyText from "../support/check/checkContainsAnyText"; -import checkIsEmpty from "../support/check/checkIsEmpty"; -import checkContainsText from "../support/check/checkContainsText"; -import checkCookieContent from "../support/check/checkCookieContent"; -import checkCookieExists from "../support/check/checkCookieExists"; -import checkDimension from "../support/check/checkDimension"; -import checkEqualsText from "../support/check/checkEqualsText"; -import checkFocus from "../support/check/checkFocus"; -import checkInURLPath from "../support/check/checkInURLPath"; -import checkIsOpenedInNewWindow from "../support/check/checkIsOpenedInNewWindow"; -import checkModal from "../support/check/checkModal"; -import checkModalText from "../support/check/checkModalText"; -import checkNewWindow from "../support/check/checkNewWindow"; -import checkOffset from "../support/check/checkOffset"; -import checkProperty from "../support/check/checkProperty"; -import checkFontProperty from "../support/check/checkFontProperty"; -import checkSelected from "../support/check/checkSelected"; -import checkMatsDatesValue from "../support/check/checkMatsDatesValue"; -import checkMatsCurveDatesValue from "../support/check/checkMatsCurveDatesValue"; -import checkTitle from "../support/check/checkTitle"; -import checkTitleContains from "../support/check/checkTitleContains"; -import checkURL from "../support/check/checkURL"; -import checkURLPath from "../support/check/checkURLPath"; -import checkWithinViewport from "../support/check/checkWithinViewport"; -import compareText from "../support/check/compareText"; -import isEnabled from "../support/check/isEnabled"; -import isExisting from "../support/check/isExisting"; -import isVisible from "../support/check/isDisplayed"; -import waitFor from "../support/action/waitFor"; -import waitForVisible from "../support/action/waitForDisplayed"; -import checkIfElementExists from "../support/lib/checkIfElementExists"; -import checkParameterValue from "../support/check/checkParameterValue"; -import checkMatsAppTitle from "../support/check/checkMatsAppTitle"; -import checkMatsCurveIsAdded from "../support/check/checkMatsCurveIsAdded"; -import checkMatsGraphPlotType from "../support/check/checkMatsGraphPlotType"; -import checkMatsCurveNumber from "../support/check/checkMatsCurveNumber"; -import checkMatsPlotNumber from "../support/check/checkMatsPlotNumber"; -import checkMatsCurveListContains from "../support/check/checkMatsCurveListContains"; -import checkMatsLegendListContains from "../support/check/checkMatsLegendListContains"; -import isGraphDisplayed from "../support/check/isMatsGraphDisplayed"; -import isMainDisplayed from "../support/check/isMainDisplayed"; -import isMatsButtonVisible from "../support/check/isMatsButtonVisible"; -import isMatsPlotType from "../support/check/isMatsPlotType"; -import isMatsPlotFormat from "../support/check/isMatsPlotFormat"; -import isMatsSelectedOption from "../support/check/isMatsSelectedOption"; -import isMatsCurveColor from "../support/check/isMatsCurveColor"; -import checkMatsParameters from "../support/check/checkMatsParameters"; -import isMatsInfoVisible from "../support/check/isMatsInfoVisible"; -import checkMatsInfoMessage from "../support/check/checkMatsInfoMessage"; -import matsDebug from "../support/action/matsDebug"; -import isMatsButtonEnabled from "../support/check/isMatsButtonEnabled"; - -const { Then } = require("cucumber"); - -Then(/^I debug$/, matsDebug); - -Then(/^the "info" dialog should( not)* be visible$/, isMatsInfoVisible); - -Then(/^the "([^"]*)" button should( not)* be enabled$/, isMatsButtonEnabled); - -Then(/^I should see "([^"]*)" in the "info" dialog$/, checkMatsInfoMessage); - -Then(/^the parameter values should remain unchanged$/, checkMatsParameters); - -Then(/^the "([^"]*)" color should be "([^"]*)"$/, isMatsCurveColor); - -Then(/^the "([^"]*)?" parameter value matches "([^"]*)?"$/, isMatsSelectedOption); - -Then(/^the "([^"]*)?" button should be visible$/, isMatsButtonVisible); - -Then(/^"([^"]*)?" is added$/, checkMatsCurveIsAdded); - -Then(/^I should be on the graph page$/, isGraphDisplayed); - -Then(/^I should be on the main page$/, isMainDisplayed); - -Then(/^I should have a "([^"]*)?" plot$/, checkMatsGraphPlotType); - -Then(/^the plot type should be "([^"]*)?"$/, isMatsPlotType); - -Then(/^the plot format should be "([^"]*)?"$/, isMatsPlotFormat); - -Then(/^I should have (\d+) curve.*$/, checkMatsCurveNumber); - -Then(/^I should have (\d+) trace.*$/, checkMatsPlotNumber); - -Then(/^I expect the app title to be "([^"]*)?"$/, checkMatsAppTitle); - -Then( - /^I should see a list of curves containing "([^"]*)?"$/, - checkMatsCurveListContains -); - -Then( - /^I should see a list of legends containing "([^"]*)?"$/, - checkMatsLegendListContains -); - -Then( - /^I expect that the "([^"]*)?" parameter value matches "([^"]*)?"$/, - checkParameterValue -); - -Then(/^the dates value is "([^"]*)?"$/, checkMatsDatesValue); - -Then(/^the curve-dates value is "([^"]*)?"$/, checkMatsCurveDatesValue); - -Then(/^the plot type should be "([^"]*)?"&/, isMatsPlotType); -Then(/^I expect that the title is( not)* "([^"]*)?"$/, checkTitle); - -Then(/^I expect that the title( not)* contains "([^"]*)?"$/, checkTitleContains); - -Then( - /^I expect that element "([^"]*)?" does( not)* appear exactly "([^"]*)?" times$/, - checkIfElementExists -); - -Then(/^I expect that element "([^"]*)?" is( not)* displayed$/, isVisible); - -Then(/^I expect that element "([^"]*)?" becomes( not)* displayed$/, waitForVisible); - -Then( - /^I expect that element "([^"]*)?" is( not)* within the viewport$/, - checkWithinViewport -); - -Then(/^I expect that element "([^"]*)?" does( not)* exist$/, isExisting); - -Then( - /^I expect that element "([^"]*)?"( not)* contains the same text as element "([^"]*)?"$/, - compareText -); - -Then( - /^I expect that (button|element) "([^"]*)?"( not)* matches the text "([^"]*)?"$/, - checkEqualsText -); - -Then( - /^I expect that (button|element|container) "([^"]*)?"( not)* contains the text "([^"]*)?"$/, - checkContainsText -); - -Then( - /^I expect that (button|element) "([^"]*)?"( not)* contains any text$/, - checkContainsAnyText -); - -Then(/^I expect that (button|element) "([^"]*)?" is( not)* empty$/, checkIsEmpty); - -Then(/^I expect that the url is( not)* "([^"]*)?"$/, checkURL); - -Then(/^I expect that the path is( not)* "([^"]*)?"$/, checkURLPath); - -Then(/^I expect the url to( not)* contain "([^"]*)?"$/, checkInURLPath); - -Then( - /^I expect that the( css)* attribute "([^"]*)?" from element "([^"]*)?" is( not)* "([^"]*)?"$/, - checkProperty -); - -Then( - /^I expect that the font( css)* attribute "([^"]*)?" from element "([^"]*)?" is( not)* "([^"]*)?"$/, - checkFontProperty -); - -Then(/^I expect that checkbox "([^"]*)?" is( not)* checked$/, checkSelected); - -Then(/^I expect that element "([^"]*)?" is( not)* selected$/, checkSelected); - -Then(/^I expect that element "([^"]*)?" is( not)* enabled$/, isEnabled); - -Then( - /^I expect that cookie "([^"]*)?"( not)* contains "([^"]*)?"$/, - checkCookieContent -); - -Then(/^I expect that cookie "([^"]*)?"( not)* exists$/, checkCookieExists); - -Then( - /^I expect that element "([^"]*)?" is( not)* ([\d]+)px (broad|tall)$/, - checkDimension -); - -Then( - /^I expect that element "([^"]*)?" is( not)* positioned at ([\d+.?\d*]+)px on the (x|y) axis$/, - checkOffset -); - -Then( - /^I expect that element "([^"]*)?" (has|does not have) the class "([^"]*)?"$/, - checkClass -); - -Then(/^I expect a new (window|tab) has( not)* been opened$/, checkNewWindow); - -Then( - /^I expect the url "([^"]*)?" is opened in a new (tab|window)$/, - checkIsOpenedInNewWindow -); - -Then(/^I expect that element "([^"]*)?" is( not)* focused$/, checkFocus); - -Then( - /^I wait on element "([^"]*)?"(?: for (\d+)ms)*(?: to( not)* (be checked|be enabled|be selected|be displayed|contain a text|contain a value|exist))*$/, - { - wrapperOptions: { - retry: 3, - }, - }, - waitFor -); - -Then(/^I expect that a (alertbox|confirmbox|prompt) is( not)* opened$/, checkModal); - -Then( - /^I expect that a (alertbox|confirmbox|prompt)( not)* contains the text "([^"]*)?"$/, - checkModalText -); diff --git a/tests/src/steps/when.js b/tests/src/steps/when.js deleted file mode 100644 index 770fe5094..000000000 --- a/tests/src/steps/when.js +++ /dev/null @@ -1,110 +0,0 @@ -import clearInputField from "../support/action/clearInputField"; -import clickElement from "../support/action/clickElement"; -import closeLastOpenedWindow from "../support/action/closeLastOpenedWindow"; -import deleteCookies from "../support/action/deleteCookies"; -import dragElement from "../support/action/dragElement"; -import focusLastOpenedWindow from "../support/action/focusLastOpenedWindow"; -import handleModal from "../support/action/handleModal"; -import moveTo from "../support/action/moveTo"; -import pause from "../support/action/pause"; -import pressButton from "../support/action/pressButton"; -import scroll from "../support/action/scroll"; -import selectOption from "../support/action/selectOption"; -import selectOptionByIndex from "../support/action/selectOptionByIndex"; -import setCookie from "../support/action/setCookie"; -import setInputField from "../support/action/setInputField"; -import setPromptText from "../support/action/setPromptText"; - -import setPredefinedDateRange from "../support/action/setPredefinedDateRange"; -import setMatsDateRange from "../support/action/setMatsDateRange"; -import setMatsCurveDateRange from "../support/action/setMatsCurveDateRange"; -import setScatterDateRange from "../support/action/setScatterDateRange"; -import setMatsPlotType from "../support/action/setMatsPlotType"; -import setMatsPlotFormat from "../support/action/setMatsPlotFormat"; -import clickMatsButton from "../support/action/clickMatsButton"; -import setMatsSelectedOption from "../support/action/setMatsSelectedOption"; -import matsRefreshBrowser from "../support/action/matsRefreshBrowser"; -import matsRefreshPage from "../support/action/matsRefreshPage"; -import matsClearParameter from "../support/action/matsClearParameter"; - -const { When } = require("cucumber"); - -When(/^I clear the "([^"]*)?" parameter$/, matsClearParameter); - -When(/^I refresh the browser$/, matsRefreshBrowser); - -When(/^I refresh the page$/, matsRefreshPage); - -When(/^I click the "([^"]*)?" radio button$/, setMatsPlotFormat); - -When(/^I click the "([^"]*)?" button$/, clickMatsButton); - -When( - /^I change the "([^"]*)" parameter to "([^"]*)"$/, - { wrapperOptions: { retry: 2 } }, - setMatsSelectedOption -); - -When(/^I set the plot type to "([^"]*)?"$/, setMatsPlotType); - -When( - /^I choose a predefined "([^"]*)?" range of "([^"]*)?"$/, - { wrapperOptions: { retry: 2 } }, - setPredefinedDateRange -); - -When( - /^I set the dates to "([^"]*)?"$/, - { wrapperOptions: { retry: 2 } }, - setMatsDateRange -); - -When( - /^I set the curve-dates to "([^"]*)?"$/, - { wrapperOptions: { retry: 2 } }, - setMatsCurveDateRange -); - -When( - /^I set the scatter dates to "([^"]*)?"$/, - { wrapperOptions: { retry: 2 } }, - setScatterDateRange -); - -When(/^I (click|doubleclick) on the (link|button|element) "([^"]*)?"$/, clickElement); - -When(/^I (add|set) "([^"]*)?" to the inputfield "([^"]*)?"$/, setInputField); - -When(/^I clear the inputfield "([^"]*)?"$/, clearInputField); - -When(/^I drag element "([^"]*)?" to element "([^"]*)?"$/, dragElement); - -When(/^I pause for (\d+)ms$/, pause); - -When(/^I set a cookie "([^"]*)?" with the content "([^"]*)?"$/, setCookie); - -When(/^I delete the cookie "([^"]*)?"$/, deleteCookies); - -When(/^I press "([^"]*)?"$/, pressButton); - -When(/^I (accept|dismiss) the (alertbox|confirmbox|prompt)$/, handleModal); - -When(/^I enter "([^"]*)?" into the prompt$/, setPromptText); - -When(/^I scroll to element "([^"]*)?"$/, scroll); - -When(/^I close the last opened (window|tab)$/, closeLastOpenedWindow); - -When(/^I focus the last opened (window|tab)$/, focusLastOpenedWindow); - -When( - /^I select the (\d+)(st|nd|rd|th) option for element "([^"]*)?"$/, - selectOptionByIndex -); - -When( - /^I select the option with the (name|value|text) "([^"]*)?" for element "([^"]*)?"$/, - selectOption -); - -When(/^I move to element "([^"]*)?"(?: with an offset of (\d+),(\d+))*$/, moveTo); diff --git a/tests/src/support/action/clearInputField.js b/tests/src/support/action/clearInputField.js deleted file mode 100644 index a5d5f81bf..000000000 --- a/tests/src/support/action/clearInputField.js +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Clear a given input field (placeholder for WDIO's clearElement) - * @param {String} selector Element selector - */ -export default (selector) => { - $(selector).clearValue(); -}; diff --git a/tests/src/support/action/clickElement.js b/tests/src/support/action/clickElement.js deleted file mode 100644 index 0ae44d390..000000000 --- a/tests/src/support/action/clickElement.js +++ /dev/null @@ -1,25 +0,0 @@ -import checkIfElementExists from "../lib/checkIfElementExists"; - -/** - * Perform an click action on the given element - * @param {String} action The action to perform (click or doubleClick) - * @param {String} type Type of the element (link or selector) - * @param {String} selector Element selector - */ -export default (action, type, selector) => { - /** - * Element to perform the action on - * @type {String} - */ - const selector2 = type === "link" ? `=${selector}` : selector; - - /** - * The method to call on the browser object - * @type {String} - */ - const method = action === "click" ? "click" : "doubleClick"; - - checkIfElementExists(selector2); - - $(selector2)[method](); -}; diff --git a/tests/src/support/action/clickMatsButton.js b/tests/src/support/action/clickMatsButton.js deleted file mode 100644 index d182c4d86..000000000 --- a/tests/src/support/action/clickMatsButton.js +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Perform an click action on the button with the given label - * @param {String} label button label - */ -export default (label) => { - /** - * LabelOf the Mats button to click - * @type {String} - */ - let selector; - let nrOfElements; - let cPart; - // special buttons first - if (label === "Remove All") { - nrOfElements = $$("#remove-all").length; - $("#remove-all").waitForClickable(); - $("#remove-all").click(); - } else if (label === "Remove all the curves") { - nrOfElements = $$("#confirm-remove-all").length; - // I don't know why there are two of the confirm buttons - // there has to be a better way to handle this - $$("#confirm-remove-all")[1].waitForClickable(); - $$("#confirm-remove-all")[1].click(); - } else if (label.match("Remove curve .*")) { - // this is the 'Remove curve curvelabel' confirm button - cPart = label.replace("Remove curve ", ""); - nrOfElements = $$(`#confirm-remove-curve*=${cPart}`).length; - expect(nrOfElements).toBeGreaterThan( - 0, - `Expected an "${selector}" button to exist` - ); - $$(`#confirm-remove-curve*=${cPart}`)[1].waitForDisplayed(); - $$(`#confirm-remove-curve*=${cPart}`)[1].waitForClickable(); - $$(`#confirm-remove-curve*=${cPart}`)[1].click(); - } else if (label.match("Remove .*")) { - // This is the 'Remove curvelabel' remove button - cPart = label.replace("Remove ", ""); - nrOfElements = $$(`#curve-list-remove*=${cPart}`).length; - expect(nrOfElements).toBeGreaterThan( - 0, - `Expected an "${selector}" button to exist` - ); - $(`#curve-list-remove*=${cPart}`).waitForClickable(); - $(`#curve-list-remove*=${cPart}`).click(); - } else { - // normal buttons - switch (label) { - case "Add Curve": - selector = $("#add"); - selector.waitForDisplayed(); - nrOfElements = $$("#add").length; - break; - case "Back": - selector = $("#backButton"); - selector.waitForDisplayed(); - nrOfElements = $$("#backButton").length; - break; - case "Plot Unmatched": - selector = $("#plotUnmatched"); - selector.waitForDisplayed(); - nrOfElements = $$("#plotUnmatched").length; - break; - case "Plot Matched": - selector = $("#plotMatched"); - selector.waitForDisplayed(); - nrOfElements = $$("#plotMatched").length; - break; - case "Reset to Defaults": - selector = $("#reset"); - selector.waitForDisplayed(); - nrOfElements = $$("#reset").length; - break; - case "Clear": - selector = $("#clear-info"); - selector.waitForDisplayed(); - nrOfElements = $$("#clear-info").length; - break; - default: - throw new Error("Unhandled button label???"); - } - // these are for the switch statement i.e. 'normal buttons' - expect(nrOfElements).toBeGreaterThan( - 0, - `Expected an "${selector}" button to exist` - ); - selector.waitForClickable(); - selector.click(); - } -}; diff --git a/tests/src/support/action/clickMatsButtonReturnImmediate.js b/tests/src/support/action/clickMatsButtonReturnImmediate.js deleted file mode 100644 index 78d223872..000000000 --- a/tests/src/support/action/clickMatsButtonReturnImmediate.js +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Perform an click action on the button with the given label - * @param {String} label button label - */ -export default (label) => { - /** - * LabelOf the Mats button to click - * @type {String} - */ - const method = "click"; - let selector; - let nrOfElements; - let cPart; - // special buttons first - if (label === "Remove All") { - nrOfElements = $$("#remove-all").length; - $("#remove-all")[method](); - } else if (label === "Remove all the curves") { - nrOfElements = $$("#confirm-remove-all").length; - // I don't know why there are two of the confirm buttons - // there has to be a better way to handle this - $$("#confirm-remove-all")[1][method](); - } else if (label.match("Remove curve .*")) { - // this is the 'Remove curve curvelabel' confirm button - cPart = label.replace("Remove curve ", ""); - nrOfElements = $$(`#confirm-remove-curve*=${cPart}`).length; - expect(nrOfElements).toBeGreaterThan( - 0, - `Expected an "${selector}" button to exist` - ); - $$(`#confirm-remove-curve*=${cPart}`)[1].waitForDisplayed(); - $$(`#confirm-remove-curve*=${cPart}`)[1].click(); - } else if (label.match("Remove .*")) { - // This is the 'Remove curvelabel' remove button - cPart = label.replace("Remove ", ""); - nrOfElements = $$(`#curve-list-remove*=${cPart}`).length; - expect(nrOfElements).toBeGreaterThan( - 0, - `Expected an "${selector}" button to exist` - ); - $(`#curve-list-remove*=${cPart}`)[method](); - } else { - // normal buttons - switch (label) { - case "Add Curve": - selector = $("#add"); - selector.waitForDisplayed(); - nrOfElements = $$("#add").length; - break; - case "Back": - selector = $("#backButton"); - selector.waitForDisplayed(); - nrOfElements = $$("#backButton").length; - break; - case "Plot Unmatched": - selector = $("#plotUnmatched"); - selector.waitForDisplayed(); - nrOfElements = $$("#plotUnmatched").length; - break; - case "Plot Matched": - selector = $("#plotMatched"); - selector.waitForDisplayed(); - nrOfElements = $$("#plotMatched").length; - break; - case "Reset to Defaults": - selector = $("#reset"); - selector.waitForDisplayed(); - nrOfElements = $$("#reset").length; - break; - case "Clear": - selector = $("#clear-info"); - selector.waitForDisplayed(); - nrOfElements = $$("#clear-info").length; - break; - default: - throw new Error("Unhandled button label???"); - } - // these are for the switch statement i.e. 'normal buttons' - expect(nrOfElements).toBeGreaterThan( - 0, - `Expected an "${selector}" button to exist` - ); - selector[method](); - } -}; diff --git a/tests/src/support/action/closeAllButFirstTab.js b/tests/src/support/action/closeAllButFirstTab.js deleted file mode 100644 index 209445e44..000000000 --- a/tests/src/support/action/closeAllButFirstTab.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Close all but the first tab - * @param {String} obsolete Type of object to close (window or tab) - */ -/* eslint-disable no-unused-vars */ -export default (obsolete) => { - /* eslint-enable no-unused-vars */ - /** - * Get all the window handles - * @type {Object} - */ - const windowHandles = browser.getWindowHandles(); - - // Close all tabs but the first one - windowHandles.reverse(); - windowHandles.forEach((handle, index) => { - browser.switchToWindow(handle); - if (index < windowHandles.length - 1) { - browser.closeWindow(); - } - }); -}; diff --git a/tests/src/support/action/closeLastOpenedWindow.js b/tests/src/support/action/closeLastOpenedWindow.js deleted file mode 100644 index 85b53b0d3..000000000 --- a/tests/src/support/action/closeLastOpenedWindow.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Close the last opened window - * @param {String} obsolete Type of object to close (window or tab) - */ -/* eslint-disable no-unused-vars */ -export default (obsolete) => { - /* eslint-enable no-unused-vars */ - /** - * The last opened window handle - * @type {Object} - */ - const lastWindowHandle = browser.getWindowHandles().slice(-1)[0]; - - browser.closeWindow(); - browser.switchToWindow(lastWindowHandle); -}; diff --git a/tests/src/support/action/deleteCookies.js b/tests/src/support/action/deleteCookies.js deleted file mode 100644 index 196a20628..000000000 --- a/tests/src/support/action/deleteCookies.js +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Delete a cookie - * @param {String} name The name of the cookie to delete - */ -export default (name) => { - browser.deleteCookies(name); -}; diff --git a/tests/src/support/action/dragElement.js b/tests/src/support/action/dragElement.js deleted file mode 100644 index f7a783984..000000000 --- a/tests/src/support/action/dragElement.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Drag a element to a given destination - * @param {String} selector The selector for the source element - * @param {String} destination The selector for the destination element - */ -export default (selector, destination) => { - $(selector).dragAndDrop($(destination)); -}; diff --git a/tests/src/support/action/focusLastOpenedWindow.js b/tests/src/support/action/focusLastOpenedWindow.js deleted file mode 100644 index b11f16247..000000000 --- a/tests/src/support/action/focusLastOpenedWindow.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Focus the last opened window - * @param {String} obsolete Type of object to focus to (window or tab) - */ -/* eslint-disable no-unused-vars */ -export default (obsolete) => { - /* eslint-enable no-unused-vars */ - /** - * The last opened window - * @type {Object} - */ - const lastWindowHandle = browser.getWindowHandles().slice(-1)[0]; - - browser.switchToWindow(lastWindowHandle); -}; diff --git a/tests/src/support/action/handleModal.js b/tests/src/support/action/handleModal.js deleted file mode 100644 index 0098369ae..000000000 --- a/tests/src/support/action/handleModal.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Handle a modal - * @param {String} action Action to perform on the modal (accept, dismiss) - * @param {String} modalType Type of modal (alertbox, confirmbox, prompt) - */ -export default (action, modalType) => { - /** - * The command to perform on the browser object - * @type {String} - */ - let command = `${action.slice(0, 1).toLowerCase()}${action.slice(1)}Alert`; - - /** - * Alert boxes can't be dismissed, this causes Chrome to crash during tests - */ - if (modalType === "alertbox") { - command = "acceptAlert"; - } - - browser[command](); -}; diff --git a/tests/src/support/action/matsClearParameter.js b/tests/src/support/action/matsClearParameter.js deleted file mode 100644 index 0fc817e31..000000000 --- a/tests/src/support/action/matsClearParameter.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Clear a given input parameter - * @param {String} parameter Element selector - */ -export default (parameter) => { - $(`[id='controlButton-${parameter}-value']`).scrollIntoView(); - $(`#controlButton-${parameter}-value`).click(); - if ($(`[id*='${parameter}-select-clear']`).waitForDisplayed()) { - $(`[id*='${parameter}-select-clear']`).click(); - } - $(`#controlButton-${parameter}-value`).click(); -}; diff --git a/tests/src/support/action/matsDebug.js b/tests/src/support/action/matsDebug.js deleted file mode 100644 index 5e719fb2e..000000000 --- a/tests/src/support/action/matsDebug.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * browser.debug - */ -export default () => { - browser.debug(); -}; diff --git a/tests/src/support/action/matsRefreshBrowser.js b/tests/src/support/action/matsRefreshBrowser.js deleted file mode 100644 index fe5a9b09d..000000000 --- a/tests/src/support/action/matsRefreshBrowser.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * refresh the browser - * Creates a new Selenium session with your current capabilities. - * This is useful if you test highly stateful application where you need - * to clean the browser session between the tests in your spec file - * to avoid creating hundreds of single test files with WDIO. - */ -export default () => { - browser.reloadSession(); -}; diff --git a/tests/src/support/action/matsRefreshPage.js b/tests/src/support/action/matsRefreshPage.js deleted file mode 100644 index c90389b1e..000000000 --- a/tests/src/support/action/matsRefreshPage.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Refresh the current page. - */ -export default () => { - browser.refresh(); -}; diff --git a/tests/src/support/action/moveTo.js b/tests/src/support/action/moveTo.js deleted file mode 100644 index decc45b37..000000000 --- a/tests/src/support/action/moveTo.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Move to the given selector with an optional offset on a X and Y position - * @param {String} selector Element selector - * @param {String} x X coordinate to move to - * @param {String} y Y coordinate to move to - */ -export default (selector, x, y) => { - /** - * X coordinate - * @type {Int} - */ - const intX = parseInt(x, 10) || undefined; - - /** - * Y coordinate - * @type {Int} - */ - const intY = parseInt(y, 10) || undefined; - - $(selector).moveTo(intX, intY); -}; diff --git a/tests/src/support/action/openWebsite.js b/tests/src/support/action/openWebsite.js deleted file mode 100644 index 9609cef17..000000000 --- a/tests/src/support/action/openWebsite.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Open the given URL - * @param {String} type Type of navigation (getUrl or site) - * @param {String} page The URL to navigate to - */ -export default (type, page) => { - /** - * The URL to navigate to - * @type {String} - */ - const url = type === "url" ? page : browser.options.baseUrl + page; - browser.url(url); -}; diff --git a/tests/src/support/action/openWebsiteAndWaitForPlotType.js b/tests/src/support/action/openWebsiteAndWaitForPlotType.js deleted file mode 100644 index 1766ad29e..000000000 --- a/tests/src/support/action/openWebsiteAndWaitForPlotType.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Open the given URL - * @param {String} page The URL to navigate to - */ - -export default (page) => { - /** - * The URL to navigate to - * @type {String} - */ - const url = browser.options.baseUrl + page; - browser.url(url); - const ms = 120000; - // wait for the curve label selector to exist - // noinspection JSJQueryEfficiency - $("#controlButton-label-value").waitForExist({ timeout: ms }); - // noinspection JSJQueryEfficiency - $("#controlButton-label-value").waitForEnabled({ timeout: ms }); - $("#controlButton-label-value").waitForClickable({ timeout: ms }); -}; diff --git a/tests/src/support/action/pause.js b/tests/src/support/action/pause.js deleted file mode 100644 index 1b591da14..000000000 --- a/tests/src/support/action/pause.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Pause execution for a given number of milliseconds - * @param {String} ms Number of milliseconds to pause - */ -export default (ms) => { - /** - * Number of milliseconds - * @type {Int} - */ - const intMs = parseInt(ms, 10); - - browser.pause(intMs); -}; diff --git a/tests/src/support/action/pressButton.js b/tests/src/support/action/pressButton.js deleted file mode 100644 index 79b7fdf7f..000000000 --- a/tests/src/support/action/pressButton.js +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Perform a key press - * @param {String} key The key to press - */ -export default (key) => { - browser.keys(key); -}; diff --git a/tests/src/support/action/saveMatsParameters.js b/tests/src/support/action/saveMatsParameters.js deleted file mode 100644 index fd32325df..000000000 --- a/tests/src/support/action/saveMatsParameters.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Check if the previously stored parameters match the current parameters. - */ -export default () => { - browser.saveMatsParameters = $$(".control-button").map((element) => - element.getText() - ); - // console.log(browser.saveMatsParameters); - // browser.debug(); -}; diff --git a/tests/src/support/action/scroll.js b/tests/src/support/action/scroll.js deleted file mode 100644 index 11ec4c931..000000000 --- a/tests/src/support/action/scroll.js +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Scroll the page to the given element - * @param {String} selector Element selector - */ -export default (selector) => { - $(selector).scrollIntoView(); -}; diff --git a/tests/src/support/action/selectOption.js b/tests/src/support/action/selectOption.js deleted file mode 100644 index c9fd19eed..000000000 --- a/tests/src/support/action/selectOption.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Select an option of a select element - * @param {String} selectionType Type of method to select by (name, value or - * text) - * @param {String} selectionValue Value to select by - * @param {String} selector Element selector - */ -export default (selectionType, selectionValue, selector) => { - /** - * The method to use for selecting the option - * @type {String} - */ - let command = ""; - const commandArguments = [selectionValue]; - - switch (selectionType) { - case "name": { - command = "selectByAttribute"; - - // The selectByAttribute command expects the attribute name as it - // second argument so let's add it - commandArguments.unshift("name"); - - break; - } - - case "value": { - // The selectByAttribute command expects the attribute name as it - // second argument so let's add it - commandArguments.unshift("value"); - command = "selectByAttribute"; - break; - } - - case "text": { - command = "selectByVisibleText"; - break; - } - - default: { - throw new Error(`Unknown selection type "${selectionType}"`); - } - } - - $(selector)[command](...commandArguments); -}; diff --git a/tests/src/support/action/selectOptionByIndex.js b/tests/src/support/action/selectOptionByIndex.js deleted file mode 100644 index b806e32a1..000000000 --- a/tests/src/support/action/selectOptionByIndex.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Select a option from a select element by it's index - * @param {String} index The index of the option - * @param {String} obsolete The ordinal indicator of the index (unused) - * @param {String} selector Element selector - * - * @todo merge with selectOption - */ -export default (index, obsolete, selector) => { - /** - * The index of the option to select - * @type {Int} - */ - const optionIndex = parseInt(index, 10); - - $(selector).selectByIndex(optionIndex); -}; diff --git a/tests/src/support/action/setCookie.js b/tests/src/support/action/setCookie.js deleted file mode 100644 index 06219c679..000000000 --- a/tests/src/support/action/setCookie.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Set a given cookie to a given value. When the cookies does not exist it will - * be created - * @param {String} cookieName The name of the cookie - * @param {String} cookieContent The value of the cookie - */ -export default (cookieName, cookieContent) => { - browser.setCookies({ - name: cookieName, - value: cookieContent, - }); -}; diff --git a/tests/src/support/action/setInputField.js b/tests/src/support/action/setInputField.js deleted file mode 100644 index ea6200e32..000000000 --- a/tests/src/support/action/setInputField.js +++ /dev/null @@ -1,26 +0,0 @@ -import checkIfElementExists from "../lib/checkIfElementExists"; - -/** - * Set the value of the given input field to a new value or add a value to the - * current selector value - * @param {String} method The method to use (add or set) - * @param {String} value The value to set the selector to - * @param {String} selector Element selector - */ -export default (method, value, selector) => { - /** - * The command to perform on the browser object (addValue or setValue) - * @type {String} - */ - const command = method === "add" ? "addValue" : "setValue"; - - let checkValue = value; - - checkIfElementExists(selector, false, 1); - - if (!value) { - checkValue = ""; - } - - $(selector)[command](checkValue); -}; diff --git a/tests/src/support/action/setMatsCurveDateRange.js b/tests/src/support/action/setMatsCurveDateRange.js deleted file mode 100644 index 4874cf685..000000000 --- a/tests/src/support/action/setMatsCurveDateRange.js +++ /dev/null @@ -1,38 +0,0 @@ -import pause from "./pause"; - -/** - * Set the curve date range to a predefined range - * @param {String} value The range to set the selector to - * */ -export default (value) => { - const dateRange = value; - const dates = dateRange.split(" - "); - $("#controlButton-curve-dates-value").waitForDisplayed(); - $("#controlButton-curve-dates-value").scrollIntoView(); - $("#controlButton-curve-dates-value").waitForClickable(); - $("#controlButton-curve-dates-value").click(); // brings up date menu - $$('input[name="daterangepicker_start"]')[0].setValue(""); - $$('input[name="daterangepicker_start"]')[0].setValue(dates[0]); - $$('input[name="daterangepicker_end"]')[0].setValue(""); - $$('input[name="daterangepicker_end"]')[0].setValue(dates[1]); - $$("/html/body/div[2]/div[1]/div/button[1]")[0].waitForClickable(); - $$("/html/body/div[2]/div[1]/div/button[1]")[0].click(); - let datesValue = ""; - let count = 0; - while (count < 10 && datesValue !== dateRange) { - datesValue = $("#controlButton-curve-dates-value").getText(); - if (datesValue !== dateRange) { - pause(2000); - } - count += 1; - } - if (datesValue !== dateRange) { - console.log(`value is ${value}`); - // browser.debug(); - } - - expect(datesValue).toEqual( - value, - `"curve date range" should be ${value} but was ${datesValue}` - ); -}; diff --git a/tests/src/support/action/setMatsDateRange.js b/tests/src/support/action/setMatsDateRange.js deleted file mode 100644 index 682305e38..000000000 --- a/tests/src/support/action/setMatsDateRange.js +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Set the date range to a predefined range - * @param {String} value The range to set the selector to - * */ -import pause from "./pause"; - -export default (value) => { - const dateRange = value; - const dates = dateRange.split(" - "); - $("#controlButton-dates-value").waitForDisplayed(); - $("#controlButton-dates-value").scrollIntoView(); - $("#controlButton-dates-value").waitForClickable(); - $("#controlButton-dates-value").click(); // brings up date menu - // eslint-disable-next-line max-len - $$('input[name="daterangepicker_start"]')[ - $$('input[name="daterangepicker_start"]').length - 1 - ].setValue(""); - // eslint-disable-next-line max-len - $$('input[name="daterangepicker_start"]')[ - $$('input[name="daterangepicker_start"]').length - 1 - ].setValue(dates[0]); - // eslint-disable-next-line max-len - $$('input[name="daterangepicker_end"]')[ - $$('input[name="daterangepicker_end"]').length - 1 - ].setValue(""); - // eslint-disable-next-line max-len - $$('input[name="daterangepicker_end"]')[ - $$('input[name="daterangepicker_end"]').length - 1 - ].setValue(dates[1]); - $$("/html/body/div[3]/div[1]/div/button[1]")[0].waitForClickable(); - $$("/html/body/div[3]/div[1]/div/button[1]")[0].click(); - let datesValue = ""; - let count = 0; - while (count < 10 && datesValue !== dateRange) { - datesValue = $("#controlButton-dates-value").getText(); - if (datesValue !== dateRange) { - pause(2000); - } - count += 1; - } - if (datesValue !== dateRange) { - console.log(`value is ${value}`); - // browser.debug(); - } - expect(datesValue).toEqual( - value, - `"date range" should be ${value} but was ${datesValue}` - ); -}; diff --git a/tests/src/support/action/setMatsPlotFormat.js b/tests/src/support/action/setMatsPlotFormat.js deleted file mode 100644 index 1521e1a6e..000000000 --- a/tests/src/support/action/setMatsPlotFormat.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Set the plotFormat - * @param {String} plotFormat The plot format - * */ -export default (plotFormat) => { - switch (plotFormat) { - case "matching diffs": - $("#plotFormat-radioGroup-matching").scrollIntoView(); - $("#plotFormat-radioGroup-matching").click(); - break; - case "pairwise diffs": - $("#plotFormat-radioGroup-pairwise").scrollIntoView(); - $("#plotFormat-radioGroup-pairwise").click(); - break; - case "no diffs": - $("#plotFormat-radioGroup-none").scrollIntoView(); - $("#plotFormat-radioGroup-none").click(); - break; - default: - throw new Error("invalid plotFormat in setMatsPlotFormat"); - } -}; diff --git a/tests/src/support/action/setMatsPlotType.js b/tests/src/support/action/setMatsPlotType.js deleted file mode 100644 index 81361d031..000000000 --- a/tests/src/support/action/setMatsPlotType.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Set the date range to a predefined range - * @param {String} plotType The type of date range selector (curve or date) - * */ -export default (plotType) => { - $("#plotTypes-selector").scrollIntoView(); - $("#plotTypes-selector").click(); - $(`#plot-type-${plotType}`).scrollIntoView(); - $(`#plot-type-${plotType}`).click(); -}; diff --git a/tests/src/support/action/setMatsSelectedOption.js b/tests/src/support/action/setMatsSelectedOption.js deleted file mode 100644 index 68fb1c428..000000000 --- a/tests/src/support/action/setMatsSelectedOption.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Select an option of a select element - * @param {String} parameter Element selector label - * @param {String} selectionValue Value to select by - */ -import pause from "./pause"; - -export default (parameter, selectionValue) => { - /** - * The method to use for selecting the option - * @type {String} - */ - - // console.log(`$('#controlButton-${parameter}')`); - // console.log(`$('.select2-results__option=${selectionValue}')`); - // console.log(`$('.select2-results__option=${selectionValue}')`); - // browser.debug(); - - // noinspection JSJQueryEfficiency - $(`#controlButton-${parameter}`).waitForDisplayed(); - let len = $$(`.select2-results__option=${selectionValue}`).length; - // it might already be clicked! Sometimes the click doesn't seem to take on the first try. - let c = 0; - while (len === 0 && c < 20) { - $(`#controlButton-${parameter}`).waitForClickable(); - $(`#controlButton-${parameter}`).click(); - len = $$(`.select2-results__option=${selectionValue}`).length; - pause(1000); - c += 1; - } - let multi = false; - if ($(`#${parameter}-select-clear`).isDisplayed()) { - multi = true; - // if it is a multi-select selector it has a clear button. Better clear it - $(`#${parameter}-select-clear`).waitForClickable(); - $(`#${parameter}-select-clear`).click(); - } - // noinspection JSJQueryEfficiency - $(`.select2-results__option=${selectionValue}`).scrollIntoView(); - // noinspection JSJQueryEfficiency - $(`.select2-results__option=${selectionValue}`).waitForClickable(); - $(`.select2-results__option=${selectionValue}`).click(); - if ($(`#${parameter}-select-done`).isDisplayed()) { - // if it is a multi-select selector, have to click the done button - $(`#${parameter}-select-done`).waitForClickable(); - $(`#${parameter}-select-done`).click(); - } - - let matchValue = selectionValue; - if (multi === true) { - // multi-selects have a range value - matchValue = `${selectionValue} .. ${selectionValue}`; - } - let text = ""; - let count = 0; - // this is essentially giving the parameter 20 seconds to show the new value - // this is mostly for when it is really busy doing parallel instances - while (count < 20 && text !== matchValue) { - text = $(`#controlButton-${parameter}-value`).getText(); - if (text !== matchValue) { - pause(2000); - } - count += 1; - } - if (text !== matchValue) { - console.log(`parameter is ${parameter}, selectionValue is ${selectionValue}`); - // browser.debug(); - } - expect(text).toEqual( - matchValue, - `Expexted ${text} to be ${matchValue} for parameter: ${parameter}` - ); -}; diff --git a/tests/src/support/action/setPredefinedDateRange.js b/tests/src/support/action/setPredefinedDateRange.js deleted file mode 100644 index ff41ae6c2..000000000 --- a/tests/src/support/action/setPredefinedDateRange.js +++ /dev/null @@ -1,46 +0,0 @@ -// noinspection JSIgnoredPromiseFromCall -/** * - * Set the date range to a predefined range - * @param {String} parameterType The type of date range selector (curve or date) - * @param {String} value The range to set the selector to - ** */ -export default (parameterType, value) => { - let definedRange = value; - if (!definedRange) { - definedRange = ""; - } - expect(parameterType === "curve-date" || parameterType === "date").toEqual( - true, - `Expected element "${parameterType}" to be "curve-date OR date"` - ); - if (parameterType === "curve-date") { - $("#controlButton-curve-dates-value").scrollIntoView(); - $("#controlButton-curve-dates-value").click(); // brings up date menu - } else if (parameterType === "date") { - $("#controlButton-dates-value").scrollIntoView(); - $("#controlButton-dates-value").click(); - } - browser.execute((dRange) => { - // eslint-disable-next-line no-undef - const dateRangePickers = document.getElementsByClassName("show-calendar"); - let dateRangePicker = null; - for (let dri = 0; dri < dateRangePickers.length; dri += 1) { - if (dateRangePickers[dri].style.display === "block") { - dateRangePicker = dateRangePickers[dri]; - break; - } - } - expect(dateRangePicker).not.toBe(null, "no dateRangePickerFound!"); - // noinspection JSObjectNullOrUndefined - const liTags = dateRangePicker.getElementsByTagName("li"); - let item = null; - for (let i = 0; i < liTags.length; i += 1) { - if (liTags[i].textContent === dRange) { - item = liTags[i]; - break; - } - } - // noinspection JSObjectNullOrUndefined - item.click(); - }, definedRange); -}; diff --git a/tests/src/support/action/setPromptText.js b/tests/src/support/action/setPromptText.js deleted file mode 100644 index 31af52347..000000000 --- a/tests/src/support/action/setPromptText.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Set the text of the current prompt - * @param {String} modalText The text to set to the prompt - */ -export default (modalText) => { - try { - browser.sendAlertText(modalText); - } catch (e) { - assert(e, "A prompt was not open when it should have been open"); - } -}; diff --git a/tests/src/support/action/setScatterDateRange.js b/tests/src/support/action/setScatterDateRange.js deleted file mode 100644 index 1c1e7ad24..000000000 --- a/tests/src/support/action/setScatterDateRange.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Set the curve date range to a predefined range - * @param {String} value The range to set the selector to - * */ -export default (value) => { - const dates = value.split(" - "); - $("#controlButton-dates-value").scrollIntoView(); - $("#controlButton-dates-value").click(); // brings up date menu - // eslint-disable-next-line max-len - $$('input[name="daterangepicker_start"]')[ - $$('input[name="daterangepicker_start"]').length - 3 - ].setValue(""); - // eslint-disable-next-line max-len - $$('input[name="daterangepicker_start"]')[ - $$('input[name="daterangepicker_start"]').length - 3 - ].setValue(dates[0]); - // eslint-disable-next-line max-len - $$('input[name="daterangepicker_end"]')[ - $$('input[name="daterangepicker_end"]').length - 3 - ].setValue(""); - // eslint-disable-next-line max-len - $$('input[name="daterangepicker_end"]')[ - $$('input[name="daterangepicker_end"]').length - 3 - ].setValue(dates[1]); - // eslint-disable-next-line max-len - $$("/html/body/div[1]/div[1]/div/button")[ - $$("/html/body/div[3]/div[1]/div/button").length - 3 - ].click(); -}; diff --git a/tests/src/support/action/setWindowSize.js b/tests/src/support/action/setWindowSize.js deleted file mode 100644 index 957715787..000000000 --- a/tests/src/support/action/setWindowSize.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Resize the browser window - * @param {String} screenWidth The width of the window to resize to - * @param {String} screenHeight The height of the window to resize to - */ -export default (screenWidth, screenHeight) => { - browser.setWindowSize(parseInt(screenWidth, 10), parseInt(screenHeight, 10)); -}; diff --git a/tests/src/support/action/waitFor.js b/tests/src/support/action/waitFor.js deleted file mode 100644 index 83f18e16d..000000000 --- a/tests/src/support/action/waitFor.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Wait for the given element to be enabled, displayed, or to exist - * @param {String} selector Element selector - * @param {String} ms Wait duration (optional) - * @param {String} falseState Check for opposite state - * @param {String} state State to check for (default - * existence) - */ -export default (selector, ms, falseState, state) => { - /** - * Maximum number of milliseconds to wait, default 3000 - * @type {Int} - */ - const intMs = parseInt(ms, 10) || 3000; - - /** - * Command to perform on the browser object - * @type {String} - */ - let command = "waitForExist"; - - /** - * Boolean interpretation of the false state - * @type {Boolean} - */ - let boolFalseState = !!falseState; - - /** - * Parsed interpretation of the state - * @type {String} - */ - let parsedState = ""; - - if (falseState || state) { - parsedState = - state.indexOf(" ") > -1 ? state.split(/\s/)[state.split(/\s/).length - 1] : state; - - if (parsedState) { - command = `waitFor${parsedState[0].toUpperCase()}` + `${parsedState.slice(1)}`; - } - } - - if (typeof falseState === "undefined") { - boolFalseState = false; - } - - $(selector)[command](intMs, boolFalseState); -}; diff --git a/tests/src/support/action/waitForDisplayed.js b/tests/src/support/action/waitForDisplayed.js deleted file mode 100644 index d0dea2bfc..000000000 --- a/tests/src/support/action/waitForDisplayed.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Wait for the given element to become visible - * @param {String} selector Element selector - * @param {String} falseCase Whether or not to expect a visible or hidden - * state - * - * @todo merge with waitfor - */ -export default (selector, falseCase) => { - /** - * Maximum number of milliseconds to wait for - * @type {Int} - */ - const ms = 10000; - - $(selector).waitForDisplayed(ms, !!falseCase); -}; diff --git a/tests/src/support/check/checkClass.js b/tests/src/support/check/checkClass.js deleted file mode 100644 index 972ec31ef..000000000 --- a/tests/src/support/check/checkClass.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Check if the given element has the given class - * @param {String} selector Element selector - * @param {String} falseCase Whether to check for the class to exist - * or not ('has', 'does not have') - * @param {String} expectedClassName The class name to check - */ -export default (selector, falseCase, expectedClassName) => { - /** - * List of all the classes of the element - * @type {Array} - */ - const classesList = $(selector).getAttribute("className").split(" "); - - if (falseCase === "does not have") { - expect(classesList).not.toContain( - expectedClassName, - `Element ${selector} should not have the class ${expectedClassName}` - ); - } else { - expect(classesList).toContain( - expectedClassName, - `Element ${selector} should have the class ${expectedClassName}` - ); - } -}; diff --git a/tests/src/support/check/checkContainsAnyText.js b/tests/src/support/check/checkContainsAnyText.js deleted file mode 100644 index a5bbef569..000000000 --- a/tests/src/support/check/checkContainsAnyText.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Check if the given elements contains text - * @param {String} elementType Element type (element or button) - * @param {String} selector Element selector - * @param {String} falseCase Whether to check if the content contains - * text or not - */ -export default (elementType, selector, falseCase) => { - /** - * The command to perform on the browser object - * @type {String} - */ - let command = "getValue"; - - if (elementType === "button" || $(selector).getAttribute("value") === null) { - command = "getText"; - } - - /** - * False case - * @type {Boolean} - */ - let boolFalseCase; - - /** - * The text of the element - * @type {String} - */ - const text = $(selector)[command](); - - if (typeof falseCase === "undefined") { - boolFalseCase = false; - } else { - boolFalseCase = !!falseCase; - } - - if (boolFalseCase) { - expect(text).toBe(""); - } else { - expect(text).not.toBe(""); - } -}; diff --git a/tests/src/support/check/checkContainsText.js b/tests/src/support/check/checkContainsText.js deleted file mode 100644 index 194cdc3b0..000000000 --- a/tests/src/support/check/checkContainsText.js +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Check if the given elements contains text - * @param {String} elementType Element type (element or button) - * @param {String} selector Element selector - * @param {String} falseCase Whether to check if the content contains - * the given text or not - * @param {String} expectedText The text to check against - */ -export default (elementType, selector, falseCase, expectedText) => { - /** - * The command to perform on the browser object - * @type {String} - */ - let command = "getValue"; - - if ( - ["button", "container"].includes(elementType) || - $(selector).getAttribute("value") === null - ) { - command = "getText"; - } - - /** - * False case - * @type {Boolean} - */ - let boolFalseCase; - - /** - * The expected text - * @type {String} - */ - let stringExpectedText = expectedText; - - /** - * The text of the element - * @type {String} - */ - const elem = $(selector); - elem.waitForDisplayed(); - const text = elem[command](); - - if (typeof expectedText === "undefined") { - stringExpectedText = falseCase; - boolFalseCase = false; - } else { - boolFalseCase = falseCase === " not"; - } - - if (boolFalseCase) { - expect(text).not.toContain(stringExpectedText); - } else { - expect(text).toContain(stringExpectedText); - } -}; diff --git a/tests/src/support/check/checkCookieContent.js b/tests/src/support/check/checkCookieContent.js deleted file mode 100644 index 374e28b2c..000000000 --- a/tests/src/support/check/checkCookieContent.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Check the content of a cookie against a given value - * @param {String} name The name of the cookie - * @param {String} falseCase Whether or not to check if the value matches - * or not - * @param {String} expectedValue The value to check against - */ -export default (name, falseCase, expectedValue) => { - /** - * The cookie retrieved from the browser object - * @type {Object} - */ - const cookie = browser.getCookies(name)[0]; - expect(cookie.name).toBe(name, `no cookie found with the name "${name}"`); - - if (falseCase) { - expect(cookie.value).not.toBe( - expectedValue, - `expected cookie "${name}" not to have value "${expectedValue}"` - ); - } else { - expect(cookie.value).toBe( - expectedValue, - `expected cookie "${name}" to have value "${expectedValue}"` + - ` but got "${cookie.value}"` - ); - } -}; diff --git a/tests/src/support/check/checkCookieExists.js b/tests/src/support/check/checkCookieExists.js deleted file mode 100644 index daab2d03f..000000000 --- a/tests/src/support/check/checkCookieExists.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Check if a cookie with the given name exists - * @param {[type]} name The name of the cookie - * @param {[type]} falseCase Whether or not to check if the cookie exists or - * not - */ -export default (name, falseCase) => { - /** - * The cookie as retrieved from the browser - * @type {Object} - */ - const cookie = browser.getCookies(name); - - if (falseCase) { - expect(cookie).toHaveLength( - 0, - `Expected cookie "${name}" not to exists but it does` - ); - } else { - expect(cookie).not.toHaveLength( - 0, - `Expected cookie "${name}" to exists but it does not` - ); - } -}; diff --git a/tests/src/support/check/checkDimension.js b/tests/src/support/check/checkDimension.js deleted file mode 100644 index f5738fa57..000000000 --- a/tests/src/support/check/checkDimension.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Check the dimensions of the given element - * @param {String} selector Element selector - * @param {String} falseCase Whether to check if the dimensions match or - * not - * @param {String} expectedSize Expected size - * @param {String} dimension Dimension to check (broad or tall) - */ -export default (selector, falseCase, expectedSize, dimension) => { - /** - * The size of the given element - * @type {Object} - */ - const elementSize = $(selector).getSize(); - - /** - * Parsed size to check for - * @type {Int} - */ - const intExpectedSize = parseInt(expectedSize, 10); - - /** - * The size property to check against - * @type {Int} - */ - let originalSize = elementSize.height; - - /** - * The label of the checked property - * @type {String} - */ - let label = "height"; - - if (dimension === "broad") { - originalSize = elementSize.width; - label = "width"; - } - - if (falseCase) { - expect(originalSize).not.toBe( - intExpectedSize, - `Element "${selector}" should not have a ${label} of ` + `${intExpectedSize}px` - ); - } else { - expect(originalSize).toBe( - intExpectedSize, - `Element "${selector}" should have a ${label} of ` + - `${intExpectedSize}px, but is ${originalSize}px` - ); - } -}; diff --git a/tests/src/support/check/checkElementExists.js b/tests/src/support/check/checkElementExists.js deleted file mode 100644 index dbc632014..000000000 --- a/tests/src/support/check/checkElementExists.js +++ /dev/null @@ -1,21 +0,0 @@ -import checkIfElementExists from "../lib/checkIfElementExists"; - -/** - * Check if the given element exists - * @param {String} isExisting Whether the element should be existing or not - * (an or no) - * @param {String} selector Element selector - */ -export default (isExisting, selector) => { - /** - * Falsecase assertion - * @type {Boolean} - */ - let falseCase = true; - - if (isExisting === "an") { - falseCase = false; - } - - checkIfElementExists(selector, falseCase); -}; diff --git a/tests/src/support/check/checkEqualsText.js b/tests/src/support/check/checkEqualsText.js deleted file mode 100644 index 1558a768a..000000000 --- a/tests/src/support/check/checkEqualsText.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Check if the given elements text is the same as the given text - * @param {String} elementType Element type (element or button) - * @param {String} selector Element selector - * @param {String} falseCase Whether to check if the content equals the - * given text or not - * @param {String} expectedText The text to validate against - */ -export default (elementType, selector, falseCase, expectedText) => { - /** - * The command to execute on the browser object - * @type {String} - */ - let command = "getValue"; - - if (elementType === "button" || $(selector).getAttribute("value") === null) { - command = "getText"; - } - - /** - * The expected text to validate against - * @type {String} - */ - let parsedExpectedText = expectedText; - - /** - * Whether to check if the content equals the given text or not - * @type {Boolean} - */ - let boolFalseCase = !!falseCase; - - // Check for empty element - if (typeof parsedExpectedText === "function") { - parsedExpectedText = ""; - - boolFalseCase = !boolFalseCase; - } - - if (parsedExpectedText === undefined && falseCase === undefined) { - parsedExpectedText = ""; - boolFalseCase = true; - } - - const text = browser[command](selector); - - if (boolFalseCase) { - expect(parsedExpectedText).not.toBe(text); - } else { - expect(parsedExpectedText).toBe(text); - } -}; diff --git a/tests/src/support/check/checkFocus.js b/tests/src/support/check/checkFocus.js deleted file mode 100644 index 4371c1a5a..000000000 --- a/tests/src/support/check/checkFocus.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Check if the given element has the focus - * @param {String} selector Element selector - * @param {String} falseCase Whether to check if the given element has focus - * or not - */ -export default (selector, falseCase) => { - /** - * Value of the hasFocus function for the given element - * @type {Boolean} - */ - const hasFocus = $(selector).isFocused(); - - if (falseCase) { - expect(hasFocus).not.toBe(true, "Expected element to not be focused, but it is"); - } else { - expect(hasFocus).toBe(true, "Expected element to be focused, but it is not"); - } -}; diff --git a/tests/src/support/check/checkFontProperty.js b/tests/src/support/check/checkFontProperty.js deleted file mode 100644 index fbdca5b30..000000000 --- a/tests/src/support/check/checkFontProperty.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Check the given property of the given element - * @param {String} isCSS Whether to check for a CSS property or an - * attribute - * @param {String} attrName The name of the attribute to check - * @param {String} elem Element selector - * @param {String} falseCase Whether to check if the value of the - * attribute matches or not - * @param {String} expectedValue The value to match against - */ -export default (isCSS, attrName, elem, falseCase, expectedValue) => { - /** - * The command to use for fetching the expected value - * @type {String} - */ - const command = isCSS ? "getCssProperty" : "getAttribute"; - - /** - * Te label to identify the attribute by - * @type {String} - */ - const attrType = isCSS ? "CSS attribute" : "Attribute"; - - /** - * The actual attribute value - * @type {Mixed} - */ - let attributeValue = browser[command](elem, attrName); - - /** - * when getting something with a color or font-weight WebdriverIO returns a - * object but we want to assert against a string - */ - if (attrName.match(/(font-size|line-height|display|font-weight)/)) { - attributeValue = attributeValue.value; - } - - if (falseCase) { - expect(attributeValue).not.toBe( - expectedValue, - `${attrType}: ${attrName} of element "${elem}" should not ` + - `contain "${attributeValue}"` - ); - } else { - expect(attributeValue).toBe( - expectedValue, - `${attrType}: ${attrName} of element "${elem}" should contain ` + - `"${attributeValue}", but "${expectedValue}"` - ); - } -}; diff --git a/tests/src/support/check/checkInURLPath.js b/tests/src/support/check/checkInURLPath.js deleted file mode 100644 index a0306dbd7..000000000 --- a/tests/src/support/check/checkInURLPath.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Check if the given string is in the URL path - * @param {String} falseCase Whether to check if the given string is in - * the URL path or not - * @param {String} expectedUrlPart The string to check for - */ -export default (falseCase, expectedUrlPart) => { - /** - * The URL of the current browser window - * @type {String} - */ - const currentUrl = browser.getUrl(); - - if (falseCase) { - expect(currentUrl).not.toContain( - expectedUrlPart, - `Expected URL "${currentUrl}" not to contain ` + `"${expectedUrlPart}"` - ); - } else { - expect(currentUrl).toContain( - expectedUrlPart, - `Expected URL "${currentUrl}" to contain "${expectedUrlPart}"` - ); - } -}; diff --git a/tests/src/support/check/checkIsEmpty.js b/tests/src/support/check/checkIsEmpty.js deleted file mode 100644 index acf8a4008..000000000 --- a/tests/src/support/check/checkIsEmpty.js +++ /dev/null @@ -1,13 +0,0 @@ -import checkContainsAnyText from "./checkContainsAnyText"; - -export default (elementType, element, falseCase) => { - let newFalseCase = true; - - if (typeof falseCase === "function") { - newFalseCase = false; - } else if (falseCase === " not") { - newFalseCase = false; - } - - checkContainsAnyText(elementType, element, newFalseCase); -}; diff --git a/tests/src/support/check/checkIsOpenedInNewWindow.js b/tests/src/support/check/checkIsOpenedInNewWindow.js deleted file mode 100644 index 95571f7db..000000000 --- a/tests/src/support/check/checkIsOpenedInNewWindow.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Check if the given URL was opened in a new window - * @param {String} expectedUrl The URL to check for - */ -/* eslint-disable no-unused-vars */ -export default (expectedUrl, type) => { - /* eslint-enable no-unused-vars */ - /** - * All the current window handles - * @type {Object} - */ - const windowHandles = browser.getWindowHandles(); - - expect(windowHandles).not.toHaveLength(1, "A popup was not opened"); - - /** - * The last opened window handle - * @type {Object} - */ - const lastWindowHandle = windowHandles.slice(-1); - - // Make sure we focus on the last opened window handle - browser.switchToWindow(lastWindowHandle[0]); - - /** - * Get the URL of the current browser window - * @type {String} - */ - const windowUrl = browser.getUrl(); - - expect(windowUrl).toContain(expectedUrl, "The popup has a incorrect getUrl"); - - browser.closeWindow(); -}; diff --git a/tests/src/support/check/checkMatsAppTitle.js b/tests/src/support/check/checkMatsAppTitle.js deleted file mode 100644 index 028e5b42f..000000000 --- a/tests/src/support/check/checkMatsAppTitle.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Check the title (in the plottype element) - * @param {String} title the selection parameter - */ -export default (title) => { - const command = "getText"; - - /** - * The expected text - * @type {String} - */ - const stringExpectedText = title; - - /** - * The text of the element - * @type {String} - */ - const elem = $("#plotType"); - elem.waitForDisplayed(); - const text = elem[command](); - - expect(text).toContain(stringExpectedText); -}; diff --git a/tests/src/support/check/checkMatsCurveDatesValue.js b/tests/src/support/check/checkMatsCurveDatesValue.js deleted file mode 100644 index 9b6353a97..000000000 --- a/tests/src/support/check/checkMatsCurveDatesValue.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Check the selected state of the given element - * @param {String} value the expected value - */ -export default (value) => { - /** - * The expected value - * @type {string} - */ - const datesValue = $("#controlButton-curve-dates-value").getText(); - expect(datesValue).toEqual( - value, - `"daterange" should be ${value} but was ${datesValue}` - ); -}; diff --git a/tests/src/support/check/checkMatsCurveIsAdded.js b/tests/src/support/check/checkMatsCurveIsAdded.js deleted file mode 100644 index a250dd8b8..000000000 --- a/tests/src/support/check/checkMatsCurveIsAdded.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Check the curve has been added - * @param {String} the label of the curve - */ - -export default (curve) => { - const command = "getText"; - const selector = $(`#curveItem-${curve}`); - /** - * The expected text - * @type {String} - */ - const stringExpectedText = curve; - - /** - * The text of the element - * @type {String} - */ - selector.waitForDisplayed(); - const text = selector[command](); - - expect(text).toContain(stringExpectedText); -}; diff --git a/tests/src/support/check/checkMatsCurveListContains.js b/tests/src/support/check/checkMatsCurveListContains.js deleted file mode 100644 index 1e4e99060..000000000 --- a/tests/src/support/check/checkMatsCurveListContains.js +++ /dev/null @@ -1,25 +0,0 @@ -import pause from "../action/pause"; - -/** - * Check if the given elements contains text - * @param {String} expected The textual list to check against - */ -export default (expected) => { - /** - * Check that the curve list contains specific curve label - * @curveNumber {Number} - */ - const expectedList = expected.split(",").sort(); - $(".displayItemLabelSpan").waitForDisplayed(); - pause(1000); - const actualList = $$(".displayItemLabelSpan") - .map((elem) => elem.getText()) - .sort(); - const expectedText = expectedList.join(","); - const actualText = actualList.join(","); - const matches = expectedText === actualText; - expect(matches).toBe( - true, - `expected list ${expectedList} does not match actualList ${actualList}` - ); -}; diff --git a/tests/src/support/check/checkMatsCurveNumber.js b/tests/src/support/check/checkMatsCurveNumber.js deleted file mode 100644 index b292b91cb..000000000 --- a/tests/src/support/check/checkMatsCurveNumber.js +++ /dev/null @@ -1,39 +0,0 @@ -import pause from "../action/pause"; - -/** - * Check if the given elements contains text - * @param {number} curveNumber The text to check against - */ -export default (curveNumber) => { - /** - * Check that the graph contains curveNumber of curves - * @curveNumber {Number} - * @type {String} - */ - if (curveNumber === 0) { - // there won't be any curvelist - let count = 0; - let exists = $("#curveList").isExisting() && $("#curveList").isDisplayed(); - while (count < 10 && exists !== false) { - if (exists !== false) { - pause(2000); - exists = $("#curveList").isExisting() && $("#curveList").isDisplayed(); - count += 1; - } - } - expect(exists).toEqual(false, "There should be no curves remaining"); - } else { - let count = 0; - $("#curveList").waitForDisplayed(20000); - let curveItemsLength = $$("[id|='curveItem']").length; - while (count < 5 && curveItemsLength !== curveNumber) { - pause(1000); - curveItemsLength = $$("[id|='curveItem']").length; - count += 1; - } - expect(curveItemsLength).toEqual( - curveNumber, - `The expected number of curves #{curveNumber} does not match ${curveItemsLength}` - ); - } -}; diff --git a/tests/src/support/check/checkMatsDatesValue.js b/tests/src/support/check/checkMatsDatesValue.js deleted file mode 100644 index 7e954ba3f..000000000 --- a/tests/src/support/check/checkMatsDatesValue.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Check the selected state of the given element - * @param {String} value the expected value - */ -export default (value) => { - /** - * The expected value - * @type {string} - */ - const datesValue = $("#controlButton-dates-value").getText(); - expect(datesValue).toEqual( - value, - `"daterange" should be ${value} but was ${datesValue}` - ); -}; diff --git a/tests/src/support/check/checkMatsGraphPlotType.js b/tests/src/support/check/checkMatsGraphPlotType.js deleted file mode 100644 index 484e67ca4..000000000 --- a/tests/src/support/check/checkMatsGraphPlotType.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Check if the given elements contains text - * @param {String} plotType The text to check against - */ -export default (plotType) => { - /** - * Check that the header contains the plot type - * @plotType {String} - */ - const command = "getText"; - - const stringExpectedText = plotType; - - const elem = $("#header"); - elem.waitForDisplayed(); - const text = elem[command](); - - expect(text).toContain(stringExpectedText); -}; diff --git a/tests/src/support/check/checkMatsInfoMessage.js b/tests/src/support/check/checkMatsInfoMessage.js deleted file mode 100644 index 2cad7753f..000000000 --- a/tests/src/support/check/checkMatsInfoMessage.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Check the message in the Mats info modal - * @param {String} message the modal message - */ -export default (message) => { - const command = "getText"; - const expectedText = message; - const elem = $("#info").$(".modal-body").$("

"); - elem.waitForDisplayed(); - const text = elem[command](); - // notice that the expectedText contains the actual text. - // that is because the expected text has a leading "Info: " - // that the actual modal text selector filters out - expect(expectedText).toContain( - text, - `The info modal does not contain the expected text ${expectedText}` - ); -}; diff --git a/tests/src/support/check/checkMatsLegendListContains.js b/tests/src/support/check/checkMatsLegendListContains.js deleted file mode 100644 index a6bb4d1c8..000000000 --- a/tests/src/support/check/checkMatsLegendListContains.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Check if the given elements contains text - * @param {String} expected The textual list to check against - */ -export default (expected) => { - /** - * Check that the curve list contains specific curve label - * @curveNumber {Number} - */ - const expectedList = expected.split(",").sort(); - const actualList = $$(".legendtext") - .map((elem) => elem.getText().split(":")[0]) - .sort(); - const expectedText = expectedList.join(","); - const actualText = actualList.join(","); - const matches = expectedText === actualText; - expect(matches).toBe( - true, - `expected list ${expectedList} does not match actualList ${actualList}` - ); -}; diff --git a/tests/src/support/check/checkMatsParameters.js b/tests/src/support/check/checkMatsParameters.js deleted file mode 100644 index 395139ad3..000000000 --- a/tests/src/support/check/checkMatsParameters.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Check if the previously stored parameters match the current parameters. - */ -export default () => { - const currentMatsParameters = $$(".control-button").map((element) => - element.getText() - ); - const matches = - currentMatsParameters.sort().join(",") === - browser.saveMatsParameters.sort().join(","); - expect(matches).toEqual( - true, - "saved MATS parameters do not match current parameters" - ); - // browser.debug(); -}; diff --git a/tests/src/support/check/checkMatsPlotNumber.js b/tests/src/support/check/checkMatsPlotNumber.js deleted file mode 100644 index 756710c14..000000000 --- a/tests/src/support/check/checkMatsPlotNumber.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Check if the given elements contains text - * @param {number} curveNumber The text to check against - */ -export default (curveNumber) => { - /** - * Check that the graph contains curveNumber of curves - * @curveNumber {Number} - * @type {String} - */ - $("#curves").waitForDisplayed(20000); - // use the heatMapVisibility button (it's a unique selector) to count the curves - const curveItems = $$(".traces"); - // eslint-disable-next-line no-template-curly-in-string - expect(curveItems).toHaveLength(curveNumber, 'Should have "${curveNumber}" curves'); -}; diff --git a/tests/src/support/check/checkModal.js b/tests/src/support/check/checkModal.js deleted file mode 100644 index 6fe2c36b9..000000000 --- a/tests/src/support/check/checkModal.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Check if a modal was opened - * @param {String} modalType The type of modal that is expected (alertbox, - * confirmbox or prompt) - * @param {String} falseState Whether to check if the modal was opened or not - */ -export default (modalType, falseState) => { - /** - * The text of the prompt - * @type {String} - */ - let promptText = ""; - - try { - promptText = browser.getAlertText(); - - if (falseState) { - expect(promptText).not.toEqual( - null, - `A ${modalType} was opened when it shouldn't` - ); - } - } catch (e) { - if (!falseState) { - expect(promptText).toEqual( - null, - `A ${modalType} was not opened when it should have been` - ); - } - } -}; diff --git a/tests/src/support/check/checkModalText.js b/tests/src/support/check/checkModalText.js deleted file mode 100644 index 2b39da90d..000000000 --- a/tests/src/support/check/checkModalText.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Check the text of a modal - * @param {String} modalType The type of modal that is expected - * (alertbox, confirmbox or prompt) - * @param {String} falseState Whether to check if the text matches or not - * @param {String} expectedText The text to check against - */ -export default (modalType, falseState, expectedText) => { - try { - /** - * The text of the current modal - * @type {String} - */ - const text = browser.getAlertText(); - - if (falseState) { - expect(text).not.toEqual( - expectedText, - `Expected the text of ${modalType} not to equal ` + `"${expectedText}"` - ); - } else { - expect(text).toEqual( - expectedText, - `Expected the text of ${modalType} to equal ` + - `"${expectedText}", instead found "${text}"` - ); - } - } catch (e) { - throw new Error(`A ${modalType} was not opened when it should have been opened`); - } -}; diff --git a/tests/src/support/check/checkNewWindow.js b/tests/src/support/check/checkNewWindow.js deleted file mode 100644 index cd42026bf..000000000 --- a/tests/src/support/check/checkNewWindow.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Check if a new window or tab is opened - * @param {String} obsolete The type of opened object (window or tab) - * @param {String} falseCase Whether to check if a new window/tab was opened - * or not - */ -export default (obsolete, falseCase) => { - /** - * The handles of all open windows/tabs - * @type {Object} - */ - const windowHandles = browser.getWindowHandles(); - - if (falseCase) { - expect(windowHandles).toHaveLength(1, "A new window should not have been opened"); - } else { - expect(windowHandles).not.toHaveLength(1, "A new window has been opened"); - } -}; diff --git a/tests/src/support/check/checkOffset.js b/tests/src/support/check/checkOffset.js deleted file mode 100644 index 0722c56b0..000000000 --- a/tests/src/support/check/checkOffset.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Check the offset of the given element - * @param {String} selector Element selector - * @param {String} falseCase Whether to check if the offset matches - * or not - * @param {String} expectedPosition The position to check against - * @param {String} axis The axis to check on (x or y) - */ -export default (selector, falseCase, expectedPosition, axis) => { - /** - * Get the location of the element on the given axis - * @type {[type]} - */ - const location = $(selector).getLocation(axis); - - /** - * Parsed expected position - * @type {Int} - */ - const intExpectedPosition = parseFloat(expectedPosition); - - if (falseCase) { - expect(location).not.toEqual( - intExpectedPosition, - `Element "${selector}" should not be positioned at ` + - `${intExpectedPosition}px on the ${axis} axis` - ); - } else { - expect(location).toEqual( - intExpectedPosition, - `Element "${selector}" should be positioned at ` + - `${intExpectedPosition}px on the ${axis} axis, but was found ` + - `at ${location}px` - ); - } -}; diff --git a/tests/src/support/check/checkParameterValue.js b/tests/src/support/check/checkParameterValue.js deleted file mode 100644 index b0fabf15b..000000000 --- a/tests/src/support/check/checkParameterValue.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Check the selected state of the given element - * @param {String} parameter the selection parameter - * @param {String} option the selected option - */ -export default (parameter, option) => { - /** - * The selected state - * @type {Boolean} - */ - const isSelected = $(parameter).isSelected(); - - if (option) { - expect(isSelected).not.toEqual(true, `"${option}" should not be selected`); - } else { - expect(isSelected).toEqual(true, `"${option}" should be selected`); - } -}; diff --git a/tests/src/support/check/checkProperty.js b/tests/src/support/check/checkProperty.js deleted file mode 100644 index 9c0426db2..000000000 --- a/tests/src/support/check/checkProperty.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Check the given property of the given element - * @param {String} isCSS Whether to check for a CSS property or an - * attribute - * @param {String} attrName The name of the attribute to check - * @param {String} selector Element selector - * @param {String} falseCase Whether to check if the value of the - * attribute matches or not - * @param {String} expectedValue The value to match against - */ -export default (isCSS, attrName, selector, falseCase, expectedValue) => { - /** - * The command to use for fetching the expected value - * @type {String} - */ - const command = isCSS ? "getCSSProperty" : "getAttribute"; - - /** - * Te label to identify the attribute by - * @type {String} - */ - const attrType = isCSS ? "CSS attribute" : "Attribute"; - - /** - * The actual attribute value - * @type {Mixed} - */ - let attributeValue = $(selector)[command](attrName); - - // eslint-disable-next-line - expectedValue = isFinite(expectedValue) ? parseFloat(expectedValue) : expectedValue; - - /** - * when getting something with a color or font-weight WebdriverIO returns a - * object but we want to assert against a string - */ - if (attrName.match(/(color|font-weight)/)) { - attributeValue = attributeValue.value; - } - if (falseCase) { - expect(attributeValue).not.toEqual( - expectedValue, - `${attrType}: ${attrName} of element "${selector}" should ` + - `not contain "${attributeValue}"` - ); - } else { - expect(attributeValue).toEqual( - expectedValue, - `${attrType}: ${attrName} of element "${selector}" should ` + - `contain "${attributeValue}", but "${expectedValue}"` - ); - } -}; diff --git a/tests/src/support/check/checkSelected.js b/tests/src/support/check/checkSelected.js deleted file mode 100644 index 1e961cde3..000000000 --- a/tests/src/support/check/checkSelected.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Check the selected state of the given element - * @param {String} selector Element selector - * @param {String} falseCase Whether to check if the element is elected or - * not - */ -export default (selector, falseCase) => { - /** - * The selected state - * @type {Boolean} - */ - const isSelected = $(selector).isSelected(); - - if (falseCase) { - expect(isSelected).not.toEqual(true, `"${selector}" should not be selected`); - } else { - expect(isSelected).toEqual(true, `"${selector}" should be selected`); - } -}; diff --git a/tests/src/support/check/checkTitle.js b/tests/src/support/check/checkTitle.js deleted file mode 100644 index e5733ad87..000000000 --- a/tests/src/support/check/checkTitle.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Check the title of the current browser window - * @param {Type} falseCase Whether to check if the title matches the - * expected value or not - * @param {Type} expectedTitle The expected title - */ -export default (falseCase, expectedTitle) => { - /** - * The title of the current browser window - * @type {String} - */ - const title = browser.getTitle(); - - if (falseCase) { - expect(title).not.toEqual( - expectedTitle, - `Expected title not to be "${expectedTitle}"` - ); - } else { - expect(title).toEqual( - expectedTitle, - `Expected title to be "${expectedTitle}" but found "${title}"` - ); - } -}; diff --git a/tests/src/support/check/checkTitleContains.js b/tests/src/support/check/checkTitleContains.js deleted file mode 100644 index 8e10efc04..000000000 --- a/tests/src/support/check/checkTitleContains.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Check the title of the current browser window contains expected text/title - * @param {Type} falseCase Whether to check if the title contains the - * expected value or not - * @param {Type} expectedTitle The expected title - */ -export default (falseCase, expectedTitle) => { - /** - * The actual title of the current browser window - * @type {String} - */ - const title = browser.getTitle(); - - if (falseCase) { - expect(title).not.toContain( - expectedTitle, - `Expected title not to contain "${expectedTitle}"` - ); - } else { - expect(title).toContain( - expectedTitle, - `Expected title to contain "${expectedTitle}" but found "${title}"` - ); - } -}; diff --git a/tests/src/support/check/checkURL.js b/tests/src/support/check/checkURL.js deleted file mode 100644 index d14355504..000000000 --- a/tests/src/support/check/checkURL.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Check the URL of the given browser window - * @param {String} falseCase Whether to check if the URL matches the - * expected value or not - * @param {String} expectedUrl The expected URL to check against - */ -export default (falseCase, expectedUrl) => { - /** - * The current browser window's URL - * @type {String} - */ - const currentUrl = browser.getUrl(); - - if (falseCase) { - expect(currentUrl).not.toEqual( - expectedUrl, - `expected url not to be "${currentUrl}"` - ); - } else { - expect(currentUrl).toEqual( - expectedUrl, - `expected url to be "${expectedUrl}" but found ` + `"${currentUrl}"` - ); - } -}; diff --git a/tests/src/support/check/checkURLPath.js b/tests/src/support/check/checkURLPath.js deleted file mode 100644 index 722f6681d..000000000 --- a/tests/src/support/check/checkURLPath.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Check if the current URL path matches the given path - * @param {String} falseCase Whether to check if the path matches the - * expected value or not - * @param {String} expectedPath The expected path to match against - */ -export default (falseCase, expectedPath) => { - /** - * The URL of the current browser window - * @type {String} - */ - let currentUrl = browser.getUrl().replace(/http(s?):\/\//, ""); - - /** - * The base URL of the current browser window - * @type {Object} - */ - const domain = `${currentUrl.split("/")[0]}`; - - currentUrl = currentUrl.replace(domain, ""); - - if (falseCase) { - expect(currentUrl).not.toEqual( - expectedPath, - `expected path not to be "${currentUrl}"` - ); - } else { - expect(currentUrl).toEqual( - expectedPath, - `expected path to be "${expectedPath}" but found ` + `"${currentUrl}"` - ); - } -}; diff --git a/tests/src/support/check/checkWithinViewport.js b/tests/src/support/check/checkWithinViewport.js deleted file mode 100644 index eeda306f5..000000000 --- a/tests/src/support/check/checkWithinViewport.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Check if the given element is visible inside the current viewport - * @param {String} selector Element selector - * @param {String} falseCase Whether to check if the element is visible - * within the current viewport or not - */ -export default (selector, falseCase) => { - /** - * The state of visibility of the given element inside the viewport - * @type {Boolean} - */ - const isDisplayed = $(selector).isDisplayedInViewport(); - - if (falseCase) { - expect(isDisplayed).not.toEqual( - true, - `Expected element "${selector}" to be outside the viewport` - ); - } else { - expect(isDisplayed).toEqual( - true, - `Expected element "${selector}" to be inside the viewport` - ); - } -}; diff --git a/tests/src/support/check/compareText.js b/tests/src/support/check/compareText.js deleted file mode 100644 index 578500cb4..000000000 --- a/tests/src/support/check/compareText.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Compare the contents of two elements with each other - * @param {String} selector1 Element selector for the first element - * @param {String} falseCase Whether to check if the contents of both - * elements match or not - * @param {String} selector2 Element selector for the second element - */ -export default (selector1, falseCase, selector2) => { - /** - * The text of the first element - * @type {String} - */ - const text1 = $(selector1).getText(); - - /** - * The text of the second element - * @type {String} - */ - const text2 = $(selector2).getText(); - - if (falseCase) { - expect(text1).not.toEqual(text2, `Expected text not to be "${text1}"`); - } else { - expect(text1).toEqual(text2, `Expected text to be "${text1}" but found "${text2}"`); - } -}; diff --git a/tests/src/support/check/isDisplayed.js b/tests/src/support/check/isDisplayed.js deleted file mode 100644 index b402d9ce3..000000000 --- a/tests/src/support/check/isDisplayed.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Check if the given element is (not) visible - * @param {String} selector Element selector - * @param {String} falseCase Check for a visible or a hidden element - */ -export default (selector, falseCase) => { - /** - * Visible state of the give element - * @type {String} - */ - const isDisplayed = $(selector).isDisplayed(); - - if (falseCase) { - expect(isDisplayed).not.toEqual( - true, - `Expected element "${selector}" not to be displayed` - ); - } else { - expect(isDisplayed).toEqual(true, `Expected element "${selector}" to be displayed`); - } -}; diff --git a/tests/src/support/check/isEnabled.js b/tests/src/support/check/isEnabled.js deleted file mode 100644 index ef9a9f78b..000000000 --- a/tests/src/support/check/isEnabled.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Check if the given selector is enabled - * @param {String} selector Element selector - * @param {String} falseCase Whether to check if the given selector - * is enabled or not - */ -export default (selector, falseCase) => { - /** - * The enabled state of the given selector - * @type {Boolean} - */ - const isEnabled = $(selector).isEnabled(); - - if (falseCase) { - expect(isEnabled).not.toEqual( - true, - `Expected element "${selector}" not to be enabled` - ); - } else { - expect(isEnabled).toEqual(true, `Expected element "${selector}" to be enabled`); - } -}; diff --git a/tests/src/support/check/isExisting.js b/tests/src/support/check/isExisting.js deleted file mode 100644 index be5e032a6..000000000 --- a/tests/src/support/check/isExisting.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Check if the given element exists in the current DOM - * @param {String} selector Element selector - * @param {String} falseCase Whether to check if the element exists or not - */ -export default (selector, falseCase) => { - /** - * Elements found in the DOM - * @type {Object} - */ - const elements = $$(selector); - - if (falseCase) { - expect(elements).toHaveLength(0, `Expected element "${selector}" not to exist`); - } else { - expect(elements.length).toBeGreaterThan( - 0, - `Expected element "${selector}" to exist` - ); - } -}; diff --git a/tests/src/support/check/isGroupValue.js b/tests/src/support/check/isGroupValue.js deleted file mode 100644 index 92e74be8f..000000000 --- a/tests/src/support/check/isGroupValue.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Check the current value (selected element of named group) of the given radio group selector against a provided value - * @param {String} selector Element group selector - * @param {String} the expected value - */ -export default (name, value) => { - /** - * The selected state - * @type {Boolean} - */ - const selector = `input[name=${name}]`; - const selectedValue = $(selector).getValue(); - expect(selectedValue).toBe(value, `"${name}" should should have selected ${value}`); -}; diff --git a/tests/src/support/check/isMainDisplayed.js b/tests/src/support/check/isMainDisplayed.js deleted file mode 100644 index 75a1e84aa..000000000 --- a/tests/src/support/check/isMainDisplayed.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Check if the graph page is visible - */ -export default () => { - /** - * Is the main page visible? - */ - const isDisplayed = $("#plotType").isDisplayed(); - - expect(isDisplayed).toEqual(true, 'Expected element "plotType" to be displayed'); -}; diff --git a/tests/src/support/check/isMatsButtonEnabled.js b/tests/src/support/check/isMatsButtonEnabled.js deleted file mode 100644 index 603ac35f6..000000000 --- a/tests/src/support/check/isMatsButtonEnabled.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Check if the given MATS button is enabled - * @param {String} buttonLabel Button label - * @param {String} falseCase Whether to check if the button is enabled or not - * */ -export default (buttonLabel, falseCase) => { - /** - * Visible state of the give element - * @type {String} - * @type {Boolean} - */ - let selector; - let boolFalseCase; - switch (buttonLabel) { - case "Add Curve": - selector = $("#add"); - break; - case "Back": - selector = $("#backButton"); - break; - case "Plot Matched": - selector = $("#plotMatched"); - break; - case "Plot Unmatched": - selector = $("#plotUnmatched"); - break; - default: - } - - if (typeof falseCase === "undefined") { - boolFalseCase = false; - } else { - boolFalseCase = !!falseCase; - } - if (boolFalseCase) { - const isEnabled = selector.isEnabled(); - expect(isEnabled).toEqual(false, `Expected element "${buttonLabel}" to be enabled`); - } else { - const isEnabled = selector.waitForEnabled(); - expect(isEnabled).toEqual(true, `Expected element "${buttonLabel}" to be enabled`); - } -}; diff --git a/tests/src/support/check/isMatsButtonVisible.js b/tests/src/support/check/isMatsButtonVisible.js deleted file mode 100644 index 7af29d2a9..000000000 --- a/tests/src/support/check/isMatsButtonVisible.js +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Check if the given MATS button is visible - * @param {String} buttonLabel Button label */ -export default (buttonLabel) => { - /** - * Visible state of the give element - * @type {String} - */ - let selector; - if (buttonLabel === "Remove All") { - selector = $("#remove-all"); - } else if (buttonLabel === "Remove all the curves") { - // this is the 'Remove all the curves' confirm button - // I don't know why there are two of the confirm buttons - // there has to be a better way to handle this - // eslint-disable-next-line prefer-destructuring - selector = $$("#confirm-remove-all")[1]; - } else if (buttonLabel.match("Remove curve .*")) { - // this is the 'Remove curve curvelabel' confirm button - // $$('#curve-list-remove*=Curve0').length - const cPart = buttonLabel.replace("Remove curve ", ""); - // eslint-disable-next-line no-template-curly-in-string - selector = $(`#curve-list-remove*=${cPart}`); - } else if (buttonLabel.match("Remove .*")) { - // This is the 'Remove curvelabel' remove button - // $$('#curve-list-remove*=Curve0').length - const cPart = buttonLabel.replace("Remove ", ""); - // eslint-disable-next-line no-template-curly-in-string - selector = $(`#curve-list-remove*=${cPart}`); - } else { - switch (buttonLabel) { - case "Add Curve": - selector = $("#add"); - break; - case "Back": - selector = $("#backButton"); - break; - case "Plot Matched": - selector = $("#plotMatched"); - break; - case "Plot Unmatched": - selector = $("#plotUnmatched"); - break; - default: - } - } - const ms = 10000; - selector.waitForDisplayed({ timeout: ms }); - const isDisplayed = selector.isDisplayed({ timeout: ms }); - expect(isDisplayed).toEqual( - true, - `Expected element "${buttonLabel}" to be displayed` - ); -}; diff --git a/tests/src/support/check/isMatsCurveColor.js b/tests/src/support/check/isMatsCurveColor.js deleted file mode 100644 index 7cd36e6fc..000000000 --- a/tests/src/support/check/isMatsCurveColor.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Check the curve has the correct color - * @param {String} label of the curve - * @param {String} color of the curve - */ - -export default (curve, color) => { - const actualColor = $(`#${curve}-color-value`).getValue(); - const expectedColor = color; - expect(actualColor).toEqual( - expectedColor, - `expected color ${expectedColor} does not match actualColor ${actualColor}` - ); -}; diff --git a/tests/src/support/check/isMatsGraphDisplayed.js b/tests/src/support/check/isMatsGraphDisplayed.js deleted file mode 100644 index f2c32faeb..000000000 --- a/tests/src/support/check/isMatsGraphDisplayed.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Check if the graph page becomes visible - */ - -import pause from "../action/pause"; - -export default () => { - /** - * Is the graph page visible within ms milliseconds? - */ - - let count = 0; - let isDisplayed = false; - while (count < 10 && isDisplayed !== true) { - isDisplayed = $("#graph-container").waitForDisplayed(); - if (isDisplayed !== true) { - pause(1000); - } - count += 1; - } - expect(isDisplayed).toEqual( - true, - 'Expected element "#graph-container" to be displayed' - ); -}; diff --git a/tests/src/support/check/isMatsInfoVisible.js b/tests/src/support/check/isMatsInfoVisible.js deleted file mode 100644 index 49167c773..000000000 --- a/tests/src/support/check/isMatsInfoVisible.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Visible state of the info modal - * @type {String} - */ - -export default (falseCase) => { - const selector = $("#info"); - if (falseCase) { - const isDisplayed = selector.isDisplayed(); - expect(isDisplayed).not.toEqual( - true, - "Expected info modal to NOT be displayed and it is visible" - ); - } else { - const ms = 120000; - selector.waitForDisplayed({ timeout: ms }); - const isDisplayed = selector.isDisplayed({ timeout: ms }); - expect(isDisplayed).toEqual( - true, - "Expected info modal to be displayed and it is not visible" - ); - } -}; diff --git a/tests/src/support/check/isMatsPlotFormat.js b/tests/src/support/check/isMatsPlotFormat.js deleted file mode 100644 index 34f4054f8..000000000 --- a/tests/src/support/check/isMatsPlotFormat.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Check the current value (selected element of named group) - * of the plot-format selector against a provided value - * @param {String} value the expected value - */ -export default (value) => { - /** - * The selected state - * @type {Boolean} - */ - const selected = $$("input[name=plotFormat]").find((elem) => elem.isSelected()); - const selectedValue = $(selected).getValue(); - expect(selectedValue).toBe( - value, - `"plot format" should be ${value} and is ${selectedValue}` - ); -}; diff --git a/tests/src/support/check/isMatsPlotType.js b/tests/src/support/check/isMatsPlotType.js deleted file mode 100644 index 4de455c4c..000000000 --- a/tests/src/support/check/isMatsPlotType.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Check the current value (selected element of named group) - * of the plot-type selector against a provided value - * @param {String} value the expected value - */ -export default (value) => { - /** - * The selected state - * @type {Boolean} - */ - const selectedValue = $("#plotTypes-selector").getValue(); - expect(selectedValue).toBe( - value, - `"plot type" should be ${value} and is ${selectedValue}` - ); -}; diff --git a/tests/src/support/check/isMatsSelectedOption.js b/tests/src/support/check/isMatsSelectedOption.js deleted file mode 100644 index dacd0ba1e..000000000 --- a/tests/src/support/check/isMatsSelectedOption.js +++ /dev/null @@ -1,29 +0,0 @@ -import pause from "../action/pause"; - -export default (parameter, value) => { - /** - * Check the selected state of the given element - * @param {String} parameter paramaeter - * @param {String} value the selected option - */ - $(`#controlButton-${parameter}-value`).waitForDisplayed(); - $(`#controlButton-${parameter}-value`).scrollIntoView(); - let count = 0; - let text = ""; - while (count < 10 && text !== value) { - text = $(`#controlButton-${parameter}-value`).getText(); - if (text !== value) { - if (text.includes(" .. ") && !value.includes(" .. ")) { - // this is a multiselect, which have different display formats than regular selectors. - // we need to reformat our expected value to match. - value = `${value} .. ${value}`; - } - pause(1000); - } - count += 1; - } - expect(text).toEqual( - value, - `Expexted ${text} to be ${value} for parameter: ${parameter}` - ); -}; diff --git a/tests/src/support/hooks.js b/tests/src/support/hooks.js deleted file mode 100644 index 34bb7274c..000000000 --- a/tests/src/support/hooks.js +++ /dev/null @@ -1,151 +0,0 @@ -// -// ===== -// Hooks -// ===== -// WebdriverIO provides a several hooks you can use to interfere the test process in order to -// enhance it and build services around it. You can either apply a single function to it or -// an array of methods. If one of them returns with a promise, -// WebdriverIO will wait until that promise is resolved to continue. -// -exports.hooks = { - /** - * Gets executed once before all workers get launched. - * @param {Object} config wdio configuration object - * @param {Array.} capabilities list of capabilities details - */ - // onPrepare: function (config, capabilities) { - // }, - /** - * Gets executed before a worker process is spawned & can be used to initialize specific service - * for that worker as well as modify runtime environments in an async fashion. - * @param {String} cid capability id (e.g 0-0) - * @param {[type]} caps object containing capabilities for session - * @param {[type]} specs specs to be run in the worker process - * @param {[type]} args object that will be merged with the main - * configuration once worker is initialized - * @param {[type]} execArgv list of string arguments passed to the worker process - */ - // onWorkerStart: function (cid, caps, specs, args, execArgv) { - // }, - /** - * Gets executed just before initializing the webdriver session and test framework. - * It allows you to manipulate configurations depending on the capability or spec. - * @param {Object} config wdio configuration object - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that are to be run - */ - // beforeSession: function (config, capabilities, specs) { - // }, - /** - * Gets executed before test execution begins. At this point you can access to all global - * variables like `browser`. It is the perfect place to define custom commands. - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that are to be run - */ - // before: function (capabilities, specs) { - // }, - /** - * Gets executed before the suite starts. - * @param {Object} suite suite details - */ - // beforeSuite: function (suite) { - // }, - /** - * This hook gets executed _before_ every hook within the suite starts. - * (For example, this runs before calling `before`, `beforeEach`, `after`) - * - * (`stepData` and `world` are Cucumber-specific.) - * - */ - // beforeHook: function (test, context, stepData, world) { - // }, - /** - * Hook that gets executed _after_ every hook within the suite ends. - * (For example, this runs after calling `before`, `beforeEach`, `after`, `afterEach` in Mocha.) - * - * (`stepData` and `world` are Cucumber-specific.) - */ - // afterHook:function(test,context,{error, result, duration, passed, retries}, stepData,world) { - // }, - /** - * Function to be executed before a test (in Mocha/Jasmine) starts. - */ - // beforeTest: function (test, context) { - // }, - /** - * Runs before a WebdriverIO command is executed. - * @param {String} commandName hook command name - * @param {Array} args arguments that the command would receive - */ - // beforeCommand: function (commandName, args) { - // }, - /** - * Runs after a WebdriverIO command gets executed - * @param {String} commandName hook command name - * @param {Array} args arguments that command would receive - * @param {Number} result 0 - command success, 1 - command error - * @param {Object} error error object, if any - */ - // afterCommand: function (commandName, args, result, error) { - // }, - /** - * Function to be executed after a test (in Mocha/Jasmine) - */ - // afterTest: function (test, context, {error, result, duration, passed, retries}) { - // }, - /** - * Hook that gets executed after the suite has ended. - * @param {Object} suite suite details - */ - // afterSuite: function (suite) { - // }, - /** - * Gets executed after all tests are done. You still have access to all global variables from - * the test. - * @param {Number} result 0 - test pass, 1 - test fail - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that ran - */ - // after: function (result, capabilities, specs) { - // }, - /** - * Gets executed right after terminating the webdriver session. - * @param {Object} config wdio configuration object - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that ran - */ - // afterSession: function (config, capabilities, specs) { - // }, - /** - * Gets executed after all workers have shut down and the process is about to exit. - * An error thrown in the `onComplete` hook will result in the test run failing. - * @param {Object} exitCode 0 - success, 1 - fail - * @param {Object} config wdio configuration object - * @param {Array.} capabilities list of capabilities details - * @param {} results object containing test results - */ - // onComplete: function (exitCode, config, capabilities, results) { - // }, - /** - * Gets executed when a refresh happens. - * @param {String} oldSessionId session ID of the old session - * @param {String} newSessionId session ID of the new session - */ - // onReload: function (oldSessionId, newSessionId) { - // }, - /** - * Cucumber-specific hooks - */ - // beforeFeature: function (uri, feature, scenarios) { - // }, - // beforeScenario: function (uri, feature, scenario, sourceLocation) { - // }, - // beforeStep: function ({uri, feature, step}, context) { - // }, - // afterStep: function ({uri, feature, step}, context, {error, result, duration, passed}) { - // }, - // afterScenario: function (uri, feature, scenario, result, sourceLocation) { - // }, - // afterFeature: function (uri, feature, scenarios) { - // } -}; diff --git a/tests/src/support/lib/checkIfElementExists.js b/tests/src/support/lib/checkIfElementExists.js deleted file mode 100644 index 1d03cca68..000000000 --- a/tests/src/support/lib/checkIfElementExists.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Check if the given element exists in the DOM one or more times - * @param {String} selector Element selector - * @param {Boolean} falseCase Check if the element (does not) exists - * @param {Number} exactly Check if the element exists exactly this number - * of times - */ -export default (selector, falseCase, exactly) => { - /** - * The number of elements found in the DOM - * @type {Int} - */ - const nrOfElements = $$(selector); - - if (falseCase === true) { - expect(nrOfElements).toHaveLength( - 0, - `Element with selector "${selector}" should not exist on the page` - ); - } else if (exactly) { - expect(nrOfElements).toHaveLength( - exactly, - `Element with selector "${selector}" should exist exactly ` + `${exactly} time(s)` - ); - } else { - expect(nrOfElements.length).toBeGreaterThanOrEqual( - 1, - `Element with selector "${selector}" should exist on the page` - ); - } -};