Added testing and auto-testing with selenium

pull/1/head
Caleb James DeLisle 9 years ago
parent b16e53505f
commit 2a0b3a007d

1
.gitignore vendored

@ -6,3 +6,4 @@ customization
*.db *.db
/customize/ /customize/
messages.log messages.log
.DS_Store

@ -0,0 +1,30 @@
'use strict';
const WebDriver = require("selenium-webdriver");
let driver;
if (process.env.SAUCE_USERNAME != undefined) {
driver = new WebDriver.Builder().usingServer(
'http://'+ process.env.SAUCE_USERNAME+':'+process.env.SAUCE_ACCESS_KEY+'@ondemand.saucelabs.com:80/wd/hub'
).withCapabilities({
"tunnel-identifier": process.env.TRAVIS_JOB_NUMBER,
"build": process.env.TRAVIS_BUILD_NUMBER,
"username": process.env.SAUCE_USERNAME,
"accessKey": process.env.SAUCE_ACCESS_KEY,
"browserName": "chrome"
}).build();
} else {
driver = new WebDriver.Builder().withCapabilities({ browserName: "chrome" }).build();
}
driver.get('http://localhost:3000/assert/');
const report = driver.wait(WebDriver.until.elementLocated(WebDriver.By.className("report")), 5000);
report.getAttribute("class").then(function (cls) {
driver.quit();
if (!cls) {
throw new Error("cls is null");
} else if (cls.indexOf("failure") !== -1) {
throw new Error("cls contains the word failure");
} else if (cls.indexOf("success") === -1) {
throw new Error("cls does not contain the word success");
}
});

@ -13,6 +13,7 @@
"selenium-webdriver": "^2.53.1" "selenium-webdriver": "^2.53.1"
}, },
"scripts": { "scripts": {
"lint": "jshint --config .jshintrc --exclude-path .jshintignore ." "lint": "jshint --config .jshintrc --exclude-path .jshintignore .",
"test": "node TestSelenium.js"
} }
} }

@ -25,7 +25,7 @@ To install:
npm install -g bower ## if necessary npm install -g bower ## if necessary
bower install bower install
## copy config.js.dist to config.js ## copy config.js.dist to config.js
cp config.js.dist config.js cp config.js.dist config.js
## modify configuration to use your own mongodb instance ## modify configuration to use your own mongodb instance
@ -67,6 +67,13 @@ rm -rf ./cryptpad.db
If you are using the mongodb adaptor, [drop the relevant collection](https://docs.mongodb.org/manual/reference/method/db.collection.drop/#db.collection.drop). If you are using the mongodb adaptor, [drop the relevant collection](https://docs.mongodb.org/manual/reference/method/db.collection.drop/#db.collection.drop).
## Testing
To test CryptPad, go to http://your.server:3000/assert/
You can use WebDriver to run this test automatically by running TestSelenium.js but you will need chromedriver installed.
If you use Mac, you can `brew install chromedriver`.
## Security ## Security
CryptPad is *private*, not *anonymous*. Privacy protects your data, anonymity protects you. CryptPad is *private*, not *anonymous*. Privacy protects your data, anonymity protects you.

Loading…
Cancel
Save