This repository has been archived by the owner on Jan 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added accessibility tests for home page
* added tox to run tests in py27 and py35 * modified circleci config to run a11y tests
- Loading branch information
1 parent
2565abc
commit e912480
Showing
7 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,6 @@ cookie-jar.txt | |
.vscode | ||
# Created by py.test: | ||
/test/server/.cache | ||
.pytest_cache | ||
__pycache__ | ||
.tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |