diff --git a/.github/workflows/accessibility.yml b/.github/workflows/accessibility.yml index 11ac03ff8c..4e722f7a1e 100644 --- a/.github/workflows/accessibility.yml +++ b/.github/workflows/accessibility.yml @@ -28,7 +28,12 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 + with: + repository: knyghty/django-admin-demo + path: demo - name: Set up Python uses: actions/setup-python@v4 with: @@ -37,17 +42,15 @@ jobs: with: node-version: "16" - name: Install Requirements - run: python -m pip install . + run: pip install -r demo/requirements.txt - name: Cache Django uses: actions/cache@v3 with: path: Django/* key: Django - - name: Create dummy app - run: | - django-admin startproject allyapp - python allyapp/manage.py migrate + - name: Launch migrations + run: python demo/manage.py migrate - name: Install pa11y run: npm install -g pa11y - name: Run the project and pa11y - run: python allyapp/manage.py runserver & (sleep 10 && pa11y http://127.0.0.1:8000/ --runner axe) + run: python demo/manage.py runserver & (sleep 10 && pa11y http://127.0.0.1:8000/ --runner axe --include-warnings) diff --git a/.pa11y.json b/.pa11y.json deleted file mode 100644 index bbb5feec3d..0000000000 --- a/.pa11y.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "defaults": { - "timeout": 10000 - }, - "urls": [ - "http://127.0.0.1:8000/", - "http://127.0.0.1:8000/admin/" - ] -} \ No newline at end of file diff --git a/.pa11yci b/.pa11yci deleted file mode 100644 index bbb5feec3d..0000000000 --- a/.pa11yci +++ /dev/null @@ -1,9 +0,0 @@ -{ - "defaults": { - "timeout": 10000 - }, - "urls": [ - "http://127.0.0.1:8000/", - "http://127.0.0.1:8000/admin/" - ] -} \ No newline at end of file diff --git a/js_tests/admin/pa11y.test.js b/js_tests/admin/pa11y.test.js new file mode 100644 index 0000000000..bbd43f2e5c --- /dev/null +++ b/js_tests/admin/pa11y.test.js @@ -0,0 +1,46 @@ +// An example of executing some actions before Pa11y runs. +// This example logs in to a fictional site then waits +// until the account page has loaded before running Pa11y +'use strict'; + +const pa11y = require('../..'); + +runExample(); + +async function runExample() { + try { + + const options = { + actions: [ + 'set field #username to admin', + 'set field #password to correcthorsebatterystaple', + 'click element #submit', + 'wait for url to be http://127.0.0.1:8000/admin/' + ], + + log: { + debug: console.log, + error: console.error, + info: console.log + } + }; + + const results = await Promise.all([ + pa11y('http://127.0.0.1:8000/en/admin/', options), + pa11y('http://127.0.0.1:8000/en/admin/demo/artist/', options), + pa11y('http://127.0.0.1:8000/en/admin/demo/artist/7zX2wRWDKLiW2V5QlI4QXU/change/', options), + pa11y('http://127.0.0.1:8000/en/admin/demo/release/', options), + pa11y('http://127.0.0.1:8000/en/admin/demo/release/7xxg6PunBVeuTliClh4H5p/change/', options) + ]); + + + // Output the raw result object + results.forEach(result => { + console.log(result); + }) + + } catch (error) { + // Output an error if it occurred + console.error(error.message); + } +} diff --git a/pa11y.json b/pa11y.json new file mode 100644 index 0000000000..f0048e69a7 --- /dev/null +++ b/pa11y.json @@ -0,0 +1,14 @@ +{ + "defaults": { + "timeout": 10000 + }, + "urls": [ + "http://127.0.0.1:8000/", + "http://127.0.0.1:8000/admin/", + "http://127.0.0.1:8000/admin/demo/artist/", + "http://127.0.0.1:8000/admin/demo/artist/7zX2wRWDKLiW2V5QlI4QXU/change/", + "http://127.0.0.1:8000/admin/demo/release/", + "http://127.0.0.1:8000/admin/demo/release/7xxg6PunBVeuTliClh4H5p/change/" + + ] +} \ No newline at end of file