Skip to content

TagSpaces is an offline, open source, document manager with tagging support

adding support for ui testing framework nightmare

uggrocke79ef7dfbb1c
diff --git a/Makefile b/Makefile
new file mode 100644
index 000000000..282acc600
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,10 @@
+GREP ?=.
+
+test: node_modules
+ @rm -rf /tmp/nightmare
+ @node_modules/.bin/mocha --harmony --grep "$(GREP)"
+
+node_modules: package.json
+ @npm install
+
+.PHONY: test
\ No newline at end of file
diff --git a/package.json b/package.json
index 2f3a4714b..1e25ed5af 100644
--- a/package.json
+++ b/package.json
@@ -41,7 +41,12 @@
"grunt-jscs": "~1.1.0",
"grunt-jsdoc": "^0.5.7",
"grunt-mozilla-addon-sdk": "~0.3.2",
- "jsDAV": "~0.3.2"
+ "jsDAV": "~0.3.2",
+ "nightmare": "~2.2.0",
+ "chai": "~3.5.0",
+ "express": "^4.13.3",
+ "mocha-generators": "^1.2.0",
+ "mocha": "^2.3.0"
},
"private": true,
"scripts": {
@@ -49,6 +54,7 @@
"debug": "cd data && electron . --debug",
"webdav": "cd data && cd web && node webdavserver.js",
"firefoxdev": "cfx run -b ~/Apps/firefoxdev/firefox -p ../mozprofile",
- "firefox": "cfx run -p ../mozprofile --static-args='{ \"disableStrict\": true }'"
+ "firefox": "cfx run -p ../mozprofile --static-args='{ \"disableStrict\": true }'",
+ "test": "make test"
}
}
diff --git a/test/webdav-test.js b/test/webdav-test.js
new file mode 100644
index 000000000..b1cf8f6f9
--- /dev/null
+++ b/test/webdav-test.js
@@ -0,0 +1,43 @@
+var Nightmare = require('nightmare');
+var expect = require('chai').expect; // jshint ignore:line
+
+describe('test yahoo search results', function() {
+ it('should find the nightmare github link first', function*() {
+ var nightmare = Nightmare();
+ var link = yield nightmare
+ .goto('http://yahoo.com')
+ .type('input[title="Search"]', 'github nightmare')
+ .click('#UHSearchWeb')
+ .wait('#main')
+ .evaluate(function () {
+ return document.querySelector('#main .searchCenterMiddle li a').href
+ })
+ expect(link).to.equal('https://github.com/segmentio/nightmare');
+ });
+});
+
+
+describe('test webdav login', function() {
+ it('should find the nightmare github link first', function*() {
+ var nightmare = Nightmare();
+ var link = yield nightmare
+ .goto('http://demo:[email protected]:8000/index.html')
+ .wait('#main')
+ .evaluate(function () {
+ return true;
+ })
+ expect(link).to.equal(true);
+ });
+});
+
+describe('test the electron app', function() {
+ it('should find the nightmare github link first', function*() {
+ var nightmare = Nightmare();
+ var link = yield nightmare
+ .goto('file:///home/na/TagSpaces/repo/data/index.html')
+ .evaluate(function () {
+ return true;
+ })
+ expect(link).to.equal(1);
+ });
+});
\ No newline at end of file
diff --git a/testdev.js b/testdev.js
new file mode 100644
index 000000000..ada919f71
--- /dev/null
+++ b/testdev.js
@@ -0,0 +1,17 @@
+var Nightmare = require('nightmare');
+var nightmare = Nightmare({ show: true })
+
+nightmare
+ //.goto('http://demo:[email protected]:8000/index.html')
+ .goto('file:///home/na/TagSpaces/repo/data/index.html')
+ .type('input[title="Search"]', 'github nightmare')
+ .click('#UHSearchWeb')
+ .wait('#main')
+ .evaluate(function () {
+ return document.querySelector('#main .searchCenterMiddle li a').href
+ })
+ .then(function (result) {
+ console.log(result)
+ })
+
+nightmare.end()