From bc18e4f0f0268476c0217721161958ef4e640da9 Mon Sep 17 00:00:00 2001 From: Ian Ross Date: Mon, 22 Feb 2016 21:09:49 +0100 Subject: [PATCH 1/2] Functional testing * Move Webpack setup into development VM * Functional test support: Selenium + PhantomJS * Functional testing infrastructure: test runner and "pages" pattern * Functional tests for: login, registration, user profile editing * Functional tests on Travis See documentation at: - https://github.com/Cadasta/cadasta-platform/wiki/Running-functional-tests - https://github.com/Cadasta/cadasta-platform/wiki/Writing-functional-tests --- .gitignore | 5 + .travis.yml | 13 +- README.md | 6 +- Vagrantfile | 4 +- app/src/js/account/components/Login.jsx | 1 + app/src/js/account/components/Profile.jsx | 3 +- .../account/components/RegistrationForm.jsx | 1 + app/src/locale/gettext.po | 144 ++++++++--------- app/webpack.config.js | 8 + functional_tests/accounts/test_login.py | 56 +++++++ functional_tests/accounts/test_profile.py | 41 +++++ .../accounts/test_registration.py | 78 +++++++++ functional_tests/base.py | 150 ++++++++++++++++++ functional_tests/pages/Login.py | 38 +++++ functional_tests/pages/Profile.py | 42 +++++ functional_tests/pages/Registration.py | 80 ++++++++++ functional_tests/pages/base.py | 4 + functional_tests/run.py | 12 ++ .../roles/cadasta/application/tasks/main.yml | 21 ++- .../roles/cadasta/production/tasks/main.yml | 13 -- provision/roles/testing/tasks/main.yml | 18 +++ .../development/templates/nginx-development | 10 +- provision/vagrant.yml | 5 +- requirements/dev.txt | 1 + 24 files changed, 655 insertions(+), 99 deletions(-) create mode 100644 functional_tests/accounts/test_login.py create mode 100644 functional_tests/accounts/test_profile.py create mode 100644 functional_tests/accounts/test_registration.py create mode 100644 functional_tests/base.py create mode 100644 functional_tests/pages/Login.py create mode 100644 functional_tests/pages/Profile.py create mode 100644 functional_tests/pages/Registration.py create mode 100644 functional_tests/pages/base.py create mode 100755 functional_tests/run.py create mode 100644 provision/roles/testing/tasks/main.yml diff --git a/.gitignore b/.gitignore index fd3388955..efb5ab9da 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,8 @@ htmlcov # JS */dist/bundle.js node_modules/ +/.envrc +/.virtualenv/ + +ghostdriver.log +npm-debug.log diff --git a/.travis.yml b/.travis.yml index 37a9718af..cdb087cca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,13 @@ services: - postgresql addons: postgresql: "9.4" +# env: +# - DJANGO_LIVE_TEST_SERVER_ADDRESS=127.0.0.1:5000 +# before_install: +# - travis_retry sudo apt-get update +# - travis_retry sudo apt-get install phantomjs +# - sudo mkdir /var/log/django +# - sudo chmod 777 /var/log/django install: - pip install -r requirements/common.txt - pip install -r requirements/dev.txt @@ -23,4 +30,8 @@ script: - py.test cadasta --cov=cadasta --ds=config.settings.travis - cd app - npm run travis-test - - cd .. +# - npm start | tee /tmp/npm-start.log & +# - while ! grep 'bundle is now VALID' /tmp/npm-start.log; do sleep 1; done +# - sleep 2 +# - cd ../functional_tests +# - ./run.py --ds=config.settings.travis diff --git a/README.md b/README.md index e2ec463a4..21a81ea29 100644 --- a/README.md +++ b/README.md @@ -23,15 +23,17 @@ SSH into to the VM, activate the virtualenv and run the server: ``` vagrant ssh cd /vagrant/ -source env/bin/activate +source /opt/cadasta/env/bin/activate python cadasta/manage.py runserver ``` Open `http://localhost:5000/` in your browser, you should see a default Django page. +See the wiki ([here](https://github.com/Cadasta/cadasta-platform/wiki/Installation) and [here](https://github.com/Cadasta/cadasta-platform/wiki/Run-for-development)) for detailed instructions on installation and running the platform for development. + ## Run tests -From the repository's root run: +Within the development VM, from the `/vagrant` directory run: ``` py.test cadasta diff --git a/Vagrantfile b/Vagrantfile index c5831bdc6..f962852e3 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -22,7 +22,9 @@ Vagrant.configure(2) do |config| # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine. In the example below, # accessing "localhost:8080" will access port 80 on the guest machine. - config.vm.network "forwarded_port", guest: 8080, host: 5000 + config.vm.network "forwarded_port", guest: 5000, host: 5000 + config.vm.network "forwarded_port", guest: 3000, host: 3000 + config.vm.network "forwarded_port", guest: 8080, host: 8080 # Create a private network, which allows host-only access to the machine # using a specific IP. diff --git a/app/src/js/account/components/Login.jsx b/app/src/js/account/components/Login.jsx index 36a7a293f..2eddf895e 100644 --- a/app/src/js/account/components/Login.jsx +++ b/app/src/js/account/components/Login.jsx @@ -85,6 +85,7 @@ export class Login extends React.Component { />