Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added functional tests #55

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: node_js
node_js:
- '0.10'
env:
global:
- secure: e4GaB/OyaU5A5o1vXJtCFaFvzFYyCiCdPiiC0te35wyWJUej7PFWQzHDYXGeohNdP5NCc9vN8hSt27bwIj+OEMJWPFfyRRxg2IeBKNtGXjnW70TmHbSI5IT34xIMuWC009rLdvNOB/imxAXIP6f0ezQ7aTENr5RHT0J6a2nom60=
- secure: L9+pdp2QCIpHE0iz1XfKet4S4S7liFmOeCQGvBp8xDBQJxfCMg20MAkC0SagZ3/hVsWWp/vBhbfS1u+KV+GF/SfbB44WoMCjpQLsTkEeSyreHL3LzJ2SsyO7ccmGq1sSia3VDo/TvMhmXHRx2rvG3qBQNH6c6q04Xom2DMjmtYI=
services:
- mongodb
- redis-server
before_script:
- export NODE_CONFIG_DIR=$(pwd)/node_modules/mbc-common/config
- node server.js &
- sleep 30
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq imagemagick unzip
- sudo apt-get install -qq libavahi-compat-libdnssd-dev
- sudo apt-get build-dep libavahi-compat-libdnssd-dev
36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
export NODE_CONFIG_DIR ?= $(PWD)/node_modules/mbc-common/config

ifeq ($(shell getconf LONG_BIT), 64)
CHROMEDRIVER = chromedriver_linux64.zip
else
CHROMEDRIVER = chromedriver_linux32.zip
endif

all: update serve

mos: locale/es/LC_MESSAGES/messages.mo
Expand All @@ -26,4 +32,34 @@ serve_noweb:
serve_debug:
node --debug-brk server.js

sauce_connect: bin/Sauce-Connect.jar

bin/Sauce-Connect.jar:
@echo 'Downloading Sauce Connect...'
@curl -o bin/Sauce-Connect-latest.zip \
https://saucelabs.com/downloads/Sauce-Connect-3.0-r24.zip
@echo 'Done.'
@echo 'Unzipping Sauce Connect...'
@cd bin/; unzip Sauce-Connect-latest.zip; rm Sauce-Connect-latest.zip; cd -
@echo 'Done.'

bin/chromedriver:
@echo 'Downloading Chrome Driver $(CHROMEDRIVER)...'
@curl -o bin/$(CHROMEDRIVER) \
http://chromedriver.storage.googleapis.com/2.9/$(CHROMEDRIVER)
@echo 'Done.'
@echo 'Unzipping Chrome Driver...'
@cd bin/; unzip $(CHROMEDRIVER); rm $(CHROMEDRIVER); cd -
@echo 'Done.'

test_sauce:
@echo "Running funcional tests on saucelabs..."
@bin/run-sauce-test

test_local: bin/chromedriver
@echo "Running local funcional tests..."
@bin/run-local-test

test: sauce_connect test_sauce

.PHONY: npm serve serve_noweb serve_debug
27 changes: 27 additions & 0 deletions bin/run-local-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Start Local Chromedriver

CHROMEDRIVER=bin/chromedriver


if [ ! -f $CHROMEDRIVER ]
then
echo "$CHROMEDRIVER is missing"
echo "Abort."
exit 1
fi

echo "Starting Chrome Driver..."
./$CHROMEDRIVER &
PID=$!

echo "Testing..."
CHROMEDRIVER=1 node_modules/mocha/bin/mocha --timeout 20000 tests/func/gui.js
EXIT_STATUS=$?

echo -n "Killing Chrome Driver... "
kill $PID
echo "Done."

exit $EXIT_STATUS
56 changes: 56 additions & 0 deletions bin/run-sauce-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

# Start Sauce Connect
# This script requires the following two env variables:
# SAUCE_OPCODE_USERNAME
# SAUCE_OPCODE_ACCESS_KEY


SAUCE_BIN=bin/Sauce-Connect.jar


if [ -z "$SAUCE_OPCODE_USERNAME" ]
then
echo "SAUCE_OPCODE_USERNAME is unset"
echo "Abort."
exit 1
fi

if [ -z "$SAUCE_OPCODE_ACCESS_KEY" ]
then
echo "SAUCE_OPCODE_ACCESS_KEY is unset"
echo "Abort."
exit 1
fi

if [ ! -f $SAUCE_BIN ]
then
echo "$SAUCE_BIN is missing"
echo "Abort."
exit 1
fi

READY_FILE="/tmp/connect-ready-$RANDOM"

echo -n "Starting "
java -jar $SAUCE_BIN \
--readyfile $READY_FILE \
$SAUCE_OPCODE_USERNAME \
$SAUCE_OPCODE_ACCESS_KEY &
SAUCE_PID=$!

# Wait for Connect to be ready before exiting
while [ ! -f $READY_FILE ]; do
sleep .5
done
echo "Done."

echo "Testing..."
SAUCELABS=1 node_modules/mocha/bin/mocha --timeout 50000 tests/func/gui.js
EXIT_STATUS=$?

echo -n "Killing sauce connect... "
kill $SAUCE_PID
echo "Done."

exit $EXIT_STATUS
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
"knockback" : "0.17.x",
"knockout" : "2.2.x"
},
"devDependencies": {
"mocha": "1.12.x",
"chai": "1.9.0",
"wd": "0.2.10",
"colors": "~0.6.2"
},
"scripts": {
"test": "make test"
},
"license" : "agplv3",
"engines" : {
"node" : ">=0.8"
Expand Down
94 changes: 94 additions & 0 deletions tests/func/gui.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Using Sauce Connect: https://saucelabs.com/docs/connect

var webdriver = require('wd');
var expect = require('chai').expect;


describe('Test In-Out Video Editor', function() {

var browser;

before(function(done) {
if (process.env.CHROMEDRIVER) {
browser = webdriver.promiseChainRemote('http://localhost:9515');
}
else if (process.env.SAUCELABS) {
browser = webdriver.promiseChainRemote(
"localhost",
4445,
process.env.SAUCE_OPCODE_USERNAME,
process.env.SAUCE_OPCODE_ACCESS_KEY
);
}

browser.on('status', function(info) {
console.log(info);
});
browser.on('command', function(meth, path, data) {
console.log(' > ' + meth, path, data || '');
});

var options = {
browserName: 'chrome',
version: '31',
platform: 'Linux',
tags: ["mbc-etiquette"],
name: "MBC-Etiquette Tests Suite"
};

return browser
.init(options)
.get('http://localhost:3100/editor')
.nodeify(done);
});

after(function(done) {
return browser
.quit()
.nodeify(done);
});

describe('Check UI', function() {

it('Should see the correct title', function(done) {
browser
.title(function(err, title) {
expect(title).equals('MBC Webvfx Editor');
})
.nodeify(done);
});

it('Should create an object', function(done) {
setTimeout(function() {
browser
.elementById('objects')
.click()
.elementByXPath('//*[@id="objects"]/option[5]')
.click()
.eval('$(".webvfx-obj").length', function(err, value) {
expect(value).equals(1);
})
.nodeify(done);
}, 15000);
});

it('Should save a sketch', function(done) {
setTimeout(function() {
browser
.elementById('save-sketch')
.click()
.elementById('textkey')
.type('sketch-test')
.elementByClassName('submit')
.click()
.eval('$("#sketchs option").length', function(err, value) {
expect(value).equals(2);
})
.nodeify(done);
}, 15000);
});

});

})