Skip to content

Commit 6bd459f

Browse files
test: update UI schema tests to reject i18n objects after I18nLabelSchema simplification
I18nLabelSchema was changed from z.union([z.string(), I18nObjectSchema]) to z.string(), so label/description/title fields now only accept plain strings. Updated 32 tests across 12 UI schema test files to expect i18n objects to be rejected (toThrow) instead of accepted (not.toThrow). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent 5c51e24 commit 6bd459f

12 files changed

Lines changed: 75 additions & 91 deletions

packages/spec/src/ui/action.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -530,28 +530,28 @@ describe('Action Factory', () => {
530530
});
531531

532532
describe('Action I18n Integration', () => {
533-
it('should accept i18n object as action label', () => {
533+
it('should reject i18n object as action label', () => {
534534
expect(() => ActionSchema.parse({
535535
name: 'i18n_action',
536536
label: { key: 'actions.approve', defaultValue: 'Approve' },
537-
})).not.toThrow();
537+
})).toThrow();
538538
});
539-
it('should accept i18n as confirmText and successMessage', () => {
539+
it('should reject i18n as confirmText and successMessage', () => {
540540
expect(() => ActionSchema.parse({
541541
name: 'i18n_confirm',
542542
label: 'Delete',
543543
confirmText: { key: 'actions.confirm_delete', defaultValue: 'Are you sure?' },
544544
successMessage: { key: 'actions.delete_success', defaultValue: 'Deleted!' },
545-
})).not.toThrow();
545+
})).toThrow();
546546
});
547-
it('should accept i18n in param labels', () => {
547+
it('should reject i18n in param labels', () => {
548548
expect(() => ActionParamSchema.parse({
549549
name: 'reason',
550550
label: { key: 'params.reason', defaultValue: 'Reason' },
551551
type: 'textarea',
552-
})).not.toThrow();
552+
})).toThrow();
553553
});
554-
it('should accept i18n in param option labels', () => {
554+
it('should reject i18n in param option labels', () => {
555555
expect(() => ActionParamSchema.parse({
556556
name: 'priority',
557557
label: 'Priority',
@@ -560,7 +560,7 @@ describe('Action I18n Integration', () => {
560560
{ label: { key: 'options.high', defaultValue: 'High' }, value: 'high' },
561561
{ label: { key: 'options.low', defaultValue: 'Low' }, value: 'low' },
562562
],
563-
})).not.toThrow();
563+
})).toThrow();
564564
});
565565
});
566566

packages/spec/src/ui/animation.test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,10 @@ describe('Type exports', () => {
197197
});
198198

199199
describe('I18n and ARIA integration', () => {
200-
it('should accept I18n label on ComponentAnimationSchema', () => {
201-
const result = ComponentAnimationSchema.parse({
200+
it('should reject I18n label on ComponentAnimationSchema', () => {
201+
expect(() => ComponentAnimationSchema.parse({
202202
label: { key: 'animations.card_enter', defaultValue: 'Card Enter' },
203-
});
204-
expect(result.label).toEqual({ key: 'animations.card_enter', defaultValue: 'Card Enter' });
203+
})).toThrow();
205204
});
206205

207206
it('should accept plain string label on ComponentAnimationSchema', () => {
@@ -220,11 +219,10 @@ describe('I18n and ARIA integration', () => {
220219
expect(result.role).toBe('presentation');
221220
});
222221

223-
it('should accept I18n label on MotionConfigSchema', () => {
224-
const result = MotionConfigSchema.parse({
222+
it('should reject I18n label on MotionConfigSchema', () => {
223+
expect(() => MotionConfigSchema.parse({
225224
label: { key: 'motion.global', defaultValue: 'Global Motion Config' },
226-
});
227-
expect(result.label).toEqual({ key: 'motion.global', defaultValue: 'Global Motion Config' });
225+
})).toThrow();
228226
});
229227

230228
it('should leave I18n/ARIA fields undefined when not provided', () => {

packages/spec/src/ui/chart.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,20 +210,19 @@ describe('Real-World Chart Configuration Examples', () => {
210210
});
211211

212212
describe('Chart I18n Integration', () => {
213-
it('should accept i18n object as chart title', () => {
214-
const result = ChartConfigSchema.parse({
213+
it('should reject i18n object as chart title', () => {
214+
expect(() => ChartConfigSchema.parse({
215215
type: 'bar',
216216
title: { key: 'charts.sales', defaultValue: 'Sales Chart' },
217-
});
218-
expect(typeof result.title).toBe('object');
217+
})).toThrow();
219218
});
220-
it('should accept i18n as chart subtitle and description', () => {
219+
it('should reject i18n as chart subtitle and description', () => {
221220
expect(() => ChartConfigSchema.parse({
222221
type: 'line',
223222
title: 'Revenue',
224223
subtitle: { key: 'charts.subtitle', defaultValue: 'Monthly breakdown' },
225224
description: { key: 'charts.desc', defaultValue: 'Revenue over time' },
226-
})).not.toThrow();
225+
})).toThrow();
227226
});
228227
});
229228

packages/spec/src/ui/dashboard.test.ts

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -576,30 +576,30 @@ describe('Dashboard Factory', () => {
576576
});
577577

578578
describe('Dashboard I18n Integration', () => {
579-
it('should accept i18n object as dashboard label', () => {
579+
it('should reject i18n object as dashboard label', () => {
580580
expect(() => DashboardSchema.parse({
581581
name: 'i18n_dashboard',
582582
label: { key: 'dashboards.sales', defaultValue: 'Sales Dashboard' },
583583
widgets: [],
584-
})).not.toThrow();
584+
})).toThrow();
585585
});
586-
it('should accept i18n object as dashboard description', () => {
586+
it('should reject i18n object as dashboard description', () => {
587587
expect(() => DashboardSchema.parse({
588588
name: 'test_dashboard',
589589
label: 'Test',
590590
description: { key: 'dashboards.test.desc', defaultValue: 'Test dashboard' },
591591
widgets: [],
592-
})).not.toThrow();
592+
})).toThrow();
593593
});
594-
it('should accept i18n object as widget title', () => {
594+
it('should reject i18n object as widget title', () => {
595595
expect(() => DashboardWidgetSchema.parse({
596596
id: 'total_revenue',
597597
title: { key: 'widgets.revenue', defaultValue: 'Total Revenue' },
598598
type: 'metric',
599599
layout: { x: 0, y: 0, w: 3, h: 2 },
600-
})).not.toThrow();
600+
})).toThrow();
601601
});
602-
it('should accept i18n object in global filter label', () => {
602+
it('should reject i18n object in global filter label', () => {
603603
expect(() => DashboardSchema.parse({
604604
name: 'filter_dash',
605605
label: 'Filtered',
@@ -609,7 +609,7 @@ describe('Dashboard I18n Integration', () => {
609609
label: { key: 'filters.status', defaultValue: 'Status' },
610610
type: 'select',
611611
}],
612-
})).not.toThrow();
612+
})).toThrow();
613613
});
614614
});
615615

@@ -783,15 +783,14 @@ describe('DashboardWidgetSchema - description', () => {
783783
expect(result.description).toBe('Year-to-date total revenue');
784784
});
785785

786-
it('should accept widget with i18n description', () => {
787-
const result = DashboardWidgetSchema.parse({
786+
it('should reject widget with i18n description', () => {
787+
expect(() => DashboardWidgetSchema.parse({
788788
id: 'revenue_i18n',
789789
title: 'Revenue',
790790
description: { key: 'widgets.revenue.desc', defaultValue: 'Total revenue' },
791791
type: 'metric',
792792
layout: { x: 0, y: 0, w: 3, h: 2 },
793-
});
794-
expect(result.description).toEqual({ key: 'widgets.revenue.desc', defaultValue: 'Total revenue' });
793+
})).toThrow();
795794
});
796795

797796
it('should accept widget without description (optional)', () => {
@@ -1043,15 +1042,14 @@ describe('GlobalFilterSchema', () => {
10431042
expect(result.options![0].label).toBe('High');
10441043
});
10451044

1046-
it('should accept filter with i18n option labels', () => {
1047-
const result = GlobalFilterSchema.parse({
1045+
it('should reject filter with i18n option labels', () => {
1046+
expect(() => GlobalFilterSchema.parse({
10481047
field: 'priority',
10491048
type: 'select',
10501049
options: [
10511050
{ value: 'high', label: { key: 'filter.priority.high', defaultValue: 'High' } },
10521051
],
1053-
});
1054-
expect(result.options![0].label).toEqual({ key: 'filter.priority.high', defaultValue: 'High' });
1052+
})).toThrow();
10551053
});
10561054

10571055
it('should accept filter with optionsFrom (dynamic binding)', () => {
@@ -1295,12 +1293,11 @@ describe('DashboardHeaderActionSchema', () => {
12951293
expect(result.icon).toBe('play');
12961294
});
12971295

1298-
it('should accept i18n label', () => {
1299-
const result = DashboardHeaderActionSchema.parse({
1296+
it('should reject i18n label', () => {
1297+
expect(() => DashboardHeaderActionSchema.parse({
13001298
label: { key: 'actions.export', defaultValue: 'Export' },
13011299
actionUrl: '/export',
1302-
});
1303-
expect(result.label).toEqual({ key: 'actions.export', defaultValue: 'Export' });
1300+
})).toThrow();
13041301
});
13051302

13061303
it('should reject action without required fields', () => {
@@ -1429,13 +1426,12 @@ describe('WidgetMeasureSchema', () => {
14291426
expect(result.format).toBe('$0,0.00');
14301427
});
14311428

1432-
it('should accept measure with i18n label', () => {
1433-
const result = WidgetMeasureSchema.parse({
1429+
it('should reject measure with i18n label', () => {
1430+
expect(() => WidgetMeasureSchema.parse({
14341431
valueField: 'quantity',
14351432
aggregate: 'avg',
14361433
label: { key: 'measures.avg_qty', defaultValue: 'Average Quantity' },
1437-
});
1438-
expect(result.label).toEqual({ key: 'measures.avg_qty', defaultValue: 'Average Quantity' });
1434+
})).toThrow();
14391435
});
14401436

14411437
it('should accept all aggregate functions', () => {

packages/spec/src/ui/dnd.test.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,11 @@ describe('Type exports', () => {
190190
});
191191

192192
describe('I18n and ARIA integration', () => {
193-
it('should accept I18n label on DropZoneSchema', () => {
194-
const result = DropZoneSchema.parse({
193+
it('should reject I18n label on DropZoneSchema', () => {
194+
expect(() => DropZoneSchema.parse({
195195
accept: ['card'],
196196
label: { key: 'dnd.drop_zone', defaultValue: 'Drop items here' },
197-
});
198-
expect(result.label).toEqual({ key: 'dnd.drop_zone', defaultValue: 'Drop items here' });
197+
})).toThrow();
199198
});
200199

201200
it('should accept ARIA props on DropZoneSchema', () => {
@@ -216,14 +215,12 @@ describe('I18n and ARIA integration', () => {
216215
expect(result.label).toBe('Drag this card');
217216
});
218217

219-
it('should accept ARIA props on DragItemSchema', () => {
220-
const result = DragItemSchema.parse({
218+
it('should reject ARIA props on DragItemSchema', () => {
219+
expect(() => DragItemSchema.parse({
221220
type: 'row',
222221
ariaLabel: { key: 'dnd.drag_row', defaultValue: 'Draggable row' },
223222
ariaDescribedBy: 'row-desc',
224-
});
225-
expect(result.ariaLabel).toEqual({ key: 'dnd.drag_row', defaultValue: 'Draggable row' });
226-
expect(result.ariaDescribedBy).toBe('row-desc');
223+
})).toThrow();
227224
});
228225

229226
it('should leave I18n/ARIA fields undefined when not provided', () => {

packages/spec/src/ui/keyboard.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,12 @@ describe('Type exports', () => {
152152
});
153153

154154
describe('I18n and ARIA integration', () => {
155-
it('should accept I18n description on KeyboardShortcutSchema', () => {
156-
const result = KeyboardShortcutSchema.parse({
155+
it('should reject I18n description on KeyboardShortcutSchema', () => {
156+
expect(() => KeyboardShortcutSchema.parse({
157157
key: 'Ctrl+S',
158158
action: 'save',
159159
description: { key: 'shortcuts.save', defaultValue: 'Save the current document' },
160-
});
161-
expect(result.description).toEqual({ key: 'shortcuts.save', defaultValue: 'Save the current document' });
160+
})).toThrow();
162161
});
163162

164163
it('should accept plain string description on KeyboardShortcutSchema', () => {

packages/spec/src/ui/notification.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,11 @@ describe('ARIA integration', () => {
180180
expect(result.role).toBe('alert');
181181
});
182182

183-
it('should accept I18n ariaLabel on NotificationSchema', () => {
184-
const result = NotificationSchema.parse({
183+
it('should reject I18n ariaLabel on NotificationSchema', () => {
184+
expect(() => NotificationSchema.parse({
185185
message: 'Error occurred',
186186
ariaLabel: { key: 'notifications.error_alert', defaultValue: 'Error alert' },
187-
});
188-
expect(result.ariaLabel).toEqual({ key: 'notifications.error_alert', defaultValue: 'Error alert' });
187+
})).toThrow();
189188
});
190189

191190
it('should leave ARIA fields undefined when not provided', () => {

packages/spec/src/ui/offline.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,10 @@ describe('Type exports', () => {
163163
});
164164

165165
describe('I18n integration', () => {
166-
it('should accept I18n offlineMessage on OfflineConfigSchema', () => {
167-
const result = OfflineConfigSchema.parse({
166+
it('should reject I18n offlineMessage on OfflineConfigSchema', () => {
167+
expect(() => OfflineConfigSchema.parse({
168168
offlineMessage: { key: 'offline.status', defaultValue: 'You are offline' },
169-
});
170-
expect(result.offlineMessage).toEqual({ key: 'offline.status', defaultValue: 'You are offline' });
169+
})).toThrow();
171170
});
172171

173172
it('should accept plain string offlineMessage', () => {

packages/spec/src/ui/page.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -421,27 +421,27 @@ describe('PageSchema', () => {
421421
});
422422

423423
describe('Page I18n Integration', () => {
424-
it('should accept i18n object as page label', () => {
424+
it('should reject i18n object as page label', () => {
425425
expect(() => PageSchema.parse({
426426
name: 'i18n_page',
427427
label: { key: 'pages.dashboard', defaultValue: 'Dashboard' },
428428
regions: [],
429-
})).not.toThrow();
429+
})).toThrow();
430430
});
431-
it('should accept i18n as page description', () => {
431+
it('should reject i18n as page description', () => {
432432
expect(() => PageSchema.parse({
433433
name: 'desc_page',
434434
label: 'Test',
435435
description: { key: 'pages.test.desc', defaultValue: 'A test page' },
436436
regions: [],
437-
})).not.toThrow();
437+
})).toThrow();
438438
});
439-
it('should accept i18n as component label', () => {
439+
it('should reject i18n as component label', () => {
440440
expect(() => PageComponentSchema.parse({
441441
type: 'page:header',
442442
label: { key: 'components.header', defaultValue: 'Header' },
443443
properties: {},
444-
})).not.toThrow();
444+
})).toThrow();
445445
});
446446
});
447447

@@ -700,12 +700,12 @@ describe('PageSchema with page types', () => {
700700
expect(page.icon).toBe('bar-chart');
701701
});
702702

703-
it('should accept page with i18n label', () => {
703+
it('should reject page with i18n label', () => {
704704
expect(() => PageSchema.parse({
705705
name: 'i18n_page',
706706
label: { key: 'pages.overview', defaultValue: 'Overview' },
707707
regions: [],
708-
})).not.toThrow();
708+
})).toThrow();
709709
});
710710

711711
it('should accept page with ARIA attributes', () => {

packages/spec/src/ui/report.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -430,20 +430,19 @@ describe('ReportSchema', () => {
430430
});
431431

432432
describe('Report I18n Integration', () => {
433-
it('should accept i18n object as report label', () => {
433+
it('should reject i18n object as report label', () => {
434434
expect(() => ReportSchema.parse({
435435
name: 'i18n_report',
436436
label: { key: 'reports.sales', defaultValue: 'Sales Report' },
437437
objectName: 'opportunity',
438438
columns: [{ field: 'name' }],
439-
})).not.toThrow();
439+
})).toThrow();
440440
});
441-
it('should accept i18n object as column label', () => {
442-
const result = ReportColumnSchema.parse({
441+
it('should reject i18n object as column label', () => {
442+
expect(() => ReportColumnSchema.parse({
443443
field: 'amount',
444444
label: { key: 'columns.amount', defaultValue: 'Amount' },
445-
});
446-
expect(typeof result.label).toBe('object');
445+
})).toThrow();
447446
});
448447
});
449448

0 commit comments

Comments
 (0)