-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
326 | Add skip to main content accessibility navigation
- Loading branch information
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe 'Skip to main content navigation', :js, type: :system do | ||
let(:user) { create_user(role: "challenge_manager") } | ||
|
||
before do | ||
system_login_user(user) | ||
end | ||
|
||
context "when on dashboard index page" do | ||
before { visit dashboard_path } | ||
|
||
it 'is hidden by default but present in the DOM' do | ||
expect(page).to have_css('.usa-skipnav', visible: false) | ||
end | ||
|
||
it 'becomes visible when focused via keyboard tab' do | ||
find('body').send_keys(:tab) | ||
expect(page).to have_css('.usa-skipnav', visible: true) | ||
end | ||
|
||
it 'moves focus to main content when using keyboard' do | ||
find('body').send_keys(:tab) | ||
find('.usa-skipnav', visible: true).send_keys(:return) | ||
expect(page.evaluate_script('document.activeElement.id')).to eq('main-content') | ||
end | ||
|
||
it 'passes accessibility checks' do | ||
expect(page).to be_axe_clean | ||
end | ||
end | ||
|
||
context "when on phases index page" do | ||
before { visit phases_path } | ||
|
||
it 'is hidden by default but present in the DOM' do | ||
expect(page).to have_css('.usa-skipnav', visible: false) | ||
end | ||
|
||
it 'becomes visible when focused via keyboard tab' do | ||
find('body').send_keys(:tab) | ||
expect(page).to have_css('.usa-skipnav', visible: true) | ||
end | ||
|
||
it 'moves focus to main content when using keyboard' do | ||
find('body').send_keys(:tab) | ||
find('.usa-skipnav', visible: true).send_keys(:return) | ||
expect(page.evaluate_script('document.activeElement.id')).to eq('main-content') | ||
end | ||
|
||
it 'passes accessibility checks' do | ||
expect(page).to be_axe_clean | ||
end | ||
end | ||
end |