summaryrefslogtreecommitdiff
path: root/src/client-tests
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-12-16 17:37:42 +0200
committerAlon Levy <alon@pobox.com>2014-12-16 17:37:42 +0200
commitade19de410e0a789a921ec1666b278b2a64176d6 (patch)
treec4c54b106de93609ca7bb70a20fd4be696715dbe /src/client-tests
parentc7d026b1d504323a8c61d51b726e5e8d2337fc4b (diff)
moving files around after repository merger
Diffstat (limited to 'src/client-tests')
-rw-r--r--src/client-tests/anotherScript.js2
-rw-r--r--src/client-tests/base.js87
-rwxr-xr-xsrc/client-tests/commit_run_tests_output_update3
-rw-r--r--src/client-tests/cri.json5
-rw-r--r--src/client-tests/output/test_analyzer.js.stderr0
-rw-r--r--src/client-tests/output/test_analyzer.js.stdout82
-rw-r--r--src/client-tests/output/test_app.js.stderr0
-rw-r--r--src/client-tests/output/test_app.js.stdout1
-rw-r--r--src/client-tests/output/test_globals.js.stderr0
-rw-r--r--src/client-tests/output/test_globals.js.stdout11
-rw-r--r--src/client-tests/output/test_require_js.js.stderr0
-rw-r--r--src/client-tests/output/test_require_js.js.stdout17
-rw-r--r--src/client-tests/output/test_script_jsdom.js.stderr0
-rw-r--r--src/client-tests/output/test_script_jsdom.js.stdout1
-rw-r--r--src/client-tests/output/test_util.js.stderr0
-rw-r--r--src/client-tests/output/test_util.js.stdout0
-rw-r--r--src/client-tests/run_tests.js31
-rw-r--r--src/client-tests/test2.js4
-rw-r--r--src/client-tests/test_analyzer.js49
-rw-r--r--src/client-tests/test_app.js32
-rw-r--r--src/client-tests/test_globals.js30
-rw-r--r--src/client-tests/test_require_js.js25
-rw-r--r--src/client-tests/test_script_jsdom.js9
-rw-r--r--src/client-tests/test_util.js44
-rw-r--r--src/client-tests/util/RhiziHTTPServer.py78
-rw-r--r--src/client-tests/weizmann.json1
26 files changed, 512 insertions, 0 deletions
diff --git a/src/client-tests/anotherScript.js b/src/client-tests/anotherScript.js
new file mode 100644
index 00000000..93da9fbf
--- /dev/null
+++ b/src/client-tests/anotherScript.js
@@ -0,0 +1,2 @@
+debugger
+console.log(window.__myObject);
diff --git a/src/client-tests/base.js b/src/client-tests/base.js
new file mode 100644
index 00000000..320edccf
--- /dev/null
+++ b/src/client-tests/base.js
@@ -0,0 +1,87 @@
+var fs = require('fs'),
+ jsdom = require('jsdom'),
+ addScript = require('./test_util').addScript;
+
+function dump_nodes(window) {
+ var nodes = window.force.nodes();
+ for(var i = 0 ; i < nodes.length; ++i) {
+ console.log('nodes[' + nodes[i].id + '/' + nodes[i].type + '].[xy] = (' + nodes[i].x + ',' + nodes[i].y + ')');
+ }
+}
+
+function dump_graphviz(force) {
+ var i;
+ var nodes = force.nodes();
+ var links = force.links();
+ var q = function(s) {
+ if (s.search(' ') == -1) {
+ return s;
+ }
+ return '"' + s + '"';
+ };
+
+ console.log('digraph {');
+ for (i = 0 ; i < nodes.length; ++i) {
+ if (nodes[i].type == 'bubble') {
+ console.log(' BUBBLE;');
+ } else {
+ console.log(' ' + q(nodes[i].name) + ';');
+ }
+ }
+ for (i = 0 ; i < links.length; ++i) {
+ var link = links[i];
+ console.log(' ' + q(link.__src.name) + ' -> ' + q(link.__dst.name) + ' [label=' + link.name + '];');
+ }
+ console.log('}');
+}
+
+function run_tests(settings) {
+ var document = jsdom.jsdom('<html><body></body></html>');
+ var window = document.parentWindow;
+
+ window.console.log = console.log; // slightly evil
+ window.process = process; // more evil
+ window.is_node = true;
+ if (settings.created) {
+ settings.created(undefined, window);
+ }
+ debugger
+ addScript(window, '../src/external/require.js')
+ .load_next('../src/app.js')
+ .done(function () {
+ console.log('test harness: starting script loading with requirejs');
+ window.require.config(window.rhizi_require_config);
+ window.requirejs(['main'], function(main) {
+ console.log('test harness: main loaded');
+ main.main();
+ if (settings.done) {
+ settings.done(undefined, window);
+ }
+ process.quit();
+ });
+ });
+ //window.setInterval(function() { console.log('.'); return true; }, 100);
+}
+
+function reset(window) {
+ window.require('rz_core').graph.clear();
+}
+
+function nodes(window) {
+ return window.require('rz_core').force.nodes().map(function (n) {
+ return n.name;
+ });
+}
+
+function links(window) {
+ return window.require('rz_core').force.links().map(function (l) {
+ debugger;
+ return [l.__src.name, l.__dst.name, l.name];
+ });
+}
+
+exports.run_tests = run_tests;
+exports.dump_graphviz = dump_graphviz;
+exports.reset = reset;
+exports.links = links;
+exports.nodes = nodes;
diff --git a/src/client-tests/commit_run_tests_output_update b/src/client-tests/commit_run_tests_output_update
new file mode 100755
index 00000000..5912fb8d
--- /dev/null
+++ b/src/client-tests/commit_run_tests_output_update
@@ -0,0 +1,3 @@
+#!/bin/bash
+git add output
+git commit -m "update run_tests.js output"
diff --git a/src/client-tests/cri.json b/src/client-tests/cri.json
new file mode 100644
index 00000000..c53c7a3d
--- /dev/null
+++ b/src/client-tests/cri.json
@@ -0,0 +1,5 @@
+{
+ "nodes":[{"name":"Jean- Christophe Thalabard","type":"person","state":"perm"},{"name":"Owen Cornec","type":"person","state":"perm"},{"name":"Vincent ALexandrine","type":"person","state":"perm"}, {"name":"Maéva Vignes","type":"person","state":"perm"}, {"name":"Abdel El Abed","type":"person","state":"perm"}, {"name":"Valérie Taly","type":"person","state":"perm"}, {"name":"Sébastien Dutreuil","type":"person","state":"perm"}, {"name":"Antoine BERGEL","type":"person","state":"perm"}, {"name":"Antoine Angot","type":"person","state":"perm"}, {"name":"Jérôme Feret","type":"person","state":"perm"}, {"name":"Charlène Gayrard","type":"person","state":"perm"}, {"name":"Hugo Jimenez Perez","type":"person","state":"perm"}, {"name":"Caterina Urban","type":"person","state":"perm"}, {"name":"Gaëlle Chevalon","type":"person","state":"perm"}, {"name":"Ian Marcus","type":"person","state":"perm"}, {"name":"Antoine TALY","type":"person","state":"perm"}, {"name":"Chantal LOTTON","type":"person","state":"perm"}, {"name":"Ana-Maria Lennon-Duménil","type":"person","state":"perm"}, {"name":"Frédérique Carlier-Grynkorn","type":"person","state":"perm"}, {"name":"Pascal Martin","type":"person","state":"perm"}, {"name":"Tamara Milosevic","type":"person","state":"perm"}, {"name":"Nicolas Carpi","type":"person","state":"perm"}, {"name":"Stéphane Daoudy","type":"person","state":"perm"}, {"name":"Danijela Matic Vignjevic","type":"person","state":"perm"}, {"name":"Eugenio Cinquemani","type":"person","state":"perm"}, {"name":"Vincent DAHIREL","type":"person","state":"perm"}, {"name":"Martin Lenz","type":"person","state":"perm"}, {"name":"Maïlys Chassagne","type":"person","state":"perm"}, {"name":"Anne Schmidt","type":"person","state":"perm"}, {"name":"Sophie Sacquin Mora","type":"person","state":"perm"}, {"name":"Richard-Emmanuel Eastes","type":"person","state":"perm"}, {"name":"Michel Morange","type":"person","state":"perm"}, {"name":"Ewa Zlotek-Zlotkiewicz","type":"person","state":"perm"}, {"name":"A.m.o.d.s.e.n C.h.o.t.i.a","type":"person","state":"perm"}, {"name":"Alexandre Vaugoux","type":"person","state":"perm"}, {"name":"Annemiek JM Cornelissen","type":"person","state":"perm"}, {"name":"Clément Nizak","type":"person","state":"perm"}, {"name":"Antoine Frenoy","type":"person","state":"perm"}, {"name":"Ariel B. Lindner","type":"person","state":"perm"}, {"name":"Benjamin Brogniart","type":"person","state":"perm"}, {"name":"Christophe Zimmer","type":"person","state":"perm"}, {"name":"Claire Ribrault","type":"person","state":"perm"}, {"name":"David Tareste","type":"person","state":"perm"}, {"name":"Denis Lafeuille","type":"person","state":"perm"}, {"name":"Dor Garbash","type":"person","state":"perm"}, {"name":"Dusan MISEVIC","type":"person","state":"perm"}, {"name":"Edda Nitschke","type":"person","state":"perm"}, {"name":"François Taddei","type":"person","state":"perm"}, {"name":"Gregory Batt","type":"person","state":"perm"}, {"name":"Jean Luc Lebrun","type":"person","state":"perm"}, {"name":"Jesse Himmelstein","type":"person","state":"perm"}, {"name":"Kevin Lhoste","type":"person","state":"perm"}, {"name":"Laura Ciriani","type":"person","state":"perm"}, {"name":"Livio Riboli-Sasco","type":"person","state":"perm"}, {"name":"Nathalie Sussfeld","type":"person","state":"perm"}, {"name":"Jake Edwin Wintermute","type":"person","state":"perm"}, {"name":"Marlyne Nogbou","type":"person","state":"perm"}, {"name":"Matthieu Piel","type":"person","state":"perm"}, {"name":"Pascal Hersen","type":"person","state":"perm"}, {"name":"Pierre-Yves Bourguignon","type":"person","state":"perm"}, {"name":"Timo Betz","type":"person","state":"perm"}, {"name":"Raphaël Goujet","type":"person","state":"perm"}, {"name":"Stéphane Debove","type":"person","state":"perm"}, {"name":"Vincent Danos","type":"person","state":"perm"}, {"name":"Tam Kien Duong","type":"person","state":"perm"}],
+ "links":[{"__src":"Jean- Christophe Thalabard","__dst":"Maéva Vignes","name":"works with"}],
+ "projects":[{"name":"Rhizi","type":"project","state":"perm"},{"name":"RedWire","type":"project","state":"perm"},{"name":"IdStorm","type":"project","state":"perm"},{"name":"Savanturiers","type":"project","state":"perm"},{"name":"Hero.coli","type":"project","state":"perm"}]
+}
diff --git a/src/client-tests/output/test_analyzer.js.stderr b/src/client-tests/output/test_analyzer.js.stderr
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/client-tests/output/test_analyzer.js.stderr
diff --git a/src/client-tests/output/test_analyzer.js.stdout b/src/client-tests/output/test_analyzer.js.stdout
new file mode 100644
index 00000000..7e15edcb
--- /dev/null
+++ b/src/client-tests/output/test_analyzer.js.stdout
@@ -0,0 +1,82 @@
+addScript: loaded ../src/external/require.js
+app: running under node
+addScript: loaded ../src/app.js
+test harness: starting script loading with requirejs
+test harness: main loaded
+Rhizi main started
+rhizi: init drag-n-drop
+analyzing #a hello there #b
+not same size: new/old 2 / 0; 1 / 0
+bug: temp node creation on finalize
+expected: a,b
+got: a|b
+expected: a,b,hello there
+got: a,b,hello there
+digraph {
+ a;
+ b;
+ a -> b [label=hello there];
+}
+analyzing #c and #d like #e
+not same size: new/old 3 / 0; 3 / 0
+bug: temp node creation on finalize
+expected: c,d,e
+got: c|d|e
+expected: c,e,like,d,e,like
+got: c,d,and,d,e,like,c,e,like
+digraph {
+ c;
+ d;
+ e;
+ c -> d [label=and];
+ d -> e [label=like];
+ c -> e [label=like];
+}
+analyzing #f and #g and #h are cool
+not same size: new/old 5 / 0; 3 / 0
+bug: temp node creation on finalize
+bug: temp node creation on finalize
+expected: f,g,h,f and g and h are cool
+got: f|g|h|f and g and h are cool
+expected: f,f and g and h are cool,,g,f and g and h are cool,,h,f and g and h are cool,
+got: f,f and g and h are cool,,g,f and g and h are cool,,h,f and g and h are cool,
+digraph {
+ f;
+ g;
+ h;
+ "f and g and h are cool";
+ f -> "f and g and h are cool" [label=];
+ g -> "f and g and h are cool" [label=];
+ h -> "f and g and h are cool" [label=];
+}
+analyzing #i likes #j and #k
+not same size: new/old 3 / 0; 3 / 0
+bug: temp node creation on finalize
+expected: i,j,k
+got: i|j|k
+expected: i,j,likes
+got: i,j,likes,j,k,and,i,k,likes
+digraph {
+ i;
+ j;
+ k;
+ i -> j [label=likes];
+ j -> k [label=and];
+ i -> k [label=likes];
+}
+analyzing #q likes #r but doesn't like #l
+not same size: new/old 4 / 0; 3 / 0
+bug: temp node creation on finalize
+expected: q,r,l
+got: q|r|l|q likes r but doesn't like l
+expected:
+got: q,q likes r but doesn't like l,,r,q likes r but doesn't like l,,l,q likes r but doesn't like l,
+digraph {
+ q;
+ r;
+ l;
+ "q likes r but doesn't like l";
+ q -> "q likes r but doesn't like l" [label=];
+ r -> "q likes r but doesn't like l" [label=];
+ l -> "q likes r but doesn't like l" [label=];
+}
diff --git a/src/client-tests/output/test_app.js.stderr b/src/client-tests/output/test_app.js.stderr
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/client-tests/output/test_app.js.stderr
diff --git a/src/client-tests/output/test_app.js.stdout b/src/client-tests/output/test_app.js.stdout
new file mode 100644
index 00000000..2d2c7940
--- /dev/null
+++ b/src/client-tests/output/test_app.js.stdout
@@ -0,0 +1 @@
+test_app: running under node
diff --git a/src/client-tests/output/test_globals.js.stderr b/src/client-tests/output/test_globals.js.stderr
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/client-tests/output/test_globals.js.stderr
diff --git a/src/client-tests/output/test_globals.js.stdout b/src/client-tests/output/test_globals.js.stdout
new file mode 100644
index 00000000..9aa7f822
--- /dev/null
+++ b/src/client-tests/output/test_globals.js.stdout
@@ -0,0 +1,11 @@
+before fields count: 187
+addScript: loaded ../src/external/require.js
+app: running under node
+addScript: loaded ../src/app.js
+test harness: starting script loading with requirejs
+test harness: main loaded
+Rhizi main started
+rhizi: init drag-n-drop
+after fields count: 195
+new fields count: 8
+requirejs,require,define,rhizi_require_config,$,jQuery,d3,saveAs
diff --git a/src/client-tests/output/test_require_js.js.stderr b/src/client-tests/output/test_require_js.js.stderr
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/client-tests/output/test_require_js.js.stderr
diff --git a/src/client-tests/output/test_require_js.js.stdout b/src/client-tests/output/test_require_js.js.stdout
new file mode 100644
index 00000000..82ea089e
--- /dev/null
+++ b/src/client-tests/output/test_require_js.js.stdout
@@ -0,0 +1,17 @@
+addScript: loaded ../src/external/require.js
+test_app: running under node
+addScript: loaded test_app.js
+callback after test_app.js loading
+{ paths:
+ { jquery: 'external/jquery',
+ 'jquery-ui': 'external/jquery-ui',
+ caret: 'external/caret',
+ d3: 'external/d3/d3',
+ autocomplete: 'external/autocomplete',
+ FileSaver: 'external/FileSaver' },
+ baseUrl: '../src/' }
+hello from test factory
+here we are after test_app prerequisites
+42
+Rhizi main started
+rhizi: init drag-n-drop
diff --git a/src/client-tests/output/test_script_jsdom.js.stderr b/src/client-tests/output/test_script_jsdom.js.stderr
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/client-tests/output/test_script_jsdom.js.stderr
diff --git a/src/client-tests/output/test_script_jsdom.js.stdout b/src/client-tests/output/test_script_jsdom.js.stdout
new file mode 100644
index 00000000..02b09a7b
--- /dev/null
+++ b/src/client-tests/output/test_script_jsdom.js.stdout
@@ -0,0 +1 @@
+{ foo: 'bar' }
diff --git a/src/client-tests/output/test_util.js.stderr b/src/client-tests/output/test_util.js.stderr
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/client-tests/output/test_util.js.stderr
diff --git a/src/client-tests/output/test_util.js.stdout b/src/client-tests/output/test_util.js.stdout
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/client-tests/output/test_util.js.stdout
diff --git a/src/client-tests/run_tests.js b/src/client-tests/run_tests.js
new file mode 100644
index 00000000..bfc129eb
--- /dev/null
+++ b/src/client-tests/run_tests.js
@@ -0,0 +1,31 @@
+var fs = require('fs');
+var spawn = require('child_process').spawn;
+
+var tests = fs.readdirSync('.').filter(function (x) { return /^test_.*\.js$/.test(x); });
+var i;
+var testname;
+
+function store_output(proc, args, stdout, stderr)
+{
+ var out = fs.openSync(stdout, 'w+');
+ var err = fs.openSync(stderr, 'w+');
+ var p = spawn(proc, args);
+
+ p.stdout.on('data', function (data) {
+ console.log(args + ' gives ' + data.length);
+ fs.appendFileSync(stdout, data);
+ });
+ p.stderr.on('data', function (data) {
+ console.log(args + ' gives ' + data.length + ' (err)');
+ fs.appendFileSync(stderr, data);
+ });
+ p.on('close', function (code, signal) {
+ console.log(proc + '(' + args.join(', ') + ') exited with ' + code);
+ });
+
+}
+
+for (i in tests) {
+ testname = tests[i];
+ store_output('/usr/bin/node', [__dirname + '/' + testname], 'output/' + testname + '.stdout', 'output/' + testname + '.stderr');
+}
diff --git a/src/client-tests/test2.js b/src/client-tests/test2.js
new file mode 100644
index 00000000..0f8db81f
--- /dev/null
+++ b/src/client-tests/test2.js
@@ -0,0 +1,4 @@
+define('test2', function() {
+ console.log('hello from test2 factory');
+ return {'me': 'not you'};
+});
diff --git a/src/client-tests/test_analyzer.js b/src/client-tests/test_analyzer.js
new file mode 100644
index 00000000..441f0dde
--- /dev/null
+++ b/src/client-tests/test_analyzer.js
@@ -0,0 +1,49 @@
+var base = require('./base');
+
+var data = [
+["#a hello there #b", ["a", "b"], [["a", "b", "hello there"]],
+["#a hello there2 #ba", ["a", "ba"], ["a", "ba", "hello there2"]]],
+["#c and #d like #e", ["c", "d", "e"], [["c", "e", "like"], ["d", "e", "like"]]],
+// issue 86
+["#f and #g and #h are cool", ["f", "g", "h", "f and g and h are cool"], [["f", "f and g and h are cool", ""], ["g", "f and g and h are cool", ""], ["h", "f and g and h are cool", ""]]],
+["#i likes #j and #k", ["i", "j", "k"], ["i", "j", "likes"], ["i", "k", "likes"]],
+["#q likes #r but doesn't like #l", ["q", "r", "l"], []],
+];
+/*
+#t and #u like #v
+#w #x #y
+sometimes #z and #ab aren't friends
+I like to work with #a
+*/
+
+base.run_tests({
+ done: function (errors, window) {
+ debugger;
+ var analyzeSentence = window.require('textanalysis.ui').analyzeSentence;
+ if (process.argv.length > 2) {
+ analyzeSentence(process.argv.slice(2).join(" "), true);
+ base.dump_graphviz(window.require('rz_core').force);
+ } else {
+ for (var k = 0; k < data.length; ++k) {
+ var sentence = data[k][0];
+ var expected_nodes = data[k][1];
+ var expected_links = data[k][2];
+ base.reset(window);
+ console.log('analyzing ' + sentence);
+ analyzeSentence(sentence, true);
+ var nodes = base.nodes(window);
+ var links = base.links(window);
+ if (nodes != expected_nodes) {
+ console.log('expected: ' + expected_nodes);
+ console.log('got: ' + nodes.join('|'));
+ }
+ if (links != expected_links) {
+ console.log('expected: ' + expected_links);
+ console.log('got: ' + links);
+ }
+ base.dump_graphviz(window.require('rz_core').force);
+ }
+ }
+ process.exit();
+ }
+});
diff --git a/src/client-tests/test_app.js b/src/client-tests/test_app.js
new file mode 100644
index 00000000..6696c1fc
--- /dev/null
+++ b/src/client-tests/test_app.js
@@ -0,0 +1,32 @@
+// mocks just to all run_tests to succeed
+if (typeof define == 'undefined') {
+ function define(mod, cb) {
+ }
+}
+if (typeof document == 'undefined') {
+ var document = {};
+}
+
+(function() {
+var config = {
+ //urlArgs: "bust=" + (new Date()).getTime(), // NOTE: useful for debugging
+ paths: {
+ jquery: 'external/jquery',
+ 'jquery-ui': 'external/jquery-ui',
+ caret: 'external/caret',
+ 'd3': 'external/d3/d3',
+ autocomplete: 'external/autocomplete',
+ FileSaver: 'external/FileSaver',
+ }
+}
+
+define('test', function() {
+ console.log('hello from test factory');
+ return {f:function(){console.log(42);}};
+});
+
+console.log('test_app: running under node');
+config.baseUrl = '../src/';
+
+document.config = config;
+}());
diff --git a/src/client-tests/test_globals.js b/src/client-tests/test_globals.js
new file mode 100644
index 00000000..03dd1cf9
--- /dev/null
+++ b/src/client-tests/test_globals.js
@@ -0,0 +1,30 @@
+var base = require('./base');
+var util = require('../src/util');
+
+var count;
+
+function object_length(obj) {
+ var count = 0;
+ for (var k in obj) {
+ count += 1;
+ }
+ return count;
+}
+
+var win_before;
+var win_after;
+
+base.run_tests({
+ created: function(errors, window) {
+ count = object_length(window);
+ console.log('before fields count: ' + count);
+ win_before = util.set_from_object(window);
+ },
+ done:function (errors, window) {
+ var new_count = object_length(window);
+ console.log('after fields count: ' + new_count);
+ console.log('new fields count: ' + (new_count - count));
+ win_after = util.set_from_object(window);
+ console.log(util.set_diff(win_after, win_before).a_b.join(','));
+ }
+});
diff --git a/src/client-tests/test_require_js.js b/src/client-tests/test_require_js.js
new file mode 100644
index 00000000..aa71018e
--- /dev/null
+++ b/src/client-tests/test_require_js.js
@@ -0,0 +1,25 @@
+var jsdom = require("jsdom").jsdom;
+var document = jsdom();
+var window = document.parentWindow;
+var addScript = require('./test_util').addScript;
+
+window.console.log = console.log;
+window.is_node = true;
+
+addScript(window, '../src/external/require.js')
+ .load_next('test_app.js')
+ .done(function () {
+ var config = document.config
+ var requirejs = window.requirejs;
+ var require = window.require;
+ console.log('callback after test_app.js loading');
+ console.log(config);
+ require.config(config);
+ requirejs(['require', 'test', './test2.js', 'main'], function(require, test, test2, main) {
+ console.log('here we are after test_app prerequisites');
+ debugger;
+ test.f();
+ main.main();
+ process.exit();
+ });
+ });
diff --git a/src/client-tests/test_script_jsdom.js b/src/client-tests/test_script_jsdom.js
new file mode 100644
index 00000000..1ae5835f
--- /dev/null
+++ b/src/client-tests/test_script_jsdom.js
@@ -0,0 +1,9 @@
+var jsdom = require("jsdom").jsdom;
+var window = jsdom().parentWindow;
+
+window.__myObject = { foo: "bar" };
+
+var scriptEl = window.document.createElement("script");
+scriptEl.src = "../tests/anotherScript.js";
+window.console.log = console.log;
+window.document.body.appendChild(scriptEl);
diff --git a/src/client-tests/test_util.js b/src/client-tests/test_util.js
new file mode 100644
index 00000000..7780b0ad
--- /dev/null
+++ b/src/client-tests/test_util.js
@@ -0,0 +1,44 @@
+function new_deffer() {
+ var deffer = {
+ cb: null,
+ call_cb: false,
+ };
+ deffer.done = function(cb) {
+ deffer.cb = cb;
+ if (deffer.call_cb) {
+ // warning: going down callstack - should probably use setInterval
+ deffer.call_cb = false; // first do this to avoid endless recursion
+ return deffer.cb();
+ }
+ };
+ deffer.on_done = function() {
+ if (this.cb) {
+ this.call_cb = false;
+ this.cb();
+ } else {
+ this.call_cb = true;
+ }
+ };
+ return deffer;
+}
+
+function addScript(window, name) {
+ var scriptEl = window.document.createElement("script");
+ scriptEl.src = name;
+ var deffer = new_deffer();
+ deffer.load_next = function(script) {
+ var sec_deffer = new_deffer();
+ addScript(window, script).done(
+ function() { sec_deffer.on_done(); })
+ return sec_deffer;
+ }
+ function onload_cb() {
+ console.log('addScript: loaded ' + name);
+ deffer.on_done();
+ }
+ scriptEl.onload = onload_cb;
+ window.document.body.appendChild(scriptEl);
+ return deffer;
+}
+
+exports.addScript = addScript;
diff --git a/src/client-tests/util/RhiziHTTPServer.py b/src/client-tests/util/RhiziHTTPServer.py
new file mode 100644
index 00000000..29e8980d
--- /dev/null
+++ b/src/client-tests/util/RhiziHTTPServer.py
@@ -0,0 +1,78 @@
+"""
+Inherits from python-2 SimpleHTTPServer (same bug exists in python3
+http.server) to fix issue where query argument is mistakenly treated as a
+improperly non slash terminated path.
+"""
+
+
+import os
+import BaseHTTPServer
+import SimpleHTTPServer
+
+try:
+ from cStringIO import StringIO
+except ImportError:
+ from StringIO import StringIO
+
+
+class MyHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
+
+ """
+ Fix lack of handling for query parameters in SimpleHTTPRequestHandler
+ """
+
+ def send_head(self):
+ """Common code for GET and HEAD commands.
+
+ This sends the response code and MIME headers.
+
+ Return value is either a file object (which has to be copied
+ to the outputfile by the caller unless the command was HEAD,
+ and must be closed by the caller under all circumstances), or
+ None, in which case the caller has nothing further to do.
+
+ """
+ path = self.translate_path(self.path)
+ f = None
+ if os.path.isdir(path):
+ if not path.endswith('/'):
+ # redirect browser - doing basically what apache does
+ self.send_response(301)
+ self.send_header("Location", self.path + "/")
+ self.end_headers()
+ return None
+ for index in "index.html", "index.htm":
+ index = os.path.join(path, index)
+ if os.path.exists(index):
+ path = index
+ break
+ else:
+ return self.list_directory(path)
+ ctype = self.guess_type(path)
+ try:
+ # Always read in binary mode. Opening files in text mode may cause
+ # newline translations, making the actual size of the content
+ # transmitted *less* than the content-length!
+ f = open(path, 'rb')
+ except IOError:
+ self.send_error(404, "File not found")
+ return None
+ try:
+ self.send_response(200)
+ self.send_header("Content-type", ctype)
+ fs = os.fstat(f.fileno())
+ self.send_header("Content-Length", str(fs[6]))
+ self.send_header("Last-Modified", self.date_time_string(fs.st_mtime))
+ self.end_headers()
+ return f
+ except:
+ f.close()
+ raise
+
+def test(HandlerClass = MyHTTPRequestHandler,
+ ServerClass = BaseHTTPServer.HTTPServer):
+ BaseHTTPServer.test(HandlerClass, ServerClass)
+
+
+if __name__ == '__main__':
+ test()
diff --git a/src/client-tests/weizmann.json b/src/client-tests/weizmann.json
new file mode 100644
index 00000000..fac5fe08
--- /dev/null
+++ b/src/client-tests/weizmann.json
@@ -0,0 +1 @@
+{"nodes":[{"id":"Oren","type":"person","state":"perm","start":0,"end":0,"status":"unknown"},{"id":"Hila","type":"person","state":"perm","start":0,"end":0,"status":"unknown"},{"id":"Yuval","type":"person","state":"perm","start":0,"end":0,"status":"unknown"},{"id":"Pareto Morphology","type":"project","state":"perm","start":0,"end":0,"status":"unknown"},{"id":"Avi","type":"person","state":"perm","start":0,"end":0,"status":"unknown"},{"id":"circuits","type":"project","state":"perm","start":0,"end":0,"status":"unknown"},{"id":"Pablo","type":"person","state":"perm","start":0,"end":0,"status":"unknown"},{"id":"FCD","type":"project","state":"perm","start":0,"end":0,"status":"unknown"},{"id":"animals","type":"project","state":"perm","start":0,"end":0,"status":"unknown"},{"id":"ParTI","type":"project","state":"perm","start":0,"end":0,"status":"unknown"},{"id":"genotypes","type":"project","state":"perm","start":0,"end":0,"status":"unknown"},{"id":"Miri","type":"person","state":"perm","start":0,"end":0,"status":"unknown"},{"id":"Jean","type":"person","state":"perm","start":0,"end":0,"status":"unknown"},{"id":"Physisist","type":"skill","state":"perm","start":0,"end":0,"status":"unknown"},{"id":"Chemist","type":"skill","state":"perm","start":0,"end":0,"status":"unknown"},{"id":"Mathematician","type":"skill","state":"perm","start":0,"end":0,"status":"unknown"}],"links":[{"__src":"Yuval","__dst":"Pareto Morphology","name":"work on "},{"__src":"Oren","__dst":"Pareto Morphology","name":"work on "},{"__src":"Oren","__dst":"Pareto Morphology","name":"work on "},{"__src":"Hila","__dst":"Pareto Morphology","name":"work on "},{"__src":"Hila","__dst":"Pareto Morphology","name":"work on "},{"__src":"Avi","__dst":"Pareto Morphology","name":"works on "},{"__src":"Avi","__dst":"Pareto Morphology","name":"works on "},{"__src":"Avi","__dst":"circuits","name":"works on "},{"__src":"Avi","__dst":"circuits","name":"works on "},{"__src":"Pablo","__dst":"circuits","name":"works on "},{"__src":"Pablo","__dst":"circuits","name":"works on "},{"__src":"Pablo","__dst":"FCD","name":"works on "},{"__src":"Pablo","__dst":"animals","name":"works on "},{"__src":"Pablo","__dst":"ParTI","name":"works on "},{"__src":"Avi","__dst":"circuits","name":"works on "},{"__src":"Avi","__dst":"circuits","name":"works on "},{"__src":"Avi","__dst":"FCD","name":"works on "},{"__src":"Avi","__dst":"animals","name":"works on "},{"__src":"Yuval","__dst":"ParTI","name":"works on "},{"__src":"Yuval","__dst":"ParTI","name":"works on "},{"__src":"Hila","__dst":"circuits","name":"works on "},{"__src":"Hila","__dst":"circuits","name":"works on "},{"__src":"Hila","__dst":"genotypes","name":"works on "},{"__src":"Miri","__dst":"FCD","name":"works on "},{"__src":"Miri","__dst":"FCD","name":"works on "},{"__src":"Hila","__dst":"ParTI","name":"wrote the code and consulted with the math in "},{"__src":"Hila","__dst":"ParTI","name":"wrote the code and consulted with the math in "},{"__src":"Avi","__dst":"ParTI","name":"prepared graphical interface to "},{"__src":"Avi","__dst":"ParTI","name":"prepared graphical interface to "},{"__src":"Jean","__dst":"ParTI","name":"helped with biological interpretations in the project "},{"__src":"Jean","__dst":"ParTI","name":"helped with biological interpretations in the project "},{"__src":"Pablo","__dst":"Physisist","name":"is a "},{"__src":"Physisist","__dst":"Chemist","name":" and a "},{"__src":"Pablo","__dst":"Physisist","name":"is a "},{"__src":"Pablo","__dst":"Chemist","name":"is a "},{"__src":"Yuval","__dst":"Physisist","name":"is a "},{"__src":"Physisist","__dst":"Mathematician","name":" and a "},{"__src":"Hila","__dst":"Physisist","name":"is a "},{"__src":"Hila","__dst":"Mathematician","name":"is a "},{"__src":"Yuval","__dst":"Physisist","name":"is a "},{"__src":"Yuval","__dst":"Mathematician","name":"is a "}]} \ No newline at end of file