-
Notifications
You must be signed in to change notification settings - Fork 11
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
Set up Storybook Documentation #113
Conversation
To view the Storybook page, run: The .stories.js files in src/stories are responsible for rendering the docs. |
It looks like maybe this is based off an old version of
That might pull the commit that fixed these issues to this branch |
hmm it looks like maybe that wasn't the issue... we've caused this issue to re-appear another way. interesting. |
Does running tests locally work @hreineck? UPDATE: They don't |
No, i get this error that we had encountered before: |
@hreineck I get the same error. I have tried reinstalling both |
Initial feedback after a quick look here:
|
So should we keep the markdown page listing the required/optional props for each component? Or is that |
I wonder if linting error is due to not committing the changes to |
This is correct. |
const exampleImplStatements = { | ||
description: "This is the control implementation for the system.", | ||
"implemented-requirements": [ | ||
{ | ||
uuid: "implemented-requirements-1", | ||
"control-id": "control-1", | ||
statements: [ | ||
{ | ||
"statement-id": "control-1_smt.a", | ||
uuid: "f3887a91-9ed3-425c-b305-21e4634a1c34", |
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.
Overall, this PR looks pretty good! Although, maybe we could avoid some code duplication in a couple parts that come directly from the test mock data. For example, this code here looks like it could be imported from OSCALControlImplementationImpReq.test.js
.
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.
Agreed, that what I was suggesting in my comment:
We should look to extend the existing granular test data to be able to support the import of it into stories so we have as little duplication as possible and are testing with data that then surfaces in the docs.
Made inital setup for writing Storybook docs and wrote up docs for components related to OSCAL Controls. Added .stories.js files to the src/stories directory for each component. These files render the components in the Storybook stories. Created a markdown page at src/stories/OSCALDocs.stories.mdx that can serve as an initial framework for documenting the Storybook page. This will include a short description of each control and the required and optional props for each one.
Moved all Storybook stories into a "Components" directory. Changed the name and order of the stories of components to list "Default" first, and then variants on the default. Added story for Replaced Prose with By-Component Parameter Value and changed the name of Replaced Prose with Parameter Label accordingly.
Added "@testing-library/dom" to dependecies in package.json in order to fix the broken tests. Seems the storybook init command "npx sb init" was also overwriting and deleting this dependency. Adding it explicity to package.json keeps it from doing that.
Commit changes to example/package-lock.json in order to get the linting checks working.
Some override rules were added to package.json when setting up Storybook. These are removed to clean up the code.
Removed the name of the components in front of "With" in the variations to. lign with the rest of the documentation. For example, "BackMatterWithDescription" is now "WithDescription". Metadata.stories were changed also based on this. Consolidated the SystemImplementation variation into the default. Now, the default displays the version and the last modified values. Changed SystemData.js based on consolidating the SystemImplementation.stories.
Fixed some outdated testing for Replaced Prose with Parameter Label. Changes were made to the props that got passed in, but this branch still had test data that did not account for the changes.
Changed the titles of Storybook stories for Control Part and Control Implentation stories to be consistent with the rest of the stories. Changed test data for Modifications to display slightly more verbose information on Storybook. Edited the README to flow better by moving the link to Storybook further up into the Intro section. Deleted the unused file stories/OSCALControlProseByComponent.stories.js
Delete a trailing space in README.md to address the linting failure.
The structure of props passed into Modification components was changed, so the tests and Storybook files were updated to match. Also cleaned up the Modification test data to make these changes in a more efficient way.
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.
A few more minor suggestions, but they don't have to hold up approval.
@@ -0,0 +1,13 @@ | |||
/* The following URLs are all of the URLs used in testing and in the stories. */ |
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.
Is it worth pulling these into their own file?
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 think it's a bit cleaner to keep them in their own file, but if we'd rather pull it into something else that's easy enough to 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.
Would it make more sense to have the urls that go with specific data go in that data file? The other urls could go with other common data.
For example: backMatterTestUrl
goes into BackMatterData.js
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.
Having the urls in their own file will be a nice fix if/when the urls change in the future.
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 agree with @zclarkEDC - plus I think the Urls file is justified because some of the Urls are used across a couple different files.
src/test-data/OtherData.js
Outdated
@@ -0,0 +1,94 @@ | |||
import { backMatterTestData } from "./BackMatterData"; | |||
|
|||
const adds = [ |
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 seems specific to modifications, should it be moved there?
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.
Are you referring to the adds const?
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.
adds is only used in that file and isn't referenced anywhere else, that is why I placed it in OtherData.js (or whatever we rename that file to)
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.
For #124 having the modify
, including the adds
portion, of a profile is used in places other than just Profile
(SSP
& Component Definition
specifically). Maybe having a ModificationData
file makes sense? I am not sure if that is exactly what you mean @rgauss but it could prevent some duplication later.
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 related to modifications, but the only place it's used is the profile test.
I think it'd technically be cleanest to modify the profile test to use the existing
test data in test-data/ModificationsData
but that might be more trouble than it's worth
if it requires changing the test in some fundamental way.
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 moved this to a more accurately named 'ProfileData.js` - hope that makes this more readable.
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 am still going to keep my "Request changes" until all other approvals are complete and we have made our last push to the branch; this is in regards to on.push.branches[1]
and the need to remove that value but needing to not impact the ability to see live deployments while developing.
Rename test-data/OtherData.js to CommonData.js to be a bit more descriptive.
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.
All local tests pass
Test Suites: 14 passed, 14 total
Tests: 66 passed, 66 total
Snapshots: 0 total
Time: 17.925 s
Ran all test suites.
Doing npm run storybook
successfully builds all modules and opens the Storybook on localhost.
Console error when opening Control Prose -> Parameters Replaced With By-Component Value
This issue is most likely caused in OSCALControlProse.stories.js
line 51
ByComp.storyName = "Parameters Replaced With By-Component Value";
Removing this line caused the same error, however as you can see:
It changed the name to what looks like the correct naming scheme.
EDIT: this was fixed with 20d45a5
Seems this is actually caused by this prop. Not sure how we should fix this though; as far as I can tell What should this title prop actually be? I thought of passing in something like the |
When
If <StyledTooltip title={description ?? props.componentId}> |
Removed a console error caused by a `title` prop being undefined under certain circumstances in `OSCALReplacedProseWithByComponentParameterValue` this was done by a quick workaround adding a conditional if the prop is undefined. Also added the `componentId` prop into the ImplReq test data to work with this change and better document the props for Control Prose.
Moved around some test data to make it more readable. Since `otherData` was renamed to `commonData` it makes more sense to move any data that is only used in one place to a more accurately named file. Moved control prose data to ControlsData.js Moved profile test data to new file ProfileData.js
Change the export in ProfileData.js to export default to pass the linting check.
Removed `EGRC-275` from the branches that are watched by the GitHub actions script, so that when this branch is merged it only publishes on changes to develop.
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.
Everything looks good! Thanks again for all your hard work on this. The storybook looks even cooler than I thought it would.
I was still curious about what everyone thought about Ray's recommendations of:
- Putting urls into their relevant components
- Creating a
modification
test data file and moving theadds
&modify
parameters to that file.
I was just hoping to get a final opinion on what to do for those conversations then I think we should be good to merge.
Made inital setup for writing Storybook docs and
wrote up docs for components related to OSCAL Controls.
Added .stories.js files to the src/stories directory for
each component. These files render the components in the
Storybook stories.
Created a markdown page at src/stories/OSCALDocs.stories.mdx
that can serve as an initial framework for documenting the
Storybook page.
This will include a short description of each control
and the required and optional props for each one.