From f1cbac11569f13eef28516eaf83b8a8ab9f90637 Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Thu, 17 Feb 2022 22:01:51 +0100 Subject: [PATCH 01/22] first test of pa11y --- .github/workflows/regression-test-pa11y.yml | 32 +++++ tests/a11y_pa11y.py | 134 ++++++++++---------- utils.py | 7 +- 3 files changed, 108 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/regression-test-pa11y.yml diff --git a/.github/workflows/regression-test-pa11y.yml b/.github/workflows/regression-test-pa11y.yml new file mode 100644 index 00000000..2f8de68e --- /dev/null +++ b/.github/workflows/regression-test-pa11y.yml @@ -0,0 +1,32 @@ +name: "Regression Test - Accessibility (Pa11y) Test" +on: + push: + paths-ignore: + - '**.md' +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v2 + if: ${{ success() }} + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax + architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified + - name: Setup dependencies using pip + run: pip install -r requirements.txt + if: ${{ success() }} + - name: Setup node + uses: actions/setup-node@v2 + - name: Setup Pa11y CI npm package + run: npm install -g pa11y-ci + - name: Setup config (using SAMPLE-config.py as config.py) + run: python .github/workflows/verify_result.py -c false + if: ${{ success() }} + - name: Accessibility (Pa11y) + run: | + python default.py -t 18 -r -u https://webperf.se/ -o .github/workflows/testresult-18.json + python .github/workflows/verify_result.py -t 18 + if: ${{ success() }} diff --git a/tests/a11y_pa11y.py b/tests/a11y_pa11y.py index 831ad136..400ff10d 100644 --- a/tests/a11y_pa11y.py +++ b/tests/a11y_pa11y.py @@ -1,75 +1,81 @@ # -*- coding: utf-8 -*- -#from urllib.parse import urlparse # https://docs.python.org/3/library/urllib.parse.html +# from urllib.parse import urlparse # https://docs.python.org/3/library/urllib.parse.html import subprocess import json from models import Rating +import config + +review_show_improvements_only = config.review_show_improvements_only + def run_test(_, langCode, url): - """ - - """ - - print(langCode, url) - - result = subprocess.run(['pa11y', '--reporter', 'json', url[0][1]], stdout=subprocess.PIPE) - - mod_results = result.stdout.decode("utf-8") - result_list = json.loads(mod_results) - num_errors = len(result_list) - return_dict = {} - - points = 0 - review_overall = '' - review = '' - - if num_errors == 0: - points = 5 - review_overall = '* Webbplatsen har inga uppenbara fel kring tillgänglighet!\n' - elif num_errors == 1: - points = 4 - review_overall = '* Webbplatsen kan bli mer tillgänglig, men är helt ok.\n' - elif num_errors > 8: - points = 1 - review_overall = '* Väldigt dålig tillgänglighet!\n' - elif num_errors >= 4: - points = 2 - review_overall = '* Dålig tillgänglighet.\n' - elif num_errors >= 2: - points = 3 - review_overall = '* Genomsnittlig tillgänglighet men kan bli bättre.\n' - - review += '* Antal tillgänglighetsproblem: {} st\n'.format(num_errors) - return_dict['antal_problem'] = num_errors - - if num_errors > 0: - review += '\nProblem:\n' - - i = 1 - old_error = '' - - for error in result_list: - err_mess = error.get('message').replace('This', 'A') - if err_mess != old_error: - old_error = err_mess - review += '* {0}\n'.format(err_mess) - key = error.get('code') #'{0}-{1}'.format(error.get('code'), i) - return_dict.update( { key : err_mess } ) - - i += 1 - - if i > 10: - review += '* Info: För många unika problem för att lista alla\n' - break - - rating = Rating(_) - rating.set_overall(points, review_overall) - rating.set_a11y(points, review) - - print(points, review, return_dict) - return (rating, return_dict) + """ + + """ + + print(langCode, url) + + result = subprocess.run( + ['pa11y', '--reporter', 'json', url[0][1]], stdout=subprocess.PIPE) + + mod_results = result.stdout.decode("utf-8") + result_list = json.loads(mod_results) + num_errors = len(result_list) + return_dict = {} + + points = 0 + review_overall = '' + review = '' + + if num_errors == 0: + points = 5 + review_overall = '* Webbplatsen har inga uppenbara fel kring tillgänglighet!\n' + elif num_errors == 1: + points = 4 + review_overall = '* Webbplatsen kan bli mer tillgänglig, men är helt ok.\n' + elif num_errors > 8: + points = 1 + review_overall = '* Väldigt dålig tillgänglighet!\n' + elif num_errors >= 4: + points = 2 + review_overall = '* Dålig tillgänglighet.\n' + elif num_errors >= 2: + points = 3 + review_overall = '* Genomsnittlig tillgänglighet men kan bli bättre.\n' + + review += '* Antal tillgänglighetsproblem: {} st\n'.format(num_errors) + return_dict['antal_problem'] = num_errors + + if num_errors > 0: + review += '\nProblem:\n' + + i = 1 + old_error = '' + + for error in result_list: + err_mess = error.get('message').replace('This', 'A') + if err_mess != old_error: + old_error = err_mess + review += '* {0}\n'.format(err_mess) + key = error.get('code') # '{0}-{1}'.format(error.get('code'), i) + return_dict.update({key: err_mess}) + + i += 1 + + if i > 10: + review += '* Info: För många unika problem för att lista alla\n' + break + + rating = Rating(_, review_show_improvements_only) + rating.set_overall(points, review_overall) + rating.set_a11y(points, review) + + print(points, review, return_dict) + return (rating, return_dict) + """ If file is executed on itself then call a definition, mostly for testing purposes """ if __name__ == '__main__': - print(run_test('sv', 'https://webperf.se')) \ No newline at end of file + print(run_test('sv', 'https://webperf.se')) diff --git a/utils.py b/utils.py index 4e9229f6..77a31e59 100644 --- a/utils.py +++ b/utils.py @@ -9,7 +9,7 @@ TEST_ALL = -1 (TEST_UNKNOWN_01, TEST_GOOGLE_LIGHTHOUSE, TEST_PAGE_NOT_FOUND, TEST_UNKNOWN_03, TEST_GOOGLE_LIGHTHOUSE_SEO, TEST_GOOGLE_LIGHTHOUSE_BEST_PRACTICE, TEST_HTML, TEST_CSS, TEST_GOOGLE_LIGHTHOUSE_PWA, TEST_STANDARD_FILES, - TEST_GOOGLE_LIGHTHOUSE_A11Y, TEST_UNKNOWN_11, TEST_UNKNOWN_12, TEST_UNKNOWN_13, TEST_UNKNOWN_14, TEST_SITESPEED, TEST_UNKNOWN_16, TEST_YELLOW_LAB_TOOLS, TEST_UNKNOWN_18, TEST_UNKNOWN_19, TEST_WEBBKOLL, TEST_HTTP, TEST_ENERGY_EFFICIENCY, TEST_TRACKING) = range(24) + TEST_GOOGLE_LIGHTHOUSE_A11Y, TEST_UNKNOWN_11, TEST_UNKNOWN_12, TEST_UNKNOWN_13, TEST_UNKNOWN_14, TEST_SITESPEED, TEST_UNKNOWN_16, TEST_YELLOW_LAB_TOOLS, TEST_PA11Y, TEST_UNKNOWN_19, TEST_WEBBKOLL, TEST_HTTP, TEST_ENERGY_EFFICIENCY, TEST_TRACKING) = range(24) def test(_, langCode, site, test_type=None, show_reviews=False,): @@ -47,6 +47,8 @@ def test(_, langCode, site, test_type=None, show_reviews=False,): from tests.performance_sitespeed_io import run_test elif test_type == TEST_YELLOW_LAB_TOOLS: from tests.frontend_quality_yellow_lab_tools import run_test + elif test_type == TEST_PA11Y: + from tests.a11y_pa11y import run_test elif test_type == TEST_HTTP: from tests.http_validator import run_test elif test_type == TEST_ENERGY_EFFICIENCY: @@ -128,6 +130,9 @@ def test_site(_, langCode, site, test_type=TEST_ALL, show_reviews=False): if (run_all_tests or test_type == TEST_YELLOW_LAB_TOOLS): tests.extend(test(_, langCode, site, test_type=TEST_YELLOW_LAB_TOOLS, show_reviews=show_reviews)) + if (run_all_tests or test_type == TEST_PA11Y): + tests.extend(test(_, + langCode, site, test_type=TEST_PA11Y, show_reviews=show_reviews)) if (run_all_tests or test_type == TEST_WEBBKOLL): tests.extend(test(_, langCode, site, test_type=TEST_WEBBKOLL, show_reviews=show_reviews)) From 9be33061a777f63ce045ced71ea3be0e1593ded2 Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Thu, 17 Feb 2022 22:07:30 +0100 Subject: [PATCH 02/22] added text and flag to allow running pa11y --- default.py | 3 ++- locales/en/LC_MESSAGES/webperf-core.po | 3 +++ locales/sv/LC_MESSAGES/webperf-core.po | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/default.py b/default.py index d0e55b28..d3fdbe5b 100644 --- a/default.py +++ b/default.py @@ -9,7 +9,7 @@ def validate_test_type(test_type): - if test_type != utils.TEST_HTML and test_type != utils.TEST_PAGE_NOT_FOUND and test_type != utils.TEST_CSS and test_type != utils.TEST_WEBBKOLL and test_type != utils.TEST_GOOGLE_LIGHTHOUSE and test_type != utils.TEST_GOOGLE_LIGHTHOUSE_PWA and test_type != utils.TEST_GOOGLE_LIGHTHOUSE_A11Y and test_type != utils.TEST_GOOGLE_LIGHTHOUSE_SEO and test_type != utils.TEST_GOOGLE_LIGHTHOUSE_BEST_PRACTICE and test_type != utils.TEST_STANDARD_FILES and test_type != utils.TEST_YELLOW_LAB_TOOLS and test_type != utils.TEST_HTTP and test_type != utils.TEST_ENERGY_EFFICIENCY and test_type != utils.TEST_TRACKING and test_type != utils.TEST_SITESPEED: + if test_type != utils.TEST_HTML and test_type != utils.TEST_PAGE_NOT_FOUND and test_type != utils.TEST_CSS and test_type != utils.TEST_WEBBKOLL and test_type != utils.TEST_GOOGLE_LIGHTHOUSE and test_type != utils.TEST_GOOGLE_LIGHTHOUSE_PWA and test_type != utils.TEST_GOOGLE_LIGHTHOUSE_A11Y and test_type != utils.TEST_GOOGLE_LIGHTHOUSE_SEO and test_type != utils.TEST_GOOGLE_LIGHTHOUSE_BEST_PRACTICE and test_type != utils.TEST_STANDARD_FILES and test_type != utils.TEST_YELLOW_LAB_TOOLS and test_type != utils.TEST_PA11Y and test_type != utils.TEST_HTTP and test_type != utils.TEST_ENERGY_EFFICIENCY and test_type != utils.TEST_TRACKING and test_type != utils.TEST_SITESPEED: print(_('TEXT_TEST_VALID_ARGUMENTS')) print(_('TEXT_TEST_VALID_ARGUMENTS_GOOGLE_LIGHTHOUSE')) print(_('TEXT_TEST_VALID_ARGUMENTS_PAGE_NOT_FOUND')) @@ -22,6 +22,7 @@ def validate_test_type(test_type): print(_('TEXT_TEST_VALID_ARGUMENTS_GOOGLE_LIGHTHOUSE_A11Y')) print(_('TEXT_TEST_VALID_ARGUMENTS_SITESPEED')) print(_('TEXT_TEST_VALID_ARGUMENTS_YELLOW_LAB_TOOLS')) + print(_('TEXT_TEST_VALID_ARGUMENTS_PA11Y')) print(_('TEXT_TEST_VALID_ARGUMENTS_WEBBKOLL')) print(_('TEXT_TEST_VALID_ARGUMENTS_HTTP')) print(_('TEXT_TEST_VALID_ARGUMENTS_ENERGY_EFFICIENCY')) diff --git a/locales/en/LC_MESSAGES/webperf-core.po b/locales/en/LC_MESSAGES/webperf-core.po index 8b98d9e2..d7abad52 100644 --- a/locales/en/LC_MESSAGES/webperf-core.po +++ b/locales/en/LC_MESSAGES/webperf-core.po @@ -81,6 +81,9 @@ msgstr "-t 5\t: Best Practice (Google Lighthouse)" msgid "TEXT_TEST_VALID_ARGUMENTS_YELLOW_LAB_TOOLS" msgstr "-t 17\t: Quality on frontend (Yellow Lab Tools)" +msgid "TEXT_TEST_VALID_ARGUMENTS_PA11Y" +msgstr "-t 18\t: Accessibility (Pa11y)" + #: default.py:133 msgid "TEXT_TEST_VALID_ARGUMENTS_PAGE_NOT_FOUND" msgstr "-t 2\t: 404 (Page not Found)" diff --git a/locales/sv/LC_MESSAGES/webperf-core.po b/locales/sv/LC_MESSAGES/webperf-core.po index 49be9bde..4120938b 100644 --- a/locales/sv/LC_MESSAGES/webperf-core.po +++ b/locales/sv/LC_MESSAGES/webperf-core.po @@ -72,6 +72,9 @@ msgstr "-t 5\t: God praxis (Google Lighthouse)" msgid "TEXT_TEST_VALID_ARGUMENTS_YELLOW_LAB_TOOLS" msgstr "-t 17\t: Kvalitet på frontend (Yellow Lab Tools)" +msgid "TEXT_TEST_VALID_ARGUMENTS_PA11Y" +msgstr "-t 18\t: Tillgänglighet (Pa11y)" + msgid "TEXT_TEST_VALID_ARGUMENTS_PAGE_NOT_FOUND" msgstr "-t 2\t: 404 (sida finns inte)" From 7eaf55069ff7596c473c4d4010351446c17cad3c Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Thu, 17 Feb 2022 22:19:52 +0100 Subject: [PATCH 03/22] debug msg --- tests/a11y_pa11y.py | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/tests/a11y_pa11y.py b/tests/a11y_pa11y.py index 400ff10d..4f7cb0a3 100644 --- a/tests/a11y_pa11y.py +++ b/tests/a11y_pa11y.py @@ -15,12 +15,50 @@ def run_test(_, langCode, url): print(langCode, url) - result = subprocess.run( - ['pa11y', '--reporter', 'json', url[0][1]], stdout=subprocess.PIPE) + import subprocess + + print('A') + + bashCommand = "pa11y --reporter json {0}".format(url) + + print('B') + + process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE) + + print('C') + + output, error = process.communicate() + + print('D') + + result = str(output) + + print('E') + + error_result = str(error) + + print('F') + + print('result:', result) + print('error_result:', error_result) + + # result = subprocess.run( + # ['pa11y', '--reporter', 'json', url[0][1]], stdout=subprocess.PIPE) + + print('G') mod_results = result.stdout.decode("utf-8") + + print('H') + result_list = json.loads(mod_results) + + print('I') + num_errors = len(result_list) + + print('J') + return_dict = {} points = 0 From 91302911a098920e146c298de4fd99f2ca5c1609 Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Thu, 17 Feb 2022 22:22:18 +0100 Subject: [PATCH 04/22] test --- tests/a11y_pa11y.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/a11y_pa11y.py b/tests/a11y_pa11y.py index 4f7cb0a3..4bc413b3 100644 --- a/tests/a11y_pa11y.py +++ b/tests/a11y_pa11y.py @@ -19,7 +19,7 @@ def run_test(_, langCode, url): print('A') - bashCommand = "pa11y --reporter json {0}".format(url) + bashCommand = "pa11y-ci --reporter json {0}".format(url) print('B') From 20511f2167ab217a27b37b1093769f8ee9cbd6bd Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Fri, 18 Feb 2022 07:10:16 +0100 Subject: [PATCH 05/22] test --- tests/a11y_pa11y.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/a11y_pa11y.py b/tests/a11y_pa11y.py index 4bc413b3..28e37f69 100644 --- a/tests/a11y_pa11y.py +++ b/tests/a11y_pa11y.py @@ -47,7 +47,7 @@ def run_test(_, langCode, url): print('G') - mod_results = result.stdout.decode("utf-8") + mod_results = result.decode("utf-8") print('H') From 3fc0f901da2798ab3b0cd5cddbfeb34365ec4327 Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Fri, 18 Feb 2022 07:13:39 +0100 Subject: [PATCH 06/22] changed parsing --- tests/a11y_pa11y.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/a11y_pa11y.py b/tests/a11y_pa11y.py index 28e37f69..50e99bf9 100644 --- a/tests/a11y_pa11y.py +++ b/tests/a11y_pa11y.py @@ -47,11 +47,16 @@ def run_test(_, langCode, url): print('G') - mod_results = result.decode("utf-8") + # mod_results = result.decode("utf-8") print('H') - result_list = json.loads(mod_results) + # result_list = json.loads(mod_results) + json_result = json.loads(result) + + result_list = list() + if 'results' in json_result: + result_list = json_result['results'] print('I') From 5d71723779f8bc0774c75ed43fae12c333351a82 Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Fri, 18 Feb 2022 19:32:37 +0100 Subject: [PATCH 07/22] test --- tests/a11y_pa11y.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/a11y_pa11y.py b/tests/a11y_pa11y.py index 50e99bf9..ddd7c7c2 100644 --- a/tests/a11y_pa11y.py +++ b/tests/a11y_pa11y.py @@ -54,15 +54,21 @@ def run_test(_, langCode, url): # result_list = json.loads(mod_results) json_result = json.loads(result) + print('I.1', json_result) + + json_result = json.loads(output) + + print('I.2', json_result) + result_list = list() if 'results' in json_result: result_list = json_result['results'] - print('I') + print('J') num_errors = len(result_list) - print('J') + print('K') return_dict = {} From cae41f58ab8b2009f2c69e6d99e78b4a107d4f7d Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Fri, 18 Feb 2022 19:34:04 +0100 Subject: [PATCH 08/22] test --- tests/a11y_pa11y.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/a11y_pa11y.py b/tests/a11y_pa11y.py index ddd7c7c2..b557b214 100644 --- a/tests/a11y_pa11y.py +++ b/tests/a11y_pa11y.py @@ -52,7 +52,7 @@ def run_test(_, langCode, url): print('H') # result_list = json.loads(mod_results) - json_result = json.loads(result) + # json_result = json.loads(result) print('I.1', json_result) From bb2f43708e1c08826be0c52ee69caf6486850b88 Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Fri, 18 Feb 2022 19:41:35 +0100 Subject: [PATCH 09/22] test --- tests/a11y_pa11y.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/a11y_pa11y.py b/tests/a11y_pa11y.py index b557b214..646a7213 100644 --- a/tests/a11y_pa11y.py +++ b/tests/a11y_pa11y.py @@ -54,7 +54,7 @@ def run_test(_, langCode, url): # result_list = json.loads(mod_results) # json_result = json.loads(result) - print('I.1', json_result) + #print('I.1', json_result) json_result = json.loads(output) From d0402147d269d466cd96736c9293c3dfd1cf7d61 Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Fri, 18 Feb 2022 19:55:44 +0100 Subject: [PATCH 10/22] try to find website with errors --- .github/workflows/regression-test-pa11y.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/regression-test-pa11y.yml b/.github/workflows/regression-test-pa11y.yml index 2f8de68e..5e205f81 100644 --- a/.github/workflows/regression-test-pa11y.yml +++ b/.github/workflows/regression-test-pa11y.yml @@ -30,3 +30,20 @@ jobs: python default.py -t 18 -r -u https://webperf.se/ -o .github/workflows/testresult-18.json python .github/workflows/verify_result.py -t 18 if: ${{ success() }} + - name: Accessibility (Pa11y) + run: | + python default.py -t 18 -r -u https://feber.se/ -o .github/workflows/testresult-18.json + python .github/workflows/verify_result.py -t 18 + if: ${{ always() }} + - name: Accessibility (Pa11y) + run: | + python default.py -t 18 -r -u https://aftonbladet.se/ -o .github/workflows/testresult-18.json + python .github/workflows/verify_result.py -t 18 + if: ${{ always() }} + - name: Accessibility (Pa11y) + run: | + python default.py -t 18 -r -u https://www.linkedin.se/ -o .github/workflows/testresult-18.json + python .github/workflows/verify_result.py -t 18 + if: ${{ always() }} + + From 4084139e790d2ff9bfa6cef3145ac377e4f332e4 Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Fri, 18 Feb 2022 20:09:11 +0100 Subject: [PATCH 11/22] cleanup and testing with sites with a11y errors --- .github/workflows/regression-test-pa11y.yml | 9 +-- tests/a11y_pa11y.py | 70 ++++++--------------- 2 files changed, 21 insertions(+), 58 deletions(-) diff --git a/.github/workflows/regression-test-pa11y.yml b/.github/workflows/regression-test-pa11y.yml index 5e205f81..e3c22766 100644 --- a/.github/workflows/regression-test-pa11y.yml +++ b/.github/workflows/regression-test-pa11y.yml @@ -39,11 +39,4 @@ jobs: run: | python default.py -t 18 -r -u https://aftonbladet.se/ -o .github/workflows/testresult-18.json python .github/workflows/verify_result.py -t 18 - if: ${{ always() }} - - name: Accessibility (Pa11y) - run: | - python default.py -t 18 -r -u https://www.linkedin.se/ -o .github/workflows/testresult-18.json - python .github/workflows/verify_result.py -t 18 - if: ${{ always() }} - - + if: ${{ always() }} \ No newline at end of file diff --git a/tests/a11y_pa11y.py b/tests/a11y_pa11y.py index 646a7213..88a86dfb 100644 --- a/tests/a11y_pa11y.py +++ b/tests/a11y_pa11y.py @@ -16,59 +16,20 @@ def run_test(_, langCode, url): print(langCode, url) import subprocess - - print('A') - bashCommand = "pa11y-ci --reporter json {0}".format(url) - - print('B') - process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE) - - print('C') - output, error = process.communicate() - print('D') - - result = str(output) - - print('E') - - error_result = str(error) - - print('F') - - print('result:', result) - print('error_result:', error_result) - - # result = subprocess.run( - # ['pa11y', '--reporter', 'json', url[0][1]], stdout=subprocess.PIPE) - - print('G') - - # mod_results = result.decode("utf-8") - - print('H') - - # result_list = json.loads(mod_results) - # json_result = json.loads(result) - - #print('I.1', json_result) - json_result = json.loads(output) - print('I.2', json_result) - result_list = list() if 'results' in json_result: result_list = json_result['results'] - print('J') + num_errors = 0 - num_errors = len(result_list) - - print('K') + if 'errors' in json_result: + num_errors = json_result['errors'] return_dict = {} @@ -101,13 +62,20 @@ def run_test(_, langCode, url): i = 1 old_error = '' - for error in result_list: - err_mess = error.get('message').replace('This', 'A') - if err_mess != old_error: - old_error = err_mess - review += '* {0}\n'.format(err_mess) - key = error.get('code') # '{0}-{1}'.format(error.get('code'), i) - return_dict.update({key: err_mess}) + errors = list() + if url in result_list: + errors = result_list[url] + + for error in errors: + if 'message' in error: + err_mess = error['message'].replace('This', 'A') + if err_mess != old_error: + old_error = err_mess + review += '- {0}\n'.format(err_mess) + if 'code' in error: + # '{0}-{1}'.format(error.get('code'), i) + key = error['code'] + return_dict.update({key: err_mess}) i += 1 @@ -117,7 +85,9 @@ def run_test(_, langCode, url): rating = Rating(_, review_show_improvements_only) rating.set_overall(points, review_overall) - rating.set_a11y(points, review) + rating.set_a11y(points) + + rating.a11y_review = rating.a11y_review + review print(points, review, return_dict) return (rating, return_dict) From a9ed3a1ff860eb7d37d6b497cf9cdf055869886a Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Fri, 18 Feb 2022 20:18:01 +0100 Subject: [PATCH 12/22] removed some print and changed text formating --- tests/a11y_pa11y.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/tests/a11y_pa11y.py b/tests/a11y_pa11y.py index 88a86dfb..e3a8761f 100644 --- a/tests/a11y_pa11y.py +++ b/tests/a11y_pa11y.py @@ -13,8 +13,6 @@ def run_test(_, langCode, url): """ - print(langCode, url) - import subprocess bashCommand = "pa11y-ci --reporter json {0}".format(url) process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE) @@ -39,21 +37,21 @@ def run_test(_, langCode, url): if num_errors == 0: points = 5 - review_overall = '* Webbplatsen har inga uppenbara fel kring tillgänglighet!\n' + review_overall = '- Webbplatsen har inga uppenbara fel kring tillgänglighet!\n' elif num_errors == 1: points = 4 - review_overall = '* Webbplatsen kan bli mer tillgänglig, men är helt ok.\n' + review_overall = '- Webbplatsen kan bli mer tillgänglig, men är helt ok.\n' elif num_errors > 8: points = 1 - review_overall = '* Väldigt dålig tillgänglighet!\n' + review_overall = '- Väldigt dålig tillgänglighet!\n' elif num_errors >= 4: points = 2 - review_overall = '* Dålig tillgänglighet.\n' + review_overall = '- Dålig tillgänglighet.\n' elif num_errors >= 2: points = 3 - review_overall = '* Genomsnittlig tillgänglighet men kan bli bättre.\n' + review_overall = '- Genomsnittlig tillgänglighet men kan bli bättre.\n' - review += '* Antal tillgänglighetsproblem: {} st\n'.format(num_errors) + review += '- Antal tillgänglighetsproblem: {} st\n'.format(num_errors) return_dict['antal_problem'] = num_errors if num_errors > 0: @@ -80,7 +78,7 @@ def run_test(_, langCode, url): i += 1 if i > 10: - review += '* Info: För många unika problem för att lista alla\n' + review += '- Info: För många unika problem för att lista alla\n' break rating = Rating(_, review_show_improvements_only) @@ -89,7 +87,6 @@ def run_test(_, langCode, url): rating.a11y_review = rating.a11y_review + review - print(points, review, return_dict) return (rating, return_dict) From e3ff54e84b1d41af6e2713fe5a8b634e72d0f93a Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Fri, 18 Feb 2022 20:24:48 +0100 Subject: [PATCH 13/22] to cleanup review, can't we just show unique errors? --- tests/a11y_pa11y.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/a11y_pa11y.py b/tests/a11y_pa11y.py index e3a8761f..e85712f3 100644 --- a/tests/a11y_pa11y.py +++ b/tests/a11y_pa11y.py @@ -60,6 +60,8 @@ def run_test(_, langCode, url): i = 1 old_error = '' + error_types = set() + errors = list() if url in result_list: errors = result_list[url] @@ -69,7 +71,9 @@ def run_test(_, langCode, url): err_mess = error['message'].replace('This', 'A') if err_mess != old_error: old_error = err_mess - review += '- {0}\n'.format(err_mess) + error_review = '- {0}\n'.format(err_mess) + error_types.add(error_review) + review += error_review if 'code' in error: # '{0}-{1}'.format(error.get('code'), i) key = error['code'] @@ -81,6 +85,8 @@ def run_test(_, langCode, url): review += '- Info: För många unika problem för att lista alla\n' break + print('error_types:', error_types) + rating = Rating(_, review_show_improvements_only) rating.set_overall(points, review_overall) rating.set_a11y(points) From 78c0da4b092e7561c594d45e2966893cb5f1ee4f Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Fri, 18 Feb 2022 20:30:22 +0100 Subject: [PATCH 14/22] show only unique errors in review --- tests/a11y_pa11y.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/tests/a11y_pa11y.py b/tests/a11y_pa11y.py index e85712f3..53e31d3b 100644 --- a/tests/a11y_pa11y.py +++ b/tests/a11y_pa11y.py @@ -57,10 +57,7 @@ def run_test(_, langCode, url): if num_errors > 0: review += '\nProblem:\n' - i = 1 - old_error = '' - - error_types = set() + unique_errors = set() errors = list() if url in result_list: @@ -69,24 +66,21 @@ def run_test(_, langCode, url): for error in errors: if 'message' in error: err_mess = error['message'].replace('This', 'A') - if err_mess != old_error: - old_error = err_mess - error_review = '- {0}\n'.format(err_mess) - error_types.add(error_review) - review += error_review - if 'code' in error: - # '{0}-{1}'.format(error.get('code'), i) - key = error['code'] - return_dict.update({key: err_mess}) - - i += 1 + error_review = '- {0}\n'.format(err_mess) + unique_errors.add(error_review) + if 'code' in error: + # '{0}-{1}'.format(error.get('code'), i) + key = error['code'] + return_dict.update({key: err_mess}) + i = 1 + for error in unique_errors: + review += error + i += 1 if i > 10: review += '- Info: För många unika problem för att lista alla\n' break - print('error_types:', error_types) - rating = Rating(_, review_show_improvements_only) rating.set_overall(points, review_overall) rating.set_a11y(points) From f37e65ba71574a64912cc73d8671332eae953f4a Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Fri, 18 Feb 2022 20:41:01 +0100 Subject: [PATCH 15/22] some review restructuring --- tests/a11y_pa11y.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/a11y_pa11y.py b/tests/a11y_pa11y.py index 53e31d3b..018334c4 100644 --- a/tests/a11y_pa11y.py +++ b/tests/a11y_pa11y.py @@ -33,6 +33,7 @@ def run_test(_, langCode, url): points = 0 review_overall = '' + review_a11y = '' review = '' if num_errors == 0: @@ -51,12 +52,10 @@ def run_test(_, langCode, url): points = 3 review_overall = '- Genomsnittlig tillgänglighet men kan bli bättre.\n' - review += '- Antal tillgänglighetsproblem: {} st\n'.format(num_errors) + review_a11y = '- Antal tillgänglighetsproblem: {} st\n'.format(num_errors) + # review += '- Antal tillgänglighetsproblem: {} st\n'.format(num_errors) return_dict['antal_problem'] = num_errors - if num_errors > 0: - review += '\nProblem:\n' - unique_errors = set() errors = list() @@ -74,6 +73,10 @@ def run_test(_, langCode, url): return_dict.update({key: err_mess}) i = 1 + + if len(unique_errors) > 0: + review += '\nProblem:\n' + for error in unique_errors: review += error i += 1 @@ -83,7 +86,7 @@ def run_test(_, langCode, url): rating = Rating(_, review_show_improvements_only) rating.set_overall(points, review_overall) - rating.set_a11y(points) + rating.set_a11y(points, review_a11y) rating.a11y_review = rating.a11y_review + review From 9b2d46d4db270bd0ca82daf7a58dac6d38f88e6a Mon Sep 17 00:00:00 2001 From: Mattias Date: Fri, 18 Feb 2022 20:47:26 +0100 Subject: [PATCH 16/22] changed some text for pa11y --- locales/en/LC_MESSAGES/a11y_pa11y.mo | Bin 1140 -> 1141 bytes locales/en/LC_MESSAGES/a11y_pa11y.po | 18 +++++++++--------- locales/sv/LC_MESSAGES/a11y_pa11y.mo | Bin 1126 -> 1127 bytes locales/sv/LC_MESSAGES/a11y_pa11y.po | 18 +++++++++--------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/locales/en/LC_MESSAGES/a11y_pa11y.mo b/locales/en/LC_MESSAGES/a11y_pa11y.mo index eb1974c645b69ce872a8e6808ea7e3de001ba3c3..70badd3d176d5e1dc5a1797315745ce35072cfb4 100644 GIT binary patch delta 127 zcmeyu@s(pjjIApp14A$ndoeID%w%F@;Kw29}KLpZFK$@3@ zfk6dG2W*@v!^m!=Yha{nXfb&YqdZ?pNoHcPf=zBBm@)Yg`KNd9r+ix70 delta 136 zcmey$@r7eTjIA9b14A$ndowUFOk!eSumaNefV4f3mSkpNXaUlZKw1YR4y2udG&c(a zg9?!L-#Al-k=;<&z)aW3aPl5TdG?~@(qaXh+{rH)e=%}Re#~SABxRZH!KCEmQs!(R R>jAS4kmO-;29o|PY5;SX8m#~T diff --git a/locales/en/LC_MESSAGES/a11y_pa11y.po b/locales/en/LC_MESSAGES/a11y_pa11y.po index ddcb6212..80b0e9a2 100644 --- a/locales/en/LC_MESSAGES/a11y_pa11y.po +++ b/locales/en/LC_MESSAGES/a11y_pa11y.po @@ -1,13 +1,13 @@ # English -# Copyright (C) 2020 WebPerf +# Copyright (C) 2022 WebPerf # FIRST AUTHOR , 2020. # msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "POT-Creation-Date: 2020-12-12 10:45+0200\n" -"PO-Revision-Date: 2021-06-21 17:15+0200\n" -"Last-Translator: Marcus \n" +"PO-Revision-Date: 2022-02-18 17:15+0200\n" +"Last-Translator: Mattias \n" "Language-Team: English \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -18,19 +18,19 @@ msgid "TEXT_RUNNING_TEST" msgstr "## Test: 18 - Accessibility (Pa11y)\n" msgid "TEXT_REVIEW_A11Y_VERY_GOOD" -msgstr "- The website do not have any apparent issues with accessibility!!\n" +msgstr "- The website do not have any apparent issues with accessibility!!" msgid "TEXT_REVIEW_A11Y_IS_GOOD" -msgstr "- The website can be more accessible, but is rather good!\n" +msgstr "- The website can be more accessible, but is rather good!" msgid "TEXT_REVIEW_A11Y_IS_OK" -msgstr "- The accessibility is about average, but needs to get better.\n" +msgstr "- The accessibility is about average, but needs to get better." msgid "TEXT_REVIEW_A11Y_IS_BAD" -msgstr "- The website is quite bad at accessibility and sucks for disabled people!\n" +msgstr "- The website is quite bad at accessibility and sucks for disabled people!" msgid "TEXT_REVIEW_A11Y_IS_VERY_BAD" -msgstr "- The accessibility is apparently really bad! Probably both for disabled people and everyone of us when we need some accessibility!\n" +msgstr "- The accessibility is apparently really bad! Probably both for disabled people and everyone of us when we need some accessibility!" msgid "TEXT_REVIEW_A11Y_NUMBER_OF_PROBLEMS" -msgstr "- Number of problems with accessibility: {}\n" \ No newline at end of file +msgstr "- Number of problems with accessibility: {}" \ No newline at end of file diff --git a/locales/sv/LC_MESSAGES/a11y_pa11y.mo b/locales/sv/LC_MESSAGES/a11y_pa11y.mo index 12397795939bb120d197edb1123cde0dcdd8c0c3..1f28fe59117cbcdbaddc6bb1fe0476701e2d6688 100644 GIT binary patch delta 128 zcmaFH@tk8qjIApp14A$n2Qe@(%w%F9e4 zRs+%w8)wQevK#3d80i{XOy0vN&sS2CnOLk~lbZ-;Y<|SZ#5nmWll5dp=D^9t%*vCe PGwVz~!dyAojzt3i@TnZ1 delta 133 zcmaFP@r+|ajIA9b14A$fGcYhrVq##h2GY-fbRdvcVrF1a2GS)!S_eqa0MeB}`Y4cA z1Jd>zXUZ_L8|oUE=^7bM-oq%*UX)x~tYDM7`6VM0BO}-3*G$$xQjIwfNR~4z1Iby; PIzaLmb0v_pXVCxv7O5HN diff --git a/locales/sv/LC_MESSAGES/a11y_pa11y.po b/locales/sv/LC_MESSAGES/a11y_pa11y.po index 64c3bb58..f95e69d8 100644 --- a/locales/sv/LC_MESSAGES/a11y_pa11y.po +++ b/locales/sv/LC_MESSAGES/a11y_pa11y.po @@ -1,13 +1,13 @@ # Swedish -# Copyright (C) 2020 WebPerf +# Copyright (C) 2022 WebPerf # FIRST AUTHOR , 2020. # msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "POT-Creation-Date: 2020-12-12 10:45+0200\n" -"PO-Revision-Date: 2021-06-21 17:15+0200\n" -"Last-Translator: Marcus \n" +"PO-Revision-Date: 2022-02-18 17:15+0200\n" +"Last-Translator: Mattias \n" "Language-Team: Swedish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -18,19 +18,19 @@ msgid "TEXT_RUNNING_TEST" msgstr "## Test: 18 - Tillgänglighet (Pa11y)\n" msgid "TEXT_REVIEW_A11Y_VERY_GOOD" -msgstr "- Webbplatsen har inga uppenbara fel inom tillgänglighet! Bra, men gör manuella undersökningar för säkerhets skull!\n" +msgstr "- Webbplatsen har inga uppenbara fel inom tillgänglighet! Bra, men gör manuella undersökningar för säkerhets skull!" msgid "TEXT_REVIEW_A11Y_IS_GOOD" -msgstr "- Webbplatsen kan bli mer tillgänglig, men är ganska ok.\n" +msgstr "- Webbplatsen kan bli mer tillgänglig, men är ganska ok." msgid "TEXT_REVIEW_A11Y_IS_OK" -msgstr "- Genomsnittlig tillgänglighet men och bli bättre gentemot automatiska tester.\n" +msgstr "- Genomsnittlig tillgänglighet men och bli bättre gentemot automatiska tester." msgid "TEXT_REVIEW_A11Y_IS_BAD" -msgstr "- Webbplatsen är dålig på tillgänglighet för funktions­nedsatta personer.\n" +msgstr "- Webbplatsen är dålig på tillgänglighet för funktions­nedsatta personer." msgid "TEXT_REVIEW_A11Y_IS_VERY_BAD" -msgstr "- Väldigt dålig tillgänglighet!\n" +msgstr "- Väldigt dålig tillgänglighet!" msgid "TEXT_REVIEW_A11Y_NUMBER_OF_PROBLEMS" -msgstr "- Antal tillgänglighets­problem: {} st\n" \ No newline at end of file +msgstr "- Antal tillgänglighets­problem: {} st" \ No newline at end of file From e3ca6d3fe83bb5169d4ee2f853e7668e94cb75ec Mon Sep 17 00:00:00 2001 From: Mattias Date: Fri, 18 Feb 2022 20:49:10 +0100 Subject: [PATCH 17/22] regenerated general text file --- locales/en/LC_MESSAGES/webperf-core.mo | Bin 4050 -> 4128 bytes locales/sv/LC_MESSAGES/webperf-core.mo | Bin 4228 -> 4308 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/locales/en/LC_MESSAGES/webperf-core.mo b/locales/en/LC_MESSAGES/webperf-core.mo index cb41b5d79ec27e4c74e4c89c69d6dc2fb4acf83d..6380380bce7bde7338263760013482f6dc76a0f4 100644 GIT binary patch delta 742 zcmYMyPe@cz6vy%7%+u7-@lRGZ>Nq&~AFYQGDhO%{f*ZF6E_6&B5D~_WAPfd>Tu2ZK z)gl*e1Y6W7VjzgiHiig3RK6rfYIdlJ%@l>#ng3!$GrRjNv0}$2bn)Q=CT4e~S^bw0&lviQh4f z$Eb-nsEJ|k&Q@fB4Pgl;@G+)P^H;D2H?b9uoLPKM9LY87!eM-d%eSV@b{RxTTsXZv zvs&UfHsLE&VKXj%hjqmJ&R^I<{0~)7%LB7Y?8Arn8VBj>EC#sLPQF!{9bp)RoRem_O+mqitp%Vt^^#WXqV zV4#-tVm;2GKFK=1#BFTAbJYK&kgC*~7pTsSITuj}eZnXB4OQ?DtinrF=RB&^{*5IZ ztBra{s3lX_j;p9b4qW~mRdJ{^^D(d%4Ep})`>$SArY&zSKjL>5bjSJ-yzb75sc$7w%{D<_%&=5$;ciJ9hk>B-lGnDM;%x) zhMnaJGKN0-XR!&FP{(g#JMLp2UK)!yL|juPGL92Ci0frDA}2H=bQFv~sMV-?O@{1u1R5KS7I7Ky+XlD~UZjo;KcWXts<(!v?|I0OvI6j~*^od$( zho@4?AnMLys7H~+2AnZ*8nq%D7{#pleu}!@Eox!~)BlCs;^3SzS_(gnPE4U5MH)wO z3%k(5UVKHZgp=&FV*SQx)E_NlGj3xT4^S(1g}Uww>iloiN`!pmJ3u2v`kKHh>W3Wa V4sU!`-kx(<3$7Kn_2C_{{Qh(wRnV*e~Ha_j~)1_S#O{y;$a-XHT1H-I{O>&MQCNhWX$Qo7UBtX z;xbBM2U?uQR^m5JV?nNqE|h}&SdU9sg>f9ByN5W!$7Ku2XMbfcRjL@rQCc>GO&CO3 zxQQjWkCK-_$xEUXm`2&?3FTLPqpUNMBpqr*JGxOiH;&a9!dM-H4F=NsJ!GvqMK4~V zoQn@_-pm2$BX(jN&ZD$=3)}GmyD*C$G_bpLq8FvWF_eNAP|i%;q=uA@L4pTT(G7ND z7G0?4q{%v7uV6diUjIV_jUw_e{%^!|LLbu1!P$V2$46fRo PlL4P^-IeMwP3e9CA>2$l delta 706 zcmYMyyGufG6u|N0BNHoc**ncNjqIs|Ar-a-1vLn@HiSk?Lyb{L5lBK~ThI~+Q4kn} zO9cG^E#?#wjc#t$Qs0vox^VgY&i$R=>)c;CcoNK3J@#|q8RPZwrY#!%KQ~qp58*Ak z@d?}U#q=F@Tpc^mZ4>Fo0Jh;AcHIa>G(1AJ47PHNz@H(nQ|wjng%(tk5SB_p6CI!{{s{F ziD8U!5wx`HID$twg$10(SJX<_*@bS Date: Fri, 18 Feb 2022 21:00:46 +0100 Subject: [PATCH 18/22] updated pa11y test to use locales --- locales/en/LC_MESSAGES/a11y_pa11y.po | 8 ++++++- locales/sv/LC_MESSAGES/a11y_pa11y.po | 8 ++++++- tests/a11y_pa11y.py | 36 +++++++++++++++++++--------- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/locales/en/LC_MESSAGES/a11y_pa11y.po b/locales/en/LC_MESSAGES/a11y_pa11y.po index 80b0e9a2..4c01b4d7 100644 --- a/locales/en/LC_MESSAGES/a11y_pa11y.po +++ b/locales/en/LC_MESSAGES/a11y_pa11y.po @@ -33,4 +33,10 @@ msgid "TEXT_REVIEW_A11Y_IS_VERY_BAD" msgstr "- The accessibility is apparently really bad! Probably both for disabled people and everyone of us when we need some accessibility!" msgid "TEXT_REVIEW_A11Y_NUMBER_OF_PROBLEMS" -msgstr "- Number of problems with accessibility: {}" \ No newline at end of file +msgstr "- Number of problems with accessibility: {}" + +msgid "TEXT_REVIEW_A11Y_TOO_MANY_PROBLEMS" +msgstr "- Info: Too many unique problems to show them all.\n" + +msgid "TEXT_REVIEW_A11Y_PROBLEMS" +msgstr "\nProblems:\n" \ No newline at end of file diff --git a/locales/sv/LC_MESSAGES/a11y_pa11y.po b/locales/sv/LC_MESSAGES/a11y_pa11y.po index f95e69d8..0f6bd2af 100644 --- a/locales/sv/LC_MESSAGES/a11y_pa11y.po +++ b/locales/sv/LC_MESSAGES/a11y_pa11y.po @@ -33,4 +33,10 @@ msgid "TEXT_REVIEW_A11Y_IS_VERY_BAD" msgstr "- Väldigt dålig tillgänglighet!" msgid "TEXT_REVIEW_A11Y_NUMBER_OF_PROBLEMS" -msgstr "- Antal tillgänglighets­problem: {} st" \ No newline at end of file +msgstr "- Antal tillgänglighets­problem: {} st" + +msgid "TEXT_REVIEW_A11Y_TOO_MANY_PROBLEMS" +msgstr "- Info: För många unika problem för att lista alla.\n" + +msgid "TEXT_REVIEW_A11Y_PROBLEMS" +msgstr "\nProblem:\n" \ No newline at end of file diff --git a/tests/a11y_pa11y.py b/tests/a11y_pa11y.py index 018334c4..ec3694fd 100644 --- a/tests/a11y_pa11y.py +++ b/tests/a11y_pa11y.py @@ -1,9 +1,11 @@ # -*- coding: utf-8 -*- -# from urllib.parse import urlparse # https://docs.python.org/3/library/urllib.parse.html import subprocess +import datetime import json from models import Rating import config +import gettext +_ = gettext.gettext review_show_improvements_only = config.review_show_improvements_only @@ -13,7 +15,16 @@ def run_test(_, langCode, url): """ - import subprocess + language = gettext.translation( + 'ally_pa11y', localedir='locales', languages=[langCode]) + language.install() + _local = language.gettext + + print(_local('TEXT_RUNNING_TEST')) + + print(_('TEXT_TEST_START').format( + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))) + bashCommand = "pa11y-ci --reporter json {0}".format(url) process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE) output, error = process.communicate() @@ -38,22 +49,22 @@ def run_test(_, langCode, url): if num_errors == 0: points = 5 - review_overall = '- Webbplatsen har inga uppenbara fel kring tillgänglighet!\n' + review_overall = _local('TEXT_REVIEW_A11Y_VERY_GOOD') elif num_errors == 1: points = 4 - review_overall = '- Webbplatsen kan bli mer tillgänglig, men är helt ok.\n' + review_overall = _local('TEXT_REVIEW_A11Y_IS_GOOD') elif num_errors > 8: points = 1 - review_overall = '- Väldigt dålig tillgänglighet!\n' + review_overall = _local('TEXT_REVIEW_A11Y_IS_VERY_BAD') elif num_errors >= 4: points = 2 - review_overall = '- Dålig tillgänglighet.\n' + review_overall = _local('TEXT_REVIEW_A11Y_IS_BAD') elif num_errors >= 2: points = 3 - review_overall = '- Genomsnittlig tillgänglighet men kan bli bättre.\n' + review_overall = _local('TEXT_REVIEW_A11Y_IS_OK') - review_a11y = '- Antal tillgänglighetsproblem: {} st\n'.format(num_errors) - # review += '- Antal tillgänglighetsproblem: {} st\n'.format(num_errors) + review_a11y = _local( + 'TEXT_REVIEW_A11Y_NUMBER_OF_PROBLEMS').format(num_errors) return_dict['antal_problem'] = num_errors unique_errors = set() @@ -75,13 +86,13 @@ def run_test(_, langCode, url): i = 1 if len(unique_errors) > 0: - review += '\nProblem:\n' + review += _local('TEXT_REVIEW_A11Y_PROBLEMS') for error in unique_errors: review += error i += 1 if i > 10: - review += '- Info: För många unika problem för att lista alla\n' + review += _local('TEXT_REVIEW_A11Y_TOO_MANY_PROBLEMS') break rating = Rating(_, review_show_improvements_only) @@ -90,6 +101,9 @@ def run_test(_, langCode, url): rating.a11y_review = rating.a11y_review + review + print(_('TEXT_TEST_END').format( + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))) + return (rating, return_dict) From e723395847a851d14d4aa49e14b375542277f0c5 Mon Sep 17 00:00:00 2001 From: Mattias Date: Fri, 18 Feb 2022 21:01:35 +0100 Subject: [PATCH 19/22] generated new translation --- locales/en/LC_MESSAGES/a11y_pa11y.mo | Bin 1141 -> 1298 bytes locales/sv/LC_MESSAGES/a11y_pa11y.mo | Bin 1127 -> 1287 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/locales/en/LC_MESSAGES/a11y_pa11y.mo b/locales/en/LC_MESSAGES/a11y_pa11y.mo index 70badd3d176d5e1dc5a1797315745ce35072cfb4..9b2eea5a72d10d3ddaf9809e8543f798298baead 100644 GIT binary patch delta 280 zcmey$F^Q}Go)F7a1|Z-9Vi_RL0dbJP9w1vBi1z}q1Q1^ZVlg0o2gD%ttc(l{%0OBP zNJ|1~Hz2J9q!WO&6p(HP(t<#G9*}kg;tfFT1>}EYVqmajV6b9vWM*Kn0}50F>1H6k z3rK4NX*(7M25umo1*DCEbQzF#0@AC1v7!e202QFg@M5wNb3XX3Lu>hq}71*gNZZeO_pVp;t28gkN0)-i`*>3xSGj{E1)Pp zDJM18ii<&4!80!{-%7#l@U|j_+`~)r(i0U*^D?s&6$&6~6w*L4i6tcpIhn;Ji3*81 NIf;5)laDbk1OTT(GmiiO delta 171 zcmZqYdd^XQPl#nI0}yZku?!H$fH+8C4v;Ml#B+gI0*JQ)u^14a17eW+r$DR>#7v9~ z3{pT^4M+ Date: Fri, 18 Feb 2022 21:03:22 +0100 Subject: [PATCH 20/22] hard to see difference between 1 and l apparently... :P --- tests/a11y_pa11y.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/a11y_pa11y.py b/tests/a11y_pa11y.py index ec3694fd..a70ad6b4 100644 --- a/tests/a11y_pa11y.py +++ b/tests/a11y_pa11y.py @@ -16,7 +16,7 @@ def run_test(_, langCode, url): """ language = gettext.translation( - 'ally_pa11y', localedir='locales', languages=[langCode]) + 'a11y_pa11y', localedir='locales', languages=[langCode]) language.install() _local = language.gettext From 4796d04bf2d6c56c50d71f466d5e45ecc7d55478 Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Fri, 18 Feb 2022 21:21:45 +0100 Subject: [PATCH 21/22] added documentation for test --- README.md | 21 ++++++++++---------- docs/tests/README.md | 32 ++++++++++++++++-------------- docs/tests/pa11y.md | 47 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 25 deletions(-) create mode 100644 docs/tests/pa11y.md diff --git a/README.md b/README.md index a34ad682..27ce80ae 100644 --- a/README.md +++ b/README.md @@ -35,17 +35,18 @@ but you can run this project in many ways and what you choose depends on your ne Add a interesting ingress here. [Read more about our tests](./docs/tests/README.md) or go directly to a specific test below. -* [Accessibility](./docs/tests/google-lighthouse-a11y.md) -* [Website performance](./docs/tests/google-lighthouse-performance.md) -* [Best practice on Web](./docs/tests/google-lighthouse-best-practice.md) -* [Progressive web apps](./docs/tests/google-lighthouse-pwa.md) -* [SEO best practise](./docs/tests/google-lighthouse-seo.md) +* [Accessibility (Pa11y)](./docs/tests/pa11y.md) +* [Accessibility (Lighthouse)](./docs/tests/google-lighthouse-a11y.md) +* [Website performance (SiteSpeed)](./docs/tests/sitespeed.md) +* [Website performance (Lighthouse)](./docs/tests/google-lighthouse-performance.md) +* [Best practice on Web (Lighthouse)](./docs/tests/google-lighthouse-best-practice.md) +* [Progressive web apps (Lighthouse)](./docs/tests/google-lighthouse-pwa.md) +* [SEO best practise (Lighthouse)](./docs/tests/google-lighthouse-seo.md) * [Validate 404 page (by default checks for Swedish text, though)](./docs/tests/page-not-found.md) -* [Validate HTML](./docs/tests/html.md) -* [Validate CSS](./docs/tests/css.md) -* [Security, data-protecting & Integrity](./docs/tests/webbkoll.md) -* [Frontend quality](./docs/tests/yellowlab.md) -* [Website performance](./docs/tests/sitespeed.md) +* [Validate HTML (W3C)](./docs/tests/html.md) +* [Validate CSS (W3C)](./docs/tests/css.md) +* [Security, data-protecting & Integrity (Webbkoll)](./docs/tests/webbkoll.md) +* [Frontend quality (YellowLab Tools)](./docs/tests/yellowlab.md) * [Energy Efficiency](./docs/tests/energy-efficiency.md) * [Standard files](./docs/tests/standard.md) * [HTTP and Network](./docs/tests/http.md) diff --git a/docs/tests/README.md b/docs/tests/README.md index 701fb7d8..d85687c2 100644 --- a/docs/tests/README.md +++ b/docs/tests/README.md @@ -3,21 +3,23 @@ Add a small ingress here ## List of Tests -* [Google Lighthouse accessibility with Axe](google-lighthouse-a11y.md) -* [Google Lighthouse performance](google-lighthouse-performance.md) -* [Google Lighthouse best practice](google-lighthouse-best-practice.md) -* [Google Lighthouse progressive web apps](google-lighthouse-pwa.md) -* [Google Lighthouse SEO](google-lighthouse-seo.md) -* [Testing the 404 page and status code (by default checks for Swedish text, though)](page-not-found.md) -* [Validating the HTML code against W3C](html.md) -* [Validating the CSS code against W3C](css.md) -* [Users’ integrity test against Webbkoll, provided by Dataskydd.net](webbkoll.md) -* [Frontend quality against Yellow Lab Tools](yellowlab.md) -* [Website performance with Sitespeed.io](sitespeed.md) -* [Energy efficiency](energy-efficiency.md) -* [Standard files (checks for robots.txt, security.txt and more)](standard.md) -* [HTTP and Network test (checks HTTP version, TLS version and more)](http.md) -* [Tracking & Integrity test (checks GDPR compliance, tracking and more)](tracking.md) +* [Accessibility (Pa11y)](pa11y.md) +* [Accessibility (Lighthouse)](google-lighthouse-a11y.md) +* [Website performance (SiteSpeed)](sitespeed.md) +* [Website performance (Lighthouse)](google-lighthouse-performance.md) +* [Best practice on Web (Lighthouse)](google-lighthouse-best-practice.md) +* [Progressive web apps (Lighthouse)](google-lighthouse-pwa.md) +* [SEO best practise (Lighthouse)](google-lighthouse-seo.md) +* [Validate 404 page (by default checks for Swedish text, though)](page-not-found.md) +* [Validate HTML (W3C)](html.md) +* [Validate CSS (W3C)](css.md) +* [Security, data-protecting & Integrity (Webbkoll)](webbkoll.md) +* [Frontend quality (YellowLab Tools)](yellowlab.md) +* [Energy Efficiency](energy-efficiency.md) +* [Standard files](standard.md) +* [HTTP and Network](http.md) +* [Tracking & Integrity](tracking.md) + ## Code Quality diff --git a/docs/tests/pa11y.md b/docs/tests/pa11y.md new file mode 100644 index 00000000..23eabea9 --- /dev/null +++ b/docs/tests/pa11y.md @@ -0,0 +1,47 @@ +# Accessibility (Pa11y) +[![Regression Test - Accessibility (Pa11y) Test](https://github.com/Webperf-se/webperf_core/actions/workflows/regression-test-pa11y.yml/badge.svg)](https://github.com/Webperf-se/webperf_core/actions/workflows/regression-test-pa11y.yml) + +Add small description of what this test is. + +## What is being tested? + +It test accessibility on the specified url. +Please note that automated accessibility test generally only find 20-30% of all errors. +Even if this test is not finding anything you should still do a manuall check once in a while. + +## How are rating being calculated? + +We are rating the url based on: +- If Pa11y finds 0 errors you get 5.0 in rating +- If Pa11y finds just 1 error you get 4.0 in rating +- If Pa11y finds 2-3 errors you get 3.0 in rating +- If Pa11y finds 4-7 errors you get 2.0 in rating +- Else you will get 1.0 in rating + +## Read more + +* https://github.com/pa11y/pa11y-ci +* https://github.com/pa11y/pa11y + +## How to setup? + +This section has not been written yet. + +### Prerequirements + +* Fork this repository + +### Setup with GitHub Actions + +Read more on the [general page for github actions](../getting-started-github-actions.md). + +### Setup Locally + +* Follow [general local setup steps for this repository](../getting-started-local.md) +* Download and install Node.js +* Install Pa11y CI npm package ( `npm install -g pa11y-ci` ) + +## FAQ + +No frequently asked questions yet :) + From 33e93b276fc5a21509f4e82eab7f412afbab69fe Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Fri, 18 Feb 2022 21:25:57 +0100 Subject: [PATCH 22/22] removed test websites --- .github/workflows/regression-test-pa11y.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/regression-test-pa11y.yml b/.github/workflows/regression-test-pa11y.yml index e3c22766..5f5b0192 100644 --- a/.github/workflows/regression-test-pa11y.yml +++ b/.github/workflows/regression-test-pa11y.yml @@ -29,14 +29,4 @@ jobs: run: | python default.py -t 18 -r -u https://webperf.se/ -o .github/workflows/testresult-18.json python .github/workflows/verify_result.py -t 18 - if: ${{ success() }} - - name: Accessibility (Pa11y) - run: | - python default.py -t 18 -r -u https://feber.se/ -o .github/workflows/testresult-18.json - python .github/workflows/verify_result.py -t 18 - if: ${{ always() }} - - name: Accessibility (Pa11y) - run: | - python default.py -t 18 -r -u https://aftonbladet.se/ -o .github/workflows/testresult-18.json - python .github/workflows/verify_result.py -t 18 - if: ${{ always() }} \ No newline at end of file + if: ${{ success() }} \ No newline at end of file