Skip to content

Commit

Permalink
[tests] add casperjs test
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilledheart authored and lins05 committed Sep 5, 2014
1 parent 256de58 commit e8b9d2b
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ notification_email.sh
send_user_notifications.sh
shutdown.sh
cscope*
docs/_build/*
docs/_build/*
deps
tests/basic/seafile-data
36 changes: 36 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
language: python
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq valac uuid-dev libevent-dev libarchive-dev intltool re2c libjansson-dev libqt4-dev
- git clone --depth=1 --branch=release-2-11-3 https://bitbucket.org/tildeslash/libzdb.git deps/libzdb
- git clone --depth=1 --branch=master git://github.com/haiwen/libsearpc.git deps/libsearpc
- git clone --depth=1 --branch=master git://github.com/haiwen/ccnet.git deps/ccnet
- git clone --depth=1 --branch=master git://github.com/haiwen/seafile.git deps/seafile
# build libevhtp
- curl -L -o libevhtp.tar.gz https://github.com/ellzey/libevhtp/archive/1.2.9.tar.gz
- tar -xvf libevhtp.tar.gz -C deps
- cd deps/libevhtp-1.2.9 && cmake . && make -j8 && sudo make install && cd -
# build libzdb, required by ccnet/seafile
- cd deps/libzdb && ./bootstrap && ./configure --without-postgresql --without-mysql && make -j8 && sudo make install && cd -
# build libsearpc
- cd deps/libsearpc && ./autogen.sh && ./configure
- make -j8 && sudo make install && cd ../..
# build ccnet
- cd deps/ccnet && ./autogen.sh && ./configure --enable-client --enable-server
- make -j8 && sudo make install && cd ../..
# build seafile
- cd deps/seafile && ./autogen.sh && ./configure --disable-fuse --enable-server
- make -j8 && sudo make install && cd ../..
# install seahub deps
- pip install python-dateutil chardet six Image Django==1.5.8 Djblets==0.6.14 --allow-all-external --allow-unverified Djblets --allow-unverified PIL
# install phantomjs binary for linux x86_64
- curl -L -o /tmp/phantomjs.tar.bz2 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2
- tar -C /tmp -xf /tmp/phantomjs.tar.bz2
- sudo install -m 755 /tmp/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/bin/phantomjs
# ldconfig
- sudo ldconfig
script:
- ./tests/run-test.sh init
- ./tests/run-test.sh run
notifications:
email: false
11 changes: 11 additions & 0 deletions tests/basic/ccnet.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[General]
USER_NAME = server
ID = 8e4b13b49ca79f35732d9f44a0804940d985627c
NAME = server
SERVICE_URL = http://127.0.0.1:8000

[Network]
PORT = 10002

[Client]
PORT = 9999
27 changes: 27 additions & 0 deletions tests/basic/mykey.peer
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAuZFwgxkKQGaqYyFMxIUz1JHnZPaOgEQ+fX/jRVYbGMiHkSbX
K9X3XUHUGEjUt8b3zW6UZJGjgyV5S08YuaN0eE5z6Q6bnuWEhkTmgZgXaybc9Hiu
y2WAHpKj+qbXcmewE0WEys/Ov9AIe0TRXmvL6r1793VcLSzgb/aIQA2WFg97DfEA
hGAHo5BesKRfEEvXL6ZB9cGxXP9qIy0ObTvLXlOgbYchfV4rrXJk0u9xWjRyXABv
2Myv3fgxmGmTR+TAw2G5GCKeh9IoIuWVMGPyjSlERGMqQYymNz3NgyWFayyZ5HQS
tihCnflOGEiMHRkOwIczB16YZhan2YqKpsjHGwIBIwKCAQEArvbXzBBLfoyvR4XM
Cb9rYgXozOh3usQAZ7MYHM2HQ0C6VahHN/WgFhl+1RF4Gv1tTKoW4nqwHJEL9oxn
xPkzTNxBZrYAcT7NaKdc/diLG+LQVDdFuHWkrxyL+vUUR0vR5kjcSjGlrYmhmMvb
WQaNEIbFVwhA92TTnMPfjNmcI2wRKI1K9NEKDAMIPSwW/sgkls2h4KW3Y7DooJ0k
l0apjN/rlaR4ohZp6oMVifW8GFY43Xau+4dIrYTnvvSyvGvtB+8cWuhqqvWHRZdM
rFjgOJoZH5l0zxt2dYW2WFiqgT7xXsvu6L+nylXktEMxC33rehYdPrd427J409A6
caO5cwKBgQDyrBQ8UXu7cDAktiKTwH7+pA0wNyTvKsGYw0RcFILccpxty2r5gYhI
eLFPVyjoYxwauW6vX3cSAYLKR+2PlYvkPpEvBQIJbaurx++ejez/KxYD65ZeFTfs
Kb9A08hgMxCvJmnRvojhez1OZmmmWYPT57XeZXnCiNoyJWKA0mMNvwKBgQDDwn02
o5n7ugetXIlV1PiStVogPPTBobh9jsXooQFh4fB+lsrO082hapMlbVVNG1gLzvTY
V0oDM/AzdnC6feZlAEdM+IcruinVnMnbnhiwPVDInCJIhvmJ/XScvkTsgHwRiAss
Tlf8wH/uGXiaeVV/KMlkKRK6h54znTPq37/VpQKBgQDkziG1NuJgRTS05j3bxB/3
Z3omJV1Wh2YTsMtswuHIiVGpWWTcnrOyC2VZb2+2iVUDQR83oycfmwZJsYg27BYu
+SnNPzxvSiWEtTJiS00rGf7QfwoeMUNbAspEb+jPux5b/6WZ34hfkXRRO/02cagu
Mj3DDzhJtDtxG+8pAOEM9QKBgQC+KqWFiPv72UlJUpQKPJmzFpIQsD44cTbgXs7h
+32viwbhX0irqS4nxp2SEnAfBJ6sYqS05xSyp3uftOKJRxpTfJ0I8W1drYe5kP6a
1Bf7qUcpRzc/JAhaKWn3Wb9MJQrPM7MVGOfCVJmINgAhCCcrEa2xwX/oZnxsp1cB
a6RpIwKBgQDW15IebNwVOExTqtfh6UvIjMSrk9OoHDyjoPLI3eyPt3ujKdXFJ8qF
CWg9ianQyE5Y8vfDI+x1YRCOwq2WapeXzkSO8CzVFHgz5kFqJQolr4+o6wr5mLLC
+6iW9u81/X3bMAWshtNfsWbRSFLT1WNVTKRg+xO7YG/3wcyeIeqigA==
-----END RSA PRIVATE KEY-----
48 changes: 48 additions & 0 deletions tests/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
casper.test.begin('Add Library and remove library well', 7, function suite(test) {
//CSS3 selector since we running under phantomjs which is using WebKit inside
//document.querySelector

casper.start('http://127.0.0.1:8000/accounts/login', function() {
test.assertExists('form', 'login form is found');
this.fill('form', {
username: 'test@test.com',
password: 'testtest'
}, true);
});
casper.then(function() {
test.assertUrlMatch(/home\/my\/$/, 'redirect url is at home page');
this.click('#repo-create');
test.assertExists('form#repo-create-form', 'repo create form is found');
this.fill('form#repo-create-form', {
repo_name: 'Test Repo',
repo_desc: 'Test Desc'
}, false);
this.click('form#repo-create-form input.submit');
this.waitWhileVisible('form#repo-create-form');
this.reload();
});
casper.wait(500, function() {
});
casper.then(function() {
test.assertExists('table.repo-list tr:nth-child(2)');
test.assertSelectorHasText('table.repo-list tr:nth-child(2) td:nth-child(2) a', 'Test Repo');
this.mouse.move('table.repo-list tr:nth-child(2) td:last-child div');
this.captureSelector('table.png', 'table.repo-list');
//TODO fix this
//this.waitUntilVisible('table.repo-list tr:nth-child(2) td:last-child span:nth-child(2)');
this.click('table.repo-list tr:nth-child(2) td:last-child span:nth-child(2)');
test.assertExists('table.repo-list tr:nth-child(2) .op-confirm');
this.click('table.repo-list tr:nth-child(2) .op-confirm button.yes');
this.waitWhileVisible('table.repo-list tr:nth-child(2) .op-confirm');
this.reload();
});
casper.wait(500, function() {
});
casper.then(function() {
test.assertSelectorDoesntHaveText('table.repo-list tr:nth-child(2) td:nth-child(2) a', 'Test Repo');
});
casper.run(function() {
test.done();
});

});
24 changes: 24 additions & 0 deletions tests/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
casper.test.begin('Log in and out function well', 5, function suite(test) {

casper.start('http://127.0.0.1L:8000/accounts/login', function() {
test.assertExists('form', 'login form is found');
this.fill('form', {
username: 'test@test.com',
password: 'testtest'
}, true);
});
// redirect
casper.then(function() {
test.assertUrlMatch(/home\/my\/$/, 'redirect url is at home page');
test.assertNotVisible('#user-info-popup');
this.click('#my-info');
test.assertVisible('#user-info-popup');
this.click('a#logout');
});
// redirect
casper.run(function() {
test.assertUrlMatch(/accounts\/logout\/$/, 'redirect url is at logout page');
test.done();
});

});
59 changes: 59 additions & 0 deletions tests/run-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash
current_dir=$(pwd)
if [ ! -d "${current_dir}/tests/basic" ] ; then
current_dir="${current_dir}/.."
fi
if [ ! -d "${current_dir}/tests/basic" ] ; then
echo "Not found test data" && exit -1
fi

export CCNET_CONF_DIR="${current_dir}/tests/basic"
export SEAFILE_CONF_DIR="${current_dir}/tests/basic/seafile-data"
export PYTHONPATH="/usr/local/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages:${current_dir}/thirdpart:${PYTHONPATH}"
export PATH="${current_dir}/deps/casperjs/bin:${PATH}"
cd $current_dir
function init() {
seaf-server-init -d "${current_dir}/tests/basic/seafile-data" || exit -1
./manage.py syncdb

if [ ! -d "${current_dir}/deps/casperjs" ] ; then
curl -L -o /tmp/casperjs.tar.gz https://github.com/n1k0/casperjs/archive/1.1-beta3.tar.gz
tar -C /tmp -xzf /tmp/casperjs.tar.gz
mv /tmp/casperjs-1.1-beta3 ${current_dir}/deps/casperjs
fi
}
function seahub() {
ccnet-server -c "${current_dir}/tests/basic" &
seaf-server -c "${current_dir}/tests/basic" \
-d "${current_dir}/tests/basic/seafile-data" &
fileserver -c "${current_dir}/tests/basic" \
-d "${current_dir}/tests/basic/seafile-data" &
sleep 3
python -c "import ccnet; pool = ccnet.ClientPool('${CCNET_CONF_DIR}'); ccnet_threaded_rpc = ccnet.CcnetThreadedRpcClient(pool, req_pool=True); ccnet_threaded_rpc.add_emailuser('test@test.com', 'testtest', 1, 1);"

./manage.py runserver &
}
function run() {
pushd tests
casperjs test . || exit -1
popd
}
function stop_seahub() {
pkill python
pkill fileserver
pkill ccnet
}

case $1 in
"init")
init
;;
"run")
seahub
run
stop_seahub
;;
*)
run
;;
esac
Binary file added tests/table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e8b9d2b

Please sign in to comment.