@ssa-ui-kit/widgets 1.0.12 → 1.1.55-canary-79b6b0d-20250224
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AccountBalance/AccountBalance.d.ts +1 -1
- package/dist/components/AccountBalance/BalancePieChart.d.ts +1 -1
- package/dist/components/AccountBalance/BalancePieChartTitle.d.ts +1 -1
- package/dist/components/AccountKeys/AccountKeys.d.ts +1 -1
- package/dist/components/AccountKeys/stories/StoryComponent.d.ts +1 -1
- package/dist/components/Activity/Activity.d.ts +1 -1
- package/dist/components/Activity/ActivityItem.d.ts +1 -1
- package/dist/components/Bmi/Bmi.d.ts +1 -1
- package/dist/components/Bmi/BmiLabels.d.ts +1 -1
- package/dist/components/BotsTable/BotsTable.d.ts +1 -1
- package/dist/components/BotsTable/stories/BotsTable/StoryComponent.d.ts +1 -1
- package/dist/components/BotsTable/stories/BotsTable/components/Actions/ActionIcon.d.ts +1 -1
- package/dist/components/BotsTable/stories/BotsTable/components/Actions/ActionItem.d.ts +1 -1
- package/dist/components/BotsTable/stories/BotsTable/components/Actions/ActionMore.d.ts +1 -1
- package/dist/components/BotsTable/stories/BotsTable/components/Actions/ActionRun.d.ts +1 -1
- package/dist/components/BotsTable/stories/BotsTable/components/Actions/Actions.d.ts +1 -1
- package/dist/components/BotsTable/stories/BotsTable/components/Actions/ActionsWrapper.d.ts +1 -1
- package/dist/components/BotsTable/stories/BotsTable/components/Actions/consts.d.ts +3 -3
- package/dist/components/BotsTable/stories/BotsTable/components/Exchange/Exchange.d.ts +1 -1
- package/dist/components/BotsTable/stories/BotsTable/components/Exchange/consts.d.ts +3 -3
- package/dist/components/BotsTable/stories/BotsTable/components/PNL.d.ts +1 -1
- package/dist/components/BotsTable/stories/BotsTable/components/ROI.d.ts +1 -1
- package/dist/components/BotsTable/stories/BotsTable/components/TableTag.d.ts +1 -1
- package/dist/components/BotsTable/stories/BotsTable/components/Trade/Trade.d.ts +1 -1
- package/dist/components/BotsTable/stories/NoControlOrders/StoryComponent.d.ts +1 -1
- package/dist/components/BotsTable/stories/NoControlOrders/components/ActionMore.d.ts +1 -1
- package/dist/components/BotsTable/stories/NoControlOrders/components/Reason.d.ts +1 -1
- package/dist/components/BotsTable/stories/NoControlOrders/components/TableList.d.ts +1 -1
- package/dist/components/BotsTable/stories/NoControlOrders/components/TableRow.d.ts +1 -1
- package/dist/components/Calories/Calories.d.ts +1 -1
- package/dist/components/Calories/innerContent.d.ts +1 -1
- package/dist/components/ExchangeAccount/ExchangeAccount.d.ts +1 -1
- package/dist/components/HeartRate/BPM.d.ts +1 -1
- package/dist/components/HeartRate/HeartRate.d.ts +1 -1
- package/dist/components/HeartRate/HeartRateLineChart.d.ts +1 -1
- package/dist/components/ListGoals/ListGoals.d.ts +1 -1
- package/dist/components/ListGoals/ListGoalsCard.d.ts +1 -1
- package/dist/components/MealNutrients/MealNutrients.d.ts +1 -1
- package/dist/components/MealNutrients/MealNutrientsLineChart.d.ts +1 -1
- package/dist/components/MealNutrients/MealNutrientsTooltip.d.ts +1 -1
- package/dist/components/MealPlanner/MealPlanner.d.ts +1 -1
- package/dist/components/MealPlanner/MealPlannerCard.d.ts +1 -1
- package/dist/components/StepsCounter/StepsCounter.d.ts +1 -1
- package/dist/components/TradingInfoCard/TradingInfoCard.d.ts +1 -1
- package/dist/components/TradingInfoCard/TradingInfoCardContent.d.ts +1 -1
- package/dist/components/TradingInfoCard/TradingInfoCardTooltip.d.ts +1 -1
- package/dist/components/TradingInfoCard/TradingInfoCardWrapper.d.ts +1 -1
- package/dist/components/TradingScoreboard/TradingScoreboard.d.ts +1 -1
- package/dist/components/TradingScoreboard/helpers.d.ts +4 -4
- package/dist/components/UpcomingWorkouts/UpcomingWorkoutCard.d.ts +1 -1
- package/dist/components/UpcomingWorkouts/UpcomingWorkouts.d.ts +1 -1
- package/dist/components/UserCard/UserCard.d.ts +1 -1
- package/dist/components/UserCard/UserCardBMI.d.ts +1 -1
- package/dist/components/UserCard/UserCardCredentials.d.ts +1 -1
- package/dist/components/UserCard/UserCardItem.d.ts +1 -1
- package/dist/components/WaterConsume/WaterConsume.d.ts +1 -1
- package/dist/index.js +2439 -1
- package/dist/index.js.map +1 -1
- package/package.json +24 -27
- package/.babelrc.js +0 -4
- package/.env +0 -7
- package/.storybook/main.ts +0 -47
- package/.storybook/preview.tsx +0 -22
- package/.storybook/style.css +0 -40
- package/custom-shots/widgets-bots-table--no-control-orders--menu-opened_[w1920px].png +0 -0
- package/custom-shots/widgets-bots-table--no-control-orders--run-reason-modal_[w1920px].png +0 -0
- package/custom-shots/widgets-heart-rate--hint-opened__[w1440px].png +0 -0
- package/custom-shots/widgets-heart-rate--hint-opened__[w1920px].png +0 -0
- package/custom-shots/widgets-heart-rate--hint-opened__[w390px].png +0 -0
- package/custom-shots/widgets-heart-rate--hint-opened__[w900px].png +0 -0
- package/custom-shots/widgets-meal-nutrients--hint-opened__[w1440px].png +0 -0
- package/custom-shots/widgets-meal-nutrients--hint-opened__[w1920px].png +0 -0
- package/custom-shots/widgets-meal-nutrients--hint-opened__[w390px].png +0 -0
- package/custom-shots/widgets-meal-nutrients--hint-opened__[w900px].png +0 -0
- package/custom-shots/widgets-meal-nutrients--hint-opened__dropdown__[w1440px].png +0 -0
- package/custom-shots/widgets-meal-nutrients--hint-opened__dropdown__[w1920px].png +0 -0
- package/custom-shots/widgets-meal-nutrients--hint-opened__dropdown__[w390px].png +0 -0
- package/custom-shots/widgets-meal-nutrients--hint-opened__dropdown__[w900px].png +0 -0
- package/custom-shots/widgets-trading-info-card--hover__[w1920px].png +0 -0
- package/customTest.tsx +0 -35
- package/jest-setup.ts +0 -20
- package/lostpixel.config.ts +0 -29
- package/playwright.config.ts +0 -7
- package/src/components/AccountBalance/AccountBalance.specBackup.tsx +0 -105
- package/src/components/AccountBalance/AccountBalance.stories.tsx +0 -138
- package/src/components/AccountBalance/AccountBalance.tsx +0 -60
- package/src/components/AccountBalance/BalancePieChart.tsx +0 -127
- package/src/components/AccountBalance/BalancePieChartTitle.tsx +0 -54
- package/src/components/AccountBalance/index.ts +0 -4
- package/src/components/AccountBalance/stories/fixtures.ts +0 -26
- package/src/components/AccountBalance/types.ts +0 -41
- package/src/components/AccountKeys/AccountKeys.specBackup.tsx +0 -43
- package/src/components/AccountKeys/AccountKeys.stories.tsx +0 -14
- package/src/components/AccountKeys/AccountKeys.tsx +0 -73
- package/src/components/AccountKeys/helpers.ts +0 -7
- package/src/components/AccountKeys/index.ts +0 -2
- package/src/components/AccountKeys/stories/StoryComponent.tsx +0 -33
- package/src/components/AccountKeys/styles.ts +0 -87
- package/src/components/AccountKeys/types.ts +0 -8
- package/src/components/Activity/Activity.specBackup.tsx +0 -79
- package/src/components/Activity/Activity.stories.tsx +0 -15
- package/src/components/Activity/Activity.tsx +0 -83
- package/src/components/Activity/ActivityItem.tsx +0 -38
- package/src/components/Activity/index.tsx +0 -2
- package/src/components/Activity/mockActivityRequest.ts +0 -106
- package/src/components/Activity/styles.ts +0 -12
- package/src/components/Activity/types.ts +0 -10
- package/src/components/Bmi/Bmi.spec.Backup.tsx +0 -68
- package/src/components/Bmi/Bmi.stories.tsx +0 -10
- package/src/components/Bmi/Bmi.tsx +0 -96
- package/src/components/Bmi/BmiHeatbar.tsx +0 -18
- package/src/components/Bmi/BmiInfo.tsx +0 -11
- package/src/components/Bmi/BmiLabel.tsx +0 -9
- package/src/components/Bmi/BmiLabels.tsx +0 -33
- package/src/components/Bmi/BmiPointer.tsx +0 -15
- package/src/components/Bmi/index.tsx +0 -2
- package/src/components/Bmi/styles.ts +0 -18
- package/src/components/Bmi/types.ts +0 -4
- package/src/components/BotsTable/BotsTable.e2e.ts +0 -77
- package/src/components/BotsTable/BotsTable.specBackup.tsx +0 -125
- package/src/components/BotsTable/BotsTable.tsx +0 -32
- package/src/components/BotsTable/BotsTableCell.tsx +0 -13
- package/src/components/BotsTable/BotsTableHead.tsx +0 -13
- package/src/components/BotsTable/BotsTableRow.tsx +0 -17
- package/src/components/BotsTable/BotsTableWrapper.tsx +0 -23
- package/src/components/BotsTable/index.ts +0 -5
- package/src/components/BotsTable/stories/BotsTable/StoryComponent.tsx +0 -59
- package/src/components/BotsTable/stories/BotsTable/components/Actions/ActionIcon.tsx +0 -11
- package/src/components/BotsTable/stories/BotsTable/components/Actions/ActionItem.tsx +0 -40
- package/src/components/BotsTable/stories/BotsTable/components/Actions/ActionMore.tsx +0 -89
- package/src/components/BotsTable/stories/BotsTable/components/Actions/ActionRun.tsx +0 -133
- package/src/components/BotsTable/stories/BotsTable/components/Actions/Actions.tsx +0 -13
- package/src/components/BotsTable/stories/BotsTable/components/Actions/ActionsWrapper.tsx +0 -21
- package/src/components/BotsTable/stories/BotsTable/components/Actions/consts.tsx +0 -118
- package/src/components/BotsTable/stories/BotsTable/components/Actions/index.ts +0 -6
- package/src/components/BotsTable/stories/BotsTable/components/Exchange/Exchange.tsx +0 -26
- package/src/components/BotsTable/stories/BotsTable/components/Exchange/consts.tsx +0 -157
- package/src/components/BotsTable/stories/BotsTable/components/Exchange/index.ts +0 -1
- package/src/components/BotsTable/stories/BotsTable/components/Exchange/types.ts +0 -6
- package/src/components/BotsTable/stories/BotsTable/components/PNL.tsx +0 -27
- package/src/components/BotsTable/stories/BotsTable/components/ROI.tsx +0 -25
- package/src/components/BotsTable/stories/BotsTable/components/TableTag.tsx +0 -22
- package/src/components/BotsTable/stories/BotsTable/components/Trade/Trade.tsx +0 -8
- package/src/components/BotsTable/stories/BotsTable/components/Trade/consts.ts +0 -14
- package/src/components/BotsTable/stories/BotsTable/components/Trade/index.ts +0 -1
- package/src/components/BotsTable/stories/BotsTable/components/Trade/types.ts +0 -5
- package/src/components/BotsTable/stories/BotsTable/components/index.ts +0 -6
- package/src/components/BotsTable/stories/BotsTable/index.ts +0 -1
- package/src/components/BotsTable/stories/BotsTable/mockData.ts +0 -84
- package/src/components/BotsTable/stories/BotsTable.stories.tsx +0 -39
- package/src/components/BotsTable/stories/NoControlOrders/StoryComponent.tsx +0 -35
- package/src/components/BotsTable/stories/NoControlOrders/components/ActionMore.tsx +0 -95
- package/src/components/BotsTable/stories/NoControlOrders/components/Reason.tsx +0 -11
- package/src/components/BotsTable/stories/NoControlOrders/components/TableList.tsx +0 -45
- package/src/components/BotsTable/stories/NoControlOrders/components/TableRow.tsx +0 -31
- package/src/components/BotsTable/stories/NoControlOrders/components/index.ts +0 -4
- package/src/components/BotsTable/stories/NoControlOrders/mockData.ts +0 -23
- package/src/components/BotsTable/stories/NoControlOrders/types.ts +0 -16
- package/src/components/BotsTable/types.ts +0 -31
- package/src/components/Calories/Calories.specBackup.tsx +0 -11
- package/src/components/Calories/Calories.stories.tsx +0 -26
- package/src/components/Calories/Calories.tsx +0 -54
- package/src/components/Calories/index.tsx +0 -2
- package/src/components/Calories/innerContent.tsx +0 -30
- package/src/components/Calories/types.ts +0 -4
- package/src/components/ExchangeAccount/ExchangeAccount.specBackup.tsx +0 -104
- package/src/components/ExchangeAccount/ExchangeAccount.stories.tsx +0 -108
- package/src/components/ExchangeAccount/ExchangeAccount.tsx +0 -90
- package/src/components/ExchangeAccount/helpers.tsx +0 -153
- package/src/components/ExchangeAccount/index.ts +0 -2
- package/src/components/ExchangeAccount/styles.ts +0 -115
- package/src/components/ExchangeAccount/types.ts +0 -14
- package/src/components/HeartRate/BPM.tsx +0 -43
- package/src/components/HeartRate/HeartRate.e2e.ts +0 -78
- package/src/components/HeartRate/HeartRate.specBackup.tsx +0 -91
- package/src/components/HeartRate/HeartRate.stories.tsx +0 -36
- package/src/components/HeartRate/HeartRate.tsx +0 -105
- package/src/components/HeartRate/HeartRateLineChart.tsx +0 -53
- package/src/components/HeartRate/index.ts +0 -2
- package/src/components/HeartRate/mockHeartRateRequest.ts +0 -15
- package/src/components/HeartRate/types.ts +0 -15
- package/src/components/HeartRate/utils.tsx +0 -8
- package/src/components/ListGoals/ListGoals.specBackup.tsx +0 -82
- package/src/components/ListGoals/ListGoals.stories.tsx +0 -58
- package/src/components/ListGoals/ListGoals.tsx +0 -29
- package/src/components/ListGoals/ListGoalsCard.tsx +0 -61
- package/src/components/ListGoals/index.ts +0 -2
- package/src/components/ListGoals/styles.tsx +0 -11
- package/src/components/ListGoals/types.ts +0 -25
- package/src/components/MealNutrients/MealNutrients.e2e.ts +0 -68
- package/src/components/MealNutrients/MealNutrients.specBackup.tsx +0 -134
- package/src/components/MealNutrients/MealNutrients.stories.tsx +0 -37
- package/src/components/MealNutrients/MealNutrients.tsx +0 -84
- package/src/components/MealNutrients/MealNutrientsLineChart.tsx +0 -89
- package/src/components/MealNutrients/MealNutrientsTooltip.tsx +0 -30
- package/src/components/MealNutrients/chartDefaultConfig.tsx +0 -87
- package/src/components/MealNutrients/index.tsx +0 -2
- package/src/components/MealNutrients/mockMealNutrientsRequest.ts +0 -1246
- package/src/components/MealNutrients/types.ts +0 -37
- package/src/components/MealNutrients/useChartConfig.ts +0 -69
- package/src/components/MealPlanner/MealPlanner.specBackup.tsx +0 -77
- package/src/components/MealPlanner/MealPlanner.stories.tsx +0 -15
- package/src/components/MealPlanner/MealPlanner.tsx +0 -100
- package/src/components/MealPlanner/MealPlannerBadge.tsx +0 -15
- package/src/components/MealPlanner/MealPlannerBars.tsx +0 -19
- package/src/components/MealPlanner/MealPlannerCard.tsx +0 -73
- package/src/components/MealPlanner/MealPlannerLegends.tsx +0 -22
- package/src/components/MealPlanner/index.ts +0 -2
- package/src/components/MealPlanner/mockMealPlannerRequest.ts +0 -70
- package/src/components/MealPlanner/types.ts +0 -21
- package/src/components/StepsCounter/StepsCounter.specBackup.tsx +0 -14
- package/src/components/StepsCounter/StepsCounter.stories.tsx +0 -16
- package/src/components/StepsCounter/StepsCounter.tsx +0 -74
- package/src/components/StepsCounter/index.ts +0 -2
- package/src/components/StepsCounter/types.ts +0 -4
- package/src/components/TradingInfoCard/TradingInfoCard.e2e.ts +0 -18
- package/src/components/TradingInfoCard/TradingInfoCard.specBackup.tsx +0 -116
- package/src/components/TradingInfoCard/TradingInfoCard.stories.tsx +0 -118
- package/src/components/TradingInfoCard/TradingInfoCard.tsx +0 -49
- package/src/components/TradingInfoCard/TradingInfoCardContent.tsx +0 -32
- package/src/components/TradingInfoCard/TradingInfoCardTooltip.tsx +0 -47
- package/src/components/TradingInfoCard/TradingInfoCardWrapper.tsx +0 -72
- package/src/components/TradingInfoCard/index.ts +0 -3
- package/src/components/TradingInfoCard/types.ts +0 -27
- package/src/components/TradingScoreboard/TradingScoreboard.specBackup.tsx +0 -119
- package/src/components/TradingScoreboard/TradingScoreboard.stories.tsx +0 -119
- package/src/components/TradingScoreboard/TradingScoreboard.tsx +0 -41
- package/src/components/TradingScoreboard/TradingScoreboardBase.tsx +0 -17
- package/src/components/TradingScoreboard/helpers.tsx +0 -134
- package/src/components/TradingScoreboard/index.ts +0 -2
- package/src/components/TradingScoreboard/types.ts +0 -18
- package/src/components/UpcomingWorkouts/UpcomingWorkoutCard.tsx +0 -64
- package/src/components/UpcomingWorkouts/UpcomingWorkouts.specBackup.tsx +0 -56
- package/src/components/UpcomingWorkouts/UpcomingWorkouts.stories.tsx +0 -32
- package/src/components/UpcomingWorkouts/UpcomingWorkouts.tsx +0 -27
- package/src/components/UpcomingWorkouts/index.ts +0 -2
- package/src/components/UpcomingWorkouts/style.ts +0 -12
- package/src/components/UpcomingWorkouts/types.ts +0 -23
- package/src/components/UserCard/UserCard.tsx +0 -46
- package/src/components/UserCard/UserCardBMI.tsx +0 -37
- package/src/components/UserCard/UserCardCredentials.tsx +0 -56
- package/src/components/UserCard/UserCardItem.tsx +0 -42
- package/src/components/UserCard/index.tsx +0 -2
- package/src/components/UserCard/types.ts +0 -8
- package/src/components/WaterConsume/WaterConsume.specBackup.tsx +0 -62
- package/src/components/WaterConsume/WaterConsume.stories.tsx +0 -36
- package/src/components/WaterConsume/WaterConsume.tsx +0 -188
- package/src/components/WaterConsume/index.ts +0 -2
- package/src/components/WaterConsume/types.ts +0 -11
- package/src/consts.ts +0 -18
- package/src/index.ts +0 -36
- package/src/injectGlobal.ts +0 -41
- package/test-results/.last-run.json +0 -21
- package/tsbuildcache +0 -1
- package/tsconfig.build.json +0 -44
- package/tsconfig.json +0 -17
- package/webpack.config.js +0 -28
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { useState, useMemo, useEffect } from 'react';
|
|
2
|
-
import { css, useTheme } from '@emotion/react';
|
|
3
|
-
import { linearGradientDef } from '@nivo/core';
|
|
4
|
-
import { Point } from '@nivo/line';
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
CardHeader,
|
|
8
|
-
CardContent,
|
|
9
|
-
Card,
|
|
10
|
-
ResponsiveImage,
|
|
11
|
-
Typography,
|
|
12
|
-
} from '@ssa-ui-kit/core';
|
|
13
|
-
|
|
14
|
-
import { throttle } from '@ssa-ui-kit/utils';
|
|
15
|
-
|
|
16
|
-
import { HeartRateProps } from './types';
|
|
17
|
-
import { HeartRateLineChart } from './HeartRateLineChart';
|
|
18
|
-
import { BPM } from './BPM';
|
|
19
|
-
|
|
20
|
-
const gradientId = 'HeartRateGradient';
|
|
21
|
-
const chartFill = [{ match: '*' as const, id: gradientId }];
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* UI Component that shows the heart rate of the user
|
|
26
|
-
*/
|
|
27
|
-
export const HeartRate = ({
|
|
28
|
-
data,
|
|
29
|
-
caption = 'Heart Rate',
|
|
30
|
-
color,
|
|
31
|
-
}: HeartRateProps) => {
|
|
32
|
-
const [bpmValue, setBpmValue] = useState<number>(
|
|
33
|
-
data?.data?.[0]?.y as number,
|
|
34
|
-
);
|
|
35
|
-
const [onBpmValueChange, cancelTimer] = useMemo(
|
|
36
|
-
() => throttle((point: Point) => setBpmValue(point?.data?.y as any), 100),
|
|
37
|
-
[],
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
const theme = useTheme();
|
|
41
|
-
const chartColor = color || theme.colors.purpleDark;
|
|
42
|
-
|
|
43
|
-
useEffect(() => () => cancelTimer(), []);
|
|
44
|
-
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
setBpmValue(data?.data?.[0]?.y as number);
|
|
47
|
-
}, [data]);
|
|
48
|
-
|
|
49
|
-
const gradientDefs = useMemo(
|
|
50
|
-
() => [
|
|
51
|
-
linearGradientDef(gradientId, [
|
|
52
|
-
{ offset: 100, color: chartColor as string },
|
|
53
|
-
{ offset: 0, color: chartColor as string },
|
|
54
|
-
]),
|
|
55
|
-
],
|
|
56
|
-
[chartColor],
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
const chartProps = useMemo(
|
|
60
|
-
() => ({
|
|
61
|
-
data: [data],
|
|
62
|
-
colors: chartColor,
|
|
63
|
-
}),
|
|
64
|
-
[data, chartColor],
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<Card
|
|
69
|
-
css={css`
|
|
70
|
-
box-shadow: 0 10px 40px rgba(42, 48, 57, 0.08);
|
|
71
|
-
border-radius: 20px;
|
|
72
|
-
`}>
|
|
73
|
-
<CardHeader
|
|
74
|
-
icon={
|
|
75
|
-
<ResponsiveImage
|
|
76
|
-
css={{ filter: `drop-shadow(0px 5px 5px ${theme.colors.grey})` }}
|
|
77
|
-
srcSet="https://firebasestorage.googleapis.com/v0/b/admin-themes.appspot.com/o/img%2Fheart%2Fheart_64.png?alt=media&token=aca1639b-62f5-44ed-a0d1-3cea8e4797e2 64w, https://firebasestorage.googleapis.com/v0/b/admin-themes.appspot.com/o/img%2Fheart%2Fheart_48.png?alt=media&token=7ef68a25-5362-48b9-b359-c46b48d1db54 48w"
|
|
78
|
-
sizes="(min-width: 1440px) 64px, 48px"
|
|
79
|
-
src="https://firebasestorage.googleapis.com/v0/b/admin-themes.appspot.com/o/img%2Fheart%2Fheart_48.png?alt=media&token=7ef68a25-5362-48b9-b359-c46b48d1db54"
|
|
80
|
-
alt="Heart"
|
|
81
|
-
/>
|
|
82
|
-
}>
|
|
83
|
-
<Typography variant="h5" weight="bold">
|
|
84
|
-
{caption}
|
|
85
|
-
</Typography>
|
|
86
|
-
</CardHeader>
|
|
87
|
-
<CardContent direction="column" css={{ width: '100%' }}>
|
|
88
|
-
<div
|
|
89
|
-
css={css`
|
|
90
|
-
height: 65px;
|
|
91
|
-
width: calc(100% + 40px);
|
|
92
|
-
margin-inline: -20px;
|
|
93
|
-
`}>
|
|
94
|
-
<HeartRateLineChart
|
|
95
|
-
{...chartProps}
|
|
96
|
-
fill={chartFill}
|
|
97
|
-
defs={gradientDefs}
|
|
98
|
-
onMouseMove={onBpmValueChange}
|
|
99
|
-
/>
|
|
100
|
-
</div>
|
|
101
|
-
{bpmValue != null ? <BPM value={bpmValue} /> : null}
|
|
102
|
-
</CardContent>
|
|
103
|
-
</Card>
|
|
104
|
-
);
|
|
105
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { ResponsiveLine, LineSvgProps, LineProps } from '@nivo/line';
|
|
2
|
-
import { SimpleChartTooltip } from '@ssa-ui-kit/core';
|
|
3
|
-
|
|
4
|
-
import { getTime } from './utils';
|
|
5
|
-
|
|
6
|
-
// ScaleSpec is not exported from @nivo/line
|
|
7
|
-
type ScaleSpec = LineSvgProps['xScale'];
|
|
8
|
-
|
|
9
|
-
const defaults: Omit<LineProps, 'data'> = {
|
|
10
|
-
margin: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
11
|
-
xScale: { type: 'point' } as ScaleSpec,
|
|
12
|
-
yScale: {
|
|
13
|
-
type: 'linear',
|
|
14
|
-
min: 'auto',
|
|
15
|
-
max: 'auto',
|
|
16
|
-
stacked: true,
|
|
17
|
-
reverse: false,
|
|
18
|
-
} as ScaleSpec,
|
|
19
|
-
pointBorderColor: { from: 'serieColor' },
|
|
20
|
-
legends: [],
|
|
21
|
-
xFormat: (yVal) => getTime(new Date(yVal)),
|
|
22
|
-
yFormat: (xVal) => `${xVal} bpm`,
|
|
23
|
-
tooltip: (args) => <SimpleChartTooltip {...args} />,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const HeartRateLineChart = ({ data, ...props }: LineSvgProps) => {
|
|
27
|
-
return (
|
|
28
|
-
<ResponsiveLine
|
|
29
|
-
data={data}
|
|
30
|
-
curve="linear"
|
|
31
|
-
axisTop={null}
|
|
32
|
-
axisRight={null}
|
|
33
|
-
axisBottom={null}
|
|
34
|
-
axisLeft={null}
|
|
35
|
-
enableGridX={false}
|
|
36
|
-
enableGridY={false}
|
|
37
|
-
lineWidth={1}
|
|
38
|
-
enablePoints={false}
|
|
39
|
-
pointSize={3}
|
|
40
|
-
pointColor="black"
|
|
41
|
-
pointBorderWidth={2}
|
|
42
|
-
pointLabelYOffset={-12}
|
|
43
|
-
enableArea={true}
|
|
44
|
-
areaOpacity={0.1}
|
|
45
|
-
enableCrosshair={false}
|
|
46
|
-
crosshairType="top-left"
|
|
47
|
-
useMesh={true}
|
|
48
|
-
animate={false}
|
|
49
|
-
{...defaults}
|
|
50
|
-
{...props}
|
|
51
|
-
/>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const ONE_HOUR_MS = 3600000;
|
|
2
|
-
const BPMs = [
|
|
3
|
-
85, 120, 90, 95, 63, 75, 70, 140, 80, 60, 65, 100, 94, 88, 90, 58, 65, 71, 78,
|
|
4
|
-
65, 67, 57, 61,
|
|
5
|
-
];
|
|
6
|
-
|
|
7
|
-
const DATE_NOW_MOCKED = 1692626621701;
|
|
8
|
-
|
|
9
|
-
export const heartRateData = {
|
|
10
|
-
id: 'heart-rate',
|
|
11
|
-
data: BPMs.map((bpm, index) => ({
|
|
12
|
-
x: DATE_NOW_MOCKED - ONE_HOUR_MS * (BPMs.length - index - 1),
|
|
13
|
-
y: bpm,
|
|
14
|
-
})),
|
|
15
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Serie } from '@nivo/line';
|
|
2
|
-
|
|
3
|
-
export interface HeartRateProps {
|
|
4
|
-
data: Serie;
|
|
5
|
-
caption?: string;
|
|
6
|
-
color?: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface BMPProps {
|
|
10
|
-
value: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface HeartRateCaptionProps {
|
|
14
|
-
caption: string;
|
|
15
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { MainColors } from '@ssa-ui-kit/core';
|
|
2
|
-
import { screen } from '../../../customTest';
|
|
3
|
-
|
|
4
|
-
import ListGoals from './index';
|
|
5
|
-
|
|
6
|
-
describe('ListGoals', () => {
|
|
7
|
-
it('Render component', async () => {
|
|
8
|
-
render(
|
|
9
|
-
<ListGoals
|
|
10
|
-
goals={[
|
|
11
|
-
{
|
|
12
|
-
id: 'lifting_weights',
|
|
13
|
-
image:
|
|
14
|
-
'https://firebasestorage.googleapis.com/v0/b/admin-themes.appspot.com/o/img%2Fdumbbell%2Fdumbbell_42.png?alt=media&token=06312895-4372-47b0-a5fa-4a64726a6215',
|
|
15
|
-
title: 'Lifting weights',
|
|
16
|
-
details: 'Goal 25 kg | 20 kg',
|
|
17
|
-
completion: 79,
|
|
18
|
-
color: 'yellow' as keyof MainColors,
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
id: 'running',
|
|
22
|
-
image:
|
|
23
|
-
'https://firebasestorage.googleapis.com/v0/b/admin-themes.appspot.com/o/img%2Ftreadmill%2Ftreadmill_42.png?alt=media&token=151f51bb-a6ba-4f4a-9d51-57a6784c767b',
|
|
24
|
-
title: 'Running',
|
|
25
|
-
details: 'Goal 25 km | 19,7 km',
|
|
26
|
-
completion: 79,
|
|
27
|
-
color: 'pink' as keyof MainColors,
|
|
28
|
-
},
|
|
29
|
-
]}
|
|
30
|
-
/>,
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const list = await screen.findAllByRole('listitem');
|
|
34
|
-
const itemA = await screen.findByText('Lifting weights');
|
|
35
|
-
const itemB = await screen.findByText('Running');
|
|
36
|
-
|
|
37
|
-
expect(list.length).toBe(2);
|
|
38
|
-
expect(itemA).toBeInTheDocument();
|
|
39
|
-
expect(itemB).toBeInTheDocument();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('Render using default props values', async () => {
|
|
43
|
-
const mockData = [
|
|
44
|
-
{
|
|
45
|
-
id: 'lifting_weights',
|
|
46
|
-
image:
|
|
47
|
-
'https://firebasestorage.googleapis.com/v0/b/admin-themes.appspot.com/o/img%2Fdumbbell%2Fdumbbell_42.png?alt=media&token=06312895-4372-47b0-a5fa-4a64726a6215',
|
|
48
|
-
title: 'Lifting weights',
|
|
49
|
-
details: 'Goal 25 kg | 20 kg',
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
id: 'running',
|
|
53
|
-
image:
|
|
54
|
-
'https://firebasestorage.googleapis.com/v0/b/admin-themes.appspot.com/o/img%2Ftreadmill%2Ftreadmill_42.png?alt=media&token=151f51bb-a6ba-4f4a-9d51-57a6784c767b',
|
|
55
|
-
title: 'Running',
|
|
56
|
-
details: 'Goal 25 km | 19,7 km',
|
|
57
|
-
},
|
|
58
|
-
];
|
|
59
|
-
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
render(<ListGoals goals={mockData} />);
|
|
63
|
-
|
|
64
|
-
const list = await screen.findAllByRole('listitem');
|
|
65
|
-
const itemA = await screen.findByText('Lifting weights');
|
|
66
|
-
const itemB = await screen.findByText('Running');
|
|
67
|
-
|
|
68
|
-
expect(list.length).toBe(2);
|
|
69
|
-
expect(itemA).toBeInTheDocument();
|
|
70
|
-
expect(itemB).toBeInTheDocument();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('should not render a list if no data', async () => {
|
|
74
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
75
|
-
// @ts-ignore
|
|
76
|
-
render(<ListGoals goals={null} />);
|
|
77
|
-
|
|
78
|
-
const list = await screen.queryAllByRole('listitem');
|
|
79
|
-
|
|
80
|
-
expect(list.length).toBe(0);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { MainColors } from '@ssa-ui-kit/core';
|
|
3
|
-
|
|
4
|
-
import { ListGoals } from './ListGoals';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Fitness/ListGoals',
|
|
8
|
-
component: ListGoals,
|
|
9
|
-
} as Meta<typeof ListGoals>;
|
|
10
|
-
|
|
11
|
-
export const Default: StoryObj<typeof ListGoals> = () => {
|
|
12
|
-
const goals = [
|
|
13
|
-
{
|
|
14
|
-
id: 'lifting_weights',
|
|
15
|
-
image:
|
|
16
|
-
'https://firebasestorage.googleapis.com/v0/b/admin-themes.appspot.com/o/img%2Fdumbbell%2Fdumbbell_42.png?alt=media&token=06312895-4372-47b0-a5fa-4a64726a6215',
|
|
17
|
-
title: 'Lifting weights',
|
|
18
|
-
details: 'Goal 25 kg | 20 kg',
|
|
19
|
-
completion: 79,
|
|
20
|
-
color: 'yellow' as keyof MainColors,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
id: 'running',
|
|
24
|
-
image:
|
|
25
|
-
'https://firebasestorage.googleapis.com/v0/b/admin-themes.appspot.com/o/img%2Ftreadmill%2Ftreadmill_42.png?alt=media&token=151f51bb-a6ba-4f4a-9d51-57a6784c767b',
|
|
26
|
-
title: 'Running',
|
|
27
|
-
details: 'Goal 25 km | 19,7 km',
|
|
28
|
-
completion: 79,
|
|
29
|
-
color: 'pink' as keyof MainColors,
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
id: 'sleeping',
|
|
33
|
-
image:
|
|
34
|
-
'https://firebasestorage.googleapis.com/v0/b/admin-themes.appspot.com/o/img%2Fmoon%2Fmoon_42.png?alt=media&token=b279625d-091d-4dc2-9f0f-e670e1072174',
|
|
35
|
-
title: 'Sleeping',
|
|
36
|
-
details: 'Goal 8 hrs | 6 hrs',
|
|
37
|
-
completion: 60,
|
|
38
|
-
color: 'blue' as keyof MainColors,
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
id: 'weight_loss',
|
|
42
|
-
image:
|
|
43
|
-
'https://firebasestorage.googleapis.com/v0/b/admin-themes.appspot.com/o/img%2Fscales%2Fscales_42.png?alt=media&token=4f4c198b-7120-4e2f-a4b4-5602243eb732',
|
|
44
|
-
title: 'Weight Loss',
|
|
45
|
-
details: 'Goal 10 kg | 4 kg',
|
|
46
|
-
completion: 40,
|
|
47
|
-
color: 'purple' as keyof MainColors,
|
|
48
|
-
},
|
|
49
|
-
];
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<div style={{ background: '#f1f1f1', padding: 20 }}>
|
|
53
|
-
<ListGoals goals={goals} />
|
|
54
|
-
</div>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
Default.storyName = 'ListGoals';
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { CardList } from '@ssa-ui-kit/core';
|
|
2
|
-
|
|
3
|
-
import { ListGoalsCard } from './ListGoalsCard';
|
|
4
|
-
|
|
5
|
-
import { ListGoalsProps } from './types';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* UI Component that uses CardList to render a list of goals
|
|
10
|
-
*/
|
|
11
|
-
export const ListGoals = ({ goals }: ListGoalsProps) => {
|
|
12
|
-
return (
|
|
13
|
-
<CardList
|
|
14
|
-
title="Goals"
|
|
15
|
-
items={goals}
|
|
16
|
-
renderItem={(goal) => (
|
|
17
|
-
<ListGoalsCard
|
|
18
|
-
image={goal.image}
|
|
19
|
-
title={goal.title}
|
|
20
|
-
details={goal.details}
|
|
21
|
-
progressProps={{
|
|
22
|
-
currentValue: goal.completion,
|
|
23
|
-
color: goal.color,
|
|
24
|
-
}}
|
|
25
|
-
/>
|
|
26
|
-
)}
|
|
27
|
-
/>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { css } from '@emotion/react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Avatar,
|
|
5
|
-
Card,
|
|
6
|
-
CardContent,
|
|
7
|
-
ProgressCircle,
|
|
8
|
-
Typography,
|
|
9
|
-
Wrapper,
|
|
10
|
-
} from '@ssa-ui-kit/core';
|
|
11
|
-
|
|
12
|
-
import { content } from './styles';
|
|
13
|
-
import { ItemCardProps, ProgressProps } from './types';
|
|
14
|
-
|
|
15
|
-
export const ListGoalsCard = ({
|
|
16
|
-
image,
|
|
17
|
-
title,
|
|
18
|
-
details,
|
|
19
|
-
progressProps,
|
|
20
|
-
}: ItemCardProps) => {
|
|
21
|
-
const {
|
|
22
|
-
size = 50,
|
|
23
|
-
max = 100,
|
|
24
|
-
currentValue = 0,
|
|
25
|
-
infoContent,
|
|
26
|
-
color = 'blue',
|
|
27
|
-
} = progressProps;
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<Card noShadow>
|
|
31
|
-
<Wrapper direction="row" avatarSize={42}>
|
|
32
|
-
<Avatar size={42} image={image} css={{ borderRadius: 0 }} />
|
|
33
|
-
|
|
34
|
-
<CardContent
|
|
35
|
-
css={css`
|
|
36
|
-
width: calc(100% - 42px);
|
|
37
|
-
padding-left: 15px;
|
|
38
|
-
`}>
|
|
39
|
-
<div css={content}>
|
|
40
|
-
<Typography variant="h6">{title}</Typography>
|
|
41
|
-
<Typography variant="subtitle" as="p">
|
|
42
|
-
{details}
|
|
43
|
-
</Typography>
|
|
44
|
-
</div>
|
|
45
|
-
|
|
46
|
-
<ProgressCircle
|
|
47
|
-
size={size}
|
|
48
|
-
max={max}
|
|
49
|
-
currentValue={currentValue}
|
|
50
|
-
infoContent={
|
|
51
|
-
infoContent || (
|
|
52
|
-
<Typography variant="body1">{currentValue}%</Typography>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
color={color as ProgressProps['color']}
|
|
56
|
-
/>
|
|
57
|
-
</CardContent>
|
|
58
|
-
</Wrapper>
|
|
59
|
-
</Card>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { MainColors, ProgressCircle } from '@ssa-ui-kit/core';
|
|
2
|
-
|
|
3
|
-
export type Goal = {
|
|
4
|
-
id: string;
|
|
5
|
-
image: string;
|
|
6
|
-
title: string;
|
|
7
|
-
details: string;
|
|
8
|
-
completion: number;
|
|
9
|
-
color: keyof MainColors;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export interface ListGoalsProps {
|
|
13
|
-
goals: Array<Goal>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type ProgressProps = Partial<
|
|
17
|
-
React.ComponentProps<typeof ProgressCircle>
|
|
18
|
-
>;
|
|
19
|
-
|
|
20
|
-
export interface ItemCardProps {
|
|
21
|
-
image: string;
|
|
22
|
-
title: string;
|
|
23
|
-
details: string;
|
|
24
|
-
progressProps: ProgressProps;
|
|
25
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { test, expect, Page } from '@playwright/test';
|
|
2
|
-
import { SCREEN_SIZES } from '../../consts';
|
|
3
|
-
|
|
4
|
-
const WIDGETS_CUSTOM_SHOTS_PATH = './custom-shots/';
|
|
5
|
-
const SCREENSHOT_PREFIX = `${WIDGETS_CUSTOM_SHOTS_PATH}widgets-meal-nutrients--hint-opened__`;
|
|
6
|
-
const MOUSE_POSITIONS = {
|
|
7
|
-
390: [
|
|
8
|
-
{ x: 97, y: 122 },
|
|
9
|
-
{ x: 97, y: 122 },
|
|
10
|
-
],
|
|
11
|
-
900: [
|
|
12
|
-
{ x: 215, y: 123 },
|
|
13
|
-
{ x: 212, y: 123 },
|
|
14
|
-
],
|
|
15
|
-
1440: [
|
|
16
|
-
{ x: 334, y: 123 },
|
|
17
|
-
{ x: 337, y: 123 },
|
|
18
|
-
],
|
|
19
|
-
1920: [
|
|
20
|
-
{ x: 433, y: 125 },
|
|
21
|
-
{ x: 430, y: 125 },
|
|
22
|
-
],
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const gotoPage = (page: Page) => {
|
|
26
|
-
return page.goto(
|
|
27
|
-
'http://localhost:6007/iframe.html?args=&id=fitness-mealnutrients--default&viewMode=story',
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
test.describe('Industry Specific Widgets - Fitness - MealNutrients', () => {
|
|
32
|
-
test('Should be rendered', async ({ page }) => {
|
|
33
|
-
await gotoPage(page);
|
|
34
|
-
|
|
35
|
-
await expect(
|
|
36
|
-
page.getByRole('heading', { name: 'Meal Nutrients' }),
|
|
37
|
-
).toBeVisible();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
for (const resolution of Object.keys(SCREEN_SIZES)) {
|
|
41
|
-
const viewportSize =
|
|
42
|
-
SCREEN_SIZES[resolution as unknown as keyof typeof SCREEN_SIZES];
|
|
43
|
-
const mouseMoves =
|
|
44
|
-
MOUSE_POSITIONS[resolution as unknown as keyof typeof SCREEN_SIZES];
|
|
45
|
-
|
|
46
|
-
if (mouseMoves == null) {
|
|
47
|
-
throw new Error(
|
|
48
|
-
`No mouse move for the specified resolution "${resolution}" found`,
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
test(`[${resolution}] Tooltip is shown`, async ({ page }) => {
|
|
53
|
-
await page.setViewportSize(viewportSize);
|
|
54
|
-
await gotoPage(page);
|
|
55
|
-
for (const { x, y } of mouseMoves) {
|
|
56
|
-
await page.mouse.move(x, y);
|
|
57
|
-
}
|
|
58
|
-
await page.screenshot({
|
|
59
|
-
path: `${SCREENSHOT_PREFIX}[w${resolution}px].png`,
|
|
60
|
-
});
|
|
61
|
-
await page.getByRole('combobox').click();
|
|
62
|
-
await page.waitForSelector('[role="listbox"]');
|
|
63
|
-
await page.screenshot({
|
|
64
|
-
path: `${SCREENSHOT_PREFIX}dropdown__[w${resolution}px].png`,
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
});
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { within } from '@testing-library/dom';
|
|
2
|
-
import { waitFor } from '@testing-library/react';
|
|
3
|
-
import userEvent from '@testing-library/user-event';
|
|
4
|
-
import ResizeObserver from 'resize-observer-polyfill';
|
|
5
|
-
|
|
6
|
-
import mockApi from './mockMealNutrientsRequest';
|
|
7
|
-
const { getData, getOptions } = mockApi;
|
|
8
|
-
|
|
9
|
-
import { MealNutrients } from './index';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The Line charts have trouble rendering in the test suite (some issues with
|
|
13
|
-
* the ResizeObserver).
|
|
14
|
-
* As a temporal solution, we follow Kent's advice not to test charts
|
|
15
|
-
* with Jest:
|
|
16
|
-
* https://kentcdodds.com/calls/01/76/nivo-charts-issue
|
|
17
|
-
* */
|
|
18
|
-
const MealNutrientsLineChartMock = () => {
|
|
19
|
-
return <div data-testid="chart-mock"></div>;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
global.ResizeObserver = ResizeObserver;
|
|
23
|
-
|
|
24
|
-
jest.mock('./MealNutrientsLineChart', () => ({
|
|
25
|
-
MealNutrientsLineChart: MealNutrientsLineChartMock,
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
jest.mock('./useChartConfig', () => {
|
|
29
|
-
const useChartConfigMock = () => ({
|
|
30
|
-
xScale: { type: 'time', format: '%L', precision: 'month' },
|
|
31
|
-
axisBottom: {
|
|
32
|
-
tickSize: 0,
|
|
33
|
-
tickPadding: 30,
|
|
34
|
-
legend: '',
|
|
35
|
-
tickValues: 7,
|
|
36
|
-
tickRotation: 30,
|
|
37
|
-
format: jest.fn(),
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
return {
|
|
41
|
-
__esModule: true,
|
|
42
|
-
default: useChartConfigMock,
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
function setup(component: React.ReactElement) {
|
|
47
|
-
return {
|
|
48
|
-
user: userEvent.setup(),
|
|
49
|
-
...render(component),
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
describe('MealNutrients', () => {
|
|
54
|
-
it('Renders', async () => {
|
|
55
|
-
const options = await getOptions();
|
|
56
|
-
const data = await getData(options[0].value);
|
|
57
|
-
|
|
58
|
-
const { getByTestId, getByText } = setup(
|
|
59
|
-
<MealNutrients data={data} options={options} />,
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
getByText('Meal Nutrients');
|
|
63
|
-
|
|
64
|
-
await waitFor(() => {
|
|
65
|
-
getByTestId('chart-mock');
|
|
66
|
-
getByTestId('dropdown');
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('Changes an option and calls "onOptionChange"', async () => {
|
|
71
|
-
const options = await getOptions();
|
|
72
|
-
const data = await getData(options[0].value);
|
|
73
|
-
const mockOnChange = jest.fn(async ({ value }) => {
|
|
74
|
-
await getData(String(value));
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const { user, getByTestId, getByRole } = setup(
|
|
78
|
-
<MealNutrients
|
|
79
|
-
data={data}
|
|
80
|
-
options={options}
|
|
81
|
-
onOptionChange={mockOnChange}
|
|
82
|
-
/>,
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
await waitFor(async () => {
|
|
86
|
-
getByTestId('chart-mock');
|
|
87
|
-
const dropdownEl = getByTestId('dropdown');
|
|
88
|
-
const dropdownToggleEl = within(dropdownEl).getByRole('combobox');
|
|
89
|
-
|
|
90
|
-
await user.click(dropdownToggleEl);
|
|
91
|
-
|
|
92
|
-
const listboxEl = getByRole('listbox');
|
|
93
|
-
const listItemElToChoose = within(listboxEl).getAllByRole('listitem')[1];
|
|
94
|
-
|
|
95
|
-
await user.click(listItemElToChoose);
|
|
96
|
-
|
|
97
|
-
const selectedItemText = listItemElToChoose.textContent;
|
|
98
|
-
expect(selectedItemText).not.toBeFalsy();
|
|
99
|
-
within(dropdownToggleEl).getByText(selectedItemText as string);
|
|
100
|
-
|
|
101
|
-
expect(mockOnChange).toBeCalledWith(options[1]);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('Renders with a custom caption', async () => {
|
|
106
|
-
const caption = 'A custom caption';
|
|
107
|
-
const options = await getOptions();
|
|
108
|
-
const data = await getData(options[0].value);
|
|
109
|
-
|
|
110
|
-
const { getByTestId, getByText } = setup(
|
|
111
|
-
<MealNutrients caption={caption} data={data} options={options} />,
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
getByText(caption);
|
|
115
|
-
|
|
116
|
-
await waitFor(() => {
|
|
117
|
-
getByTestId('chart-mock');
|
|
118
|
-
getByTestId('dropdown');
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it("Hides chart when there's no data", async () => {
|
|
123
|
-
const caption = 'A custom caption';
|
|
124
|
-
const { queryByTestId, getByText } = setup(
|
|
125
|
-
<MealNutrients caption={caption} data={[]} options={[]} />,
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
getByText(caption);
|
|
129
|
-
|
|
130
|
-
await waitFor(() => {
|
|
131
|
-
expect(queryByTestId('chart-mock')).not.toBeInTheDocument();
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
});
|