From cf9e8a00b0d058a35f553a6133e446dbe0352a6e Mon Sep 17 00:00:00 2001 From: TimOsahenru Date: Fri, 21 Mar 2025 11:29:54 +0000 Subject: [PATCH 01/15] axe-playwright installed --- requirements.txt | 61 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/requirements.txt b/requirements.txt index bbcc2a8..eba6105 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,15 +1,46 @@ -# page-generation -gh-issues - -# linting -pre-commit -typer - -# Automation -rich - -# Testing -python-frontmatter -ephemeral_port_reserve -pytest-playwright -pytest-xprocess +anyio==4.9.0 +axe-playwright-python==0.1.4 +certifi==2025.1.31 +cfgv==3.4.0 +charset-normalizer==3.4.1 +click==8.1.8 +distlib==0.3.9 +ephemeral-port-reserve==1.1.4 +exceptiongroup==1.2.2 +filelock==3.18.0 +gh_issues==2024.10.2a4 +greenlet==3.1.1 +h11==0.14.0 +httpcore==1.0.7 +httpx==0.28.1 +identify==2.6.9 +idna==3.10 +iniconfig==2.1.0 +markdown-it-py==3.0.0 +mdurl==0.1.2 +nodeenv==1.9.1 +packaging==24.2 +platformdirs==4.3.7 +playwright==1.51.0 +pluggy==1.5.0 +pre_commit==4.2.0 +psutil==7.0.0 +pyee==12.1.1 +Pygments==2.19.1 +pytest==8.3.5 +pytest-base-url==2.1.0 +pytest-playwright==0.7.0 +pytest-xprocess==1.0.2 +python-frontmatter==1.1.0 +python-slugify==8.0.4 +PyYAML==6.0.2 +requests==2.32.3 +rich==13.9.4 +shellingham==1.5.4 +sniffio==1.3.1 +text-unidecode==1.3 +tomli==2.2.1 +typer==0.15.2 +typing_extensions==4.12.2 +urllib3==2.3.0 +virtualenv==20.29.3 From 4f75241d29e753cf013ce5b1c15fd6c95c005289 Mon Sep 17 00:00:00 2001 From: TimOsahenru Date: Fri, 21 Mar 2025 15:57:15 +0000 Subject: [PATCH 02/15] axe-core-python installed --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index eba6105..bf7059b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ anyio==4.9.0 +axe-core-python==0.1.0 axe-playwright-python==0.1.4 certifi==2025.1.31 cfgv==3.4.0 From 0469f1c295423a6ca444bbe3ec8e612f9c5eaa70 Mon Sep 17 00:00:00 2001 From: TimOsahenru Date: Fri, 21 Mar 2025 17:03:39 +0000 Subject: [PATCH 03/15] feat: add accessibility testing using axe-core-python - Integrated axe-core-python into existing test cases to check for accessibility violations --- tests/test.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/test.py b/tests/test.py index 3c068dc..abc2594 100644 --- a/tests/test.py +++ b/tests/test.py @@ -7,6 +7,9 @@ from playwright.sync_api import Page, expect, sync_playwright +from axe_core_python.sync_playwright import Axe + + @pytest.fixture(scope="module") def page_url(xprocess, url_port): """Returns the url of the live server""" @@ -42,6 +45,15 @@ class Starter(ProcessStarter): # Clean up the process xprocess.getinfo("page_url").terminate() +def test_accessibility(page_url: tuple[Page, str]): + """Run accessibility tests on the homepage""" + page, live_server_url = page_url + page.goto(f"{live_server_url}/") + + axe = Axe() + results = axe.run(page) + + assert len(results["violations"]) == 0, f"Accessibility violations found: {results['violations']}" def test_destination( loaded_route: str, @@ -79,6 +91,12 @@ def test_headers_in_language(page_url: tuple[Page, str], route: str) -> None: ] # urls start with the language if not en assert doc_lang == lang + axe = Axe() + results = axe.run(page) + + assert len(results["violations"]) == 0, f"Accessibility violations found: {results['violations']}" + + @pytest.mark.parametrize( "title, url", @@ -96,6 +114,12 @@ def test_bpdevs_title_en(page_url: tuple[Page, str], title: str, url: str) -> No page.goto(f"{live_server_url}{url}") expect(page).to_have_title(f"Black Python Devs | {title}") + axe = Axe() + results = axe.run(page) + + assert len(results["violations"]) == 0, f"Accessibility violations found: {results['violations']}" + + def test_mailto_bpdevs(page_url: tuple[Page, str]) -> None: page, live_server_url = page_url @@ -103,6 +127,12 @@ def test_mailto_bpdevs(page_url: tuple[Page, str]) -> None: mailto = page.get_by_role("link", name="email") expect(mailto).to_have_attribute("href", "mailto:contact@blackpythondevs.com") + axe = Axe() + results = axe.run(page) + + assert len(results["violations"]) == 0, f"Accessibility violations found: {results['violations']}" + + @pytest.mark.parametrize( "url", @@ -115,6 +145,12 @@ def test_page_description_in_index_and_blog(page_url: tuple[Page, str], url: str expect(page.locator("p.post-description").first).to_be_visible() expect(page.locator("p.post-description").first).not_to_be_empty() + axe = Axe() + results = axe.run(page) + + assert len(results["violations"]) == 0, f"Accessibility violations found: {results['violations']}" + + def stem_description( path: pathlib.Path, @@ -146,3 +182,9 @@ def test_page_blog_posts( page.locator('meta[name="description"]').get_attribute("content") == frontmatter["description"] ) + + axe = Axe() + results = axe.run(page) + + assert len(results["violations"]) == 0, f"Accessibility violations found: {results['violations']}" + From fd96163b99543db295ca83f09318f0ac40692195 Mon Sep 17 00:00:00 2001 From: TimOsahenru Date: Fri, 21 Mar 2025 17:34:19 +0000 Subject: [PATCH 04/15] feat: github actions workflow to test feature branches ensure accessibility testing --- .github/workflows/accessibility-tests.yml | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/accessibility-tests.yml diff --git a/.github/workflows/accessibility-tests.yml b/.github/workflows/accessibility-tests.yml new file mode 100644 index 0000000..34be516 --- /dev/null +++ b/.github/workflows/accessibility-tests.yml @@ -0,0 +1,35 @@ +name: Accessibility Tests + +on: + pull_request: + branches: + - gh-pages + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip + pip install -r requirements.txt + pip install axe-core-python pytest playwright axe-playwright-python + + - name: Install Playwright browsers + run: | + playwright install + + - name: Run accessibility tests + run: | + python3 -m pytest tests/ \ No newline at end of file From 993319575d84c57de5192441b4e64fefc29bd128 Mon Sep 17 00:00:00 2001 From: TimOsahenru Date: Fri, 21 Mar 2025 17:39:35 +0000 Subject: [PATCH 05/15] Linting test --- .github/workflows/accessibility-tests.yml | 4 +-- tests/test.py | 31 +++++++++++++++-------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.github/workflows/accessibility-tests.yml b/.github/workflows/accessibility-tests.yml index 34be516..7dcce71 100644 --- a/.github/workflows/accessibility-tests.yml +++ b/.github/workflows/accessibility-tests.yml @@ -18,7 +18,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: "3.10" - name: Install dependencies run: | @@ -32,4 +32,4 @@ jobs: - name: Run accessibility tests run: | - python3 -m pytest tests/ \ No newline at end of file + python3 -m pytest tests/ diff --git a/tests/test.py b/tests/test.py index abc2594..431a7ce 100644 --- a/tests/test.py +++ b/tests/test.py @@ -45,6 +45,7 @@ class Starter(ProcessStarter): # Clean up the process xprocess.getinfo("page_url").terminate() + def test_accessibility(page_url: tuple[Page, str]): """Run accessibility tests on the homepage""" page, live_server_url = page_url @@ -53,7 +54,10 @@ def test_accessibility(page_url: tuple[Page, str]): axe = Axe() results = axe.run(page) - assert len(results["violations"]) == 0, f"Accessibility violations found: {results['violations']}" + assert ( + len(results["violations"]) == 0 + ), f"Accessibility violations found: {results['violations']}" + def test_destination( loaded_route: str, @@ -94,8 +98,9 @@ def test_headers_in_language(page_url: tuple[Page, str], route: str) -> None: axe = Axe() results = axe.run(page) - assert len(results["violations"]) == 0, f"Accessibility violations found: {results['violations']}" - + assert ( + len(results["violations"]) == 0 + ), f"Accessibility violations found: {results['violations']}" @pytest.mark.parametrize( @@ -117,8 +122,9 @@ def test_bpdevs_title_en(page_url: tuple[Page, str], title: str, url: str) -> No axe = Axe() results = axe.run(page) - assert len(results["violations"]) == 0, f"Accessibility violations found: {results['violations']}" - + assert ( + len(results["violations"]) == 0 + ), f"Accessibility violations found: {results['violations']}" def test_mailto_bpdevs(page_url: tuple[Page, str]) -> None: @@ -130,8 +136,9 @@ def test_mailto_bpdevs(page_url: tuple[Page, str]) -> None: axe = Axe() results = axe.run(page) - assert len(results["violations"]) == 0, f"Accessibility violations found: {results['violations']}" - + assert ( + len(results["violations"]) == 0 + ), f"Accessibility violations found: {results['violations']}" @pytest.mark.parametrize( @@ -148,8 +155,9 @@ def test_page_description_in_index_and_blog(page_url: tuple[Page, str], url: str axe = Axe() results = axe.run(page) - assert len(results["violations"]) == 0, f"Accessibility violations found: {results['violations']}" - + assert ( + len(results["violations"]) == 0 + ), f"Accessibility violations found: {results['violations']}" def stem_description( @@ -186,5 +194,6 @@ def test_page_blog_posts( axe = Axe() results = axe.run(page) - assert len(results["violations"]) == 0, f"Accessibility violations found: {results['violations']}" - + assert ( + len(results["violations"]) == 0 + ), f"Accessibility violations found: {results['violations']}" From d9c67662de43dc7090f606e35474134df3a5127d Mon Sep 17 00:00:00 2001 From: TimOsahenru Date: Fri, 28 Mar 2025 14:54:07 +0000 Subject: [PATCH 06/15] Removed unwanted dependencies from requirement files --- requirements.txt | 62 +++++++++++++----------------------------------- 1 file changed, 16 insertions(+), 46 deletions(-) diff --git a/requirements.txt b/requirements.txt index bf7059b..70e8d03 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,47 +1,17 @@ -anyio==4.9.0 +# page-generation +gh-issues + +# linting +pre-commit +typer + +# Automation +rich + +# Testing +python-frontmatter +ephemeral_port_reserve +pytest-playwright +pytest-xprocess axe-core-python==0.1.0 -axe-playwright-python==0.1.4 -certifi==2025.1.31 -cfgv==3.4.0 -charset-normalizer==3.4.1 -click==8.1.8 -distlib==0.3.9 -ephemeral-port-reserve==1.1.4 -exceptiongroup==1.2.2 -filelock==3.18.0 -gh_issues==2024.10.2a4 -greenlet==3.1.1 -h11==0.14.0 -httpcore==1.0.7 -httpx==0.28.1 -identify==2.6.9 -idna==3.10 -iniconfig==2.1.0 -markdown-it-py==3.0.0 -mdurl==0.1.2 -nodeenv==1.9.1 -packaging==24.2 -platformdirs==4.3.7 -playwright==1.51.0 -pluggy==1.5.0 -pre_commit==4.2.0 -psutil==7.0.0 -pyee==12.1.1 -Pygments==2.19.1 -pytest==8.3.5 -pytest-base-url==2.1.0 -pytest-playwright==0.7.0 -pytest-xprocess==1.0.2 -python-frontmatter==1.1.0 -python-slugify==8.0.4 -PyYAML==6.0.2 -requests==2.32.3 -rich==13.9.4 -shellingham==1.5.4 -sniffio==1.3.1 -text-unidecode==1.3 -tomli==2.2.1 -typer==0.15.2 -typing_extensions==4.12.2 -urllib3==2.3.0 -virtualenv==20.29.3 +axe-playwright-python==0.1.4 \ No newline at end of file From 77d3cae1b0b111d6a44c100e1b7c78ea9fef9a2d Mon Sep 17 00:00:00 2001 From: TimOsahenru Date: Wed, 2 Apr 2025 17:15:15 +0000 Subject: [PATCH 07/15] fix WCAG 2.0 AA violations in iframe, image and nav --- _includes/header.html | 2 +- _includes/join_us.html | 15 ++++++++++++++- tests/test.py | 3 ++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/_includes/header.html b/_includes/header.html index 9ef0438..38e8924 100644 --- a/_includes/header.html +++ b/_includes/header.html @@ -1,7 +1,7 @@ {% assign t = site.data.locales[page.lang][page.lang] %}