-
Notifications
You must be signed in to change notification settings - Fork 2
Update Storybook & Start using jest #334
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
Changes from all commits
fca28c9
5879c78
3b5f0dc
a30dc33
1ed03fd
e65b685
2666146
b096759
9c76dfd
d5933fc
86dbb07
1427a9f
7603dba
646e250
85bf581
6bf1a7e
54c84a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,22 @@ | ||
| module.exports = { | ||
| "stories": ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"], | ||
| "addons": ["@storybook/addon-links", "@storybook/addon-essentials", "@storybook/addon-interactions"], | ||
| "stories": ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"], | ||
|
|
||
| "addons": [ | ||
| "@storybook/addon-links", | ||
| "@storybook/addon-essentials", | ||
| "@storybook/addon-interactions", | ||
| "@storybook/addon-webpack5-compiler-babel", | ||
| "@chromatic-com/storybook" | ||
| ], | ||
|
|
||
| "framework": { | ||
| name: "@storybook/react-webpack5", | ||
| options: {} | ||
| }, | ||
| docs: { | ||
| autodocs: true | ||
|
|
||
| docs: {}, | ||
|
|
||
| typescript: { | ||
| reactDocgen: "react-docgen-typescript" | ||
| } | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,11 +39,11 @@ export const decorators = [(story, context) => { | |
| }]; | ||
|
|
||
| export const parameters = { | ||
| actions: { argTypesRegex: "^on[A-Z].*" }, | ||
| controls: { | ||
| matchers: { | ||
| color: /(background|color)$/i, | ||
| date: /Date$/, | ||
| }, | ||
| }, | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Action Logging May Be Affected by Removal of No manual action declarations ( 🔗 Analysis chainVerify the removal of automatic action logging. The Please confirm if this removal was intentional. If so, consider the following:
If this removal was unintentional, consider restoring the export const parameters = {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
+ actions: { argTypesRegex: "^on[A-Z].*" },
}To verify the impact of this change, we can run the following script: This script will help us understand if there are manual action declarations in place that might compensate for the removal of automatic action logging. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check for manual action declarations in story files
# Search for manual action declarations in story files
echo "Searching for manual action declarations in story files:"
rg --type js --type ts 'actions:' src
Length of output: 721 |
||
| export const tags = ["autodocs"]; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| { | ||
| "name": "Unit Tests", | ||
| "type": "node", | ||
| "request": "launch", | ||
| "runtimeArgs": [ | ||
| "--inspect-brk", | ||
| "${workspaceRoot}/node_modules/jest/bin/jest.js", | ||
| "--config", | ||
| "${workspaceRoot}/build/src/test/jest.config.js", | ||
| "--runInBand" | ||
| ], | ||
| "console": "integratedTerminal", | ||
| "internalConsoleOptions": "neverOpen", | ||
| "outFiles": ["${workspaceFolder}/build/**/*.js", "!**/node_modules/**"] | ||
| } | ||
| ] | ||
| } |
reneefromhold marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { ParticipantInfo } from "@careevolution/mydatahelps-js"; | ||
|
|
||
| export const mockParticipantInfo : ParticipantInfo = { | ||
| participantID: "123", | ||
| participantIdentifier: "123", | ||
| secondaryIdentifier: "123", | ||
| linkIdentifier: "123", | ||
| demographics: { | ||
| city: 'Naples', | ||
| utcOffset: '-05:00:00', | ||
| email: "[email protected]", | ||
| firstName: "John", | ||
| lastName: "Doe", | ||
| mobilePhone: "1234567890", | ||
reneefromhold marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| state: "FL", | ||
| middleName: "", | ||
| dateOfBirth: "", | ||
| gender: "", | ||
| preferredLanguage: "", | ||
| street1: "", | ||
| street2: "", | ||
| postalCode: "", | ||
| unsubscribedFromEmails: "", | ||
| timeZone: "", | ||
| unsubscribedFromSms: "" | ||
| }, | ||
| enrollmentDate: new Date().toString(), | ||
reneefromhold marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| projectID: "123", | ||
| customFields: { | ||
| } | ||
reneefromhold marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| import { awardConnectExternalAccountActivityPoints, ConnectExternalAccountActivity } from "../../../src/helpers/BasicPointsAndBadges/ConnectExternalAccountActivity"; | ||
|
|
||
| jest.mock('@careevolution/mydatahelps-js', () => { | ||
|
|
||
| const externalAccounts = [{ | ||
| "id" : 1, | ||
| "provider": { "id": 11, "name": "Garmin", "category": "Device Manufacturer"}, | ||
| status: "fetchComplete" | ||
| }, | ||
| { | ||
| "id" : 2, | ||
| "provider": { "id": 22, "name": "Fitbit", "category": "Device Manufacturer"}, | ||
| status: "fetchComplete" | ||
| }, | ||
| { | ||
| "id" : 3, | ||
| "provider": { "id": 22, "name": "FitBit", "category": "Device Manufacturer"} , | ||
| status: "unauthorized" | ||
| }, | ||
| { | ||
| "id" : 4, | ||
| "provider": { "id": 44, "name": "Health Plan 1", "category": "Health Plan"} , | ||
| status: "fetchComplete" | ||
| }]; | ||
|
|
||
| return { | ||
| __esModule: true, | ||
| default: { | ||
| token: { access_token: '1' }, | ||
| getCurrentLanguage: () => jest.fn(), | ||
| getExternalAccounts: jest.fn(() => { | ||
| return Promise.resolve(externalAccounts); | ||
| }), | ||
| on: jest.fn(), | ||
| off: jest.fn() | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| describe("ConnectExternalAccountActivity Awards", () => { | ||
| it("should award points for connecting a single external account", async () => { | ||
| const activity = { | ||
| type: "connectExternalAccount", | ||
| points: 10, | ||
| providerCategories: ["Health Plan"] | ||
| } as ConnectExternalAccountActivity; | ||
reneefromhold marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const activityState = { | ||
| pointsAwarded: 0, | ||
| providersConnected: [] | ||
| }; | ||
| const newActivityState = await awardConnectExternalAccountActivityPoints(activity, activityState); | ||
| expect(newActivityState.pointsAwarded).toBe(10); | ||
| expect(newActivityState.providersConnected).toEqual([44]); | ||
| }); | ||
|
|
||
| it("should award points for connecting multiple external accounts", async () => { | ||
| const activity = { | ||
| type: "connectExternalAccount", | ||
| points: 10, | ||
| providerCategories: ["Health Plan", 'Provider', 'Device Manufacturer'] | ||
| } as ConnectExternalAccountActivity; | ||
| const activityState = { | ||
| pointsAwarded: 0, | ||
| providersConnected: [] | ||
| }; | ||
| const newActivityState = await awardConnectExternalAccountActivityPoints(activity, activityState); | ||
| expect(newActivityState.pointsAwarded).toBe(30); | ||
| expect(newActivityState.providersConnected).toEqual([11, 22, 44]); | ||
| }); | ||
|
|
||
| it("should NOT award points for multiple external accounts connected to same provider", async () => { | ||
| const activity = { | ||
| type: "connectExternalAccount", | ||
| points: 10, | ||
| providerCategories: ["Device Manufacturer"] | ||
| } as ConnectExternalAccountActivity; | ||
| const activityState = { | ||
| pointsAwarded: 0, | ||
| providersConnected: [] | ||
| }; | ||
| const newActivityState = await awardConnectExternalAccountActivityPoints(activity, activityState); | ||
| expect(newActivityState.pointsAwarded).toBe(20); | ||
| expect(newActivityState.providersConnected).toEqual([11, 22]); | ||
| }); | ||
|
|
||
| it("should recalculate points across all providers. Awarding points should be based on newly connected", async () => { | ||
| const activity = { | ||
| type: "connectExternalAccount", | ||
| points: 10, | ||
| providerCategories: ["Health Plan"] | ||
| } as ConnectExternalAccountActivity; | ||
| const activityState = { | ||
| pointsAwarded: 20, | ||
| providersConnected: [1,2] | ||
| }; | ||
| const newActivityState = await awardConnectExternalAccountActivityPoints(activity, activityState); | ||
| expect(newActivityState.pointsAwarded).toBe(30); | ||
| expect(newActivityState.providersConnected).toEqual([1, 2, 44]); | ||
| }); | ||
|
|
||
| it("should NOT award points when the ppt does not have this provider connected", async () => { | ||
| const activity = { | ||
| type: "connectExternalAccount", | ||
| points: 10, | ||
| providerCategories: ["Provider"] | ||
| } as ConnectExternalAccountActivity; | ||
| const activityState = { | ||
| pointsAwarded: 0, | ||
| providersConnected: [] | ||
| }; | ||
| const newActivityState = await awardConnectExternalAccountActivityPoints(activity, activityState); | ||
| expect(newActivityState.pointsAwarded).toBe(0); | ||
| expect(newActivityState.providersConnected).toEqual([]); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import { mockParticipantInfo } from "../../fixtures/participantInfo"; | ||
| import { awardCustomActivityPoints, CustomActivity } from "../../../src/helpers/BasicPointsAndBadges/CustomActivity"; | ||
|
|
||
| describe("Custom Activity Awards", () => { | ||
| const pptInfo = {...mockParticipantInfo, customFields: { DailyGoals: "8" }}; | ||
|
|
||
| it("should award points based on custom field value", async () => { | ||
| const activity : CustomActivity = { | ||
| key: "CustomGoals", | ||
| type: "custom", | ||
| points: 10, | ||
| customField: "DailyGoals" | ||
| }; | ||
|
|
||
| const newActivityState = await awardCustomActivityPoints(activity, pptInfo); | ||
| expect(newActivityState.pointsAwarded).toBe(80); | ||
| }); | ||
|
|
||
|
|
||
| it("should NOT award points where missing custom field value", async () => { | ||
| const activity : CustomActivity = { | ||
| key: "CustomGoals", | ||
| type: "custom", | ||
| points: 10, | ||
| customField: "DailyGoalsMissing" | ||
| }; | ||
|
|
||
| const newActivityState = await awardCustomActivityPoints(activity, pptInfo); | ||
| expect(newActivityState.pointsAwarded).toBe(0); | ||
| }); | ||
|
|
||
| it("should handle decimal values in custom field", async () => { | ||
| const pptInfoWithDecimal = { | ||
| ...pptInfo, | ||
| customFields: { DailyGoals: "1.2" } | ||
| }; | ||
| const activity: CustomActivity = { | ||
| key: "CustomGoals", | ||
| type: "custom", | ||
| points: 8, | ||
| customField: "DailyGoals" | ||
| }; | ||
|
|
||
| const newActivityState = await awardCustomActivityPoints(activity, pptInfoWithDecimal); | ||
| expect(newActivityState.pointsAwarded).toBe(9.6); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module.exports = { | ||
| testPathIgnorePatterns: ['/fixtures/'] | ||
| }; |
Uh oh!
There was an error while loading. Please reload this page.