Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

Commit

Permalink
reworked import test
Browse files Browse the repository at this point in the history
  • Loading branch information
torebo committed Nov 30, 2018
1 parent 2651e76 commit 6a816c4
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
hmacKey: '54b2ca8a-6752-469d-87dd-553bb450e9ad'
},
v4: {
alwaysConnected: true,
alwaysConnected: false,
math: {
mimeTypes: ['application/x-latex']
}
Expand Down
6 changes: 6 additions & 0 deletions test/lib/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
114 changes: 57 additions & 57 deletions test/lib/inks/one.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
]
]
8 changes: 4 additions & 4 deletions test/nightwatch/commands/getJiixExports.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -12,6 +12,6 @@ exports.command = function getJiixExports(callback) {
}
}

this.execute(getElementProperty, [], getElementPropertyCallback);
this.execute(getElementProperty, [component], getElementPropertyCallback);
return this;
};
36 changes: 13 additions & 23 deletions test/nightwatch/lib/inkPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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));
})
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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()
Expand All @@ -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();
}

Expand Down
8 changes: 4 additions & 4 deletions test/nightwatch/partial/03-iink/01-math-iink-ws-cdkv4.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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));

0 comments on commit 6a816c4

Please sign in to comment.