1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

add test with demo

This commit is contained in:
Sarah Abderemane 2024-07-13 15:40:20 +02:00
parent bd69bd6ab6
commit 7e94800422
5 changed files with 70 additions and 25 deletions

View File

@ -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)

View File

@ -1,9 +0,0 @@
{
"defaults": {
"timeout": 10000
},
"urls": [
"http://127.0.0.1:8000/",
"http://127.0.0.1:8000/admin/"
]
}

View File

@ -1,9 +0,0 @@
{
"defaults": {
"timeout": 10000
},
"urls": [
"http://127.0.0.1:8000/",
"http://127.0.0.1:8000/admin/"
]
}

View File

@ -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);
}
}

14
pa11y.json Normal file
View File

@ -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/"
]
}