Skip to content

Commit baa4b59

Browse files
Copilothotlong
andauthored
fix(ci): resolve all build and test errors
Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/eb0d0766-8b77-462f-ac89-6dfeb9b0e31c Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent a8455e0 commit baa4b59

File tree

7 files changed

+55
-14
lines changed

7 files changed

+55
-14
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,21 @@ vi.mock('../context/MetadataProvider', async () => {
131131

132132
// --- 2. Import AppContent ---
133133
import { AppContent } from '../App';
134+
import { NavigationProvider } from '../context/NavigationContext';
135+
import { FavoritesProvider } from '../context/FavoritesProvider';
134136

135137
describe('Console Application Simulation', () => {
136138

137139
// Helper to render App at specific route
138140
const renderApp = (initialRoute: string) => {
139141
return render(
142+
<NavigationProvider>
143+
<FavoritesProvider>
140144
<MemoryRouter initialEntries={[initialRoute]}>
141145
<AppContent />
142146
</MemoryRouter>
147+
</FavoritesProvider>
148+
</NavigationProvider>
143149
);
144150
};
145151

@@ -832,9 +838,13 @@ describe('Fields Integration', () => {
832838
describe('Dashboard Integration', () => {
833839
const renderApp = (initialRoute: string) => {
834840
return render(
841+
<NavigationProvider>
842+
<FavoritesProvider>
835843
<MemoryRouter initialEntries={[initialRoute]}>
836844
<AppContent />
837845
</MemoryRouter>
846+
</FavoritesProvider>
847+
</NavigationProvider>
838848
);
839849
};
840850

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { render, screen, waitFor, fireEvent } from '@testing-library/react';
33
import '@testing-library/jest-dom';
44
import { AppContent } from '../App';
55
import { MemoryRouter, Routes, Route } from 'react-router-dom';
6+
import { NavigationProvider } from '../context/NavigationContext';
7+
import { FavoritesProvider } from '../context/FavoritesProvider';
68

79
// --- Mocks ---
810

@@ -181,11 +183,15 @@ describe('Console App Integration', () => {
181183

182184
const renderApp = (initialRoute = '/apps/sales/') => {
183185
return render(
186+
<NavigationProvider>
187+
<FavoritesProvider>
184188
<MemoryRouter initialEntries={[initialRoute]}>
185189
<Routes>
186190
<Route path="/apps/:appName/*" element={<AppContent />} />
187191
</Routes>
188192
</MemoryRouter>
193+
</FavoritesProvider>
194+
</NavigationProvider>
189195
);
190196
};
191197

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ vi.mock('@object-ui/components', async (importOriginal) => {
5454
};
5555
});
5656

57+
// Mock UnifiedSidebar entirely — HomeLayout tests verify layout composition,
58+
// not the sidebar's internal rendering. This also avoids SidebarProvider
59+
// dependency when AppShell is mocked as a plain div.
60+
vi.mock('../components/UnifiedSidebar', () => ({
61+
UnifiedSidebar: () => <nav data-testid="unified-sidebar" />,
62+
}));
63+
5764
// Mock @object-ui/layout AppShell
5865
vi.mock('@object-ui/layout', () => ({
5966
AppShell: ({ children, sidebar }: any) => (

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,20 @@ describe('Object Manager (Metadata Pipeline)', () => {
166166
ComponentRegistry.register('object-data-experience', mockWidget('data-experience-section'));
167167
ComponentRegistry.register('object-data-preview', mockWidget('data-preview-section'));
168168
ComponentRegistry.register('object-field-designer', mockWidget('field-management-section'));
169+
170+
// object-detail-tabs wraps all sub-widgets in the PageSchema-driven detail view.
171+
// The mock renders all sections inline so tests can find each by testid without
172+
// simulating tab-switching interactions.
173+
ComponentRegistry.register('object-detail-tabs', (props: any) => (
174+
<div data-testid="mock-object-detail-tabs">
175+
<div data-testid="object-properties" data-object-name={props?.schema?.objectName}>object-properties</div>
176+
<div data-testid="field-management-section" data-object-name={props?.schema?.objectName}>field-management-section</div>
177+
<div data-testid="relationships-section" data-object-name={props?.schema?.objectName}>relationships-section</div>
178+
<div data-testid="keys-section" data-object-name={props?.schema?.objectName}>keys-section</div>
179+
<div data-testid="data-experience-section" data-object-name={props?.schema?.objectName}>data-experience-section</div>
180+
<div data-testid="data-preview-section" data-object-name={props?.schema?.objectName}>data-preview-section</div>
181+
</div>
182+
));
169183
});
170184

171185
// =========================================================================

apps/console/src/__tests__/app-creation-integration.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import '@testing-library/jest-dom';
1818
import { MemoryRouter, Routes, Route } from 'react-router-dom';
1919
import { AppContent } from '../App';
2020
import { CommandPalette } from '../components/CommandPalette';
21+
import { NavigationProvider } from '../context/NavigationContext';
2122

2223
// --- Mocks ---
2324

@@ -286,11 +287,13 @@ describe('Console App Creation Integration', () => {
286287

287288
const renderApp = (initialRoute = '/apps/sales/') => {
288289
return render(
290+
<NavigationProvider>
289291
<MemoryRouter initialEntries={[initialRoute]}>
290292
<Routes>
291293
<Route path="/apps/:appName/*" element={<AppContent />} />
292294
</Routes>
293-
</MemoryRouter>,
295+
</MemoryRouter>
296+
</NavigationProvider>,
294297
);
295298
};
296299

apps/console/src/components/UnifiedSidebar.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ import {
4040
AvatarImage,
4141
AvatarFallback,
4242
useSidebar,
43-
Button,
4443
} from '@object-ui/components';
4544
import {
4645
ChevronsUpDown,
47-
Plus,
4846
Settings,
4947
LogOut,
5048
Database,
@@ -55,7 +53,6 @@ import {
5553
Pencil,
5654
ChevronRight,
5755
Home,
58-
Grid3x3,
5956
HelpCircle,
6057
ArrowLeft,
6158
Layers,
@@ -135,24 +132,28 @@ function useNavOrder(appName: string) {
135132

136133
/**
137134
* Resolve a Lucide icon component by name string.
135+
* Safely handles both exact names and kebab-case → PascalCase conversion.
136+
* The try/catch guards against strict module proxy environments (e.g. vitest mocks).
138137
*/
139138
function getIcon(name?: string): React.ComponentType<any> {
140139
if (!name) return LucideIcons.Database;
141140

142-
if ((LucideIcons as any)[name]) {
143-
return (LucideIcons as any)[name];
144-
}
141+
const lookup = (key: string): React.ComponentType<any> | undefined => {
142+
try {
143+
const icon = (LucideIcons as Record<string, unknown>)[key];
144+
return typeof icon === 'function' ? (icon as React.ComponentType<any>) : undefined;
145+
} catch {
146+
return undefined;
147+
}
148+
};
145149

150+
// Try exact match first, then convert kebab-case / lowercase to PascalCase
146151
const pascalName = name
147-
.split('-')
152+
.split(/[-_]/)
148153
.map(part => part.charAt(0).toUpperCase() + part.slice(1))
149154
.join('');
150155

151-
if ((LucideIcons as any)[pascalName]) {
152-
return (LucideIcons as any)[pascalName];
153-
}
154-
155-
return LucideIcons.Database;
156+
return lookup(name) ?? lookup(pascalName) ?? LucideIcons.Database;
156157
}
157158

158159
interface UnifiedSidebarProps {

apps/console/src/components/schema/objectDetailWidgets.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export function ObjectRelationshipsWidget({ schema }: { schema: ObjectWidgetSche
161161
</h3>
162162
{hasRelationships ? (
163163
<div className="space-y-3">
164-
{object.relationships.map((rel, i) => (
164+
{object.relationships!.map((rel, i) => (
165165
<div
166166
key={i}
167167
className="flex items-start gap-4 p-4 rounded-lg border bg-card hover:bg-accent/50 transition-colors"

0 commit comments

Comments
 (0)