<commit_before>#!/bin/bash

# Script to run pa11y accessibility checker against local running copy
# generates html reports stored in test/accessibility
# requires pa11y installed globally `npm install -g pa11y`
# requires existing workload data in the application so screens load correctly

if [ $# -ne 4 ]; then
  echo $0: usage: ./run-pa11y regionId lduId teamId omId
  exit 1
fi

regionId=$1
lduId=$2
teamId=$3
omId=$4

pa11yCommand="""pa11y --standard WCAG2AA --ignore "notice" --hide-elements "div[role=presentation]" --reporter html"""

# Root
$pa11yCommand "http://localhost:3000/" > "test/accessibility/001-root.html"

# Caseload Capacity
capacity_url='caseload-capacity'
$pa11yCommand "http://localhost:3000/offender-manager/$omId/$capacity_url" > "test/accessibility/002-om-$capacity_url.html"
$pa11yCommand "http://localhost:3000/team/$teamId/$capacity_url" > "test/accessibility/003-team-$capacity_url.html"
$pa11yCommand "http://localhost:3000/ldu/$lduId/$capacity_url" > "test/accessibility/004-ldu-$capacity_url.html"
$pa11yCommand "http://localhost:3000/region/$regionId/$capacity_url" > "test/accessibility/005-region-$capacity_url.html"

# Case Progress
case_progress_url='case-progress'
$pa11yCommand "http://localhost:3000/offender-manager/$omId/$case_progress_url" > "test/accessibility/006-om-$case_progress_url.html"
$pa11yCommand "http://localhost:3000/team/$teamId/$case_progress_url" > "test/accessibility/007-team-case-$case_progress_url.html"
$pa11yCommand "http://localhost:3000/ldu/$lduId/$case_progress_url" > "test/accessibility/008-ldu-case-$case_progress_url.html"
$pa11yCommand "http://localhost:3000/region/$regionId/$case_progress_url" > "test/accessibility/009-region-$case_progress_url.html"<commit_msg>Update pa11y script for use in Jenkins<commit_after>#!/bin/bash

# Script to run pa11y accessibility checker against local running copy
# generates html reports stored in test/accessibility
# requires pa11y installed globally `npm install -g pa11y`
# requires existing workload data in the application so screens load correctly

if [ $# -ne 4 ]; then
  echo $0: usage: ./run-pa11y regionId lduId teamId omId
  exit 1
fi

regionId=$1
lduId=$2
teamId=$3
omId=$4

pa11yCommand="""pa11y --standard WCAG2AA --ignore "warning\;notice" --hide-elements "div[role=presentation]" """
host="http://localhost:3000"

urls=()
errors=false

# Root
urls+=("$host/")

# Caseload Capacity
capacity_url='caseload-capacity'
urls+=("$host/offender-manager/$omId/$capacity_url")
urls+=("$host/team/$teamId/$capacity_url")
urls+=("$host/ldu/$lduId/$capacity_url")
urls+=("$host/region/$regionId/$capacity_url")

# Case Progress
case_progress_url='case-progress'
urls+=("$host/offender-manager/$omId/$case_progress_url")
urls+=("$host/team/$teamId/$case_progress_url")
urls+=("$host/ldu/$lduId/$case_progress_url")
urls+=("$host/region/$regionId/$case_progress_url")

for url in "${urls[@]}"
do
  $pa11yCommand $url
  if [ $? == 2 ]
  then
    errors=true
  fi
done

if [ "$errors" = true ]
then
  echo "Errors found"
  exit 1
fi
{'fraction_non_alphanumeric': 0.15321522309711286, 'fraction_numerical': 0.042979002624671914, 'mean_word_length': 5.898190045248869, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1619980', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1045, 'n_words': 207}