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

Enable selenium tests on Travis #337

Merged
merged 23 commits into from
Sep 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2675f0b
CI: Enable selenium tests on Travis
aarranz Jun 24, 2018
d00b94d
CI: Install geckodriver when running selenium tests
aarranz Jun 24, 2018
e36b592
Update setup.py to require Django 1.9 as minimum
aarranz Jul 29, 2018
025751b
Enable postgres on the selenium tests
aarranz Jul 29, 2018
55061e4
Remove some selenium tests by implementing unittests
aarranz Jul 29, 2018
3b670fd
Fix endpoint ordering
aarranz Jul 30, 2018
3db6879
Improve test speed
aarranz Jul 30, 2018
9e456aa
Fix some problems on the gui_tutorial test
aarranz Jul 31, 2018
b7d8362
Update karma to v3
aarranz Aug 17, 2018
5cf207f
Update django_relative dependency
aarranz Sep 10, 2018
16cea65
Improve search indexes handling when passing selenium tests
aarranz Sep 10, 2018
02b04b5
Fix some problems entering WiringView contexts
aarranz Sep 10, 2018
e9c3366
Remove some selenium tests by implementing WirecloudCatalogue unittests
aarranz Sep 11, 2018
8ceabc9
Fix out of bounds problems in the component_dropped_out_of_bounds_sho…
aarranz Sep 11, 2018
816e76f
Move MessageWindowMenu to commons
aarranz Sep 11, 2018
60ae319
Improve Widget unit tests
aarranz Sep 12, 2018
a8c873d
Fix some problems using AlertWindowMenu
aarranz Sep 13, 2018
8e70356
Make get_current_view return none if wirecloud is in transition
aarranz Sep 13, 2018
096eaf9
Fix some problems in the wait_wirecloud_ready method
aarranz Sep 13, 2018
d4677a1
Fix problems selecting components on the wirecloud view (WiringViewTe…
aarranz Sep 13, 2018
9ce4e60
Reduce time spent passing local catalogue selenium tests
aarranz Sep 14, 2018
5f194d1
Selenium: Fix some races conditions
aarranz Sep 14, 2018
0a87bbb
CI: Use jasmine clock mocks in the Command Queue Spec to avoid some r…
aarranz Sep 17, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ matrix:
addons:
firefox: latest-esr
env: TEST_SUITE=js_unittests
- addons:
firefox: "60.0.2esr"
env:
- TEST_SUITE=selenium
- DJANGO_VERSION=1.11

install:
- . src/ci_scripts/travis_install.sh
Expand All @@ -34,10 +39,10 @@ before_script:
- . src/ci_scripts/travis_before_script.sh

script:
- src/ci_scripts/travis.sh sqlite3 django$DJANGO_VERSION unittest
- src/ci_scripts/travis.sh

after_success:
- . src/ci_scripts/travis_after_success.sh
- src/ci_scripts/travis_after_success.sh

branches:
only:
Expand Down
2 changes: 1 addition & 1 deletion docs/installation_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ step, as they will be installed throughout the documentation:**
- futures 2.1.3+ (only on python 2.7)
- selenium 3.4+
- pytz
- django_relatives
- django_relatives 0.3.x
- user-agents
- regex
- markdown
Expand Down
4 changes: 3 additions & 1 deletion src/GruntFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,12 @@ var WirecloudFiles = [
'wirecloud/platform/static/js/wirecloud/LogManager.js',
'wirecloud/commons/static/js/wirecloud/Task.js',
'wirecloud/commons/static/js/wirecloud/ui/Draggable.js',
'wirecloud/commons/static/js/wirecloud/ui/MACSearch.js',
'wirecloud/commons/static/js/wirecloud/ui/WindowMenu.js',
'wirecloud/commons/static/js/wirecloud/ui/AlertWindowMenu.js',
'wirecloud/commons/static/js/wirecloud/ui/MessageWindowMenu.js',
'wirecloud/catalogue/static/js/wirecloud/WirecloudCatalogue.js',
'wirecloud/catalogue/static/js/wirecloud/ui/ResourcePainter.js',
'wirecloud/platform/static/js/wirecloud/io.js',
'wirecloud/platform/static/js/wirecloud/LocalCatalogue.js',
'wirecloud/platform/static/js/wirecloud/PersistentVariableDef.js',
Expand All @@ -117,7 +120,6 @@ var WirecloudFiles = [
'wirecloud/platform/static/js/wirecloud/Wiring.js',
'wirecloud/platform/static/js/wirecloud/Workspace.js',
'wirecloud/platform/static/js/wirecloud/wiring/Operator.js',
'wirecloud/platform/static/js/wirecloud/ui/MessageWindowMenu.js',
'wirecloud/platform/static/js/wirecloud/ui/WiringEditor.js',
'wirecloud/platform/static/js/wirecloud/ui/WiringEditor/Endpoint.js',
'wirecloud/platform/static/js/wirecloud/wiring/KeywordSuggestion.js',
Expand Down
9 changes: 0 additions & 9 deletions src/ci_scripts/conf_scripts/postgres-local-prepare.sh

This file was deleted.

5 changes: 1 addition & 4 deletions src/ci_scripts/conf_scripts/postgres-prepare.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
export DB_USER=postgres
export DB_NAME=wirecloud_ci

pip install psycopg2

createdb -U postgres -h ${DB_HOST} -p ${DB_PORT} -O ${DB_USER} ${DB_NAME}
createdb -U postgres -h ${DB_HOST:-localhost} -p ${DB_PORT:-5432} -O ${DB_USER:-postgres} ${DB_NAME:-wirecloud}

cat ${WORKSPACE}/src/ci_scripts/templates/postgres-conf.template >> ${WC_INSTANCE_NAME}/settings.py
13 changes: 8 additions & 5 deletions src/ci_scripts/templates/postgres-conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import os

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ['DB_NAME'],
'USER': os.environ['DB_USER'],
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('DB_NAME', 'wirecloud'),
'USER': os.environ.get('DB_USER', 'postgres'),
'PASSWORD': '',
'HOST': os.environ.get('DB_HOST', ''),
'PORT': os.environ.get('DB_PORT', ''),
'HOST': os.environ.get('DB_HOST', 'localhost'),
'PORT': os.environ.get('DB_PORT', '5432'),
'TEST': {
'NAME': os.environ.get('DB_NAME', 'wirecloud'),
},
}
}
19 changes: 10 additions & 9 deletions src/ci_scripts/travis.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
#!/usr/bin/env bash

set -e

if [ "${TEST_SUITE}" == "js_unittests" ]; then
cd $TRAVIS_BUILD_DIR/src
grunt ci
exit
elif [ "${TEST_SUITE}" == "selenium" ]; then
FLAGS="postgres django${DJANGO_VERSION} firefox-local selenium"
else
FLAGS="sqlite3 django${DJANGO_VERSION} unittest"
fi


export WC_INSTANCE_NAME=test_instance
[ -n "${IP_ADDR}" ] || IP_ADDR="localhost"

WORKSPACE=${TRAVIS_BUILD_DIR}
PYTHON_VERSION=`python -c "import sys; print('%s.%s.%s' % sys.version_info[:3])"`
COVERAGE_CMD=coverage
RADON_CMD=radon

# Prepip scripts
for conf in $*
for conf in $FLAGS
do
file="${TRAVIS_BUILD_DIR}/src/ci_scripts/conf_scripts/${conf}-prepip.sh"
if [[ -x "$file" ]]
Expand All @@ -32,16 +37,13 @@ pip install ${TRAVIS_BUILD_DIR}/src/dist/wirecloud*.whl
# Install the required testing tools
pip install django-nose mock radon

DJANGO_VERSION=`django-admin.py --version`
DJANGO_VERSION="${DJANGO_VERSION%.*}"

# Create a WireCloud instance
~/virtualenv/python$PYTHON_VERSION/bin/wirecloud-admin startproject ${WC_INSTANCE_NAME}
wirecloud-admin startproject ${WC_INSTANCE_NAME}
cd ${WC_INSTANCE_NAME}

# And configure it
cat ${TRAVIS_BUILD_DIR}/src/ci_scripts/base_settings.py >> ${WC_INSTANCE_NAME}/settings.py
for conf in $*
for conf in $FLAGS
do
file="${TRAVIS_BUILD_DIR}/src/ci_scripts/conf_scripts/${conf}-prepare.sh"
if [[ -x "$file" ]]
Expand All @@ -51,10 +53,9 @@ do
done

python manage.py migrate --noinput
python manage.py collectstatic -v 0 --noinput
python manage.py collectstatic -v 0 -c --noinput

# Pass the tests
cd ${TRAVIS_BUILD_DIR}/src
DJANGO_LIVE_TEST_SERVER_ADDRESS="${IP_ADDR}:28081" # Used by Django 1.8-1.10
DJANGO_LIVE_TEST_SERVER_HOST="${IP_ADDR}" # Custom env variable used on Django 1.11
${COVERAGE_CMD} run -a --branch --source=wirecloud --omit="*/wirecloud/fp74caast/*,*/wirecloud/semanticwiring/*,*/wirecloud/guidebuilder/*,*/tests/*,*/tests.py" manage.py test --noinput --nologcapture -v 2 ${TESTS}
2 changes: 1 addition & 1 deletion src/ci_scripts/travis_before_script.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ "${TEST_SUITE}" == "js_unittests" ]; then
if [ "${TEST_SUITE}" == "js_unittests" ] || [ "${TEST_SUITE}" == "selenium" ]; then
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
sleep 3 # give xvfb some time to start
Expand Down
7 changes: 7 additions & 0 deletions src/ci_scripts/travis_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ if [ "${TEST_SUITE}" == "js_unittests" ]; then
else
pip install coveralls
fi

if [ "${TEST_SUITE}" == "selenium" ]; then
wget https://github.com/mozilla/geckodriver/releases/download/v0.20.1/geckodriver-v0.20.1-linux64.tar.gz
mkdir geckodriver
tar -xzf geckodriver-v0.20.1-linux64.tar.gz -C geckodriver
export PATH=$PATH:$PWD/geckodriver
fi
98 changes: 69 additions & 29 deletions src/js_tests/styledelements/CommandQueueSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@

describe("addCommand(command)", function () {

const realSetTimeout = setTimeout;
var queue, context, callback;

beforeEach(function () {
jasmine.clock().install();
context = {context: true};
callback = jasmine.createSpy('callback').and.callFake(function (context, command) {
if (command === "skip") {
Expand All @@ -86,6 +88,10 @@
queue = new CommandQueue(context, callback);
});

afterEach(() => {
jasmine.clock().uninstall();
});

it("ignore calls without a command parameter", function (done) {
var p = queue.addCommand();

Expand Down Expand Up @@ -124,42 +130,68 @@
expect(error).toEqual("reject");
done();
});
jasmine.clock().tick(200);
});

it("supports adding commands to empty queues", function (done) {
it("supports adding commands to empty queues", (done) => {
expect(queue.running).toBe(false);
queue.addCommand(1);
expect(queue.running).toBe(true);
setTimeout(function () {
jasmine.clock().tick(200);
jasmine.clock().uninstall();

setTimeout(() => {
expect(queue.running).toBe(false);
expect(callback.calls.count()).toBe(1);
expect(callback.calls.argsFor(0)).toEqual([context, 1]);
done();
}, 200);
}, 0);
});

it("supports adding several commands", function (done) {
var listener = jasmine.createSpy();
it("supports adding several commands", (done) => {
var listener1 = jasmine.createSpy();
var listener2 = jasmine.createSpy();
var listener3 = jasmine.createSpy();

expect(queue.running).toBe(false);
queue.addCommand(1);
queue.addCommand(2);
var p = queue.addCommand(3);
var p1 = queue.addCommand(1);
var p2 = queue.addCommand(2);
var p3 = queue.addCommand(3);

expect(p).toEqual(jasmine.any(Promise));
expect(p1).toEqual(jasmine.any(Promise));
expect(p2).toEqual(jasmine.any(Promise));
expect(p3).toEqual(jasmine.any(Promise));
expect(queue.running).toBe(true);

p.then(listener);

setTimeout(function () {
expect(queue.running).toBe(false);
expect(listener).toHaveBeenCalled();
expect(callback.calls.count()).toBe(3);
expect(callback.calls.argsFor(0)).toEqual([context, 1]);
expect(callback.calls.argsFor(1)).toEqual([context, 2]);
expect(callback.calls.argsFor(2)).toEqual([context, 3]);
done();
}, 620);
p1.then(listener1);
p2.then(listener2);
p3.then(listener3);

// Use realSetTimeout to allow promise resolution
// Wait resolution of command 1
jasmine.clock().tick(200);
realSetTimeout(() => {
expect(listener1).toHaveBeenCalled();
expect(listener2).not.toHaveBeenCalled();
jasmine.clock().tick(200);
// Wait resolution of command 2
realSetTimeout(() => {
expect(listener2).toHaveBeenCalled();
expect(listener3).not.toHaveBeenCalled();
jasmine.clock().tick(200);
// Wait resolution of command 3
realSetTimeout(() => {
expect(listener3).toHaveBeenCalled();

expect(queue.running).toBe(false);
expect(callback.calls.count()).toBe(3);
expect(callback.calls.argsFor(0)).toEqual([context, 1]);
expect(callback.calls.argsFor(1)).toEqual([context, 2]);
expect(callback.calls.argsFor(2)).toEqual([context, 3]);
done();
}, 0);
}, 0);
}, 0);
});

it("supports skiping a command", function (done) {
Expand All @@ -175,15 +207,23 @@

p.then(listener);

setTimeout(function () {
expect(queue.running).toBe(false);
expect(listener).toHaveBeenCalled();
expect(callback.calls.count()).toBe(3);
expect(callback.calls.argsFor(0)).toEqual([context, 1]);
expect(callback.calls.argsFor(1)).toEqual([context, "skip"]);
expect(callback.calls.argsFor(2)).toEqual([context, 3]);
done();
}, 620);
// Use realSetTimeout to allow promise resolution
// Wait resolution of command 1
jasmine.clock().tick(200);
realSetTimeout(() => {
// Command skip is immediately resolve
// Wait resolution of command 3
jasmine.clock().tick(200);
realSetTimeout(() => {
expect(queue.running).toBe(false);
expect(listener).toHaveBeenCalled();
expect(callback.calls.count()).toBe(3);
expect(callback.calls.argsFor(0)).toEqual([context, 1]);
expect(callback.calls.argsFor(1)).toEqual([context, "skip"]);
expect(callback.calls.argsFor(2)).toEqual([context, 3]);
done();
}, 0);
}, 0);
});

});
Expand Down
Loading