-
Notifications
You must be signed in to change notification settings - Fork 392
Expand accordion elements based on URL #552
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
Conversation
ebe8ff3 to
cd42a87
Compare
cd42a87 to
993473c
Compare
| (() => { | ||
| const onChange = (_event) => { | ||
| const urlHash = new URL(document.URL).hash; | ||
| const idFromHash = urlHash.match(/^(#[A-Za-z0-9_-]+)$/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this came up before I put the code up for review: I deliberately want to keep some input sanitization here. The format I've picked is in line with the general format we use for class and id attributes, so it feels appropriate to me.
| require 'capybara_helper' | ||
| require 'pry-byebug' | ||
|
|
||
| RSpec.describe 'accordions on /oidc/authorization/', :js, type: :feature do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still prefer actual JS tests instead of or in addition to these Capybara tests. That said, I agree with Jack Cody that this was likely the easiest testing to set up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure actual JS tests are beneficial when the only output is DOM manipulation. If you had a function like getSanitizedHash, you could test that, but as-is this tests everything you can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree that the coverage here is good.
Compared to some JS testing I've done in the past, doing it this way does feels to me like wearing thick, knitted gloves on my fingers when I'm not used to wearing them.
My main concern is that it feels too easy to accidentally break something here in a way that would generate a JS error that this test won't notice. Detecting a JS error like that in a headless browser with Capybara is tricky and fragile. I'm particularly concerned with breaking unrelated behavior on a page where this JS is included but the page doesn't have an accordion (or doesn't have one anymore).
ajfarkas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Relevant Ticket or Conversation:
[identity-dev-docs] direct links to accordions should auto-expand — on GitLab
(Previously https://cm-jira.usa.gov/browse/LG-14871 )
Description of Changes: