Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
* added accessibility tests for home page
Browse files Browse the repository at this point in the history
* added tox to run tests in py27 and py35
* modified circleci config to run a11y tests
  • Loading branch information
kimberlythegeek committed Oct 5, 2018
1 parent 2565abc commit e912480
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- ENABLE_COVERAGE: false
- NODE_ENV: dev
- CIRCLE_TEST_REPORTS: /home/circleci/test-reports
- GECKODRIVER: 0.23.0
# A machine executor is used here because of the OWASP ZAP step. When using
# a docker executor, all the run steps are executed in the primary
# container, so we cannot run zap-baseline.py. A CircleCI employee
Expand Down Expand Up @@ -78,13 +79,28 @@ jobs:
npm i -g get-firefox
get-firefox --branch nightly --platform linux --extract --target ~/
~/firefox/firefox -v
wget -O /tmp/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v$GECKODRIVER/geckodriver-v$GECKODRIVER-linux64.tar.gz
mkdir $HOME/geckodriver && tar xvf /tmp/geckodriver.tar.gz -C $HOME/geckodriver
export PATH=$HOME/geckodriver:$PATH
firefox --version
geckodriver --version
- run:
name: Run npm test
command: |
. "$NVM_DIR/nvm.sh"
nvm use 8.10.0
export PATH=~/firefox:$PATH
FIREFOX_CHANNEL=NIGHTLY MOZ_HEADLESS=1 npm test
- run:
name: Run Accessibility Tests
command: |
pip install -U pip
pip install tox
export PATH=~/firefox:$PATH
export PATH=$HOME/geckodriver:$PATH
FIREFOX_CHANNEL=NIGHTLY MOZ_HEADLESS=1
pyenv global system 3.5.2 2.7.12
tox
- run:
# run zap baseline against the server
# Only fail on error code 1, which indicates at least one FAIL was found.
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ cookie-jar.txt
.vscode
# Created by py.test:
/test/server/.cache
.pytest_cache
__pycache__
.tox
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
exclude = .venv,built,dist,node_modules
max-line-length = 120
# E402 module level import not at top of file (test files need to set up paths)
ignore=E402
# F403: * import, unable to detect undefined names
# W503: Line break before binary operator
ignore=E402,F403,W503
35 changes: 35 additions & 0 deletions test/accessibility/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import pytest

from pytest_axe.pytest_axe import PytestAxe as Axe
from selenium import webdriver

base_url = "https://screenshots.firefox.com/"
my_shots_button_locator = "myshots-button"


@pytest.fixture(scope="session", autouse=True)
def home_page():
profile = webdriver.FirefoxProfile()
profile.set_preference("security.csp.enable", False)
driver = webdriver.Firefox(firefox_profile=profile)
driver.get(base_url)

axe = Axe(driver)
axe.inject()

yield axe
driver.close()


def pytest_configure(config):
"""
Included rule ID of tests that are expected to fail as a key, with the
github issue number as a value (or any other desired info as
reason for failure), and pass to pytestconfig to generate the tests.
Example:
config.xfail_rules = {
"meta-viewport": "Reason: GitHub issue #245"
}
"""
config.xfail_rules = {}
4 changes: 4 additions & 0 deletions test/accessibility/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
flake8==3.5.0
pytest==3.8.2
axe-selenium-python==2.1.1
pytest-axe==1.1.1
13 changes: 13 additions & 0 deletions test/accessibility/test_accessibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pytest
from pytest_axe.parameterize_tests import * # NOQA


@pytest.mark.accessibility
def test_home_page_accessibility(rule, home_page):
"""Run accessibility audits on the home page of Screenshots."""
results = home_page.run_only(rule)
assert len(results) == 0, home_page.report(results)


# TODO: Configure test account setup to enable tests for My Shots page, and
# the single screenshot view.
15 changes: 15 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tox]
envlist = py2, py35, flake8
skipsdist = true

[testenv]
passenv = MOZ_HEADLESS
deps = -rtest/accessibility/requirements.txt
commands = pytest test/accessibility \
--driver Firefox \
-srx \
--axe \
--verbose

[testenv:flake8]
commands = flake8 test/accessibility

0 comments on commit e912480

Please sign in to comment.