Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axe rspec #587

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ group :development do
# Display performance information such as SQL time and flame graphs for each request in your browser.
# Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
gem 'rack-mini-profiler', '~> 2.0'
gem 'axe-core-rspec'
end

group :development, :test do
Expand Down
25 changes: 25 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ GEM
airbrussh (1.5.3)
sshkit (>= 1.6.1, != 1.7.0)
ast (2.4.2)
axe-core-api (4.10.1)
dumb_delegator
ostruct
virtus
axe-core-rspec (4.10.1)
axe-core-api (= 4.10.1)
dumb_delegator
ostruct
virtus
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
base64 (0.2.0)
bcrypt_pbkdf (1.1.1)
benchmark (0.4.0)
Expand Down Expand Up @@ -117,6 +130,8 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
concurrent-ruby (1.3.4)
config (5.5.2)
deep_merge (~> 1.2, >= 1.2.1)
Expand All @@ -130,6 +145,8 @@ GEM
irb (~> 1.10)
reline (>= 0.3.8)
deep_merge (1.2.2)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.5.1)
dlss-capistrano (5.2.0)
bcrypt_pbkdf
Expand All @@ -142,6 +159,7 @@ GEM
domain_name (0.6.20240107)
dotenv (3.1.4)
drb (2.2.1)
dumb_delegator (1.0.0)
ed25519 (1.3.0)
erubi (1.13.0)
factory_bot (6.5.0)
Expand Down Expand Up @@ -183,6 +201,7 @@ GEM
http-form_data (2.3.0)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
importmap-rails (2.0.3)
actionpack (>= 6.0.0)
activesupport (>= 6.0.0)
Expand Down Expand Up @@ -374,6 +393,7 @@ GEM
railties (>= 6.0.0)
stringio (3.1.2)
thor (1.3.2)
thread_safe (0.3.6)
timeout (0.4.2)
tophat (2.3.1)
actionpack (>= 3.0.0)
Expand All @@ -385,6 +405,10 @@ GEM
unicode-display_width (2.6.0)
uri (1.0.1)
useragent (0.16.10)
virtus (2.0.0)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
web-console (4.2.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand All @@ -403,6 +427,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
axe-core-rspec
bootsnap (>= 1.1.0)
cancancan
capistrano
Expand Down
2 changes: 1 addition & 1 deletion app/views/libraries/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<%= form.label :public, "Display on home page", class: "form-check-label" %>
</div>

<h4>Library's Locations:</h4>
<h2 class="h4">Library's Locations:</h2>

<ul data-nested-form-target="addItem">
<%= form.fields_for :locations do |locations_form| %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/libraries/_range.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<span class="fas fa-arrow-left" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
<% end unless @range.begin.before?(24.months.ago)%>
<h4 class="fw-light mb-0"><%= l(@range.begin, format: :short) %> – <%= l(@range.end, format: :short) %></h4>
<h2 class="fw-light mb-0 h4"><%= l(@range.begin, format: :short) %> – <%= l(@range.end, format: :short) %></h2>
<%= link_to params.to_unsafe_h.merge(week: (@range.begin + 1.week + 1.day).strftime("%GW%V")) do %>
<span class="fas fa-arrow-right" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
Expand All @@ -25,7 +25,7 @@
</div>

<div class="col-xs-12 d-flex" id="jump-term-group">
<h3 class="visually-hidden">Jump to quarters &amp; holidays</h3>
<h2 class="visually-hidden">Jump to quarters &amp; holidays</h2>
<button id="jump-term" type="button" class="btn btn-outline-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
Quarters &amp; holidays <span class="caret"></span>
</button>
Expand Down
8 changes: 5 additions & 3 deletions app/views/libraries/spreadsheet.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<% title 'Upload spreadsheet' %>
<h1>Download library spreadsheet</h1>
<% title 'Download spreadsheet' %>
<form class="form" action="<%= libraries_path(format: 'csv') %>" method="GET">
<div class="mb-3">
<label class="form-label">Libraries</label>
<label class="form-label" for="ids">Libraries</label>
<%= select_tag 'ids', options_from_collection_for_select(Library.all, :id, :name), multiple: true, class: 'form-select' %>
</div>
<div class="mb-3">
<%= date_field_tag 'from' %> to <%= date_field_tag 'to' %>
<label class="form-label" id="to-from">Date range: </label>
<%= date_field_tag 'from', nil, aria: { 'labelledby': 'to-from' } %> to <%= date_field_tag 'to', nil, aria: { 'labelledby': 'to-from' } %>
</div>
<input value="Download" type="submit" class="btn btn-primary" />
</form>
2 changes: 1 addition & 1 deletion app/views/shared/feedback_forms/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<%= t('blacklight.feedback_form.feedback_alert_html', href: mail_to('[email protected]')) %>
</p>
<% end %>
<%= form_tag feedback_form_path, method: :post, class:"feedback-form", role:"form" do %>
<%= form_tag feedback_form_path, method: :post, class:"feedback-form" do %>
<div class="row mt-4">
<div class="offset-md-2 col-md-8 mb-2">
<%= render 'shared/feedback_forms/reporting_from' %>
Expand Down
4 changes: 3 additions & 1 deletion app/views/spreadsheets/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<th>Attachment content type</th>
<th>Attachment size</th>
<th>Status</th>
<th colspan="3"></th>
<th>Show link</th>
<th>Edit link</th>
<th>Destroy link</th>
</tr>
</thead>

Expand Down
4 changes: 2 additions & 2 deletions app/views/terms/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
<div class="form-check">
<p>Type</p>
<%= f.radio_button :holiday, false, class: "form-check-input"%>
<%= f.label "Quarter or Intersession" %>
<%= f.label :holiday_false, "Quarter or Intersession" %>
<%= f.radio_button :holiday, true, class: "form-check-label" %>
<%= f.label "Holiday" %>
<%= f.label :holiday_true, "Holiday" %>
</div>

<div class="actions">
Expand Down
1 change: 1 addition & 0 deletions app/views/terms/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<h1><%= @term.name %> term information</h1>
<p id="notice"><%= notice %></p>

<p>
Expand Down
106 changes: 106 additions & 0 deletions spec/features/axe_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# frozen_string_literal: true
require 'rails_helper'
require 'axe-rspec'
RSpec.describe 'Accessibility testing', :js do
# before do
# allow(controller).to receive(:current_user).and_return(user)
# end
let(:library) { create(:location, keeps_hours: true).library }

before do
stub_current_user(build(:superadmin_user))
create(:library)
create(:term_hour)
create(:location)
create(:term, dtstart: 1.month.from_now, dtend: 3.months.from_now)
end

it 'validates the home page' do
visit root_path
expect(page).to be_accessible
end

it 'validates the individual library page' do
visit library_path(library)
expect(page).to be_accessible
end

it 'validates the terms page' do
visit terms_path
expect(page).to be_accessible
end

it 'validates the term page' do
visit term_path(1)
expect(page).to be_accessible
end

it 'validates the new terms page' do
visit new_term_path
expect(page).to be_accessible
end

it 'validates the edit terms page' do
visit edit_term_path(1)
expect(page).to be_accessible
end

it 'validates the spreadsheets page' do
visit spreadsheets_path
expect(page).to be_accessible
end

it 'validates the new spreadsheets page' do
visit new_spreadsheet_path
expect(page).to be_accessible
end

it 'validates the new spreadsheets page' do
visit new_spreadsheet_path
expect(page).to be_accessible
end

it 'validates the spreadsheet libraries page' do
visit spreadsheet_libraries_path
expect(page).to be_accessible
end

it 'validates the term hours page' do
visit library_term_hours_path(1)
expect(page).to be_accessible
end

it 'validates the spreadsheet libraries page' do
visit library_term_hours_path(1)
expect(page).to be_accessible
end

it 'validates the library term hours page' do
visit library_term_hours_path(1)
expect(page).to be_accessible
end

it 'validates the library term hours page' do
visit new_library_location_path(1)
expect(page).to be_accessible
end

it 'validates the libraries page' do
visit new_library_path
expect(page).to be_accessible
end

it 'validates the edit libraries page' do
visit edit_library_path(1)
expect(page).to be_accessible
end

it 'feedback form' do
visit feedback_path
expect(page).to be_accessible
end

def be_accessible
be_axe_clean
end
end