-
Notifications
You must be signed in to change notification settings - Fork 123
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
VAGOV-TEAM-89918: Create Form Config object from normalized input #31296
VAGOV-TEAM-89918: Create Form Config object from normalized input #31296
Conversation
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.
ESLint is disabled
vets-website
uses ESLint to help enforce code quality. In most situations we would like ESLint to remain enabled.
What you can do
See if the code can be refactored to avoid disabling ESLint, or wait for a VSP review.
@@ -0,0 +1,66 @@ | |||
/* eslint-disable prefer-destructuring */ |
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.
ESLint disabled here
src/applications/form-renderer/tests/unit/utils/formConfig.unit.spec.js
Outdated
Show resolved
Hide resolved
rootUrl: `${manifest.rootUrl}/${formId}`, | ||
urlPrefix: `/${formId}/`, | ||
trackingPrefix: `${formId}-`, | ||
// eslint-disable-next-line no-console |
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.
ESLint disabled here
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.
LGTM
…orm-config-object
…orm-config-object
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.
This looks really solid. I've left a question and a few comments. None of them are blocking, so I'm approving.
|
||
// This is a sample of the data structure produced by content-build. | ||
export const normalizedForm = { | ||
id: 71160, |
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.
QUESTION
I thought we settled on cmsId
here. Has that been changed?
It is interesting to me to have cmsId
on the node but id
on the chapters/steps/other things. Perhaps we need to iron this out a bit still.
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.
We absolutely did, and cmsId
appears on https://pr18811-ps4nwwul37jtyembecv4bg0gafmyl3oj.ci.cms.va.gov/data/cms/digital-forms.json. Guess I wrote this before we had that discussion. This is the downside to using mock data for testing, but doesn't actually impact anything at the moment, because I don't think we're using cmsId
for anything on the front-end yet. Nonetheless, I'll update the mock form to reflect what is coming from content-build
.
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.
It is interesting to me to have cmsId on the node but id on the chapters/steps/other things. Perhaps we need to iron this out a bit still.
I felt no immediate need to disambiguate it as there are no other IDs on the chapter level competing for attention, but I could be persuaded to change the key label to chapterId
, pageId
, or stepId
.
chapters.forEach(chapter => { | ||
const pages = {}; | ||
pages[chapter.id] = { | ||
path: chapter.id.toString(), |
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.
MUSING
I wonder if we're going to want to generate a more human-readable path from a title field of some sort. Having a random ID in the url feels a bit odd. This can be addressed later, certainly.
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.
That makes sense. The only issue with using the chapter title is that we cannot currently guarantee that every chapter title within a form will be unique. If we can guarantee that at the CMS level, I would feel comfortable using it instead of the chapter ID.
const formatChapters = chapters => { | ||
const formattedChapters = {}; | ||
|
||
chapters.forEach(chapter => { |
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.
CONSIDER
My personal preference would be the use of reduce
(rather than forEach
) in cases like this where there are no side effects.
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 always forget reduce
exists, and whenever someone reminds me, I have go look up how it works again.
const pages = {}; | ||
pages[chapter.id] = { |
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.
CONSIDER
It feels like it would be a bit more "immutable" to simply define pages
to be an object with the key `chapter.id' all in one definition/declaration:
const pages = {
[chapter.id]: {
...
}
}
This is a very small issue in this case, but something I personally like to do when possible.
Separately, this one-page-per-chapter code is feeling increasingly odd to me now that we're getting to the point of seeing things in the context of the formConfig
. It might be the case that we settle on this constraint (one page per chapter - though I'm not sure that's likely), but it feels odd to see us indexing pages with the chapter id. Ultimately, that's not a problem in and of itself, but it feels slightly confusing to me at first glance. When browsing the code, it feels like it could be a mistake. We know it's not, so, for now, perhaps it could be useful to include a comment explaining this one-page-per-chapter setup under which we currently are operating.
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 did it the way I did solely because I forgot how to define a dynamic key in an object literal. The code has now been updated.
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.
Separately, this one-page-per-chapter code is feeling increasingly odd to me now that we're getting to the point of seeing things in the context of the formConfig. It might be the case that we settle on this constraint (one page per chapter - though I'm not sure that's likely), but it feels odd to see us indexing pages with the chapter id. Ultimately, that's not a problem in and of itself, but it feels slightly confusing to me at first glance. When browsing the code, it feels like it could be a mistake. We know it's not, so, for now, perhaps it could be useful to include a comment explaining this one-page-per-chapter setup under which we currently are operating.
I agree the code looks a little misleading here with chapter.id
being used as a page key. There's a fundamental disagreement between VA.gov Design and Engineering teams over how VA.gov forms are structured, and we're trying to bridge the divide as best we can. As I mentioned above, if we can get to the point where we can guarantee the uniqueness of chapter and/or page titles in Drupal, we'll have a lot more flexibility to play around with this structure.
In the meantime, I've added a comment explaining why chapter.id
is appearing as a key within a pages
object.
* main: [SIMPLE-FORMS] feat: add accordion to new confirmation page (#31325) MHV-60214: Landing page typo (#31425) Remove pattern validation for service number (#31417) Update URL for 'Enrollment Manager FAQs' (#31371) Add MST info to SC intro (#31416) Add SC housing & living situation questions (#31391) SC prototype | Update beginning pages (#31354) Prevent multiple TOU requests (#31347) Add trace logging to unit test stability workflow (#31421) 90728 Combine street text fields in submit transformer - forms 10-7959c, 10-7959a (#31404) updated confirmation page: (#31394) #89775: Update transformer to pull modality for appointment from the preferredModality field [VA Requests] (#31380) VAGOV-TEAM-89918: Create Form Config object from normalized input (#31296) Add features flags for upcoming HCA initiatives (#31420) Fixes flaky medications unit test (#31422) added address line 3 and address line 4 to UI (#31423)
Are you removing, renaming or moving a folder in this PR?
Summary
#31202 allowed forms to be rendered dynamically from existing Form Config objects, but we will not be receiving Form Config objects from
content-build
. This PR takes the output from department-of-veterans-affairs/content-build#2215 and creates a Form Config object from it. Actually connectingcontent-build
and the Form Renderer app together will take place in department-of-veterans-affairs/va.gov-team#89988.Related issue(s)
QA Steps
/form-renderer/digital-form/2121212
should render a form with two variations of the Name and Date of Birth pattern.Testing done
What areas of the site does it impact?
This PR touches only our team-owned application (form-renderer). Notably, the app is not yet live.
Acceptance criteria
Quality Assurance & Testing
Error Handling
Authentication
Requested Feedback
The schemas are currently hard-coded for the "Name and Date of Birth" pattern. That will change once we add in more patterns. Dynamically selecting proper schemas was not part of the scope of this ticket.