Skip to content

Commit e5afe7b

Browse files
committed
Integrate SchemaRendererProvider into AppContent; update tests to ensure field registration and improve ObjectView logic
1 parent 63b4311 commit e5afe7b

6 files changed

Lines changed: 13 additions & 22 deletions

File tree

apps/console/src/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useState, useEffect } from 'react';
33
import { ObjectStackClient } from '@objectstack/client';
44
import { ObjectForm } from '@object-ui/plugin-form';
55
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, Empty, EmptyTitle } from '@object-ui/components';
6+
import { SchemaRendererProvider } from '@object-ui/react';
67
import { ObjectStackDataSource } from './dataSource';
78
import appConfig from '../objectstack.config';
89

@@ -105,6 +106,7 @@ export function AppContent() {
105106
onAppChange={handleAppChange}
106107
objects={allObjects}
107108
>
109+
<SchemaRendererProvider dataSource={dataSource || {}}>
108110
<Routes>
109111
<Route path="/" element={
110112
<Navigate to={findFirstRoute(activeApp.navigation)} replace />
@@ -155,6 +157,7 @@ export function AppContent() {
155157
</div>
156158
</DialogContent>
157159
</Dialog>
160+
</SchemaRendererProvider>
158161
</ConsoleLayout>
159162
);
160163
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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 '@object-ui/fields'; // Ensure fields are registered for ObjectForm tests
56

67
// -----------------------------------------------------------------------------
78
// SYSTEM INTEGRATION TEST: Console Application
@@ -175,6 +176,9 @@ describe('Console Application Simulation', () => {
175176
// 3. Verify Dialog Opens
176177
await waitFor(() => {
177178
expect(screen.getByRole('dialog')).toBeInTheDocument();
179+
// Verify title to ensure object definition was found
180+
const title = screen.getByRole('heading', { name: /Create.*Sink/i });
181+
expect(title).toBeInTheDocument();
178182
});
179183

180184
// 4. Verify Field Inputs

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ vi.mock('../dataSource', () => {
5656
// Mock Child Components (Integration level)
5757
// We want to verify routing, so we mock the "Page" components but keep Layout structure mostly
5858
vi.mock('../components/ObjectView', () => ({
59-
ObjectView: ({ objects }: any) => <div data-testid="object-view">Object View</div>
59+
ObjectView: () => <div data-testid="object-view">Object View</div>
6060
}));
6161

6262
vi.mock('../components/DashboardView', () => ({

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect, vi } from 'vitest';
2-
import { render, screen, fireEvent } from '@testing-library/react';
2+
import { render, screen } from '@testing-library/react';
33
import '@testing-library/jest-dom';
44
import { ObjectView } from '../components/ObjectView';
55
import { MemoryRouter, Route, Routes } from 'react-router-dom';

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ vi.mock('@object-ui/plugin-calendar', () => ({
1919
// Mock UI Components to allow interaction testing without Radix complexity
2020
vi.mock('@object-ui/components', async () => {
2121
return {
22+
cn: (...inputs: any[]) => inputs.filter(Boolean).join(' '),
2223
Button: ({ children, onClick }: any) => <button onClick={onClick}>{children}</button>,
24+
Input: (props: any) => <input {...props} data-testid="mock-input" />,
2325
Tabs: ({ value, onValueChange, children }: any) => (
2426
<div data-testid="tabs" data-value={value} onClick={(e: any) => {
2527
// Simple event delegation for testing

apps/console/src/components/ObjectView.tsx

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useMemo } from 'react';
1+
import { useMemo } from 'react';
22
import { useParams, useSearchParams } from 'react-router-dom';
33
import { ObjectGantt } from '@object-ui/plugin-gantt';
44
import { ListView } from '@object-ui/plugin-list';
@@ -13,7 +13,6 @@ import type { ListViewSchema } from '@object-ui/types';
1313
export function ObjectView({ dataSource, objects, onEdit }: any) {
1414
const { objectName } = useParams();
1515
const [searchParams, setSearchParams] = useSearchParams();
16-
const [refreshKey, setRefreshKey] = useState(0);
1716

1817
// Get Object Definition
1918
const objectDef = objects.find((o: any) => o.name === objectName);
@@ -54,29 +53,12 @@ export function ObjectView({ dataSource, objects, onEdit }: any) {
5453
const activeViewId = searchParams.get('view') || views[0]?.id;
5554
const activeView = views.find((v: any) => v.id === activeViewId) || views[0];
5655

57-
// Helper: Normalize Columns for Grid
58-
const getGridColumns = (view: any) => {
59-
if (!view.columns) return [];
60-
return view.columns.map((colName: string) => {
61-
// Find field definition
62-
const fieldDef = Array.isArray(objectDef.fields)
63-
? objectDef.fields.find((f: any) => f.name === colName)
64-
: objectDef.fields?.[colName];
65-
66-
return {
67-
field: colName,
68-
label: fieldDef?.label || colName,
69-
width: 150
70-
};
71-
});
72-
};
73-
7456
const handleViewChange = (viewId: string) => {
7557
setSearchParams({ view: viewId });
7658
};
7759

7860
const renderCurrentView = () => {
79-
const key = `${objectName}-${activeView.id}-${refreshKey}`;
61+
const key = `${objectName}-${activeView.id}`;
8062
const commonProps = {
8163
dataSource,
8264
className: "h-full border-none"

0 commit comments

Comments
 (0)