Closed reneefromhold closed 1 month ago
The pull request introduces several updates primarily focused on enhancing the Storybook configuration and TypeScript support across various components and files. Key changes include modifications to the .storybook/main.js
and .storybook/preview.js
files, the addition of new testing configurations in .vscode/launch.json
, and updates to the package.json
file for dependency management. Several component story files have been refactored to align with the latest Storybook API, improving type safety and documentation. Additionally, new mock data structures and test suites have been introduced to ensure comprehensive testing of functionality related to external account connections and custom activities.
File | Change Summary |
---|---|
.storybook/main.js |
Updated stories array, expanded addons , modified docs , and added typescript property. |
.storybook/preview.js |
Added tags export and removed actions property from parameters . |
.vscode/launch.json |
Introduced new "Unit Tests" configuration for debugging Jest tests. |
package.json |
Updated version, added test script, and modified devDependencies for Storybook and Jest. |
src/components/container/BasicPointsForBadges/BasicPointsForBadges.stories.tsx |
Enhanced imports, changed default export to typed constant, and updated story types. |
src/components/container/BasicPointsForBadges/BasicPointsForBadges.tsx |
Added JSDoc comment and renamed default export for clarity. |
src/helpers/BasicPointsAndBadges/ConnectExternalAccountActivity.ts |
Introduced ConnectExternalActivityType and updated filtering logic for connected accounts. |
src/helpers/BasicPointsAndBadges/CustomActivity.ts |
Removed activityState parameter from awardCustomActivityPoints function signature. |
src/helpers/BasicPointsAndBadges/PointsAndBadges.ts |
Updated awardPointsForActivity to remove activityState parameter. |
src/stories/Introduction.mdx |
Updated import statement and restructured CSS styles. |
tsconfig.json |
Added new compiler options for React and modern JavaScript features. |
__tests__/helpers/BasicPointsAndBadges/ConnectExternalAccountActivity.test.ts |
Introduced comprehensive test suite for awarding points. |
__tests__/helpers/BasicPointsAndBadges/CustomActivity.test.ts |
Added new test suite for CustomActivity functionality. |
amplify.yml |
Added npm run test command to the build phase. |
__tests__/fixtures/participantInfo.ts |
Introduced mockParticipantInfo structure for testing purposes. |
jest.config.js |
Added testPathIgnorePatterns to ignore tests in /fixtures/ . |
src/components/container/ConnectEhr/ConnectEhr.stories.tsx |
Removed ComponentMeta and ComponentStory imports, updated story structure. |
src/components/container/ConnectFitbit/ConnectFitbit.stories.tsx |
Updated imports and restructured stories to use Meta and StoryObj . |
src/components/step/ConnectDeviceAccountStepContainer/ConnectDeviceAccountStepContainer.stories.tsx |
Updated to new Storybook API with meta and Story types. |
src/components/step/ConnectEhrStepContainer/ConnectEhrStepContainer.stories.tsx |
Transitioned to new Meta and StoryObj types for story definitions. |
src/components/step/ConnectDeviceAccountStepContainer/ConnectDeviceAccountStepContainer.tsx |
Added JSDoc comment and renamed default export for clarity. |
sequenceDiagram
participant User
participant Storybook
participant Component
participant Jest
User->>Storybook: Access stories
Storybook->>Component: Render component
Component-->>Storybook: Return rendered output
Storybook-->>User: Display stories
User->>Jest: Run tests
Jest->>Component: Execute test cases
Component-->>Jest: Return test results
Jest-->>User: Display test results
Maybe others feel differently, but I find having tests in a separate
tests
folder to be a less cluttered
I appreciate that feedback. I do like the tests within the same folder as the component bc it encourages creating it as part of component/helper completion and makes the tests easy to find/reference. I am interested in hearing others thoughts too.
Maybe others feel differently, but I find having tests in a separate
tests
folder to be a less clutteredI appreciate that feedback. I do like the tests within the same folder as the component bc it encourages creating it as part of component/helper completion and makes the tests easy to find/reference. I am interested in hearing others thoughts too.
I tend to prefer a separate tests
folder as well. I agree that the co-location can make it easier to find the test for a given component, but it can also make it more difficult to tell which files in the folder are test related and which are not. The .test.ts
suffix helps with the actual test files, but if there are other .ts
files to support the .test.ts
files, then it can be trickier.
We'll also want to make sure that the tests and other test related files are not included in the published builds. That'll probably be easiest if we can just exclude (or not include) the tests
folder vs using a regex or wildcard string and naming conventions for tests (and related) files that are part of the src
directory tree.
Just putting this here so we don't forget, but the existing PR about upgrading the Storybook can probably go away once this one gets merged.
In short, this repo would benefit from more testing. -Update storybook from 7.0 to 8.5 -Introduce Jest -Add unit tests for Custom and ExternalAccount activities for use in BasicPointsForBadges -Add jsdoc comment at the component level to BasicPointsForBadges -Render the previously mentioned jsdoc comment as the description of the Default story for BasicPointsForBadges. These descriptions will export as part of the npm package
Security
REMINDER: All file contents are public.
Describe briefly what security risks you considered, why they don't apply, or how they've been mitigated.
Checklist
Testing
Documentation
Consider "Squash and merge" as needed to keep the commit history reasonable on
main
.Reviewers
Assign to the appropriate reviewer(s). Minimally, a second set of eyes is needed ensure no non-public information is published. Consider also including:
Summary by CodeRabbit
New Features
Introduction.mdx
file for better clarity.Bug Fixes
Documentation
Chores
package.json
to enhance functionality and compatibility.amplify.yml
to include testing before building Storybook artifacts.