Skip to content

Commit 96f6389

Browse files
committed
2 parents b08a3ed + 0571471 commit 96f6389

File tree

3 files changed

+58
-50
lines changed

3 files changed

+58
-50
lines changed

apps/console/src/__tests__/BrowserSimulation.test.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { describe, it, expect, vi } from 'vitest';
33
import { render, screen, waitFor, fireEvent } from '@testing-library/react';
44
import { MemoryRouter } from 'react-router-dom';
5-
import React from 'react';
65

76
// -----------------------------------------------------------------------------
87
// SYSTEM INTEGRATION TEST: Console Application
@@ -225,9 +224,9 @@ describe('Console Application Simulation', () => {
225224
name: 'kitchen_sink',
226225
fields: {
227226
name: { type: 'text', label: 'Name Field' },
228-
amount: { type: 'number', label: 'Amount Field' }
227+
amount: { type: 'number', label: 'Amount Field', scale: 0 }
229228
}
230-
});
229+
} as any);
231230

232231
renderApp('/kitchen_sink');
233232
await waitFor(() => {
@@ -424,7 +423,7 @@ describe('Kanban Integration', () => {
424423
}
425424
};
426425

427-
vi.spyOn(mocks.MockDataSource.prototype, 'getObjectSchema').mockResolvedValue(mockSchema);
426+
vi.spyOn(mocks.MockDataSource.prototype, 'getObjectSchema').mockResolvedValue(mockSchema as any);
428427

429428
// Mock data for the kanban
430429
const mockTaskData = [
@@ -433,7 +432,7 @@ describe('Kanban Integration', () => {
433432
{ id: '3', title: 'Task 3', description: 'Third task', status: 'done', priority: 'low' }
434433
];
435434

436-
vi.spyOn(mocks.MockDataSource.prototype, 'find').mockResolvedValue({ data: mockTaskData });
435+
vi.spyOn(mocks.MockDataSource.prototype, 'find').mockResolvedValue({ data: mockTaskData } as any);
437436

438437
// Create a mock data source
439438
const dataSource = new mocks.MockDataSource();
@@ -538,7 +537,7 @@ describe('Kanban Integration', () => {
538537
}
539538
];
540539

541-
vi.spyOn(mocks.MockDataSource.prototype, 'find').mockResolvedValue({ data: seedData });
540+
vi.spyOn(mocks.MockDataSource.prototype, 'find').mockResolvedValue({ data: seedData } as any);
542541
vi.spyOn(mocks.MockDataSource.prototype, 'getObjectSchema').mockResolvedValue({
543542
name: 'project_task',
544543
fields: {
@@ -547,7 +546,7 @@ describe('Kanban Integration', () => {
547546
status: { type: 'picklist', label: 'Status' },
548547
priority: { type: 'picklist', label: 'Priority' }
549548
}
550-
});
549+
} as any);
551550

552551
// Create a mock data source
553552
const dataSource = new mocks.MockDataSource();
@@ -588,7 +587,6 @@ describe('Kanban Integration', () => {
588587
const { KanbanRenderer } = await import('@object-ui/plugin-kanban');
589588

590589
// Setup: Spy on update method (though drag-drop in JSDOM is complex)
591-
const updateSpy = vi.fn().mockResolvedValue({ id: 'task-1', status: 'done' });
592590
const onCardMoveSpy = vi.fn();
593591

594592
// Simple static data test with event binding
@@ -689,7 +687,7 @@ describe('Kanban Integration', () => {
689687

690688
const findSpy = vi.spyOn(mocks.MockDataSource.prototype, 'find').mockResolvedValue({
691689
data: initialData
692-
});
690+
} as any);
693691

694692
vi.spyOn(mocks.MockDataSource.prototype, 'getObjectSchema').mockResolvedValue({
695693
name: 'project_task',
@@ -698,11 +696,11 @@ describe('Kanban Integration', () => {
698696
status: { type: 'picklist', label: 'Status' },
699697
priority: { type: 'picklist', label: 'Priority' }
700698
}
701-
});
699+
} as any);
702700

703701
const dataSource = new mocks.MockDataSource();
704702

705-
const { rerender } = render(
703+
render(
706704
<ObjectKanban
707705
schema={{
708706
type: 'kanban',
@@ -812,6 +810,7 @@ describe('Dashboard Integration', () => {
812810
});
813811

814812
it('Scenario C: Component Registry Check', async () => {
813+
// @ts-expect-error - Importing from transitive dependency for testing
815814
const { ComponentRegistry } = await import('@object-ui/core');
816815

817816
const dashboardRenderer = ComponentRegistry.get('dashboard');

packages/plugin-dashboard/src/DashboardRenderer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
import { ComponentRegistry } from '@object-ui/core';
109
import type { DashboardSchema, DashboardWidgetSchema } from '@object-ui/types';
1110
import { SchemaRenderer } from '@object-ui/react';
1211
import { cn } from '@object-ui/components';

packages/plugin-dashboard/src/ReportRenderer.tsx

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ export interface ReportRendererProps {
1717

1818
export const ReportRenderer: React.FC<ReportRendererProps> = ({ schema }) => {
1919
const { title, description, data, columns } = schema;
20-
const ChartComponent = schema.chart ? ComponentRegistry.get(schema.chart.type || 'chart') : null;
20+
21+
// Get chart component type but don't store the component itself
22+
const chartType = schema.chart?.type || 'chart';
23+
const hasChart = !!schema.chart;
24+
2125
// In test environment, force fallback to simple table to avoid AG Grid complexity in JSDOM
2226
const isTest = process.env.NODE_ENV === 'test';
23-
const GridComponent = isTest ? null : (ComponentRegistry.get('aggrid') || ComponentRegistry.get('table'));
27+
const showGrid = !isTest;
2428

2529
return (
2630
<Card className={`h-full flex flex-col ${schema.className || ''}`}>
@@ -30,47 +34,53 @@ export const ReportRenderer: React.FC<ReportRendererProps> = ({ schema }) => {
3034
</CardHeader>
3135
<CardContent className="flex-1 overflow-auto space-y-4">
3236
{/* Render Chart Section if present */}
33-
{schema.chart && ChartComponent && (
34-
<div className="min-h-[300px] border rounded-md p-4 bg-white/50">
35-
<ChartComponent schema={{ ...schema.chart, data }} />
36-
</div>
37-
)}
37+
{hasChart && (() => {
38+
const ChartComponent = ComponentRegistry.get(chartType);
39+
return ChartComponent ? (
40+
<div className="min-h-[300px] border rounded-md p-4 bg-white/50">
41+
<ChartComponent schema={{ ...schema.chart, data }} />
42+
</div>
43+
) : null;
44+
})()}
3845

3946
{/* Render Data Grid Section */}
4047
{data && data.length > 0 && (
4148
<div className="border rounded-md">
42-
{GridComponent ? (
43-
<GridComponent
49+
{(() => {
50+
const GridComponent = showGrid ? (ComponentRegistry.get('aggrid') || ComponentRegistry.get('table')) : null;
51+
return GridComponent ? (
52+
<GridComponent
4453
schema={{
45-
type: 'aggrid',
46-
rowData: data,
47-
columnDefs: columns,
48-
domLayout: 'autoHeight'
49-
}}
50-
/>
51-
) : (
52-
// Simple Fallback Table if Grid plugin missing
53-
<div className="overflow-x-auto">
54-
<table className="w-full text-sm text-left">
55-
<thead className="text-xs uppercase bg-gray-50">
56-
<tr>
57-
{columns?.map((col: any) => (
58-
<th key={col.field} className="px-6 py-3">{col.headerName || col.label || col.field}</th>
59-
))}
60-
</tr>
61-
</thead>
62-
<tbody>
63-
{data.map((row: any, i: number) => (
64-
<tr key={i} className="bg-white border-b">
65-
{columns?.map((col: any) => (
66-
<td key={col.field} className="px-6 py-4">{row[col.field]}</td>
67-
))}
68-
</tr>
69-
))}
70-
</tbody>
71-
</table>
72-
</div>
73-
)}
54+
type: 'aggrid',
55+
rowData: data,
56+
columnDefs: columns,
57+
domLayout: 'autoHeight'
58+
}}
59+
/>
60+
) : (
61+
// Simple Fallback Table if Grid plugin missing
62+
<div className="overflow-x-auto">
63+
<table className="w-full text-sm text-left">
64+
<thead className="text-xs uppercase bg-gray-50">
65+
<tr>
66+
{columns?.map((col: any) => (
67+
<th key={col.field} className="px-6 py-3">{col.headerName || col.label || col.field}</th>
68+
))}
69+
</tr>
70+
</thead>
71+
<tbody>
72+
{data.map((row: any, i: number) => (
73+
<tr key={i} className="bg-white border-b">
74+
{columns?.map((col: any) => (
75+
<td key={col.field} className="px-6 py-4">{row[col.field]}</td>
76+
))}
77+
</tr>
78+
))}
79+
</tbody>
80+
</table>
81+
</div>
82+
);
83+
})()}
7484
</div>
7585
)}
7686
</CardContent>

0 commit comments

Comments
 (0)