Task/setup storybook test framework - #294
Open
MikeNeilson wants to merge 3 commits into
Open
Conversation
|
Please set a versioning label of either |
Author
|
Okay, I was having that same npm ci issue in act before I opened the PR. The thing does work, just the action being wonky. Though definitely possible it's an issue with the node version or something when package.lock got updated. Will investigate at some point. |
MikeNeilson
force-pushed
the
task/setup-storybook-test-framework
branch
from
July 31, 2026 20:43
8141903 to
12146e0
Compare
MikeNeilson
requested review from
krowvin and
willbreitkreutz
and removed request for
krowvin
July 31, 2026 20:44
Author
|
Okay, apparently a rather hard reset of package-lock.json is required when that start happening. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CodeBlock: This is a simple default render so a developer can see the component. I recommend every component have at least one of these static examples. E.g. no assertions. It is also useful to provide a Story that provides behavior mocks but no assertions. This allows exploratory operations. If there are assertions in the play method Storybook will reset it in the middle of you trying to do something.
CopyButton: Asserts the behavior of the copy button given some fixed text, As well as providing the default do nothing (except visual changes) Story.
Story had to mock navigator.clipboard has that component is striped out for "security reasons" when the tests are running in the browser and just not properly available on the terminal.
See https://storybook.js for more information.
Known gotcha that was not address in this initial PR. Any component that uses state or has callbacks and needs to have it behave correctly will likely need a "wrapper" render method (goes in the story) so that storybook can render that wrapper the way it needs. Sample is available here: https://github.com/opendcs/opendcs/blob/67d6d9e655132732796b006e94dc11fb35fe5dd9/javascript/opendcs-web-ui-react/src/pages/decodes/configs/Sample/SampleRetrieve.stories.tsx#L8
(Short version, if you keep having the thing pass in the browser but fail in odd ways on the console, that's probably what's going on.)
Additional tests should most definitely be added, I will do so as time permits and specific needs arise. I will also, of course, provide guidance should anyone start having issues with how things behave.
Otherwise consider implementing code coverage and some checks to make sure coverage doesn't go down when people submit new code. OpenDCS uses SonarCloud for that, there are other options. NOTE: getting the coverage to work with vitest + storybook will be more effort, especially here as the existing vitest config is separate from the new one. Consider combining that configuration into a single vitest.config.(ts|js) file as vitest supports "projects" (see https://github.com/opendcs/opendcs/blob/67d6d9e655132732796b006e94dc11fb35fe5dd9/javascript/opendcs-web-ui-react/vite.config.ts#L89).
Checklist
patch-bump,minor-bump, ormajor-bumpRelease impact