diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bc0e6c70b268189df30a5bae46600f75abb902de..b40a30f6088eab233c8ac0d2b15eaeb94550f552 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -62,19 +62,26 @@ build_docker: --cache=true --cleanup -test_docker: +test_docker_selenium: stage: test_integrated image: - name: debian:buster-slim + name: registry.edugit.org/teckids/docker-images/python-pimped:master services: - name: postgres:12 alias: db - - name: memcached:latest + - name: memcached alias: memcached - name: registry.edugit.org/biscuit/biscuit-ng:${CI_COMMIT_REF_NAME} alias: app + before_script: + - apt-get -y update && eatmydata apt-get -y install chromium-driver + - eatmydata pip install selenium pytest-selenium + - adduser --disabled-password --gecos "Test User" testuser script: - - echo true + - sudo -u testuser eatmydata tox -e selenium + artifacts: + paths: + - screenshots/ deploy_demo-master: stage: deploy diff --git a/biscuit/core/tests/browser/test_selenium.py b/biscuit/core/tests/browser/test_selenium.py new file mode 100644 index 0000000000000000000000000000000000000000..1a665ae3f3e95e4af5913643b02fb2d9823d5b30 --- /dev/null +++ b/biscuit/core/tests/browser/test_selenium.py @@ -0,0 +1,17 @@ +import sys + +import pytest + +if '--driver' not in sys.argv: + pytest.skip('Selenium driver not configured', allow_module_level=True) + +@pytest.fixture +def chrome_options(chrome_options): + chrome_options.add_argument('--headless') + chrome_options.add_argument('--no-sandbox') + chrome_options.add_argument('--disable-dev-shm-usage') + return chrome_options + +def test_index(selenium): + selenium.get('http://app:8000/') + selenium.save_screenshot('screenshots/index.png') diff --git a/tox.ini b/tox.ini index defacd8dd0cd0f2a60820b8c881ecc512d804421..59ea1468c0a788dc80ed4df9f649fb99bc8abb72 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,18 @@ [tox] skipsdist = True +envlist = default -[testenv] +[testenv:default] whitelist_externals = poetry pytest skip_install = true -commands = pytest --pylama --cov=biscuit biscuit/core/ +commands = pytest -p no:selenium --pylama --cov=biscuit biscuit/core/ + +[testenv:selenium] +whitelist_externals = poetry + pytest +skip_install = true +commands = pytest --driver {env:SELENIUM_DRIVER:Chrome} biscuit/core/ [pylama] linters = pycodestyle,pyflakes,radon