@umituz/web-dashboard 8.11.0 → 9.0.1
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/README.md +54 -7
- package/package.json +6 -2
- package/src/config/DashboardConfig.ts +4 -8
- package/src/domains/analytics/components/AnalyticsLayout.test.tsx +85 -0
- package/src/domains/analytics/components/AnalyticsLayout.tsx +103 -105
- package/src/domains/analytics/components/index.ts +0 -3
- package/src/domains/analytics/hooks/index.ts +1 -1
- package/src/domains/analytics/hooks/useAnalytics.test.tsx +125 -0
- package/src/domains/analytics/hooks/useAnalytics.ts +37 -56
- package/src/domains/analytics/index.ts +9 -26
- package/src/domains/analytics/services/index.ts +0 -1
- package/src/domains/analytics/types/analytics.ts +32 -149
- package/src/domains/analytics/types/index.ts +3 -15
- package/src/domains/analytics/utils/analytics.test.ts +82 -13
- package/src/domains/analytics/utils/analytics.ts +54 -77
- package/src/domains/analytics/utils/index.ts +5 -8
- package/src/domains/charts/charts.css +455 -0
- package/src/domains/charts/components/ActivityHeatmap.test.tsx +48 -0
- package/src/domains/charts/components/ActivityHeatmap.tsx +58 -0
- package/src/domains/charts/components/BarChart.test.tsx +91 -0
- package/src/domains/charts/components/BarChart.tsx +143 -0
- package/src/domains/charts/components/ChartCard.tsx +39 -0
- package/src/domains/charts/components/ChartPrimitives.test.tsx +90 -0
- package/src/domains/charts/components/ChartTip.tsx +18 -0
- package/src/domains/charts/components/Donut.test.tsx +51 -0
- package/src/domains/charts/components/Donut.tsx +97 -0
- package/src/domains/charts/components/HBars.tsx +31 -0
- package/src/domains/charts/components/Legend.tsx +21 -0
- package/src/domains/charts/components/LineChart.test.tsx +81 -0
- package/src/domains/charts/components/LineChart.tsx +244 -0
- package/src/domains/charts/components/Sparkline.tsx +35 -0
- package/src/domains/charts/components/index.ts +16 -0
- package/src/domains/charts/index.ts +16 -2
- package/src/domains/charts/ssr.test.tsx +35 -0
- package/src/domains/charts/types/index.ts +8 -0
- package/src/domains/charts/utils.ts +15 -0
- package/src/index.ts +6 -23
- package/src/styles/chrome.css +10 -490
- package/src/styles/dashboard.contract.test.ts +20 -5
- package/src/styles/dashboard.css +1 -0
- package/src/domains/analytics/components/AnalyticsCard.tsx +0 -87
- package/src/domains/analytics/components/AnalyticsChart.tsx +0 -387
- package/src/domains/analytics/components/MetricCard.tsx +0 -42
- package/src/domains/analytics/services/AnalyticsEngineService.ts +0 -300
- package/src/domains/charts/components.test.tsx +0 -141
- package/src/domains/charts/components.tsx +0 -683
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CohortAnalysis,
|
|
3
|
-
FunnelData,
|
|
4
|
-
UserSegment,
|
|
5
|
-
} from '../types/analytics';
|
|
6
|
-
|
|
7
|
-
export interface ConversionPath {
|
|
8
|
-
path: string[];
|
|
9
|
-
conversions: number;
|
|
10
|
-
value: number;
|
|
11
|
-
abandonmentRate: number;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface HeatmapData {
|
|
15
|
-
day: string;
|
|
16
|
-
hour: number;
|
|
17
|
-
value: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface UserBehaviorPrediction {
|
|
21
|
-
churnProbability: number;
|
|
22
|
-
lifetimeValue: number;
|
|
23
|
-
nextAction: string;
|
|
24
|
-
confidence: number;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface UserData {
|
|
28
|
-
signup_date?: string | Date;
|
|
29
|
-
last_activity?: string | Date;
|
|
30
|
-
last_login_days?: number;
|
|
31
|
-
session_duration?: number;
|
|
32
|
-
pages_per_session?: number;
|
|
33
|
-
bounce_rate?: number;
|
|
34
|
-
age?: number;
|
|
35
|
-
location?: string;
|
|
36
|
-
churned?: boolean;
|
|
37
|
-
lifetime_value?: number;
|
|
38
|
-
last_action?: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface ConversionData {
|
|
42
|
-
path?: string[];
|
|
43
|
-
value?: number;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface FunnelItem {
|
|
47
|
-
[key: string]: boolean | number | undefined;
|
|
48
|
-
time_spent?: number;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface ActivityItem {
|
|
52
|
-
timestamp: string | Date;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
type NumericUserMetric =
|
|
56
|
-
| 'session_duration'
|
|
57
|
-
| 'pages_per_session'
|
|
58
|
-
| 'bounce_rate'
|
|
59
|
-
| 'lifetime_value'
|
|
60
|
-
| 'last_login_days';
|
|
61
|
-
|
|
62
|
-
const isUserMetric = (key: string): key is NumericUserMetric =>
|
|
63
|
-
[
|
|
64
|
-
'session_duration',
|
|
65
|
-
'pages_per_session',
|
|
66
|
-
'bounce_rate',
|
|
67
|
-
'lifetime_value',
|
|
68
|
-
'last_login_days',
|
|
69
|
-
].includes(key);
|
|
70
|
-
|
|
71
|
-
const getNumericMetric = (user: UserData, key: NumericUserMetric): number => {
|
|
72
|
-
const value = user[key];
|
|
73
|
-
return typeof value === 'number' ? value : 0;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const SEGMENT_THRESHOLDS = {
|
|
77
|
-
activeDays: 7,
|
|
78
|
-
moderateDays: 30,
|
|
79
|
-
} as const;
|
|
80
|
-
|
|
81
|
-
export class AnalyticsEngineService {
|
|
82
|
-
public calculateRetention(data: UserData[]): CohortAnalysis[] {
|
|
83
|
-
const cohorts: Map<string, UserData[]> = new Map();
|
|
84
|
-
|
|
85
|
-
data.forEach((user) => {
|
|
86
|
-
if (!user.signup_date) return;
|
|
87
|
-
const signupMonth = new Date(user.signup_date).toISOString().slice(0, 7);
|
|
88
|
-
if (!cohorts.has(signupMonth)) {
|
|
89
|
-
cohorts.set(signupMonth, []);
|
|
90
|
-
}
|
|
91
|
-
const cohort = cohorts.get(signupMonth);
|
|
92
|
-
if (cohort) {
|
|
93
|
-
cohort.push(user);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const cohortAnalysis: CohortAnalysis[] = [];
|
|
98
|
-
|
|
99
|
-
cohorts.forEach((users, cohort) => {
|
|
100
|
-
const retention: number[] = [];
|
|
101
|
-
for (let month = 0; month < 12; month++) {
|
|
102
|
-
const activeUsersCount = users.filter((user) => {
|
|
103
|
-
if (!user.last_activity || !user.signup_date) return false;
|
|
104
|
-
const signupDate = new Date(user.signup_date);
|
|
105
|
-
const targetDate = new Date(
|
|
106
|
-
signupDate.getFullYear(),
|
|
107
|
-
signupDate.getMonth() + month,
|
|
108
|
-
1,
|
|
109
|
-
);
|
|
110
|
-
return new Date(user.last_activity) >= targetDate;
|
|
111
|
-
}).length;
|
|
112
|
-
|
|
113
|
-
retention.push((activeUsersCount / users.length) * 100);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
cohortAnalysis.push({
|
|
117
|
-
cohort,
|
|
118
|
-
size: users.length,
|
|
119
|
-
retention,
|
|
120
|
-
averageRetention: retention.length === 0
|
|
121
|
-
? 0
|
|
122
|
-
: retention.reduce((a, b) => a + b, 0) / retention.length,
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
return cohortAnalysis;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
public analyzeConversionPaths(data: ConversionData[]): ConversionPath[] {
|
|
130
|
-
const paths: Map<string, { count: number; value: number }> = new Map();
|
|
131
|
-
let totalConversions = 0;
|
|
132
|
-
|
|
133
|
-
data.forEach((conversion) => {
|
|
134
|
-
if (!conversion.path) return;
|
|
135
|
-
const pathKey = conversion.path.join(' → ');
|
|
136
|
-
if (!paths.has(pathKey)) {
|
|
137
|
-
paths.set(pathKey, { count: 0, value: 0 });
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const path = paths.get(pathKey);
|
|
141
|
-
if (path) {
|
|
142
|
-
path.count++;
|
|
143
|
-
path.value += conversion.value ?? 0;
|
|
144
|
-
totalConversions++;
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
return Array.from(paths.entries())
|
|
149
|
-
.map(([pathString, path]) => ({
|
|
150
|
-
path: pathString.split(' → '),
|
|
151
|
-
conversions: path.count,
|
|
152
|
-
value: path.value,
|
|
153
|
-
abandonmentRate:
|
|
154
|
-
totalConversions > 0
|
|
155
|
-
? ((totalConversions - path.count) / totalConversions) * 100
|
|
156
|
-
: 0,
|
|
157
|
-
}))
|
|
158
|
-
.sort((a, b) => b.conversions - a.conversions);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
public calculateFunnel(data: FunnelItem[], steps: string[]): FunnelData {
|
|
162
|
-
let previousCount = data.length;
|
|
163
|
-
const funnelSteps = steps.map((step, index) => {
|
|
164
|
-
const stepCount = data.filter((item) => Boolean(item[step])).length;
|
|
165
|
-
const conversionRate =
|
|
166
|
-
index === 0 ? 100 : previousCount > 0 ? (stepCount / previousCount) * 100 : 0;
|
|
167
|
-
previousCount = stepCount;
|
|
168
|
-
|
|
169
|
-
const stepData = data.filter((item) => Boolean(item[step]));
|
|
170
|
-
const avgTime =
|
|
171
|
-
stepData.length > 0
|
|
172
|
-
? stepData.reduce((sum, item) => sum + (item.time_spent ?? 0), 0) /
|
|
173
|
-
stepData.length
|
|
174
|
-
: 0;
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
name: step,
|
|
178
|
-
count: stepCount,
|
|
179
|
-
conversionRate,
|
|
180
|
-
dropOffRate: 100 - conversionRate,
|
|
181
|
-
averageTime: avgTime,
|
|
182
|
-
};
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
return {
|
|
186
|
-
title: 'Conversion Funnel',
|
|
187
|
-
steps: funnelSteps,
|
|
188
|
-
totalUsers: data.length,
|
|
189
|
-
finalConversion: funnelSteps[funnelSteps.length - 1]?.conversionRate ?? 0,
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
public generateActivityHeatmap(data: ActivityItem[]): HeatmapData[] {
|
|
194
|
-
const heatmap: HeatmapData[] = [];
|
|
195
|
-
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] as const;
|
|
196
|
-
|
|
197
|
-
for (let day = 0; day < 7; day++) {
|
|
198
|
-
for (let hour = 0; hour < 24; hour++) {
|
|
199
|
-
const count = data.filter((item) => {
|
|
200
|
-
const d = new Date(item.timestamp);
|
|
201
|
-
const mondayFirst = (d.getDay() + 6) % 7;
|
|
202
|
-
return mondayFirst === day && d.getHours() === hour;
|
|
203
|
-
}).length;
|
|
204
|
-
|
|
205
|
-
heatmap.push({ day: days[day], hour, value: count });
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return heatmap;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
public segmentUsers(data: UserData[]): UserSegment[] {
|
|
212
|
-
const defineSegment = (
|
|
213
|
-
name: string,
|
|
214
|
-
filter: (u: UserData) => boolean,
|
|
215
|
-
chars: string[],
|
|
216
|
-
) => {
|
|
217
|
-
const users = data.filter(filter);
|
|
218
|
-
const safeAvg = (field: string): number => {
|
|
219
|
-
if (users.length === 0) return 0;
|
|
220
|
-
if (!isUserMetric(field)) return 0;
|
|
221
|
-
return users.reduce((sum, user) => sum + getNumericMetric(user, field), 0) /
|
|
222
|
-
users.length;
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
return {
|
|
226
|
-
name,
|
|
227
|
-
count: users.length,
|
|
228
|
-
percentage: data.length === 0 ? 0 : (users.length / data.length) * 100,
|
|
229
|
-
characteristics: chars,
|
|
230
|
-
behavior: {
|
|
231
|
-
avgSessionDuration: safeAvg('session_duration'),
|
|
232
|
-
pagesPerSession: safeAvg('pages_per_session'),
|
|
233
|
-
bounceRate: safeAvg('bounce_rate'),
|
|
234
|
-
},
|
|
235
|
-
};
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
return [
|
|
239
|
-
defineSegment('Active', (u) => {
|
|
240
|
-
const days = u.last_login_days;
|
|
241
|
-
return typeof days === 'number' && days <= SEGMENT_THRESHOLDS.activeDays;
|
|
242
|
-
}, ['Recent login', 'High engagement']),
|
|
243
|
-
defineSegment('Moderate', (u) => {
|
|
244
|
-
const days = u.last_login_days;
|
|
245
|
-
return (
|
|
246
|
-
typeof days === 'number' &&
|
|
247
|
-
days > SEGMENT_THRESHOLDS.activeDays &&
|
|
248
|
-
days <= SEGMENT_THRESHOLDS.moderateDays
|
|
249
|
-
);
|
|
250
|
-
}, ['Occasional login']),
|
|
251
|
-
defineSegment('Inactive', (u) => {
|
|
252
|
-
const days = u.last_login_days;
|
|
253
|
-
return typeof days === 'number' && days > SEGMENT_THRESHOLDS.moderateDays;
|
|
254
|
-
}, ['Churn risk', 'Low activity']),
|
|
255
|
-
];
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
public predictUserBehavior(
|
|
259
|
-
user: UserData,
|
|
260
|
-
historicalData: UserData[],
|
|
261
|
-
): UserBehaviorPrediction {
|
|
262
|
-
const similarUsers = historicalData.filter(
|
|
263
|
-
(u) =>
|
|
264
|
-
Math.abs((u.age ?? 0) - (user.age ?? 0)) < 5 && u.location === user.location,
|
|
265
|
-
);
|
|
266
|
-
|
|
267
|
-
if (similarUsers.length === 0) {
|
|
268
|
-
return {
|
|
269
|
-
churnProbability: 0,
|
|
270
|
-
lifetimeValue: 0,
|
|
271
|
-
nextAction: 'none',
|
|
272
|
-
confidence: 0,
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
const churnCount = similarUsers.filter((u) => u.churned).length;
|
|
277
|
-
const totalLTV = similarUsers.reduce((s, u) => s + (u.lifetime_value ?? 0), 0);
|
|
278
|
-
|
|
279
|
-
const actions = similarUsers
|
|
280
|
-
.map((u) => u.last_action)
|
|
281
|
-
.filter((action): action is string => Boolean(action));
|
|
282
|
-
const actionCounts = actions.reduce<Record<string, number>>((c, a) => {
|
|
283
|
-
c[a] = (c[a] ?? 0) + 1;
|
|
284
|
-
return c;
|
|
285
|
-
}, {});
|
|
286
|
-
const nextAction = Object.keys(actionCounts).reduce(
|
|
287
|
-
(a, b) => (actionCounts[a] > actionCounts[b] ? a : b),
|
|
288
|
-
'unknown',
|
|
289
|
-
);
|
|
290
|
-
|
|
291
|
-
return {
|
|
292
|
-
churnProbability: churnCount / similarUsers.length,
|
|
293
|
-
lifetimeValue: totalLTV / similarUsers.length,
|
|
294
|
-
nextAction,
|
|
295
|
-
confidence: Math.min(0.9, similarUsers.length / 100),
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export const analyticsEngineService = new AnalyticsEngineService();
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { renderToString } from 'react-dom/server';
|
|
3
|
-
import { ActivityHeatmap, BarChart, Donut, Legend, LineChart, Sparkline } from './components';
|
|
4
|
-
|
|
5
|
-
describe('charts markup smoke', () => {
|
|
6
|
-
it('Sparkline renders an svg path for enough data and null for less', () => {
|
|
7
|
-
const html = renderToString(<Sparkline data={[1, 3, 2, 5]} />);
|
|
8
|
-
expect(html).toContain('<svg');
|
|
9
|
-
expect(html).toContain('<path');
|
|
10
|
-
expect(renderToString(<Sparkline data={[1]} />)).toBe('');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('BarChart renders one grouped column per label with one bar per series', () => {
|
|
14
|
-
const html = renderToString(
|
|
15
|
-
<BarChart
|
|
16
|
-
labels={['mon', 'tue', 'wed']}
|
|
17
|
-
series={[
|
|
18
|
-
{ key: 'a', label: 'A', values: [4, 8, 0] },
|
|
19
|
-
{ key: 'b', label: 'B', values: [2, 4, 6], tone: '#111111' },
|
|
20
|
-
]}
|
|
21
|
-
/>,
|
|
22
|
-
);
|
|
23
|
-
expect(html.match(/udb-barchart__col(?![a-z])/g)?.length).toBe(3);
|
|
24
|
-
expect(html.match(/udb-barchart__bar(?![a-z_])/g)?.length).toBe(6);
|
|
25
|
-
expect(html).toContain('height:100%');
|
|
26
|
-
expect(html).toContain('height:50%');
|
|
27
|
-
expect(html).toContain('#111111');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('Donut renders a segment circle per label with dash math and center fallback', () => {
|
|
31
|
-
const html = renderToString(
|
|
32
|
-
<Donut
|
|
33
|
-
segments={[
|
|
34
|
-
{ label: 'a', value: 3, tone: '#111111' },
|
|
35
|
-
{ label: 'b', value: 1, tone: '#222222' },
|
|
36
|
-
]}
|
|
37
|
-
centerValue="4"
|
|
38
|
-
centerLabel="total"
|
|
39
|
-
/>,
|
|
40
|
-
);
|
|
41
|
-
expect(html.match(/udb-donut__item(?![a-z])/g)?.length).toBe(2);
|
|
42
|
-
expect(html).toContain('75<!-- -->%');
|
|
43
|
-
expect(html).toContain('#111111');
|
|
44
|
-
expect(html).toContain('>total<');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('LineChart renders series paths, grid lines and a legend entry per series', () => {
|
|
48
|
-
const html = renderToString(
|
|
49
|
-
<LineChart
|
|
50
|
-
points={[{ label: 'w1' }, { label: 'w2' }, { label: 'w3' }]}
|
|
51
|
-
series={[
|
|
52
|
-
{ key: 's1', label: 'revenue', values: [2, 4, 8] },
|
|
53
|
-
{ key: 's2', label: 'cost', values: [5, 3, 1], kind: 'bars', axis: 'right' },
|
|
54
|
-
]}
|
|
55
|
-
/>,
|
|
56
|
-
);
|
|
57
|
-
expect(html).toContain('udb-linechart__grid');
|
|
58
|
-
expect(html).toContain('revenue');
|
|
59
|
-
expect(html).toContain('cost');
|
|
60
|
-
expect(html.match(/<rect /g)?.length).toBe(3);
|
|
61
|
-
expect(html.match(/udb-chartlegend__dot/g)?.length).toBeGreaterThanOrEqual(2);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('LineChart renders nothing without points', () => {
|
|
65
|
-
expect(renderToString(<LineChart points={[]} series={[]} />)).toBe('');
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('fleet aliases: LineChart accepts labels/formatValue and key-less series with data/color', () => {
|
|
69
|
-
const html = renderToString(
|
|
70
|
-
<LineChart
|
|
71
|
-
labels={['m1', 'm2']}
|
|
72
|
-
series={[{ label: 'views', data: [1, 3], color: '#123456' }]}
|
|
73
|
-
formatValue={(v) => String(v)}
|
|
74
|
-
/>,
|
|
75
|
-
);
|
|
76
|
-
expect(html).toContain('#123456');
|
|
77
|
-
expect(html).toContain('views');
|
|
78
|
-
expect(html).toContain('m1');
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('fleet aliases: BarChart accepts key-less series with data/color', () => {
|
|
82
|
-
const html = renderToString(
|
|
83
|
-
<BarChart labels={['a', 'b']} series={[{ label: 'A', data: [2, 4], color: '#654321' }]} />,
|
|
84
|
-
);
|
|
85
|
-
expect(html).toContain('#654321');
|
|
86
|
-
expect(html).toContain('height:100%');
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('BarChart renders a dashed goal line that counts toward max and clamps at 100%', () => {
|
|
90
|
-
const html = renderToString(
|
|
91
|
-
<BarChart
|
|
92
|
-
labels={['a', 'b']}
|
|
93
|
-
series={[{ label: 'A', values: [2, 4] }]}
|
|
94
|
-
goalLine={{ value: 4, label: 'goal 4', tone: '#111111' }}
|
|
95
|
-
/>,
|
|
96
|
-
);
|
|
97
|
-
expect(html).toContain('udb-barchart__goal');
|
|
98
|
-
expect(html).toContain('bottom:100%');
|
|
99
|
-
expect(html).toContain('border-top-color:#111111');
|
|
100
|
-
expect(html).toContain('>goal 4<');
|
|
101
|
-
|
|
102
|
-
const above = renderToString(
|
|
103
|
-
<BarChart labels={['a']} series={[{ label: 'A', values: [2] }]} goalLine={{ value: 99 }} />,
|
|
104
|
-
);
|
|
105
|
-
expect(above).toContain('bottom:100%');
|
|
106
|
-
expect(above).not.toContain('udb-barchart__goallabel');
|
|
107
|
-
|
|
108
|
-
const without = renderToString(<BarChart labels={['a']} series={[{ label: 'A', values: [2] }]} />);
|
|
109
|
-
expect(without).not.toContain('udb-barchart__goal');
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it('fleet aliases: Legend renders hint suffix and Donut accepts color', () => {
|
|
113
|
-
const html = renderToString(
|
|
114
|
-
<>
|
|
115
|
-
<Legend items={[{ label: 'A', color: '#111111', value: '12', hint: '(per month)' }]} />
|
|
116
|
-
<Donut segments={[{ label: 'x', value: 2, color: '#333333' }]} />
|
|
117
|
-
</>,
|
|
118
|
-
|
|
119
|
-
);
|
|
120
|
-
expect(html).toContain('udb-chartlegend__hint');
|
|
121
|
-
expect(html).toContain('(per month)');
|
|
122
|
-
expect(html).toContain('#333333');
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('ActivityHeatmap renders 7 rows and cells with aria-label', () => {
|
|
126
|
-
const html = renderToString(
|
|
127
|
-
<ActivityHeatmap
|
|
128
|
-
cells={[
|
|
129
|
-
{ day: '2026-10-01', value: 0 },
|
|
130
|
-
{ day: '2026-10-02', value: 5 },
|
|
131
|
-
{ day: '2026-10-03', value: 10 },
|
|
132
|
-
]}
|
|
133
|
-
ariaLabel="Activity Grid"
|
|
134
|
-
/>
|
|
135
|
-
);
|
|
136
|
-
expect(html).toContain('role="img"');
|
|
137
|
-
expect(html).toContain('aria-label="Activity Grid"');
|
|
138
|
-
expect(html).toContain('grid-rows-7');
|
|
139
|
-
expect(html).toContain('2026-10-02: 5');
|
|
140
|
-
});
|
|
141
|
-
});
|