@gntik-ai/blocks 0.9.0 → 0.11.0
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/index.d.ts +426 -55
- package/dist/index.js +2275 -639
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/auth/ForgotPasswordForm/ForgotPasswordForm.labels.test.tsx +179 -0
- package/src/auth/ForgotPasswordForm/ForgotPasswordForm.tsx +59 -24
- package/src/auth/ForgotPasswordForm/block.meta.ts +22 -1
- package/src/auth/ForgotPasswordForm/examples/Labels.tsx +29 -0
- package/src/auth/MfaChallenge/MfaChallenge.labels.test.tsx +139 -0
- package/src/auth/MfaChallenge/MfaChallenge.tsx +69 -23
- package/src/auth/MfaChallenge/block.meta.ts +29 -1
- package/src/auth/MfaChallenge/examples/Labels.tsx +28 -0
- package/src/auth/ResetPasswordForm/ResetPasswordForm.labels.test.tsx +104 -0
- package/src/auth/ResetPasswordForm/ResetPasswordForm.tsx +42 -15
- package/src/auth/ResetPasswordForm/block.meta.ts +17 -1
- package/src/auth/ResetPasswordForm/examples/Labels.tsx +28 -0
- package/src/auth/SignInForm/SignInForm.labels.test.tsx +137 -0
- package/src/auth/SignInForm/SignInForm.tsx +43 -16
- package/src/auth/SignInForm/block.meta.ts +22 -1
- package/src/auth/SignInForm/examples/Labels.tsx +29 -0
- package/src/auth/SignUpForm/SignUpForm.labels.test.tsx +217 -0
- package/src/auth/SignUpForm/SignUpForm.tsx +65 -26
- package/src/auth/SignUpForm/block.meta.ts +27 -1
- package/src/auth/SignUpForm/examples/Labels.tsx +29 -0
- package/src/auth/SsoButtons/SsoButtons.labels.test.tsx +30 -0
- package/src/auth/SsoButtons/SsoButtons.tsx +10 -2
- package/src/auth/SsoButtons/block.meta.ts +8 -1
- package/src/auth/SsoButtons/examples/Labels.tsx +24 -0
- package/src/auth/shared.i18n.test.tsx +71 -0
- package/src/auth/shared.tsx +48 -11
- package/src/billing/CostBreakdown/CostBreakdown.test.tsx +10 -0
- package/src/billing/CostBreakdown/CostBreakdown.tsx +50 -43
- package/src/billing/SpendVsBudget/SpendVsBudget.test.tsx +10 -0
- package/src/billing/SpendVsBudget/SpendVsBudget.tsx +35 -31
- package/src/builders/FlowBuilder/FlowBuilder.test.tsx +237 -2
- package/src/builders/FlowBuilder/FlowBuilder.tsx +101 -29
- package/src/builders/FlowBuilder/block.meta.ts +1 -1
- package/src/builders/FlowBuilder/connections.ts +30 -12
- package/src/builders/FlowBuilder/examples/ControlledGraph.tsx +8 -0
- package/src/builders/FlowBuilder/graph-state.ts +78 -0
- package/src/builders/LogViewer/LogViewer.labels.test.tsx +90 -0
- package/src/builders/LogViewer/LogViewer.levels.test.tsx +49 -0
- package/src/builders/LogViewer/LogViewer.tsx +72 -18
- package/src/builders/LogViewer/LogViewer.wrap.test.tsx +181 -0
- package/src/builders/LogViewer/block.meta.ts +19 -1
- package/src/builders/LogViewer/examples/Spanish.tsx +30 -0
- package/src/builders/LogViewer/examples/Wrap.tsx +62 -0
- package/src/builders/LogViewer/use-wrapped-log-rows.ts +42 -0
- package/src/data-display/ChartCard/ChartCard.locale.test.tsx +15 -0
- package/src/data-display/ChartCard/ChartCard.test.tsx +9 -0
- package/src/data-display/ChartCard/ChartCard.tsx +81 -67
- package/src/data-display/ChartCard/block.meta.ts +1 -1
- package/src/data-display/DescriptionListCard/DescriptionListCard.labels.test.tsx +73 -0
- package/src/data-display/DescriptionListCard/DescriptionListCard.options.test.tsx +64 -0
- package/src/data-display/DescriptionListCard/DescriptionListCard.tsx +74 -23
- package/src/data-display/DescriptionListCard/block.meta.ts +11 -1
- package/src/data-display/DescriptionListCard/examples/Spanish.tsx +29 -0
- package/src/feedback/EmptyStates/EmptyStates.labels.test.tsx +185 -0
- package/src/feedback/EmptyStates/EmptyStates.tsx +101 -30
- package/src/feedback/EmptyStates/NoAccessEmpty.options.test.tsx +38 -0
- package/src/feedback/EmptyStates/block.meta.ts +73 -1
- package/src/feedback/EmptyStates/examples/Spanish.tsx +48 -0
- package/src/feedback/ErrorPanel/ErrorPanel.labels.test.tsx +99 -0
- package/src/feedback/ErrorPanel/ErrorPanel.tsx +38 -9
- package/src/feedback/ErrorPanel/block.meta.ts +19 -1
- package/src/feedback/ErrorPanel/examples/Spanish.tsx +30 -0
- package/src/feedback/InlineCallout/InlineCallout.labels.test.tsx +62 -0
- package/src/feedback/InlineCallout/InlineCallout.tsx +22 -9
- package/src/feedback/InlineCallout/block.meta.ts +9 -1
- package/src/feedback/InlineCallout/examples/Spanish.tsx +19 -0
- package/src/feedback/Skeletons/Skeletons.labels.test.tsx +24 -0
- package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.labels.test.tsx +115 -0
- package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.tsx +63 -21
- package/src/forms/CreateApiKeyDialog/block.meta.ts +22 -1
- package/src/forms/CreateApiKeyDialog/examples/Labels.tsx +29 -0
- package/src/forms/CredentialDisclosureDialog/CredentialDisclosureDialog.labels.test.tsx +165 -0
- package/src/forms/CredentialDisclosureDialog/CredentialDisclosureDialog.tsx +31 -8
- package/src/forms/CredentialDisclosureDialog/SecretCopy.tsx +16 -8
- package/src/forms/CredentialDisclosureDialog/block.meta.ts +19 -1
- package/src/forms/CredentialDisclosureDialog/examples/Labels.tsx +38 -0
- package/src/forms/DangerZone/ConfirmDestructiveDialog.tsx +17 -3
- package/src/forms/DangerZone/DangerZone.labels.test.tsx +87 -0
- package/src/forms/DangerZone/DangerZone.tsx +20 -5
- package/src/forms/DangerZone/block.meta.ts +10 -1
- package/src/forms/DangerZone/examples/Labels.tsx +29 -0
- package/src/forms/DateRangeFilter/DateRangeFilter.labels.test.tsx +52 -0
- package/src/forms/DateRangeFilter/DateRangeFilter.tsx +11 -3
- package/src/forms/DateRangeFilter/block.meta.ts +8 -1
- package/src/forms/DateRangeFilter/examples/Labels.tsx +28 -0
- package/src/forms/DialogWizard/DialogWizard.labels.test.tsx +37 -0
- package/src/forms/DialogWizard/DialogWizard.tsx +13 -2
- package/src/forms/DialogWizard/block.meta.ts +7 -1
- package/src/forms/DialogWizard/examples/Labels.tsx +39 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.labels.test.tsx +126 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.test.tsx +22 -1
- package/src/forms/FileUploadPanel/FileUploadPanel.tsx +85 -22
- package/src/forms/FileUploadPanel/block.meta.ts +22 -1
- package/src/forms/FileUploadPanel/examples/Labels.tsx +29 -0
- package/src/forms/FileUploadPanel/fixtures.ts +0 -12
- package/src/forms/FileUploadPanel/format-bytes.test.ts +8 -0
- package/src/forms/FormSection/FormSection.labels.test.tsx +37 -0
- package/src/forms/FormSection/FormSection.tsx +14 -3
- package/src/forms/FormSection/block.meta.ts +7 -1
- package/src/forms/FormSection/examples/Labels.tsx +27 -0
- package/src/forms/InviteMembersDialog/InviteMembersDialog.labels.test.tsx +87 -0
- package/src/forms/InviteMembersDialog/InviteMembersDialog.tsx +51 -16
- package/src/forms/InviteMembersDialog/block.meta.ts +20 -1
- package/src/forms/InviteMembersDialog/examples/Labels.tsx +28 -0
- package/src/forms/SettingsRow/SettingsRow.labels.test.tsx +33 -0
- package/src/forms/SettingsRow/SettingsRow.tsx +14 -3
- package/src/forms/SettingsRow/block.meta.ts +7 -1
- package/src/forms/SettingsRow/examples/Labels.tsx +27 -0
- package/src/forms/ValidationSummary/ValidationSummary.labels.test.tsx +47 -0
- package/src/forms/ValidationSummary/ValidationSummary.tsx +9 -3
- package/src/forms/ValidationSummary/block.meta.ts +6 -1
- package/src/forms/ValidationSummary/examples/Labels.tsx +24 -0
- package/src/forms/index.ts +5 -1
- package/src/forms/translated-content.tsx +12 -0
- package/src/page-chrome/PageHeader/PageHeader.labels.test.tsx +56 -0
- package/src/page-chrome/PageHeader/PageHeader.options.test.tsx +34 -0
- package/src/page-chrome/PageHeader/PageHeader.tsx +26 -5
- package/src/page-chrome/PageHeader/block.meta.ts +8 -1
- package/src/page-chrome/PageHeader/examples/Labels.tsx +16 -0
- package/src/page-chrome/PageHeader/examples/Spanish.tsx +11 -0
- package/src/scheduling/AgendaList/AgendaList.test.tsx +25 -0
- package/src/scheduling/AgendaList/AgendaList.tsx +7 -2
- package/src/scheduling/AgendaList/AgendaListLocale.test.tsx +11 -0
- package/src/scheduling/AgendaList/block.meta.ts +1 -1
- package/src/scheduling/AgendaList/examples/Locale.tsx +29 -0
- package/src/scheduling/MonthCalendar/MonthCalendar.test.tsx +111 -1
- package/src/scheduling/MonthCalendar/MonthCalendar.tsx +19 -9
- package/src/scheduling/MonthCalendar/block.meta.ts +1 -1
- package/src/scheduling/MonthCalendar/examples/Locale.tsx +19 -0
- package/src/scheduling/WeekCalendar/WeekCalendar.test.tsx +73 -2
- package/src/scheduling/WeekCalendar/WeekCalendar.tsx +26 -12
- package/src/scheduling/WeekCalendar/block.meta.ts +1 -1
- package/src/scheduling/WeekCalendar/examples/Locale.tsx +19 -0
- package/src/scheduling/shared/dates.test.ts +75 -0
- package/src/scheduling/shared/dates.ts +46 -22
- package/src/scheduling/shared/useSchedulingClock.ts +13 -0
- package/src/shell/GlobalSearch/GlobalSearch.test.tsx +12 -0
- package/src/shell/GlobalSearch/fixtures.ts +2 -2
- package/src/tables/DataTable/DataTable.cross-page-selection.test.tsx +322 -0
- package/src/tables/DataTable/DataTable.labels.test.tsx +74 -0
- package/src/tables/DataTable/DataTable.server-pagination.test.tsx +1 -1
- package/src/tables/DataTable/DataTable.single-select.test.tsx +47 -7
- package/src/tables/DataTable/DataTable.test.tsx +55 -0
- package/src/tables/DataTable/DataTable.tsx +134 -67
- package/src/tables/DataTable/block.meta.ts +21 -3
- package/src/tables/DataTable/data-table-props.ts +14 -5
- package/src/tables/DataTable/data-table-row.tsx +7 -3
- package/src/tables/DataTable/data-table-utils.ts +2 -0
- package/src/tables/DataTable/examples/client-selection.tsx +33 -0
- package/src/tables/DataTable/examples/paginated-single-selection.tsx +46 -0
- package/src/tables/DataTable/examples/server-pagination.tsx +55 -15
- package/src/tables/DataTable/labels.ts +4 -0
- package/src/tables/DataTable/selection-strip.tsx +31 -0
- package/src/tables/DataTable/single-selection.tsx +0 -7
- package/src/tables/DataTable/use-multiple-selection.ts +86 -0
- package/src/tables/PaginationFooter/PaginationFooter.i18n.test.tsx +26 -0
- package/src/test/OptInDefaults.test.tsx +27 -0
- package/src/test/fixtures/opt-in-defaults.json +10 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect, useId, useMemo, useRef, useState, type ReactNode, type UIEvent } from 'react';
|
|
2
2
|
import { Check, Copy, Eye, Search } from '@gntik-ai/icons';
|
|
3
3
|
import { IconButton, Input, Switch, Toggle, ToggleGroup, cn, foldText, matchRanges, useI18n } from '@gntik-ai/ui';
|
|
4
|
+
import { useWrappedLogRows } from './use-wrapped-log-rows';
|
|
4
5
|
import { logLines as defaultLines, type LogLevel, type LogLine } from './fixtures';
|
|
5
6
|
|
|
6
7
|
export type { LogLevel, LogLine } from './fixtures';
|
|
@@ -14,7 +15,23 @@ const LEVEL_STYLE: Record<LogLevel, { label: string; className: string }> = {
|
|
|
14
15
|
error: { label: 'ERROR', className: 'bg-destructive/15 text-destructive-chip-text' },
|
|
15
16
|
};
|
|
16
17
|
|
|
18
|
+
export interface LogViewerLabels {
|
|
19
|
+
levels?: Partial<Record<LogLevel, string>>;
|
|
20
|
+
title: string;
|
|
21
|
+
levelFilter: string;
|
|
22
|
+
searchLabel: string;
|
|
23
|
+
searchPlaceholder: string;
|
|
24
|
+
follow: string;
|
|
25
|
+
count: (visible: number, total: number) => string;
|
|
26
|
+
empty: string;
|
|
27
|
+
inspect: (timestamp: string) => string;
|
|
28
|
+
copy: (timestamp: string) => string;
|
|
29
|
+
copied: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
17
32
|
export interface LogViewerProps {
|
|
33
|
+
/** Per-key copy overrides; explicit props take precedence, then labels, then the active catalog. */
|
|
34
|
+
labels?: Partial<LogViewerLabels>;
|
|
18
35
|
/** Log lines, oldest first. */
|
|
19
36
|
lines?: LogLine[];
|
|
20
37
|
/** Accessible name of the log region and visible title. */
|
|
@@ -23,6 +40,8 @@ export interface LogViewerProps {
|
|
|
23
40
|
height?: number;
|
|
24
41
|
/** Fixed row height in px (the windowing math relies on it). */
|
|
25
42
|
rowHeight?: number;
|
|
43
|
+
/** Wrap full messages and measure variable-height rows. Default false; rowHeight estimates unmeasured rows. */
|
|
44
|
+
wrap?: boolean;
|
|
26
45
|
/** Rows rendered above and below the visible window. */
|
|
27
46
|
overscan?: number;
|
|
28
47
|
/** Levels shown initially. */
|
|
@@ -70,9 +89,11 @@ function lineText(line: LogLine) {
|
|
|
70
89
|
*/
|
|
71
90
|
export function LogViewer({
|
|
72
91
|
lines = defaultLines,
|
|
73
|
-
title
|
|
92
|
+
title: titleProp,
|
|
93
|
+
labels,
|
|
74
94
|
height = 360,
|
|
75
95
|
rowHeight = 24,
|
|
96
|
+
wrap = false,
|
|
76
97
|
overscan = 8,
|
|
77
98
|
defaultLevels = LOG_LEVELS,
|
|
78
99
|
defaultFollow = true,
|
|
@@ -83,7 +104,8 @@ export function LogViewer({
|
|
|
83
104
|
titleAs: TitleTag = 'h3',
|
|
84
105
|
className,
|
|
85
106
|
}: LogViewerProps) {
|
|
86
|
-
const { locale } = useI18n();
|
|
107
|
+
const { locale, t } = useI18n();
|
|
108
|
+
const title = titleProp ?? labels?.title ?? t('logViewer.title');
|
|
87
109
|
const titleId = useId();
|
|
88
110
|
const viewport = useRef<HTMLDivElement>(null);
|
|
89
111
|
const copyTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
@@ -118,12 +140,13 @@ export function LogViewer({
|
|
|
118
140
|
.map(({ line }) => line);
|
|
119
141
|
}, [foldedLines, levels, query, locale]);
|
|
120
142
|
|
|
121
|
-
const
|
|
143
|
+
const wrapped = useWrappedLogRows(wrap, visible, rowHeight, height, overscan, scrollTop, follow);
|
|
144
|
+
const total = wrap ? wrapped.total : visible.length * rowHeight;
|
|
122
145
|
const maxScroll = Math.max(0, total - height);
|
|
123
146
|
// While following, the window is pinned to the end (the DOM scroll catches up in the effect).
|
|
124
147
|
const offset = follow ? maxScroll : Math.min(scrollTop, maxScroll);
|
|
125
|
-
const start = Math.max(0, Math.floor(offset / rowHeight) - overscan);
|
|
126
|
-
const end = Math.min(visible.length, Math.ceil((offset + height) / rowHeight) + overscan);
|
|
148
|
+
const start = wrap ? wrapped.start : Math.max(0, Math.floor(offset / rowHeight) - overscan);
|
|
149
|
+
const end = wrap ? wrapped.end : Math.min(visible.length, Math.ceil((offset + height) / rowHeight) + overscan);
|
|
127
150
|
const rows = visible.slice(start, end);
|
|
128
151
|
|
|
129
152
|
useEffect(() => {
|
|
@@ -157,14 +180,21 @@ export function LogViewer({
|
|
|
157
180
|
{title}
|
|
158
181
|
</TitleTag>
|
|
159
182
|
<span className="font-mono text-[11px] text-muted-foreground">
|
|
160
|
-
{visible.length
|
|
183
|
+
{labels?.count?.(visible.length, lines.length) ??
|
|
184
|
+
t('logViewer.count', { visible: visible.length, total: lines.length })}
|
|
161
185
|
</span>
|
|
162
186
|
</div>
|
|
163
187
|
<div className="flex flex-wrap items-center gap-2 lg:ms-auto">
|
|
164
|
-
<ToggleGroup
|
|
188
|
+
<ToggleGroup
|
|
189
|
+
aria-label={labels?.levelFilter ?? t('logViewer.levelFilter')}
|
|
190
|
+
size="sm"
|
|
191
|
+
multiple
|
|
192
|
+
value={levels}
|
|
193
|
+
onValueChange={(v) => setLevels(v)}
|
|
194
|
+
>
|
|
165
195
|
{LOG_LEVELS.map((lv) => (
|
|
166
196
|
<Toggle key={lv} value={lv}>
|
|
167
|
-
{lv}
|
|
197
|
+
{labels?.levels?.[lv] ?? t(`logViewer.levelFilterOption.${lv}`)}
|
|
168
198
|
<span className="font-mono text-[10.5px] opacity-70">{counts[lv]}</span>
|
|
169
199
|
</Toggle>
|
|
170
200
|
))}
|
|
@@ -172,14 +202,19 @@ export function LogViewer({
|
|
|
172
202
|
<Input
|
|
173
203
|
size="sm"
|
|
174
204
|
type="search"
|
|
175
|
-
aria-label=
|
|
176
|
-
placeholder=
|
|
205
|
+
aria-label={labels?.searchLabel ?? t('logViewer.searchLabel')}
|
|
206
|
+
placeholder={labels?.searchPlaceholder ?? t('logViewer.searchPlaceholder')}
|
|
177
207
|
leadingIcon={Search}
|
|
178
208
|
value={query}
|
|
179
209
|
onValueChange={(v) => setQuery(String(v))}
|
|
180
210
|
className="w-full sm:w-48"
|
|
181
211
|
/>
|
|
182
|
-
<Switch
|
|
212
|
+
<Switch
|
|
213
|
+
size="sm"
|
|
214
|
+
label={labels?.follow ?? t('logViewer.follow')}
|
|
215
|
+
checked={follow}
|
|
216
|
+
onCheckedChange={setFollow}
|
|
217
|
+
/>
|
|
183
218
|
</div>
|
|
184
219
|
</div>
|
|
185
220
|
<div
|
|
@@ -194,7 +229,7 @@ export function LogViewer({
|
|
|
194
229
|
>
|
|
195
230
|
{visible.length === 0 ? (
|
|
196
231
|
<p className="px-4 py-6 text-center font-sans text-[13px] text-muted-foreground">
|
|
197
|
-
|
|
232
|
+
{labels?.empty ?? t('logViewer.empty')}
|
|
198
233
|
</p>
|
|
199
234
|
) : (
|
|
200
235
|
<div className="relative w-full" style={{ height: total }}>
|
|
@@ -204,9 +239,18 @@ export function LogViewer({
|
|
|
204
239
|
<div
|
|
205
240
|
key={line.id}
|
|
206
241
|
data-slot="log-line"
|
|
242
|
+
ref={wrap ? (node) => wrapped.measureRow(node, line.id) : undefined}
|
|
207
243
|
onClick={onSelectLine ? () => onSelectLine(line) : undefined}
|
|
208
|
-
className=
|
|
209
|
-
|
|
244
|
+
className={
|
|
245
|
+
wrap
|
|
246
|
+
? 'group absolute inset-x-0 flex items-start gap-2.5 px-3 hover:bg-secondary/50'
|
|
247
|
+
: 'group absolute inset-x-0 flex items-center gap-2.5 px-3 hover:bg-secondary/50'
|
|
248
|
+
}
|
|
249
|
+
style={
|
|
250
|
+
wrap
|
|
251
|
+
? { top: wrapped.offsets[start + i], minHeight: rowHeight }
|
|
252
|
+
: { top: (start + i) * rowHeight, height: rowHeight }
|
|
253
|
+
}
|
|
210
254
|
>
|
|
211
255
|
<span className="shrink-0 text-muted-foreground tabular-nums">{line.timestamp}</span>
|
|
212
256
|
<span
|
|
@@ -215,21 +259,27 @@ export function LogViewer({
|
|
|
215
259
|
lv.className,
|
|
216
260
|
)}
|
|
217
261
|
>
|
|
218
|
-
{
|
|
262
|
+
{labels?.levels?.[line.level] ?? t(`logViewer.level.${line.level}`)}
|
|
219
263
|
</span>
|
|
220
264
|
{line.source && (
|
|
221
265
|
<span className="hidden shrink-0 text-muted-foreground sm:inline">
|
|
222
266
|
[{highlight(line.source, query, locale)}]
|
|
223
267
|
</span>
|
|
224
268
|
)}
|
|
225
|
-
<span
|
|
269
|
+
<span
|
|
270
|
+
className={
|
|
271
|
+
wrap
|
|
272
|
+
? 'min-w-0 flex-1 whitespace-pre-wrap break-words text-foreground'
|
|
273
|
+
: 'min-w-0 flex-1 truncate text-foreground'
|
|
274
|
+
}
|
|
275
|
+
>
|
|
226
276
|
{highlight(line.message, query, locale)}
|
|
227
277
|
</span>
|
|
228
278
|
{onSelectLine && (
|
|
229
279
|
<IconButton
|
|
230
280
|
size="sm"
|
|
231
281
|
icon={Eye}
|
|
232
|
-
label={
|
|
282
|
+
label={labels?.inspect?.(line.timestamp) ?? t('logViewer.inspect', { timestamp: line.timestamp })}
|
|
233
283
|
aria-pressed={line.id === selectedLineId}
|
|
234
284
|
onClick={(event) => {
|
|
235
285
|
event.stopPropagation();
|
|
@@ -241,7 +291,11 @@ export function LogViewer({
|
|
|
241
291
|
<IconButton
|
|
242
292
|
size="sm"
|
|
243
293
|
icon={copied === line.id ? Check : Copy}
|
|
244
|
-
label={
|
|
294
|
+
label={
|
|
295
|
+
copied === line.id
|
|
296
|
+
? (labels?.copied ?? t('common.copied'))
|
|
297
|
+
: (labels?.copy?.(line.timestamp) ?? t('logViewer.copy', { timestamp: line.timestamp }))
|
|
298
|
+
}
|
|
245
299
|
onClick={(event) => {
|
|
246
300
|
if (onSelectLine) event.stopPropagation();
|
|
247
301
|
copy(line);
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { act, fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { expectNoAxeViolations } from '../../test/a11y';
|
|
4
|
+
import { LogViewer } from './LogViewer';
|
|
5
|
+
import { makeLogLines } from './fixtures';
|
|
6
|
+
|
|
7
|
+
afterEach(() => vi.unstubAllGlobals());
|
|
8
|
+
afterEach(() => vi.restoreAllMocks());
|
|
9
|
+
|
|
10
|
+
it('preserves the fixed row attributes and English names with wrap unset or false', () => {
|
|
11
|
+
const lines = makeLogLines(20);
|
|
12
|
+
const { rerender } = render(<LogViewer lines={lines} />);
|
|
13
|
+
const attributes = () =>
|
|
14
|
+
[...screen.getByRole('log').querySelectorAll('[data-slot="log-line"]')].map((row) => ({
|
|
15
|
+
className: row.className,
|
|
16
|
+
style: row.getAttribute('style'),
|
|
17
|
+
chip: row.children[1]!.textContent,
|
|
18
|
+
}));
|
|
19
|
+
const original = attributes();
|
|
20
|
+
expect(original).toHaveLength(20);
|
|
21
|
+
expect(original[0]).toEqual({
|
|
22
|
+
className: 'group absolute inset-x-0 flex items-center gap-2.5 px-3 hover:bg-secondary/50',
|
|
23
|
+
style: 'top: 0px; height: 24px;',
|
|
24
|
+
chip: 'INFO',
|
|
25
|
+
});
|
|
26
|
+
expect(original[19]!.style).toBe('top: 456px; height: 24px;');
|
|
27
|
+
expect(original.map((row) => row.chip)).toEqual([
|
|
28
|
+
'INFO',
|
|
29
|
+
'DEBUG',
|
|
30
|
+
'INFO',
|
|
31
|
+
'WARN',
|
|
32
|
+
'INFO',
|
|
33
|
+
'ERROR',
|
|
34
|
+
'INFO',
|
|
35
|
+
'DEBUG',
|
|
36
|
+
'WARN',
|
|
37
|
+
'INFO',
|
|
38
|
+
'INFO',
|
|
39
|
+
'DEBUG',
|
|
40
|
+
'INFO',
|
|
41
|
+
'WARN',
|
|
42
|
+
'INFO',
|
|
43
|
+
'ERROR',
|
|
44
|
+
'INFO',
|
|
45
|
+
'DEBUG',
|
|
46
|
+
'WARN',
|
|
47
|
+
'INFO',
|
|
48
|
+
]);
|
|
49
|
+
expect(
|
|
50
|
+
[...screen.getByRole('group', { name: 'Log levels' }).querySelectorAll('button')].map(
|
|
51
|
+
(button) => button.textContent,
|
|
52
|
+
),
|
|
53
|
+
).toEqual(['debug4', 'info10', 'warn4', 'error2']);
|
|
54
|
+
rerender(<LogViewer lines={lines} wrap={false} />);
|
|
55
|
+
expect(attributes()).toEqual(original);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('measures rows by identity across filters and appends and disconnects observers', () => {
|
|
59
|
+
const observers = new Set<{ update: () => void; nodes: Set<Element> }>();
|
|
60
|
+
vi.stubGlobal(
|
|
61
|
+
'ResizeObserver',
|
|
62
|
+
class {
|
|
63
|
+
nodes = new Set<Element>();
|
|
64
|
+
constructor(readonly update: () => void) {
|
|
65
|
+
observers.add(this);
|
|
66
|
+
}
|
|
67
|
+
observe(node: Element) {
|
|
68
|
+
this.nodes.add(node);
|
|
69
|
+
}
|
|
70
|
+
unobserve(node: Element) {
|
|
71
|
+
this.nodes.delete(node);
|
|
72
|
+
}
|
|
73
|
+
disconnect() {
|
|
74
|
+
observers.delete(this);
|
|
75
|
+
this.nodes.clear();
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
);
|
|
79
|
+
const rect = Element.prototype.getBoundingClientRect;
|
|
80
|
+
vi.spyOn(Element.prototype, 'getBoundingClientRect').mockImplementation(function (this: Element) {
|
|
81
|
+
const result = rect.call(this);
|
|
82
|
+
if (this.matches('[data-slot="log-line"]')) {
|
|
83
|
+
return {
|
|
84
|
+
...result,
|
|
85
|
+
height: this.textContent?.includes('Message 0') ? 72 : this.textContent?.includes('Message 1') ? 48 : 24,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
});
|
|
90
|
+
const lines = makeLogLines(4).map((line, i) => ({
|
|
91
|
+
...line,
|
|
92
|
+
level: (['debug', 'warn', 'info', 'error'] as const)[i]!,
|
|
93
|
+
message: `Message ${i}`,
|
|
94
|
+
}));
|
|
95
|
+
const { rerender, unmount } = render(<LogViewer lines={lines} wrap height={240} defaultFollow={false} />);
|
|
96
|
+
const log = screen.getByRole('log');
|
|
97
|
+
expect(log.firstElementChild).toHaveStyle({ height: '168px' });
|
|
98
|
+
expect(screen.getByText('Message 2').closest('[data-slot="log-line"]')).toHaveStyle({ top: '120px' });
|
|
99
|
+
fireEvent.click(screen.getByRole('button', { name: /^debug/ }));
|
|
100
|
+
expect(log.firstElementChild).toHaveStyle({ height: '96px' });
|
|
101
|
+
expect(screen.getByText('Message 2').closest('[data-slot="log-line"]')).toHaveStyle({ top: '48px' });
|
|
102
|
+
rerender(
|
|
103
|
+
<LogViewer
|
|
104
|
+
lines={[...lines, { ...lines[2]!, id: 'appended', message: 'Appended' }]}
|
|
105
|
+
wrap
|
|
106
|
+
height={240}
|
|
107
|
+
defaultFollow={false}
|
|
108
|
+
/>,
|
|
109
|
+
);
|
|
110
|
+
act(() => {
|
|
111
|
+
for (const observer of observers) observer.update();
|
|
112
|
+
});
|
|
113
|
+
expect(log.firstElementChild).toHaveStyle({ height: '120px' });
|
|
114
|
+
expect(screen.getByText('Appended').closest('[data-slot="log-line"]')).toHaveStyle({ top: '96px' });
|
|
115
|
+
expect(log.querySelectorAll('[data-slot="log-line"]')).toHaveLength(4);
|
|
116
|
+
unmount();
|
|
117
|
+
expect(observers.size).toBe(0);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it.each(['noop', 'absent'])(
|
|
121
|
+
'wraps the full message and uses contiguous estimated rows with %s ResizeObserver',
|
|
122
|
+
(observer) => {
|
|
123
|
+
if (observer === 'absent') vi.stubGlobal('ResizeObserver', undefined);
|
|
124
|
+
const message = 'A long message '.repeat(36).slice(0, 500);
|
|
125
|
+
const lines = makeLogLines(20).map((line, i) => ({ ...line, message: i === 0 ? message : `Message ${i}` }));
|
|
126
|
+
const { rerender } = render(<LogViewer lines={lines} wrap defaultFollow={false} height={72} overscan={0} />);
|
|
127
|
+
const span = screen.getByText(message);
|
|
128
|
+
expect(span).not.toHaveClass('truncate');
|
|
129
|
+
expect(span).toHaveClass('whitespace-pre-wrap', 'break-words');
|
|
130
|
+
expect(span.textContent).toBe(message);
|
|
131
|
+
const log = screen.getByRole('log');
|
|
132
|
+
const rowMessages = () =>
|
|
133
|
+
[...log.querySelectorAll('[data-slot="log-line"]')].map((row) => row.querySelector('.flex-1')!.textContent);
|
|
134
|
+
expect(rowMessages()).toEqual([message, 'Message 1', 'Message 2']);
|
|
135
|
+
log.scrollTop = 72;
|
|
136
|
+
fireEvent.scroll(log);
|
|
137
|
+
expect(rowMessages()).toEqual(['Message 3', 'Message 4', 'Message 5']);
|
|
138
|
+
expect(log.firstElementChild).toHaveStyle({ height: '480px' });
|
|
139
|
+
rerender(<LogViewer lines={lines} wrap={false} defaultFollow={false} height={72} overscan={0} />);
|
|
140
|
+
expect(screen.getByText('Message 3')).toHaveClass('truncate');
|
|
141
|
+
},
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
it('keeps following as rows are measured and appended until the user scrolls up', () => {
|
|
145
|
+
const lines = makeLogLines(20);
|
|
146
|
+
const { rerender } = render(<LogViewer lines={lines} wrap height={72} />);
|
|
147
|
+
const log = screen.getByRole('log');
|
|
148
|
+
expect(log.scrollTop).toBe(408);
|
|
149
|
+
const rect = Element.prototype.getBoundingClientRect;
|
|
150
|
+
vi.spyOn(Element.prototype, 'getBoundingClientRect').mockImplementation(function (this: Element) {
|
|
151
|
+
const result = rect.call(this);
|
|
152
|
+
return this.matches('[data-slot="log-line"]') ? { ...result, height: 48 } : result;
|
|
153
|
+
});
|
|
154
|
+
rerender(<LogViewer lines={makeLogLines(21)} wrap height={72} />);
|
|
155
|
+
expect(log.scrollTop).toBeGreaterThan(432);
|
|
156
|
+
expect(log.scrollTop).toBe(Number((log.firstElementChild as HTMLElement).style.height.replace('px', '')) - 72);
|
|
157
|
+
fireEvent.scroll(log);
|
|
158
|
+
expect(screen.getByRole('switch', { name: 'Follow' })).toBeChecked();
|
|
159
|
+
log.scrollTop -= 48;
|
|
160
|
+
fireEvent.scroll(log);
|
|
161
|
+
expect(screen.getByRole('switch', { name: 'Follow' })).not.toBeChecked();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('preserves search marks, selection, English copying, keyboard access and accessibility while wrapping', async () => {
|
|
165
|
+
const user = userEvent.setup();
|
|
166
|
+
const line = { ...makeLogLines(1)[0]!, message: 'Full searchable message '.repeat(24) };
|
|
167
|
+
const onSelectLine = vi.fn();
|
|
168
|
+
render(<LogViewer lines={[line]} wrap onSelectLine={onSelectLine} labels={{ levels: { info: 'Notice' } }} />);
|
|
169
|
+
await user.type(screen.getByRole('searchbox'), 'searchable');
|
|
170
|
+
expect(screen.getByRole('log').querySelectorAll('mark')).toHaveLength(24);
|
|
171
|
+
fireEvent.click(screen.getByRole('log').querySelector('[data-slot="log-line"]')!);
|
|
172
|
+
expect(onSelectLine).toHaveBeenLastCalledWith(line);
|
|
173
|
+
screen.getByRole('log').focus();
|
|
174
|
+
await user.tab();
|
|
175
|
+
expect(screen.getByRole('button', { name: `Inspect event ${line.timestamp}` })).toHaveFocus();
|
|
176
|
+
await user.tab();
|
|
177
|
+
expect(screen.getByRole('button', { name: `Copy line ${line.timestamp}` })).toHaveFocus();
|
|
178
|
+
await user.keyboard('{Enter}');
|
|
179
|
+
expect(await navigator.clipboard.readText()).toBe(`${line.timestamp} INFO [api] ${line.message}`);
|
|
180
|
+
await expectNoAxeViolations();
|
|
181
|
+
});
|
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import type { BlockMeta } from '../../meta';
|
|
2
|
+
import type { LogViewerLabels } from './LogViewer';
|
|
2
3
|
|
|
3
4
|
export const meta: BlockMeta = {
|
|
4
5
|
name: 'Log viewer',
|
|
5
6
|
family: 'builders',
|
|
6
7
|
status: 'beta',
|
|
7
8
|
description:
|
|
8
|
-
'Windowed log stream (role="log"): level filter, search with highlighted matches, follow-tail and per-line copy. Renders only the visible rows.',
|
|
9
|
+
'Windowed log stream (role="log"): level filter, search with highlighted matches, follow-tail and per-line copy. Renders only the visible rows. Optional wrap (default false) shows full messages in measured, variable-height rows; rowHeight estimates unmeasured rows. Optional labels?: Partial<LogViewerLabels> overrides each built-in label, including per-level chip and filter names through labels.levels. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English. Copied log text and imported fixtures stay unchanged. See the Catalog labels and Full messages and level names live previews.',
|
|
10
|
+
labels: [
|
|
11
|
+
{ key: 'title', type: 'string', state: 'Visible heading and log region name; title prop wins' },
|
|
12
|
+
{ key: 'levelFilter', type: 'string', state: 'Level filter group name' },
|
|
13
|
+
{
|
|
14
|
+
key: 'levels',
|
|
15
|
+
type: 'Partial<Record<LogLevel, string>>',
|
|
16
|
+
state: 'Per-level chip and filter names; omitted levels use the catalog',
|
|
17
|
+
},
|
|
18
|
+
{ key: 'searchLabel', type: 'string', state: 'Searchbox name' },
|
|
19
|
+
{ key: 'searchPlaceholder', type: 'string', state: 'Searchbox placeholder' },
|
|
20
|
+
{ key: 'follow', type: 'string', state: 'Follow switch name' },
|
|
21
|
+
{ key: 'count', type: '(visible: number, total: number) => string', state: 'Filtered line count' },
|
|
22
|
+
{ key: 'empty', type: 'string', state: 'No matching lines' },
|
|
23
|
+
{ key: 'inspect', type: '(timestamp: string) => string', state: 'Inspect button name when onSelectLine exists' },
|
|
24
|
+
{ key: 'copy', type: '(timestamp: string) => string', state: 'Copy button before copying' },
|
|
25
|
+
{ key: 'copied', type: 'string', state: 'Copy button after copying' },
|
|
26
|
+
] satisfies Array<{ key: keyof LogViewerLabels; type: string; state: string }>,
|
|
9
27
|
uses: ['ToggleGroup', 'Toggle', 'Input', 'Switch', 'IconButton'],
|
|
10
28
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { I18nProvider, Stack } from '@gntik-ai/ui';
|
|
2
|
+
import { LogViewer } from '../LogViewer';
|
|
3
|
+
import { makeLogLines } from '../fixtures';
|
|
4
|
+
const lines = makeLogLines(3);
|
|
5
|
+
export default function Spanish() {
|
|
6
|
+
return (
|
|
7
|
+
<I18nProvider locale="es">
|
|
8
|
+
<Stack gap={6}>
|
|
9
|
+
<LogViewer lines={lines} height={100} onSelectLine={() => {}} />
|
|
10
|
+
<LogViewer
|
|
11
|
+
lines={lines}
|
|
12
|
+
height={100}
|
|
13
|
+
onSelectLine={() => {}}
|
|
14
|
+
labels={{
|
|
15
|
+
title: 'Application logs',
|
|
16
|
+
levelFilter: 'Severity',
|
|
17
|
+
searchLabel: 'Find log messages',
|
|
18
|
+
searchPlaceholder: 'Find…',
|
|
19
|
+
follow: 'Follow stream',
|
|
20
|
+
count: (visible, total) => `${visible}/${total} lines`,
|
|
21
|
+
empty: 'Nothing matched',
|
|
22
|
+
inspect: (timestamp) => `Open ${timestamp}`,
|
|
23
|
+
copy: (timestamp) => `Copy ${timestamp}`,
|
|
24
|
+
copied: 'Line copied',
|
|
25
|
+
}}
|
|
26
|
+
/>
|
|
27
|
+
</Stack>
|
|
28
|
+
</I18nProvider>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { Button, I18nProvider, Stack, Switch } from '@gntik-ai/ui';
|
|
3
|
+
import { LogViewer } from '../LogViewer';
|
|
4
|
+
import { makeLogLines } from '../fixtures';
|
|
5
|
+
|
|
6
|
+
const initialLines = makeLogLines(40).map((line, index) => ({
|
|
7
|
+
...line,
|
|
8
|
+
message:
|
|
9
|
+
index === 0
|
|
10
|
+
? `Long message ${'with full details for inspection. '.repeat(16)}`.slice(0, 500)
|
|
11
|
+
: index === 1
|
|
12
|
+
? 'x'.repeat(200)
|
|
13
|
+
: line.message,
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
export default function Wrap() {
|
|
17
|
+
const [lines, setLines] = useState(initialLines);
|
|
18
|
+
const [selected, setSelected] = useState('');
|
|
19
|
+
const [spanish, setSpanish] = useState(false);
|
|
20
|
+
const [override, setOverride] = useState(false);
|
|
21
|
+
return (
|
|
22
|
+
<Stack gap={4}>
|
|
23
|
+
<p className="text-[13px] text-muted-foreground">
|
|
24
|
+
Wrap full messages, including unbroken tokens. Follow the stream while appending lines, or scroll up to inspect.
|
|
25
|
+
Level names use the catalog unless overridden.
|
|
26
|
+
</p>
|
|
27
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
28
|
+
<Button
|
|
29
|
+
onClick={() =>
|
|
30
|
+
setLines((current) => [
|
|
31
|
+
...current,
|
|
32
|
+
{
|
|
33
|
+
...makeLogLines(current.length + 1)[current.length]!,
|
|
34
|
+
message: 'Appended full message with details that wrap across several lines.',
|
|
35
|
+
},
|
|
36
|
+
])
|
|
37
|
+
}
|
|
38
|
+
>
|
|
39
|
+
Append line
|
|
40
|
+
</Button>
|
|
41
|
+
<Switch label="Spanish catalog" checked={spanish} onCheckedChange={setSpanish} />
|
|
42
|
+
<Switch label="Override warning label" checked={override} onCheckedChange={setOverride} />
|
|
43
|
+
</div>
|
|
44
|
+
<I18nProvider locale={spanish ? 'es' : 'en'}>
|
|
45
|
+
<LogViewer
|
|
46
|
+
lines={lines}
|
|
47
|
+
wrap
|
|
48
|
+
title="Wrapped logs"
|
|
49
|
+
height={240}
|
|
50
|
+
rowHeight={24}
|
|
51
|
+
defaultFollow={false}
|
|
52
|
+
onSelectLine={(line) => setSelected(line.id)}
|
|
53
|
+
selectedLineId={selected}
|
|
54
|
+
labels={override ? { levels: { warn: 'Caution' } } : undefined}
|
|
55
|
+
/>
|
|
56
|
+
</I18nProvider>
|
|
57
|
+
<p role="status" className="text-[13px] text-muted-foreground">
|
|
58
|
+
{selected ? `Selected ${selected}` : 'Select a line to inspect it.'}
|
|
59
|
+
</p>
|
|
60
|
+
</Stack>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { computeOffsets, useVirtualWindow } from '@gntik-ai/ui';
|
|
3
|
+
import type { LogLine } from './fixtures';
|
|
4
|
+
|
|
5
|
+
/** Measurements belong to line IDs, independent of the current filtered indices. */
|
|
6
|
+
export function useWrappedLogRows(
|
|
7
|
+
enabled: boolean,
|
|
8
|
+
lines: LogLine[],
|
|
9
|
+
rowHeight: number,
|
|
10
|
+
height: number,
|
|
11
|
+
overscan: number,
|
|
12
|
+
scrollTop: number,
|
|
13
|
+
follow: boolean,
|
|
14
|
+
) {
|
|
15
|
+
const [sizes, setSizes] = useState<ReadonlyMap<string, number>>(new Map());
|
|
16
|
+
const count = enabled ? lines.length : 0;
|
|
17
|
+
const sizeOf = useCallback(
|
|
18
|
+
(index: number) => sizes.get(lines[index]?.id ?? '') ?? rowHeight,
|
|
19
|
+
[lines, sizes, rowHeight],
|
|
20
|
+
);
|
|
21
|
+
const offsets = useMemo(() => computeOffsets(count, sizeOf), [count, sizeOf]);
|
|
22
|
+
const total = offsets[count] ?? 0;
|
|
23
|
+
const maxScroll = Math.max(0, total - height);
|
|
24
|
+
const win = useVirtualWindow(count, sizeOf, follow ? maxScroll : Math.min(scrollTop, maxScroll), height, overscan);
|
|
25
|
+
|
|
26
|
+
const measureRow = useCallback((node: HTMLDivElement | null, id: string) => {
|
|
27
|
+
if (!node) return;
|
|
28
|
+
const measure = () => {
|
|
29
|
+
const measured = node.getBoundingClientRect().height;
|
|
30
|
+
if (measured > 0)
|
|
31
|
+
setSizes((previous) => (previous.get(id) === measured ? previous : new Map(previous).set(id, measured)));
|
|
32
|
+
};
|
|
33
|
+
measure();
|
|
34
|
+
if (typeof ResizeObserver === 'undefined') return;
|
|
35
|
+
// React 19 ref cleanup disconnects on removal, ref replacement and unmount.
|
|
36
|
+
const observer = new ResizeObserver(measure);
|
|
37
|
+
observer.observe(node);
|
|
38
|
+
return () => observer.disconnect();
|
|
39
|
+
}, []);
|
|
40
|
+
|
|
41
|
+
return { ...win, end: win.end + 1, measureRow };
|
|
42
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import LocalizedCharts from '../../../../charts/src/examples/LocalizedCharts';
|
|
4
|
+
import { expectNoAxeViolations } from '../../test/a11y';
|
|
5
|
+
|
|
6
|
+
it.each(['dark', 'light', 'high_contrast'])('keeps the localised chart example accessible in %s', async (theme) => {
|
|
7
|
+
document.documentElement.className = theme;
|
|
8
|
+
const { container } = render(<LocalizedCharts />);
|
|
9
|
+
expect(screen.getByRole('status', { name: 'Cargando gráfico' })).toBeInTheDocument();
|
|
10
|
+
await expectNoAxeViolations(container);
|
|
11
|
+
await userEvent.selectOptions(screen.getByRole('combobox', { name: 'Chart language' }), 'en');
|
|
12
|
+
expect(screen.getByRole('status', { name: 'Loading chart' })).toBeInTheDocument();
|
|
13
|
+
expect(screen.getByText('Nada que mostrar')).toBeInTheDocument();
|
|
14
|
+
expect(screen.getByText('Explicit empty message')).toBeInTheDocument();
|
|
15
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { I18nProvider } from '@gntik-ai/ui';
|
|
2
3
|
import userEvent from '@testing-library/user-event';
|
|
3
4
|
import { expectNoAxeViolations } from '../../test/a11y';
|
|
4
5
|
import { ChartCard } from './ChartCard';
|
|
@@ -6,6 +7,14 @@ import HeatmapChartCard from './examples/heatmap';
|
|
|
6
7
|
import { TRAFFIC_BY_RANGE } from './fixtures';
|
|
7
8
|
|
|
8
9
|
describe('ChartCard', () => {
|
|
10
|
+
it('uses the kit locale for the loading chart', () => {
|
|
11
|
+
render(
|
|
12
|
+
<I18nProvider locale="es">
|
|
13
|
+
<ChartCard state="loading" />
|
|
14
|
+
</I18nProvider>,
|
|
15
|
+
);
|
|
16
|
+
expect(screen.getByRole('status', { name: 'Cargando gráfico' })).toBeInTheDocument();
|
|
17
|
+
});
|
|
9
18
|
it('renders title, legend and chart for the first range', async () => {
|
|
10
19
|
const { container } = render(<ChartCard />);
|
|
11
20
|
expect(screen.getByRole('heading', { name: 'Infrastructure cost' })).toBeInTheDocument();
|