Skip to content

Commit 7ad3259

Browse files
Copilothotlong
andcommitted
Address code review feedback for integration tests
- Improve metadata-driven form test to verify form loads without errors - Enhance grid data loading test to verify mocked data is actually displayed - Add dedicated test for unknown field type fallback behavior - All 98 tests passing with improved assertions Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 5a5903b commit 7ad3259

1 file changed

Lines changed: 36 additions & 3 deletions

File tree

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

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,19 @@ describe('Console Application Simulation', () => {
234234
expect(screen.getByRole('heading', { name: /Kitchen Sink/i })).toBeInTheDocument();
235235
});
236236

237-
expect(document.body).toBeInTheDocument();
237+
// Verify the form can be opened (showing metadata was loaded)
238+
const newButton = screen.getByRole('button', { name: /New Kitchen Sink/i });
239+
fireEvent.click(newButton);
240+
241+
// Verify form loaded with schema-based fields
242+
await waitFor(() => {
243+
expect(screen.getByRole('dialog')).toBeInTheDocument();
244+
});
245+
246+
// Form should render based on mocked schema
247+
// The actual field labels might differ based on implementation
248+
// but the form should render without errors
249+
expect(screen.queryByText(/error/i)).not.toBeInTheDocument();
238250
});
239251

240252
// -----------------------------------------------------------------------------
@@ -257,14 +269,25 @@ describe('Console Application Simulation', () => {
257269
{ id: '2', name: 'Item 2', amount: 200 }
258270
];
259271

260-
vi.spyOn(mocks.MockDataSource.prototype, 'find')
272+
const findSpy = vi.spyOn(mocks.MockDataSource.prototype, 'find')
261273
.mockResolvedValue({ data: seedData });
262274

263275
renderApp('/kitchen_sink');
264276

265277
await waitFor(() => {
266278
expect(screen.getByRole('heading', { name: /Kitchen Sink/i })).toBeInTheDocument();
267279
});
280+
281+
// Verify data source was called to load grid data
282+
await waitFor(() => {
283+
expect(findSpy).toHaveBeenCalledWith('kitchen_sink', expect.any(Object));
284+
});
285+
286+
// Verify grid displays the loaded data
287+
await waitFor(() => {
288+
expect(screen.getByText('Item 1')).toBeInTheDocument();
289+
});
290+
expect(screen.getByText('Item 2')).toBeInTheDocument();
268291
});
269292

270293
});
@@ -728,7 +751,17 @@ describe('Fields Integration', () => {
728751
expect(mapFieldTypeToFormType('number')).toBe('field:number');
729752
expect(mapFieldTypeToFormType('boolean')).toBe('field:boolean');
730753
expect(mapFieldTypeToFormType('select')).toBe('field:select');
731-
expect(mapFieldTypeToFormType('unknown_type')).toBe('field:text'); // default fallback
754+
});
755+
756+
it('Scenario A.2: Unknown Field Type Fallback in Form', async () => {
757+
const { mapFieldTypeToFormType } = await import('@object-ui/fields');
758+
759+
// Verify unknown types fallback to text
760+
expect(mapFieldTypeToFormType('unknown_type')).toBe('field:text');
761+
expect(mapFieldTypeToFormType('custom_widget')).toBe('field:text');
762+
763+
// This ensures forms don't break when encountering unknown field types
764+
// The actual rendering is tested via the full form integration tests
732765
});
733766

734767
it('Scenario B: Field Formatting Utilities', async () => {

0 commit comments

Comments
 (0)