Added testing and auto-testing with selenium

This commit is contained in:
Caleb James DeLisle 2016-04-20 18:58:02 +02:00
parent b16e53505f
commit 2a0b3a007d
4 changed files with 41 additions and 2 deletions

1
.gitignore vendored
View File

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

30
TestSelenium.js Normal file
View File

@ -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");
}
});

View File

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

View File

@ -25,7 +25,7 @@ To install:
npm install -g bower ## if necessary
bower install
## copy config.js.dist to config.js
## copy config.js.dist to config.js
cp config.js.dist config.js
## 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).
## 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
CryptPad is *private*, not *anonymous*. Privacy protects your data, anonymity protects you.