Skip to content

Commit 8ac2266

Browse files
Claudehotlong
andauthored
Add all required mocks for ObjectView test
Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/23ab3978-7929-4b85-b02e-69193aa3ff88 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent c0a8669 commit 8ac2266

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

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

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,72 @@ vi.mock('@object-ui/auth', () => ({
115115
createAuthenticatedFetch: () => (input: RequestInfo | URL, init?: RequestInit) => fetch(input as any, init),
116116
}));
117117

118+
// Mock permissions
119+
vi.mock('@object-ui/permissions', () => ({
120+
usePermissions: () => ({
121+
can: () => true,
122+
}),
123+
}));
124+
125+
// Mock i18n
126+
vi.mock('@object-ui/i18n', () => ({
127+
useObjectTranslation: () => (key: string) => key,
128+
useObjectLabel: () => (objectName: string) => objectName,
129+
}));
130+
131+
// Mock collaboration
132+
vi.mock('@object-ui/collaboration', () => ({
133+
useRealtimeSubscription: () => ({}),
134+
useConflictResolution: () => ({
135+
resolveConflict: vi.fn(),
136+
}),
137+
}));
138+
139+
// Mock react utilities
140+
vi.mock('@object-ui/react', async (importOriginal) => {
141+
const actual = await importOriginal<any>();
142+
const React = await import('react');
143+
return {
144+
...actual,
145+
ActionProvider: ({ children }: any) => <>{children}</>,
146+
useNavigationOverlay: () => ({
147+
open: false,
148+
close: vi.fn(),
149+
setContent: vi.fn(),
150+
}),
151+
};
152+
});
153+
154+
// Mock sonner toast
155+
vi.mock('sonner', () => ({
156+
toast: {
157+
success: vi.fn(),
158+
error: vi.fn(),
159+
warning: vi.fn(),
160+
info: vi.fn(),
161+
},
162+
}));
163+
164+
// Mock plugin-detail
165+
vi.mock('@object-ui/plugin-detail', () => ({
166+
DetailView: ({ schema }: any) => <div data-testid="detail-view">{schema.objectName}</div>,
167+
RecordChatterPanel: () => <div data-testid="record-chatter-panel">Chatter</div>,
168+
}));
169+
170+
// Mock plugin-view components
171+
vi.mock('@object-ui/plugin-view', async (importOriginal) => {
172+
const actual = await importOriginal<any>();
173+
return {
174+
...actual,
175+
ManageViewsDialog: ({ open }: any) => open ? <div data-testid="manage-views-dialog">Manage Views</div> : null,
176+
};
177+
});
178+
179+
// Mock plugin-charts
180+
vi.mock('@object-ui/plugin-charts', () => ({
181+
ObjectChart: ({ schema }: any) => <div data-testid="object-chart">Chart: {schema.objectName}</div>,
182+
}));
183+
118184
describe('ObjectView Component', () => {
119185

120186
beforeEach(() => {

0 commit comments

Comments
 (0)