@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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { I18nProvider, es } from '@gntik-ai/ui';
|
|
4
|
+
import { ErrorPanel, type ErrorPanelLabels } from './ErrorPanel';
|
|
5
|
+
|
|
6
|
+
it('translates error chrome and announcements without translating request data or technical details', async () => {
|
|
7
|
+
const user = userEvent.setup();
|
|
8
|
+
const view = (retrying = false) => (
|
|
9
|
+
<I18nProvider locale="es">
|
|
10
|
+
<ErrorPanel retrying={retrying} onRetry={() => {}} />
|
|
11
|
+
</I18nProvider>
|
|
12
|
+
);
|
|
13
|
+
const { rerender } = render(view());
|
|
14
|
+
expect(screen.getByRole('heading', { name: es['error.title'] })).toHaveTextContent(
|
|
15
|
+
'No se pudieron cargar los despliegues',
|
|
16
|
+
);
|
|
17
|
+
expect(screen.getByText(es['error.message'])).toBeVisible();
|
|
18
|
+
expect(screen.getByText(es['error.requestId'])).toBeVisible();
|
|
19
|
+
expect(screen.getByText('req_8f2c41d07a9b')).toBeVisible();
|
|
20
|
+
expect(screen.getByText('503')).toBeVisible();
|
|
21
|
+
expect(screen.getByRole('button', { name: es['error.retry'] })).toBeVisible();
|
|
22
|
+
expect(screen.getByRole('button', { name: es['error.support'] })).toBeVisible();
|
|
23
|
+
await user.click(screen.getByRole('button', { name: es['error.copyRequestId'] }));
|
|
24
|
+
expect(screen.getByRole('button', { name: es['common.copied'] })).toBeVisible();
|
|
25
|
+
expect(screen.getByRole('status')).toHaveTextContent(es['error.requestIdCopied']);
|
|
26
|
+
expect(await navigator.clipboard.readText()).toBe('req_8f2c41d07a9b');
|
|
27
|
+
await user.click(screen.getByRole('button', { name: es['error.details'] }));
|
|
28
|
+
expect(screen.getByText(/503 Service Unavailable/).textContent).toBe(
|
|
29
|
+
'GET /v1/projects/acme-web/deployments\n503 Service Unavailable\nupstream timed out after 30000 ms (pool: api-eu-west-1)',
|
|
30
|
+
);
|
|
31
|
+
rerender(view(true));
|
|
32
|
+
expect(screen.getByRole('button', { name: es['error.retrying'] })).toBeVisible();
|
|
33
|
+
expect(screen.getByRole('status')).toHaveTextContent(es['error.retryingStatus']);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('keeps English defaults, renders all overrides and gives explicit props precedence', async () => {
|
|
37
|
+
const user = userEvent.setup();
|
|
38
|
+
const { rerender } = render(<ErrorPanel onRetry={() => {}} />);
|
|
39
|
+
expect(screen.getByRole('heading', { name: 'We couldn’t load deployments' })).toBeVisible();
|
|
40
|
+
expect(
|
|
41
|
+
screen.getByText('The service didn’t respond in time. Your data is safe; try again in a moment.'),
|
|
42
|
+
).toBeVisible();
|
|
43
|
+
for (const name of ['Contact support', 'Copy request ID', 'Try again', 'Technical details'])
|
|
44
|
+
expect(screen.getByRole('button', { name })).toBeVisible();
|
|
45
|
+
expect(screen.getByText('Request ID')).toBeVisible();
|
|
46
|
+
await user.click(screen.getByRole('button', { name: 'Copy request ID' }));
|
|
47
|
+
expect(screen.getByRole('button', { name: 'Copied' })).toBeVisible();
|
|
48
|
+
expect(screen.getByRole('status')).toHaveTextContent('Request ID copied');
|
|
49
|
+
rerender(<ErrorPanel onRetry={() => {}} retrying />);
|
|
50
|
+
expect(screen.getByRole('button', { name: 'Retrying…' })).toBeVisible();
|
|
51
|
+
expect(screen.getByRole('status')).toHaveTextContent('Retrying');
|
|
52
|
+
const labels: ErrorPanelLabels = {
|
|
53
|
+
title: 'Title override',
|
|
54
|
+
message: 'Message override',
|
|
55
|
+
support: 'Support override',
|
|
56
|
+
retry: 'Retry override',
|
|
57
|
+
retrying: 'Busy override',
|
|
58
|
+
retryingStatus: 'Busy status override',
|
|
59
|
+
requestId: 'ID override',
|
|
60
|
+
copyRequestId: 'Copy override',
|
|
61
|
+
copied: 'Copied override',
|
|
62
|
+
requestIdCopied: 'Copied status override',
|
|
63
|
+
details: 'Details override',
|
|
64
|
+
};
|
|
65
|
+
const view = (overrides: Partial<ErrorPanelLabels>, retrying = false, explicit = false) => (
|
|
66
|
+
<I18nProvider locale="es">
|
|
67
|
+
<ErrorPanel
|
|
68
|
+
labels={overrides}
|
|
69
|
+
retrying={retrying}
|
|
70
|
+
onRetry={() => {}}
|
|
71
|
+
title={explicit ? 'Explicit title' : undefined}
|
|
72
|
+
message={explicit ? 'Explicit message' : undefined}
|
|
73
|
+
retryLabel={explicit ? 'Explicit retry' : undefined}
|
|
74
|
+
secondaryAction={explicit ? { label: 'Explicit support' } : undefined}
|
|
75
|
+
/>
|
|
76
|
+
</I18nProvider>
|
|
77
|
+
);
|
|
78
|
+
rerender(view(labels));
|
|
79
|
+
expect(screen.getByRole('heading', { name: labels.title })).toBeVisible();
|
|
80
|
+
expect(screen.getByText(labels.message)).toBeVisible();
|
|
81
|
+
expect(screen.getByText(labels.requestId)).toBeVisible();
|
|
82
|
+
for (const name of [labels.support, labels.retry, labels.details])
|
|
83
|
+
expect(screen.getByRole('button', { name })).toBeVisible();
|
|
84
|
+
await user.click(screen.getByRole('button', { name: labels.copyRequestId }));
|
|
85
|
+
expect(screen.getByRole('button', { name: labels.copied })).toBeVisible();
|
|
86
|
+
expect(screen.getByRole('status')).toHaveTextContent(labels.requestIdCopied);
|
|
87
|
+
rerender(view(labels, true));
|
|
88
|
+
expect(screen.getByRole('button', { name: labels.retrying })).toBeVisible();
|
|
89
|
+
expect(screen.getByRole('status')).toHaveTextContent(labels.retryingStatus);
|
|
90
|
+
rerender(view(labels, false, true));
|
|
91
|
+
expect(screen.getByRole('heading', { name: 'Explicit title' })).toBeVisible();
|
|
92
|
+
expect(screen.getByText('Explicit message')).toBeVisible();
|
|
93
|
+
expect(screen.getByRole('button', { name: 'Explicit retry' })).toBeVisible();
|
|
94
|
+
expect(screen.getByRole('button', { name: 'Explicit support' })).toBeVisible();
|
|
95
|
+
rerender(view({ title: 'Only title' }));
|
|
96
|
+
expect(screen.getByText(es['error.message'])).toBeVisible();
|
|
97
|
+
for (const key of ['error.retry', 'error.support', 'error.details'] as const)
|
|
98
|
+
expect(screen.getByRole('button', { name: es[key] })).toBeVisible();
|
|
99
|
+
});
|
|
@@ -4,7 +4,23 @@ import { Button, Collapsible, CollapsiblePanel, CollapsibleTrigger, IconButton,
|
|
|
4
4
|
import { useId, useRef, useState, type ReactNode } from 'react';
|
|
5
5
|
import type { FeedbackAction } from '../types';
|
|
6
6
|
|
|
7
|
+
export interface ErrorPanelLabels {
|
|
8
|
+
title: string;
|
|
9
|
+
message: string;
|
|
10
|
+
support: string;
|
|
11
|
+
retry: string;
|
|
12
|
+
retrying: string;
|
|
13
|
+
retryingStatus: string;
|
|
14
|
+
requestId: string;
|
|
15
|
+
copyRequestId: string;
|
|
16
|
+
copied: string;
|
|
17
|
+
requestIdCopied: string;
|
|
18
|
+
details: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
7
21
|
export interface ErrorPanelProps {
|
|
22
|
+
/** Per-key copy overrides; explicit props take precedence, then labels, then the active catalog. */
|
|
23
|
+
labels?: Partial<ErrorPanelLabels>;
|
|
8
24
|
icon?: LucideIcon;
|
|
9
25
|
title?: ReactNode;
|
|
10
26
|
/** Human summary of what failed and what to do. */
|
|
@@ -31,21 +47,28 @@ export interface ErrorPanelProps {
|
|
|
31
47
|
/** Error summary for a failed load or action: what happened, request id, retry and technical details. */
|
|
32
48
|
export function ErrorPanel({
|
|
33
49
|
icon: Icon = ServerCrash,
|
|
34
|
-
title
|
|
35
|
-
|
|
50
|
+
title: titleProp,
|
|
51
|
+
labels,
|
|
52
|
+
message: messageProp,
|
|
36
53
|
code = 503,
|
|
37
54
|
requestId = 'req_8f2c41d07a9b',
|
|
38
55
|
details = 'GET /v1/projects/acme-web/deployments\n503 Service Unavailable\nupstream timed out after 30000 ms (pool: api-eu-west-1)',
|
|
39
56
|
onRetry,
|
|
40
57
|
retrying,
|
|
41
58
|
retryLabel: retryLabelProp,
|
|
42
|
-
secondaryAction
|
|
59
|
+
secondaryAction: secondaryActionProp,
|
|
43
60
|
titleAs: Heading = 'h3',
|
|
44
61
|
className,
|
|
45
62
|
announce = true,
|
|
46
63
|
}: ErrorPanelProps) {
|
|
47
64
|
const { t } = useI18n();
|
|
48
|
-
const
|
|
65
|
+
const title = titleProp === undefined ? (labels?.title ?? t('error.title')) : titleProp;
|
|
66
|
+
const message = messageProp === undefined ? (labels?.message ?? t('error.message')) : messageProp;
|
|
67
|
+
const secondaryAction =
|
|
68
|
+
secondaryActionProp === undefined
|
|
69
|
+
? { label: labels?.support ?? t('error.support'), variant: 'ghost' as const }
|
|
70
|
+
: secondaryActionProp;
|
|
71
|
+
const retryLabel = retryLabelProp ?? labels?.retry ?? t('error.retry');
|
|
49
72
|
const id = useId();
|
|
50
73
|
const [innerRetrying, setInnerRetrying] = useState(false);
|
|
51
74
|
const [copied, setCopied] = useState(false);
|
|
@@ -97,13 +120,15 @@ export function ErrorPanel({
|
|
|
97
120
|
{message != null && <p className="mt-1.5 max-w-xl text-[13px] leading-6 text-muted-foreground">{message}</p>}
|
|
98
121
|
{requestId && (
|
|
99
122
|
<div className="mt-3 flex items-center gap-1.5 text-[12px] text-muted-foreground">
|
|
100
|
-
<span>{t('error.requestId')}</span>
|
|
123
|
+
<span>{labels?.requestId ?? t('error.requestId')}</span>
|
|
101
124
|
<code className="rounded bg-muted px-1.5 py-0.5 font-mono text-[11.5px] text-foreground">
|
|
102
125
|
{requestId}
|
|
103
126
|
</code>
|
|
104
127
|
<IconButton
|
|
105
128
|
icon={copied ? Check : Copy}
|
|
106
|
-
label={
|
|
129
|
+
label={
|
|
130
|
+
copied ? (labels?.copied ?? t('common.copied')) : (labels?.copyRequestId ?? t('error.copyRequestId'))
|
|
131
|
+
}
|
|
107
132
|
size="sm"
|
|
108
133
|
variant="ghost"
|
|
109
134
|
className="size-7"
|
|
@@ -114,7 +139,7 @@ export function ErrorPanel({
|
|
|
114
139
|
<div className="mt-4 flex flex-wrap items-center gap-2">
|
|
115
140
|
{onRetry && (
|
|
116
141
|
<Button variant="secondary" size="sm" icon={RotateCw} loading={busy} onClick={() => void retry()}>
|
|
117
|
-
{busy ? t('error.retrying') : retryLabel}
|
|
142
|
+
{busy ? (labels?.retrying ?? t('error.retrying')) : retryLabel}
|
|
118
143
|
</Button>
|
|
119
144
|
)}
|
|
120
145
|
{secondaryAction && (
|
|
@@ -131,7 +156,7 @@ export function ErrorPanel({
|
|
|
131
156
|
</div>
|
|
132
157
|
{details && (
|
|
133
158
|
<Collapsible className="mt-4">
|
|
134
|
-
<CollapsibleTrigger className="text-[12.5px]">{t('error.details')}</CollapsibleTrigger>
|
|
159
|
+
<CollapsibleTrigger className="text-[12.5px]">{labels?.details ?? t('error.details')}</CollapsibleTrigger>
|
|
135
160
|
<CollapsiblePanel>
|
|
136
161
|
<pre className="mt-2 max-h-60 overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-[11.5px] leading-5 whitespace-pre-wrap text-foreground">
|
|
137
162
|
{details}
|
|
@@ -141,7 +166,11 @@ export function ErrorPanel({
|
|
|
141
166
|
)}
|
|
142
167
|
{announce && (
|
|
143
168
|
<p role="status" className="sr-only">
|
|
144
|
-
{busy
|
|
169
|
+
{busy
|
|
170
|
+
? (labels?.retryingStatus ?? t('error.retryingStatus'))
|
|
171
|
+
: copied
|
|
172
|
+
? (labels?.requestIdCopied ?? t('error.requestIdCopied'))
|
|
173
|
+
: ''}
|
|
145
174
|
</p>
|
|
146
175
|
)}
|
|
147
176
|
</div>
|
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import type { BlockMeta } from '../../meta';
|
|
2
|
+
import type { ErrorPanelLabels } from './ErrorPanel';
|
|
2
3
|
|
|
3
4
|
export const meta: BlockMeta = {
|
|
4
5
|
name: 'Error panel',
|
|
5
6
|
family: 'feedback',
|
|
6
7
|
status: 'beta',
|
|
7
8
|
description:
|
|
8
|
-
'Error summary with status code, copyable request id, retry with loading state and a technical-details disclosure.',
|
|
9
|
+
'Error summary with status code, copyable request id, retry with loading state and a technical-details disclosure. Optional labels?: Partial<ErrorPanelLabels> overrides each built-in label. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English. Imported fixtures and machine data stay unchanged. See the Catalog labels live preview.',
|
|
10
|
+
labels: [
|
|
11
|
+
{ key: 'title', type: 'string', state: 'Panel heading; explicit title prop wins, including null' },
|
|
12
|
+
{ key: 'message', type: 'string', state: 'Summary; explicit message prop wins, including null' },
|
|
13
|
+
{
|
|
14
|
+
key: 'support',
|
|
15
|
+
type: 'string',
|
|
16
|
+
state: 'Default secondary action; explicit secondaryAction wins, including null',
|
|
17
|
+
},
|
|
18
|
+
{ key: 'retry', type: 'string', state: 'Retry button; retryLabel prop wins' },
|
|
19
|
+
{ key: 'retrying', type: 'string', state: 'Busy retry button' },
|
|
20
|
+
{ key: 'retryingStatus', type: 'string', state: 'Busy status announcement' },
|
|
21
|
+
{ key: 'requestId', type: 'string', state: 'Request ID caption' },
|
|
22
|
+
{ key: 'copyRequestId', type: 'string', state: 'Copy request ID button' },
|
|
23
|
+
{ key: 'copied', type: 'string', state: 'Copy button after copying' },
|
|
24
|
+
{ key: 'requestIdCopied', type: 'string', state: 'Copied status announcement' },
|
|
25
|
+
{ key: 'details', type: 'string', state: 'Technical details disclosure' },
|
|
26
|
+
] satisfies Array<{ key: keyof ErrorPanelLabels; type: string; state: string }>,
|
|
9
27
|
uses: ['Button', 'IconButton', 'Collapsible'],
|
|
10
28
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { I18nProvider, Stack } from '@gntik-ai/ui';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { ErrorPanel } from '../ErrorPanel';
|
|
4
|
+
export default function Spanish() {
|
|
5
|
+
const [retrying, setRetrying] = useState(false);
|
|
6
|
+
return (
|
|
7
|
+
<I18nProvider locale="es">
|
|
8
|
+
<Stack gap={6}>
|
|
9
|
+
<ErrorPanel onRetry={() => {}} />
|
|
10
|
+
<ErrorPanel
|
|
11
|
+
retrying={retrying}
|
|
12
|
+
onRetry={() => setRetrying(true)}
|
|
13
|
+
labels={{
|
|
14
|
+
title: 'Resource unavailable',
|
|
15
|
+
message: 'Please try again.',
|
|
16
|
+
support: 'Get help',
|
|
17
|
+
retry: 'Try loading',
|
|
18
|
+
retrying: 'Loading…',
|
|
19
|
+
retryingStatus: 'Loading resource',
|
|
20
|
+
requestId: 'Reference',
|
|
21
|
+
copyRequestId: 'Copy reference',
|
|
22
|
+
copied: 'Reference copied',
|
|
23
|
+
requestIdCopied: 'Reference copied to clipboard',
|
|
24
|
+
details: 'Show diagnostics',
|
|
25
|
+
}}
|
|
26
|
+
/>
|
|
27
|
+
</Stack>
|
|
28
|
+
</I18nProvider>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { I18nProvider, es } from '@gntik-ai/ui';
|
|
3
|
+
import { InlineCallout, type InlineCalloutLabels } from './InlineCallout';
|
|
4
|
+
|
|
5
|
+
it('localizes built-in callout content and action labels, leaving the href unchanged', () => {
|
|
6
|
+
render(
|
|
7
|
+
<I18nProvider locale="es">
|
|
8
|
+
<InlineCallout />
|
|
9
|
+
</I18nProvider>,
|
|
10
|
+
);
|
|
11
|
+
expect(screen.getByText(es['callout.title'])).toHaveTextContent('Has usado el 92% de tus minutos de compilación');
|
|
12
|
+
expect(screen.getByText(es['callout.description'])).toBeVisible();
|
|
13
|
+
expect(screen.getByRole('button', { name: es['callout.upgrade'] })).toBeVisible();
|
|
14
|
+
expect(screen.getByRole('link', { name: es['callout.viewUsage'] })).toHaveAttribute('href', '#usage');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('preserves English, merges overrides per key and respects explicit content and actions', () => {
|
|
18
|
+
const { rerender } = render(<InlineCallout />);
|
|
19
|
+
expect(screen.getByText('You have used 92% of your build minutes')).toBeVisible();
|
|
20
|
+
expect(
|
|
21
|
+
screen.getByText(
|
|
22
|
+
'Builds will queue once the monthly limit is reached. Upgrade the plan or reduce concurrent builds.',
|
|
23
|
+
),
|
|
24
|
+
).toBeVisible();
|
|
25
|
+
expect(screen.getByRole('button', { name: 'Upgrade plan' })).toBeVisible();
|
|
26
|
+
expect(screen.getByRole('link', { name: 'View usage' })).toBeVisible();
|
|
27
|
+
const labels: InlineCalloutLabels = {
|
|
28
|
+
title: 'Title override',
|
|
29
|
+
description: 'Description override',
|
|
30
|
+
upgrade: 'Upgrade override',
|
|
31
|
+
viewUsage: 'Usage override',
|
|
32
|
+
};
|
|
33
|
+
rerender(
|
|
34
|
+
<I18nProvider locale="es">
|
|
35
|
+
<InlineCallout labels={labels} />
|
|
36
|
+
</I18nProvider>,
|
|
37
|
+
);
|
|
38
|
+
expect(screen.getByText(labels.title)).toBeVisible();
|
|
39
|
+
expect(screen.getByText(labels.description)).toBeVisible();
|
|
40
|
+
expect(screen.getByRole('button', { name: labels.upgrade })).toBeVisible();
|
|
41
|
+
expect(screen.getByRole('link', { name: labels.viewUsage })).toBeVisible();
|
|
42
|
+
rerender(
|
|
43
|
+
<I18nProvider locale="es">
|
|
44
|
+
<InlineCallout labels={{ title: 'Only title' }} />
|
|
45
|
+
</I18nProvider>,
|
|
46
|
+
);
|
|
47
|
+
expect(screen.getByText('Only title')).toBeVisible();
|
|
48
|
+
expect(screen.getByText(es['callout.description'])).toBeVisible();
|
|
49
|
+
expect(screen.getByRole('button', { name: es['callout.upgrade'] })).toBeVisible();
|
|
50
|
+
expect(screen.getByRole('link', { name: es['callout.viewUsage'] })).toBeVisible();
|
|
51
|
+
rerender(
|
|
52
|
+
<InlineCallout
|
|
53
|
+
labels={labels}
|
|
54
|
+
title="Explicit title"
|
|
55
|
+
description="Explicit description"
|
|
56
|
+
actions={[{ label: 'Explicit action', href: '#explicit' }]}
|
|
57
|
+
/>,
|
|
58
|
+
);
|
|
59
|
+
expect(screen.getByText('Explicit title')).toBeVisible();
|
|
60
|
+
expect(screen.getByText('Explicit description')).toBeVisible();
|
|
61
|
+
expect(screen.getByRole('link', { name: 'Explicit action' })).toHaveAttribute('href', '#explicit');
|
|
62
|
+
});
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { Alert, Button, Link, type AlertTone } from '@gntik-ai/ui';
|
|
1
|
+
import { Alert, Button, Link, useI18n, type AlertTone } from '@gntik-ai/ui';
|
|
2
2
|
import type { LucideIcon } from '@gntik-ai/icons';
|
|
3
3
|
import { useState, type ReactNode } from 'react';
|
|
4
4
|
import type { FeedbackAction } from '../types';
|
|
5
5
|
|
|
6
|
+
export interface InlineCalloutLabels {
|
|
7
|
+
title: string;
|
|
8
|
+
description: string;
|
|
9
|
+
upgrade: string;
|
|
10
|
+
viewUsage: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
6
13
|
export interface InlineCalloutProps {
|
|
14
|
+
/** Per-key copy overrides; explicit props take precedence, then labels, then the active catalog. */
|
|
15
|
+
labels?: Partial<InlineCalloutLabels>;
|
|
7
16
|
tone?: AlertTone;
|
|
8
17
|
title?: ReactNode;
|
|
9
18
|
description?: ReactNode;
|
|
@@ -18,23 +27,27 @@ export interface InlineCalloutProps {
|
|
|
18
27
|
className?: string;
|
|
19
28
|
}
|
|
20
29
|
|
|
21
|
-
const inlineCalloutDefaultActions: FeedbackAction[] = [
|
|
22
|
-
{ label: 'Upgrade plan', variant: 'secondary' },
|
|
23
|
-
{ label: 'View usage', href: '#usage' },
|
|
24
|
-
];
|
|
25
|
-
|
|
26
30
|
/** In-content callout built on Alert: tone, title, body and a row of actions. */
|
|
27
31
|
export function InlineCallout({
|
|
28
32
|
tone = 'warning',
|
|
29
|
-
title
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
title: titleProp,
|
|
34
|
+
labels,
|
|
35
|
+
description: descriptionProp,
|
|
36
|
+
actions: actionsProp,
|
|
32
37
|
icon,
|
|
33
38
|
dismissible = false,
|
|
34
39
|
open,
|
|
35
40
|
onDismiss,
|
|
36
41
|
className,
|
|
37
42
|
}: InlineCalloutProps) {
|
|
43
|
+
const { t } = useI18n();
|
|
44
|
+
const title = titleProp === undefined ? (labels?.title ?? t('callout.title')) : titleProp;
|
|
45
|
+
const description =
|
|
46
|
+
descriptionProp === undefined ? (labels?.description ?? t('callout.description')) : descriptionProp;
|
|
47
|
+
const actions: FeedbackAction[] = actionsProp ?? [
|
|
48
|
+
{ label: labels?.upgrade ?? t('callout.upgrade'), variant: 'secondary' },
|
|
49
|
+
{ label: labels?.viewUsage ?? t('callout.viewUsage'), href: '#usage' },
|
|
50
|
+
];
|
|
38
51
|
const [dismissed, setDismissed] = useState(false);
|
|
39
52
|
if (!(open ?? !dismissed)) return null;
|
|
40
53
|
return (
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import type { BlockMeta } from '../../meta';
|
|
2
|
+
import type { InlineCalloutLabels } from './InlineCallout';
|
|
2
3
|
|
|
3
4
|
export const meta: BlockMeta = {
|
|
4
5
|
name: 'Inline callout',
|
|
5
6
|
family: 'feedback',
|
|
6
7
|
status: 'beta',
|
|
7
|
-
description:
|
|
8
|
+
description:
|
|
9
|
+
'Alert-based in-content callout with a tone, title, body, action buttons or links and optional dismiss. Optional labels?: Partial<InlineCalloutLabels> overrides each built-in label. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English. Imported fixtures and machine data stay unchanged. See the Catalog labels live preview.',
|
|
10
|
+
labels: [
|
|
11
|
+
{ key: 'title', type: 'string', state: 'Callout title; explicit title prop wins, including null' },
|
|
12
|
+
{ key: 'description', type: 'string', state: 'Callout body; explicit description prop wins, including null' },
|
|
13
|
+
{ key: 'upgrade', type: 'string', state: 'Default primary action; explicit actions win' },
|
|
14
|
+
{ key: 'viewUsage', type: 'string', state: 'Default usage link; explicit actions win' },
|
|
15
|
+
] satisfies Array<{ key: keyof InlineCalloutLabels; type: string; state: string }>,
|
|
8
16
|
uses: ['Alert', 'Button', 'Link'],
|
|
9
17
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { I18nProvider, Stack } from '@gntik-ai/ui';
|
|
2
|
+
import { InlineCallout } from '../InlineCallout';
|
|
3
|
+
export default function Spanish() {
|
|
4
|
+
return (
|
|
5
|
+
<I18nProvider locale="es">
|
|
6
|
+
<Stack gap={6}>
|
|
7
|
+
<InlineCallout />
|
|
8
|
+
<InlineCallout
|
|
9
|
+
labels={{
|
|
10
|
+
title: 'Build usage',
|
|
11
|
+
description: 'Review your current allowance.',
|
|
12
|
+
upgrade: 'Change plan',
|
|
13
|
+
viewUsage: 'Open usage',
|
|
14
|
+
}}
|
|
15
|
+
/>
|
|
16
|
+
</Stack>
|
|
17
|
+
</I18nProvider>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { I18nProvider, es } from '@gntik-ai/ui';
|
|
3
|
+
import { ListSkeleton, PageSkeleton, TableSkeleton } from './Skeletons';
|
|
4
|
+
|
|
5
|
+
it.each([
|
|
6
|
+
[TableSkeleton, 'loading.table', 'Loading table'],
|
|
7
|
+
[ListSkeleton, 'loading.list', 'Loading list'],
|
|
8
|
+
[PageSkeleton, 'loading.page', 'Loading page'],
|
|
9
|
+
] as const)('audits catalog and explicit loading labels for %s', (Skeleton, key, english) => {
|
|
10
|
+
const { rerender } = render(<Skeleton />);
|
|
11
|
+
expect(screen.getByRole('status').textContent).toBe(english);
|
|
12
|
+
rerender(
|
|
13
|
+
<I18nProvider locale="es">
|
|
14
|
+
<Skeleton />
|
|
15
|
+
</I18nProvider>,
|
|
16
|
+
);
|
|
17
|
+
expect(screen.getByRole('status').textContent).toBe(es[key]);
|
|
18
|
+
rerender(
|
|
19
|
+
<I18nProvider locale="es">
|
|
20
|
+
<Skeleton label="Caller loading text" />
|
|
21
|
+
</I18nProvider>,
|
|
22
|
+
);
|
|
23
|
+
expect(screen.getByRole('status').textContent).toBe('Caller loading text');
|
|
24
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { I18nProvider, en, es } from '@gntik-ai/ui';
|
|
4
|
+
import { CreateApiKeyDialog, type CreateApiKeyDialogLabels } from './CreateApiKeyDialog';
|
|
5
|
+
import { expectNoAxeViolations } from '../../test/a11y';
|
|
6
|
+
it.each(['none', 'es'])('renders every default through the dialog lifecycle under %s', async (locale) => {
|
|
7
|
+
const messages = locale === 'es' ? es : en;
|
|
8
|
+
let fails = true;
|
|
9
|
+
const block = <CreateApiKeyDialog onCreate={() => (fails ? Promise.reject(null) : 'synthetic_api_key')} />;
|
|
10
|
+
render(locale === 'es' ? <I18nProvider locale="es">{block}</I18nProvider> : block);
|
|
11
|
+
await userEvent.click(screen.getByRole('button', { name: messages['createApiKey.title'] }));
|
|
12
|
+
const dialog = await screen.findByRole('dialog', { name: messages['createApiKey.title'] });
|
|
13
|
+
expect(dialog).toHaveAccessibleDescription(messages['createApiKey.description']);
|
|
14
|
+
expect(screen.getByPlaceholderText(messages['createApiKey.namePlaceholder'])).toHaveAccessibleName(
|
|
15
|
+
messages['createApiKey.name'],
|
|
16
|
+
);
|
|
17
|
+
expect(screen.getByText(messages['createApiKey.scopes'])).toBeVisible();
|
|
18
|
+
expect(screen.getByText(messages['createApiKey.expiration'])).toBeVisible();
|
|
19
|
+
expect(screen.getByRole('button', { name: messages['createApiKey.cancel'] })).toBeVisible();
|
|
20
|
+
await userEvent.click(screen.getByRole('button', { name: messages['createApiKey.submit'] }));
|
|
21
|
+
expect(screen.getByText(messages['createApiKey.nameRequired'])).toBeVisible();
|
|
22
|
+
expect(screen.getByText(messages['createApiKey.scopesRequired'])).toBeVisible();
|
|
23
|
+
fireEvent.change(screen.getByPlaceholderText(messages['createApiKey.namePlaceholder']), {
|
|
24
|
+
target: { value: 'automation' },
|
|
25
|
+
});
|
|
26
|
+
await userEvent.click(screen.getByRole('checkbox', { name: 'projects:read' }));
|
|
27
|
+
await userEvent.click(screen.getByRole('button', { name: messages['createApiKey.submit'] }));
|
|
28
|
+
expect(await screen.findByText(messages['createApiKey.fallbackError'])).toBeVisible();
|
|
29
|
+
expect(screen.getByText(messages['createApiKey.errorTitle'])).toBeVisible();
|
|
30
|
+
fails = false;
|
|
31
|
+
await userEvent.click(screen.getByRole('button', { name: messages['createApiKey.submit'] }));
|
|
32
|
+
expect(
|
|
33
|
+
await screen.findByRole('dialog', { name: messages['createApiKey.successTitle'] }),
|
|
34
|
+
).toHaveAccessibleDescription(messages['createApiKey.successDescription']);
|
|
35
|
+
expect(screen.getByText(messages['createApiKey.warningTitle'])).toBeVisible();
|
|
36
|
+
expect(screen.getByText(messages['createApiKey.warningDescription'])).toBeVisible();
|
|
37
|
+
expect(screen.getByRole('region', { name: messages['createApiKey.secretLabel'] })).toHaveTextContent(
|
|
38
|
+
'synthetic_api_key',
|
|
39
|
+
);
|
|
40
|
+
expect(screen.getByRole('button', { name: messages['createApiKey.done'] })).toBeVisible();
|
|
41
|
+
if (locale === 'es') await expectNoAxeViolations(dialog);
|
|
42
|
+
});
|
|
43
|
+
it.each(['en', 'es'])('honours all overrides under %s', async (locale) => {
|
|
44
|
+
const labels: CreateApiKeyDialogLabels = {
|
|
45
|
+
title: 'Custom title',
|
|
46
|
+
description: 'Custom description',
|
|
47
|
+
name: 'Custom name',
|
|
48
|
+
namePlaceholder: 'Custom namePlaceholder',
|
|
49
|
+
nameRequired: 'Custom nameRequired',
|
|
50
|
+
scopes: 'Custom scopes',
|
|
51
|
+
scopesRequired: 'Custom scopesRequired',
|
|
52
|
+
expiration: 'Custom expiration',
|
|
53
|
+
errorTitle: 'Custom errorTitle',
|
|
54
|
+
fallbackError: 'Custom fallbackError',
|
|
55
|
+
cancel: 'Custom cancel',
|
|
56
|
+
submit: 'Custom submit',
|
|
57
|
+
successTitle: 'Custom successTitle',
|
|
58
|
+
successDescription: 'Custom successDescription',
|
|
59
|
+
warningTitle: 'Custom warningTitle',
|
|
60
|
+
warningDescription: 'Custom warningDescription',
|
|
61
|
+
secretLabel: 'Custom secretLabel',
|
|
62
|
+
done: 'Custom done',
|
|
63
|
+
};
|
|
64
|
+
let fails = true;
|
|
65
|
+
render(
|
|
66
|
+
<I18nProvider locale={locale}>
|
|
67
|
+
<CreateApiKeyDialog labels={labels} onCreate={() => (fails ? Promise.reject(null) : 'synthetic_api_key')} />
|
|
68
|
+
</I18nProvider>,
|
|
69
|
+
);
|
|
70
|
+
await userEvent.click(screen.getByRole('button', { name: labels.title }));
|
|
71
|
+
expect(await screen.findByRole('dialog', { name: labels.title })).toHaveAccessibleDescription(labels.description);
|
|
72
|
+
expect(screen.getByPlaceholderText(labels.namePlaceholder)).toHaveAccessibleName(labels.name);
|
|
73
|
+
for (const text of [labels.scopes, labels.expiration]) expect(screen.getByText(text)).toBeVisible();
|
|
74
|
+
expect(screen.getByRole('button', { name: labels.cancel })).toBeVisible();
|
|
75
|
+
await userEvent.click(screen.getByRole('button', { name: labels.submit }));
|
|
76
|
+
for (const text of [labels.nameRequired, labels.scopesRequired]) expect(screen.getByText(text)).toBeVisible();
|
|
77
|
+
fireEvent.change(screen.getByPlaceholderText(labels.namePlaceholder), { target: { value: 'automation' } });
|
|
78
|
+
await userEvent.click(screen.getByRole('checkbox', { name: 'projects:read' }));
|
|
79
|
+
await userEvent.click(screen.getByRole('button', { name: labels.submit }));
|
|
80
|
+
expect(await screen.findByText(labels.fallbackError)).toBeVisible();
|
|
81
|
+
expect(screen.getByText(labels.errorTitle)).toBeVisible();
|
|
82
|
+
fails = false;
|
|
83
|
+
await userEvent.click(screen.getByRole('button', { name: labels.submit }));
|
|
84
|
+
expect(await screen.findByRole('dialog', { name: labels.successTitle })).toHaveAccessibleDescription(
|
|
85
|
+
labels.successDescription,
|
|
86
|
+
);
|
|
87
|
+
expect(screen.getByText(labels.warningTitle)).toBeVisible();
|
|
88
|
+
expect(screen.getByText(labels.warningDescription)).toBeVisible();
|
|
89
|
+
expect(screen.getByRole('region', { name: labels.secretLabel })).toHaveTextContent('synthetic_api_key');
|
|
90
|
+
expect(screen.getByRole('button', { name: labels.done })).toBeVisible();
|
|
91
|
+
});
|
|
92
|
+
it('keeps the original English copy byte for byte', () => {
|
|
93
|
+
expect(en['createApiKey.title']).toBe('Create API key');
|
|
94
|
+
expect(en['createApiKey.description']).toBe(
|
|
95
|
+
'Keys act on behalf of this workspace. Grant only the scopes the integration needs.',
|
|
96
|
+
);
|
|
97
|
+
expect(en['createApiKey.name']).toBe('Name');
|
|
98
|
+
expect(en['createApiKey.namePlaceholder']).toBe('ci-deployments');
|
|
99
|
+
expect(en['createApiKey.nameRequired']).toBe('Give the key a name.');
|
|
100
|
+
expect(en['createApiKey.scopes']).toBe('Scopes');
|
|
101
|
+
expect(en['createApiKey.scopesRequired']).toBe('Select at least one scope.');
|
|
102
|
+
expect(en['createApiKey.expiration']).toBe('Expiration');
|
|
103
|
+
expect(en['createApiKey.errorTitle']).toBe('Key not created');
|
|
104
|
+
expect(en['createApiKey.fallbackError']).toBe('The key could not be created.');
|
|
105
|
+
expect(en['createApiKey.cancel']).toBe('Cancel');
|
|
106
|
+
expect(en['createApiKey.submit']).toBe('Create key');
|
|
107
|
+
expect(en['createApiKey.successTitle']).toBe('API key created');
|
|
108
|
+
expect(en['createApiKey.successDescription']).toBe('Store it in your secrets manager. Use it as a bearer token.');
|
|
109
|
+
expect(en['createApiKey.warningTitle']).toBe('Copy this key now');
|
|
110
|
+
expect(en['createApiKey.warningDescription']).toBe(
|
|
111
|
+
'For your security it is shown only once. If you lose it, revoke it and create a new one.',
|
|
112
|
+
);
|
|
113
|
+
expect(en['createApiKey.secretLabel']).toBe('New API key');
|
|
114
|
+
expect(en['createApiKey.done']).toBe('Done');
|
|
115
|
+
});
|