From 6a816c46063b6d0c9a182a4fcd838a8c78d66f25 Mon Sep 17 00:00:00 2001 From: Olivier Berot Date: Fri, 30 Nov 2018 17:55:05 +0100 Subject: [PATCH] reworked import test --- ...bsocket_math_iink_notAlwaysConnected.html} | 2 +- test/lib/configuration.js | 6 + test/lib/inks/one.json | 114 +++++++++--------- test/nightwatch/commands/getJiixExports.js | 8 +- test/nightwatch/lib/inkPlayer.js | 36 ++---- .../partial/03-iink/01-math-iink-ws-cdkv4.js | 8 +- 6 files changed, 85 insertions(+), 89 deletions(-) rename examples/v4/{websocket_math_iink_alwaysConnected.html => websocket_math_iink_notAlwaysConnected.html} (99%) diff --git a/examples/v4/websocket_math_iink_alwaysConnected.html b/examples/v4/websocket_math_iink_notAlwaysConnected.html similarity index 99% rename from examples/v4/websocket_math_iink_alwaysConnected.html rename to examples/v4/websocket_math_iink_notAlwaysConnected.html index a1444c7e..272cae7a 100644 --- a/examples/v4/websocket_math_iink_alwaysConnected.html +++ b/examples/v4/websocket_math_iink_notAlwaysConnected.html @@ -120,7 +120,7 @@ hmacKey: '54b2ca8a-6752-469d-87dd-553bb450e9ad' }, v4: { - alwaysConnected: true, + alwaysConnected: false, math: { mimeTypes: ['application/x-latex'] } diff --git a/test/lib/configuration.js b/test/lib/configuration.js index 555feac2..a326c412 100644 --- a/test/lib/configuration.js +++ b/test/lib/configuration.js @@ -243,6 +243,12 @@ const configurations = [{ protocol: 'WEBSOCKET', apiVersion: 'V4', examples: ['/examples/v4/websocket_math_iink.html'], +}, { + type: 'MATH', + protocol: 'WEBSOCKET', + apiVersion: 'V4', + alternate: 'Import', + examples: ['/examples/v4/import_math_jiix.html'], }, { type: 'MATH', protocol: 'WEBSOCKET', diff --git a/test/lib/inks/one.json b/test/lib/inks/one.json index 78e7d587..1a36db5e 100644 --- a/test/lib/inks/one.json +++ b/test/lib/inks/one.json @@ -60,63 +60,63 @@ 443 ], [ - 334, - 330, - 326, - 321, - 315, - 310, - 306, - 303, - 298, - 293, - 290, - 286, - 282, - 280, - 273, - 269, - 266, - 263, - 260, - 263, - 268, - 272, - 276, - 280, - 283, - 286, - 291, - 294, - 298, - 303, - 307, - 311, - 317, - 320, - 324, - 327, - 331, - 334, - 338, - 342, - 347, - 351, - 354, - 358, - 363, - 368, - 372, - 375, - 379, - 382, - 385, - 388, - 391, - 395, - 399, - 402, - 405 + 134, + 130, + 126, + 121, + 115, + 110, + 106, + 103, + 98, + 93, + 90, + 86, + 82, + 80, + 73, + 69, + 66, + 63, + 60, + 63, + 68, + 72, + 76, + 80, + 83, + 86, + 91, + 94, + 98, + 103, + 107, + 111, + 117, + 120, + 124, + 127, + 131, + 134, + 138, + 142, + 147, + 151, + 154, + 158, + 163, + 168, + 172, + 175, + 179, + 182, + 185, + 188, + 191, + 195, + 199, + 202, + 205 ] ] ] \ No newline at end of file diff --git a/test/nightwatch/commands/getJiixExports.js b/test/nightwatch/commands/getJiixExports.js index e18373cb..cfcc1e1e 100644 --- a/test/nightwatch/commands/getJiixExports.js +++ b/test/nightwatch/commands/getJiixExports.js @@ -1,9 +1,9 @@ -exports.command = function getJiixExports(callback) { +exports.command = function getJiixExports(component, callback) { const self = this; - function getElementProperty() { + function getElementProperty(comp) { // eslint-disable-next-line no-undef - return document.querySelector("#editor").editor.model.exports['application/vnd.myscript.jiix']; + return document.querySelector(comp).editor.model.exports['application/vnd.myscript.jiix']; } function getElementPropertyCallback(res) { @@ -12,6 +12,6 @@ exports.command = function getJiixExports(callback) { } } - this.execute(getElementProperty, [], getElementPropertyCallback); + this.execute(getElementProperty, [component], getElementPropertyCallback); return this; }; diff --git a/test/nightwatch/lib/inkPlayer.js b/test/nightwatch/lib/inkPlayer.js index 1ef03636..316e2790 100644 --- a/test/nightwatch/lib/inkPlayer.js +++ b/test/nightwatch/lib/inkPlayer.js @@ -19,8 +19,8 @@ function checkTextNonText(browser, resultSelector) { if (resultSelector && resultSelector.length > 0) { browser.waitForElementPresent(resultSelector, 6000 * globalconfig.timeoutAmplificator); } - browser.getJiixExports(function (res) { - console.log('export res: ' + JSON.stringify(res.value)); + browser.getJiixExports('#editor', function (res) { + //console.log('export res: ' + JSON.stringify(res.value)); const parsedjiix = JSON.parse(JSON.stringify(res.value)); browser.verify.equal(parsedjiix.type, "Raw Content"); @@ -55,7 +55,7 @@ function getStrokesFromJIIX(jiix) { function checkNbStrokes(browser, config, resultSelector, property, nbStrokesExpected) { const isWebSocketV4 = (config.apiVersion === 'V4' && config.protocol !== 'REST'); if(isWebSocketV4) { - browser.getJiixExports(function (res) { + browser.getJiixExports('#editor', function (res) { //console.log('export= ' + JSON.stringify(res.value)); browser.verify.equal(getStrokesFromJIIX(res.value).length, String(nbStrokesExpected)); }) @@ -285,13 +285,13 @@ function checkDecoration(browser, config, inkName, strokes, labels, component = browser.pause(1000); - browser.getJiixExports(function (res) { - console.log('export= ' + JSON.stringify(res.value)); + browser.getJiixExports(component, function (res) { + //console.log('export= ' + JSON.stringify(res.value)); var spansList = common.findValuesByKey(res.value, 'spans'); browser.verify.equal(spansList.length, 2); - console.log("span0 string= " + JSON.stringify(spansList[0])); + //console.log("span0 string= " + JSON.stringify(spansList[0])); var span0 = JSON.parse(JSON.stringify(spansList[0])); - console.log("span0= "+ JSON.stringify(span0)); + //console.log("span0= "+ JSON.stringify(span0)); browser.verify.equal(span0["first-char"], "0"); browser.verify.equal(span0["last-char"], "4"); browser.verify.equal(span0.class, "text"); @@ -477,7 +477,6 @@ function checkRecognitionAssetBuilder(browser, config, strokes, labels, componen function checkImport(browser, config, strokes, labels, component = '#editor', resultSelector = '#editorSupervisor', emptyResultSelector = '#editorSupervisor') { console.log('url ' + browser.launchUrl + config.componentPath); - console.log('nb strokes ' + strokes.length); let jiixExport = ''; browser .init(browser.launchUrl + config.componentPath).maximizeWindow() @@ -493,24 +492,15 @@ function checkImport(browser, config, strokes, labels, component = '#editor', re checkLabel(browser, labels, strokes.length - 1, resultSelector, emptyResultSelector); - browser.getJiixExports(function (res) { + browser.getJiixExports(component, function (res) { browser - .click('#clear') - .waitForIdle('#editorSupervisor', 3000 * globalconfig.timeoutAmplificator); - - checkLabel(browser, labels, -1, resultSelector, emptyResultSelector); - - browser - .waitForElementPresent('#importContentField', 1000 * globalconfig.timeoutAmplificator) - .waitForElementPresent('#importContent', 1000 * globalconfig.timeoutAmplificator) - .setProperty('#importContentField', 'value', JSON.stringify(res.value)) - .click("#importContent") + .click('#import') .waitForIdle('#editorSupervisor', 3000 * globalconfig.timeoutAmplificator) - .waitUntilElementPropertyEqual('#editorSupervisor', 'state', 'EXPORTED', 2000 * globalconfig.timeoutAmplificator); - - checkLabel(browser, labels, strokes.length - 1, resultSelector, emptyResultSelector); + .getJiixExports('#editor2', function (res2) { + jiixExport = JSON.parse(res2.value); + browser.verify.equal(labels[strokes.length - 1], jiixExport["expressions"][0]["label"]); + }); }); - browser.end(); } diff --git a/test/nightwatch/partial/03-iink/01-math-iink-ws-cdkv4.js b/test/nightwatch/partial/03-iink/01-math-iink-ws-cdkv4.js index 7e2548d8..6affc93b 100644 --- a/test/nightwatch/partial/03-iink/01-math-iink-ws-cdkv4.js +++ b/test/nightwatch/partial/03-iink/01-math-iink-ws-cdkv4.js @@ -1,6 +1,6 @@ const inkPlayer = require('../../lib/inkPlayer'); const config = require('../../../lib/configuration').getConfiguration('MATH', 'WEBSOCKET', 'V4'); -// const configImport = require('../../../lib/configuration').getConfiguration('MATH', 'WEBSOCKET', 'V4', '', 'import'); +const configImport = require('../../../lib/configuration').getConfiguration('MATH', 'WEBSOCKET', 'V4', '', 'Import'); function runLabelTests(ink) { module.exports[config.header + ' checkConvert ' + ink.name] = function checkConvert(browser) { @@ -36,6 +36,6 @@ config.inks .forEach(ink => runUndoTests(ink)); -// configImport.inks -// .filter(ink => ['equation2', 'equation3'].includes(ink.name)) -// .forEach(ink => runImportTests(ink)); +configImport.inks + .filter(ink => ['one'].includes(ink.name)) + .forEach(ink => runImportTests(ink));