File tree Expand file tree Collapse file tree 3 files changed +38
-5
lines changed
Expand file tree Collapse file tree 3 files changed +38
-5
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,7 @@ <h1 class="usa-display">{{ page.title }}</h1>
153153 < script src ="{{ site.baseurl }}/assets/js/toggle_view.js "> </ script >
154154 < script src ="{{ site.baseurl }}/assets/js/main.js "> </ script >
155155 < script src ="{{ site.baseurl }}/assets/js/anchor.js "> </ script >
156+ < script src ="{{ site.baseurl }}/assets/js/anchor_accordion.js "> </ script >
156157
157158 < script >
158159 anchors . add ( [
Original file line number Diff line number Diff line change 1+ ( ( ) => {
2+ const onChange = ( _event ) => {
3+ const urlHash = new URL ( document . URL ) . hash ;
4+ const idFromHash = urlHash . match ( / ^ ( # [ A - Z a - z 0 - 9 _ - ] + ) $ / ) ;
5+ if ( idFromHash ) {
6+ const accordionHeading = document . querySelector (
7+ `${ idFromHash [ 1 ] } .usa-accordion__heading > button` ,
8+ ) ;
9+ if ( accordionHeading ) {
10+ accordionHeading . click ( ) ;
11+ }
12+ }
13+ } ;
14+ document . addEventListener ( 'DOMContentLoaded' , onChange ) ;
15+ window . addEventListener ( 'hashchange' , onChange ) ;
16+ } ) ( ) ;
Original file line number Diff line number Diff line change 22require 'pry-byebug'
33
44RSpec . describe 'accordions on /oidc/authorization/' , :js , type : :feature do
5- it 'loads the page' do
6- visit '/oidc/authorization/'
7- first_summary = find_all ( 'summary' ) . first
8- expect ( first_summary . text ) . to eq 'Type of Service Level'
5+ it 'is not expanded by default' do
6+ visit '/oidc/authorization'
7+ expect ( page ) . to have_element ( 'dt' )
8+ expect ( page ) . to have_no_element ( 'dd' )
9+ accordion_button = find ( '#service_level button' )
10+ expect ( accordion_button . native . attribute ( 'aria-expanded' ) ) . to eq ( 'false' )
911 end
10- end
12+
13+ it 'is expanded with an anchor in the URL' do
14+ visit '/oidc/authorization#service_level'
15+ expect ( page ) . to have_element ( 'dt' )
16+ expect ( page ) . to have_element ( 'dd' )
17+ definition = find ( '#service_level ~ dd' ) . text
18+ expect ( definition ) . to include ( 'acr.login.gov:verified' )
19+ accordion_button = find ( '#service_level > button' )
20+ expect ( accordion_button . native . attribute ( 'aria-expanded' ) ) . to eq ( 'true' )
21+
22+ visit '/oidc/authorization#aal_values'
23+ next_definition = find ( '#aal_values ~ dd' ) . text
24+ expect ( next_definition ) . to include ( 'http://idmanagement.gov/ns/assurance/aal/2' )
25+ end
26+ end
You can’t perform that action at this time.
0 commit comments